Message-ID: <3559A111.3CF9@pobox.oleane.com> Date: Wed, 13 May 1998 15:33:05 +0200 From: Francois Charton Organization: CCMSA MIME-Version: 1.0 To: Eli Zaretskii CC: djgpp AT delorie DOT com Subject: Re: Code to Fix sinh() in libm.a References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk 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