|
@ -8,7 +8,7 @@ double logX(double b, double a){ |
|
|
if(b == 1.0 || b <= 0.0 || a <= 0.0){ |
|
|
if(b == 1.0 || b <= 0.0 || a <= 0.0){ |
|
|
return -1.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){ |
|
|
double logDec(double a){ |
|
@ -22,14 +22,37 @@ double logBin(double a){ |
|
|
double logN(double x, double eps){ |
|
|
double logN(double x, double eps){ |
|
|
if(x <= 0){ |
|
|
if(x <= 0){ |
|
|
return -1.0; |
|
|
return -1.0; |
|
|
} |
|
|
|
|
|
double yn = x - 1.0; |
|
|
|
|
|
double yn1 = yn; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if(x<200){ |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
do{ |
|
|
|
|
|
yn = yn1; |
|
|
|
|
|
yn1 = yn + 2 * (x - exponential(yn)) / (x + exponential(yn)); |
|
|
|
|
|
} 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; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return yn1; |
|
|
|
|
|
} |
|
|
|