Created
March 21, 2013 14:40
-
-
Save iliaaw/5213541 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
/* | |
* В этой функции считается сумма бесконечного ряда | |
*/ | |
double my_awesome_ln(double x) { | |
double const epsilon = 0.0000001; | |
double z, delta, result; | |
int i; | |
z = (x - 1) / (x + 1); | |
delta = 1; | |
result = 0; | |
for (i = 1; delta > epsilon; i++) { | |
delta = 2 / (2 * (double)i - 1) * pow(z, 2 * (double)i - 1); | |
result += delta; | |
} | |
return result; | |
} | |
int main() { | |
double x = 123; | |
printf("%8f\n", my_awesome_ln(x)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment