Browse Source

implement first revision for ln with halley-newton-approx

master
fdai7848 11 months ago
parent
commit
79c3864687
  1. 20
      src/exponent.c

20
src/exponent.c

@ -46,4 +46,24 @@ double exponential(double x){
sum += (1.0/fac(i)*(expIN(i,x))); sum += (1.0/fac(i)*(expIN(i,x)));
} }
return sum; return sum;
}
double absD(double x){
if(x<0){
return -1 * x;
}
return x;
}
double logN(double x, double eps){
double yn = x - 1.0;
double yn1 = yn;
do
{
yn = yn1;
yn1 = yn + 2 * (x - exponential(yn)) / (x + exponential(yn));
} while (absD(yn - yn1) > eps);
return yn1;
} }
Loading…
Cancel
Save