Mail Archives: djgpp/1998/05/13/16:12:49
On Wed, 13 May 1998, Francois Charton wrote:
> > IMHO, this is not good enough, since it will blow up prematurely for
> > large arguments: when exp(x) overflows, sinh(x) not necessarily does so,
> > but the above implementation will cause it to.
>
> I don't think so. For large values of x (positive, for negative x, use
> the above for -x, remembering that sinh(-x) = - sinh(x)), exp(-x) is
> negligible, and
> sinh(x) = 0.5 exp(x) = exp(x-ln(2))
That is not the simplistic algorithm that you suggested originally ;-).
> As you can see, sinh() and exp() overflow for about the same value of x.
About, but not the same. Users of math functions usually expect to get
ERANGE only when there is no possibility to express the result in the
underlying arithmetics, but no earlier.
The version of sinh from libm.a goes to great lengths to provide such
graceful degradation. As it turns out, it needs some work in the region
of small arguments, but that's not reason good enough to throw it away
and roll something new from scratch, IMHO.
- Raw text -