Re: [pure-lang-users] ln
Status: Beta
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2008-08-21 13:26:34
|
Eddie Rucker wrote: > Yes, ln x -> -inf as x -> 0. Errm, of course I meant that ln x -> -inf as x -> +0. Oh well. I see no merit in fighting the standard there, it seems to be well-thought out after all, and backed up by substantial mathematical theory to make sure that it all makes sense, in a twisted way. > But x aint zero here, it is something close to zero. If you look at Ln x in the complex plain, the y- > axis is an asymptote and hence Ln 0 has no value at all i.e. undefined. That's why IEEE 754 distinguishes between positive and negative zero. So the C log() function can return -inf for +0.0 and nan for -0.0 (at least that's what Goldberg's IEEE 754 paper suggests). Moreover, the C99 clog() function is supposed to return clog(z) = log(cabs(z)) + i * carg(z), and that's exactly how math.pure implements the complex ln function as well. So Pure's ln function should work properly to the extent that the C log() function does. Unfortunately, on my Linux system both c_log (1/inf) and c_log (1/-inf) return -inf in Pure, even though Pure correctly displays 1/inf as 0.0 and 1/-inf as -0.0. So it seems that the glibc log() function at least does *not* distinguish between positive and negative zero. Maybe that's a non-conformance in glibc, I'll have to check POSIX to see whether it has something to say about log(-0.0). Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |