Message-ID: <355855B4.4BA9@pobox.oleane.com> Date: Tue, 12 May 1998 15:59:16 +0200 From: Francois Charton Organization: CCMSA MIME-Version: 1.0 To: Jens Bischoff 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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk 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