Date: Wed, 13 May 1998 16:53:10 +0300 (IDT) From: Eli Zaretskii To: Francois Charton cc: djgpp AT delorie DOT com Subject: Re: Code to Fix sinh() in libm.a In-Reply-To: <3559A111.3CF9@pobox.oleane.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.