|
|
@ -8,7 +8,7 @@ double logX(double b, double a){ |
|
|
|
if(b == 1.0 || b <= 0.0 || a <= 0.0){ |
|
|
|
return -1.0; |
|
|
|
} |
|
|
|
return(logN(a, 0.000001)/logN(b, 0.000001)); |
|
|
|
return(logN(a, 0.00000001)/logN(b, 0.00000001)); |
|
|
|
} |
|
|
|
|
|
|
|
double logDec(double a){ |
|
|
@ -23,6 +23,7 @@ double logN(double x, double eps){ |
|
|
|
if(x <= 0){ |
|
|
|
return -1.0; |
|
|
|
} |
|
|
|
if(x<200){ |
|
|
|
double yn = x - 1.0; |
|
|
|
double yn1 = yn; |
|
|
|
|
|
|
@ -32,4 +33,26 @@ double logN(double x, double eps){ |
|
|
|
} while (absD(yn - yn1) > eps); |
|
|
|
|
|
|
|
return yn1; |
|
|
|
} |
|
|
|
else{ |
|
|
|
int power_adjust = 0; |
|
|
|
while (x > 1.0) { |
|
|
|
x /= exponential(1); |
|
|
|
power_adjust++; |
|
|
|
} |
|
|
|
while (x < .25) { |
|
|
|
x *= exponential(1); |
|
|
|
power_adjust--; |
|
|
|
} |
|
|
|
|
|
|
|
x -= 1.0; |
|
|
|
double t = 0.0, s = 1.0, z = x; |
|
|
|
for (int k=1; k<=100; k++) { |
|
|
|
t += z * s / k; |
|
|
|
z *= x; |
|
|
|
s = -s; |
|
|
|
} |
|
|
|
return t + power_adjust; |
|
|
|
} |
|
|
|
} |
|
|
|
|