Advertisement
JewishCat

22.Тейлор

May 31st, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <math.h>
  5.  
  6. using namespace std;
  7.  
  8. double ln(double x);
  9.  
  10. int main() {
  11.     double x=0.5;
  12.     double sum = ln(x);
  13.     cout << sum << " " << log(1+x) << endl;
  14.     system("pause");
  15.     return 0;
  16. }
  17. double ln(double x) {
  18.     double n = x;
  19.     double sum = 0;
  20.     int i = 2;
  21.     do
  22.     {
  23.         sum += n;
  24.         n = pow(-1.0,i+1) * pow(x, i) / i;
  25.         i++;
  26.     } while (fabs(n) > 0.00000000001);
  27.     return sum;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement