Mail Archives: djgpp/1998/05/13/09:38:48
Eli Zaretskii wrote:
>
> > Another solution for approximating sinh(x) would be to remember that
> > sinh(x) = exp(x)/2 - 1/(2*exp(x))
>
> 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))
As you can see, sinh() and exp() overflow for about the same value of x.
In fact, I think the above formula is the right way to compute sinh(x)
(and cosh(x)) for large values of x (abs(x) > M / (2 log2(e)) is M is the
mantissa length), as exp() can usually be calculated quite fast, either
by the FPU or through an algorithm.
Francois
- Raw text -