delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/13/16:12:49

Date: Wed, 13 May 1998 16:53:10 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Francois Charton <deef AT pobox DOT oleane DOT com>
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: <Pine.SUN.3.91.980513164629.27177B-100000@is>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019