Re: Some hyperbolic function results different from that specified in C99 Annex G Peter McGoron 13 Oct 2026 14:25 UTC

I don't know why C mandates this. The value here is based off of the
limit of the function as it approaches (1,0). (Actually, when I wrote
the table of examples, I was copying Gambit’s output.)

Using the formula in the SRFI:

atanh(1+εi) = (log(2+εi) - log(-εi))/2
             = (log|2+εi| + angle(2+εi)i - log|-εi| - angle(-εi)i)/2

The real part of this is

     (log|2+εi| - log|-εi|)/2

which goes to positive infinity as ε → 0.

The imaginary part approaching at ε → 0⁺ is finite:

     (angle(2) - angle(-0.0i))/2
     angle(2) = 0
     angle(-0.0i) = -π/2
     lim_{ε→0⁺} Im(atanh(1+εi)) = π/4

Similarly

     lim_{ε→0¯} Im(atanh(1+εi)) = -π/4

This follows the requirement in that section:

 > When an implementation distinguishes the sign of inexact zero in some
number, and if that number lies on a branch cut, then the implementation
must return a value reasonably close to the appropriate one-sided limit
of the function approaching the branch cut.

-- Peter McGoron