Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <cstdlib>
- #include <iostream>
- #include <math.h>
- using namespace std;
- double ln(double x);
- int main() {
- double x=0.5;
- double sum = ln(x);
- cout << sum << " " << log(1+x) << endl;
- system("pause");
- return 0;
- }
- double ln(double x) {
- double n = x;
- double sum = 0;
- int i = 2;
- do
- {
- sum += n;
- n = pow(-1.0,i+1) * pow(x, i) / i;
- i++;
- } while (fabs(n) > 0.00000000001);
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement