From: Kbwms Message-ID: <643f6e90.3558c708@aol.com> Date: Tue, 12 May 1998 18:02:47 EDT To: j DOT bischoff AT airbus DOT dasa DOT de Cc: djgpp AT delorie DOT com Mime-Version: 1.0 Subject: Re: Code to Fix sinh() in libm.a Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit Precedence: bulk Subj: Re: Code to Fix sinh() in libm.a To: j DOT bischoff AT airbus DOT dasa DOT de (Jens Bischoff): Dear Jens Bischoff, On 05-11-98 at 03:42:34 EST you wrote: > CC: djgpp AT delorie DOT com > > Hi! > > Thank you for your work! > However, I believe that the coefficients are slightly inexact. > The correct values should be: > > long double C[] = { 1.L, > 1/6.L, > 1/120.L, > 1/5040.L, > 1/362880.L, > 1/39916800.L, > 1/6227020800.L}; > > if they are derived from the series for sinhx(x): > > sinh(x) = 1 + x^3/3! + x^5/5! + x^7/7! + ... > > Besides, this approximation (that uses 7 coefficients) is only > accurate with 64bit (double) arithmetic. > With long doubles a 8th coefficient should be added: > > C[7] = 1/1307674368000.L > /* ------------------------------------------ */ /* sinh - Returns hyperbolic sine of argument */ /* ------------------------------------------ */ /* --------------------------------------- */ /* Approxination no. 1906 from Hart, et al */ /* --------------------------------------- */ long double C[] = { .10000000000000000000428964e1, .16666666666666666026158977e0, .83333333333336099945076e-2, .19841269840742957068490e-3, .27557319739041248550000e-5, .25051838782995770000000e-7, .16130886652601000000000e-9 }; The coefficients were taken from Hart, et al, *Computer Approximations*, Wiley and Sons, New York, 1968, pages 104 & 213, approximation # 1906. For arguments in (0, .5), it is accurate to 20.84 decimal digits which is about 69 bits, certainly enough for a double precision function. The coefficients are stated in long double and the arithmetic is carried out in long double to ensure that the precision is maintained. I hasten to remind you that the subject at hand is an approximation to double precision function sinh(). For an approximation to sinhl(), formula # 1907, with 8 coefficients, yields an accuracy of about 81 bits. Thanks for the note. Regards, K.B. Williams