FENIX_libc/math/log.c
2022-10-27 08:57:08 -05:00

21 lines
No EOL
346 B
C

#include <math.h>
double _agm(double x, double y) {
double a = x;
double g = y;
double temp;
for(int i = 0; i < 15; i++) {
temp = 0.5 * (a + g);
g = sqrt(a * g);
a = temp;
}
return a;
}
double log(double x) {
double s = x * exp2(24);
double nat_log = (M_PI / (2 * _agm(1, 4/s))) - (24 * M_LN2);
return nat_log;
}