delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/12/10:05:36

Message-ID: <355855B4.4BA9@pobox.oleane.com>
Date: Tue, 12 May 1998 15:59:16 +0200
From: Francois Charton <deef AT pobox DOT oleane DOT com>
Organization: CCMSA
MIME-Version: 1.0
To: Jens Bischoff <j DOT bischoff AT airbus DOT dasa DOT de>
CC: djgpp AT delorie DOT com
Subject: Re: Code to Fix sinh() in libm.a
References: <9805110742 DOT AA14523 AT axe DOT bre DOT da>

Jens Bischoff wrote:
> 
> sinh(x) = 1 + x^3/3! + x^5/5! + x^7/7! + ...
> 

That is x+ x^3/3!+... 

Such truncated Taylor series are not good approximations of functions. In 
this specific case, note that the series always underestimate sinh(x). 

If you want to find a polynomial approximation to sinh(x), a better 
solution would be to use Chebyshev polynomials:

T_0(x)=1
T_1(x)=x
...
T_n+1(x)=2*x*T_n(x)-T_n-1(x)

Any function f(x) (with x between -1 to 1) can be approximated by a 
linear combination of T_O, T_1 ... T_n with coefficients

c_i = 2/n Sum(from 0 to n-1) (f(cos(PI*(k-1/2)/N)) cos(PI(k-1/2)/N))

These polynomials provide much better approximations than Taylor series 
(in most practical cases, you can get the same precision with a 
polynomial one or two degrees lower). 


Another solution for approximating sinh(x) would be to remember that 
sinh(x) = exp(x)/2 - 1/(2*exp(x))

On machines with fast exponential functions, this implementation can be 
fast enough.

Francois

- Raw text -


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