www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/13/09:38:48

Message-ID: <3559A111.3CF9@pobox.oleane.com>
Date: Wed, 13 May 1998 15:33:05 +0200
From: Francois Charton <deef AT pobox DOT oleane DOT com>
Organization: CCMSA
MIME-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
CC: djgpp AT delorie DOT com
Subject: Re: Code to Fix sinh() in libm.a
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980513114738 DOT 26082E-100000 AT is>

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 -


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