Monday, February 25, 2008

atanh

I was a little startled to find today that atanh's finite values seem to be bounded roughly between -18.71497 and 18.71497. These correspond to inputs of -0.999999999999999944444... and 0.99999999999999994444444... Stepping just a bit beyond these (changing any of those 4s to a 5) we get back an infinite value. I suppose I should work out analytically what's going on. Or just look at this:

> q <- function(x) (1+x) / (1 -x)
> q(0.99999999999999995)
[1] Inf
> q(0.99999999999999994)
[1] 1.80144e+16


The 9899 standard just says, "The atanh functions compute the arc hyperbolic tangent of x. A domain error occurs
for arguments not in the interval [-1, +1]. A range error may occur if the argument equals −1 or +1." Where should I look for more details?

Using R's pnorm I see there's roughly probability 1.869160e-78 beyond these points in the tails of a standard Gaussian distribution (and so the probability of seeing the points beyond them is indistinguishable from zero for any variances much less than one) so that this is of little importance for Fisher's z transform 0.5 atanh(r). Still it's a surprise to me not to see a smooth transition.

> atanh(tanh(18.71497))
[1] 18.71497
> atanh(tanh(18.71498))
[1] Inf

3 comments:

Roger Hui said...

I came upon your article when I Googled 18.71497. http://www.jsoftware.com/pipermail/programming/2008-March/009880.html answers your question.

Roger Hui
www.jsoftware.com

Roger Hui said...

The URL got mangled. It should be
http://www.jsoftware.com/
pipermail/
programming/
2008-March/009880.html
all as one string, or
http://tinyurl.com/2mwjxs

util said...

Thanks for the link! Interesting and also a reminder to take a look J.