Skip to content

Instantly share code, notes, and snippets.

@iliaaw
Created March 21, 2013 14:40
Show Gist options
  • Save iliaaw/5213541 to your computer and use it in GitHub Desktop.
Save iliaaw/5213541 to your computer and use it in GitHub Desktop.
#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