X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Flogl.c;h=03c5188fd9d79389d938cff1b6900ea90fa4aaf3;hb=a2a328bd896fa909542b492601e3689119b95de0;hp=ffd8103813eade25cc51b70944b93d78a49b8cf8;hpb=97721a5508415a2f10eb068e022093811c9ff8be;p=musl diff --git a/src/math/logl.c b/src/math/logl.c index ffd81038..03c5188f 100644 --- a/src/math/logl.c +++ b/src/math/logl.c @@ -35,9 +35,9 @@ * * log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x). * - * Otherwise, setting z = 2(x-1)/x+1), + * Otherwise, setting z = 2(x-1)/(x+1), * - * log(x) = z + z**3 P(z)/Q(z). + * log(x) = log(1+z/2) - log(1-z/2) = z + z**3 P(z)/Q(z). * * * ACCURACY: @@ -50,11 +50,6 @@ * In the tests over the interval exp(+-10000), the logarithms * of the random arguments were uniformly distributed over * [-10000, +10000]. - * - * ERROR MESSAGES: - * - * log singularity: x = 0; returns -INFINITY - * log domain: x < 0; returns NAN */ #include "libm.h" @@ -121,8 +116,8 @@ long double logl(long double x) return x; if (x <= 0.0) { if (x == 0.0) - return -INFINITY; - return NAN; + return -1/(x*x); /* -inf with divbyzero */ + return 0/0.0f; /* nan with invalid */ } /* separate mantissa from exponent */ @@ -132,7 +127,7 @@ long double logl(long double x) x = frexpl(x, &e); /* logarithm using log(x) = z + z**3 P(z)/Q(z), - * where z = 2(x-1)/x+1) + * where z = 2(x-1)/(x+1) */ if (e > 2 || e < -2) { if (x < SQRTH) { /* 2(2x-1)/(2x+1) */