Mail Archives: djgpp/1993/05/24/09:03:02
Hi,
There is a bug in tanh() function from libm.a coming with DJGPP stuff.
See an example below. Obviously one must get the same result exactly
because of
tanh(z) = (exp(z) - exp(-z))/(exp(z)+exp(-z)) !!!
Note that the C source of tanh() is correct.
Regards
Valery
==================================================
#include "stdio.h"
main()
{
/* Builtin functions */
double tanh();
double exp();
/* Local variables */
static double y, z, e;
z = -3.14159265358979324;
y = tanh(z);
e = (exp(z) - exp(-z))/(exp(z)+exp(-z));
printf(" z = %e \n tanh(z) = %e \n (exp(z) - exp(-z))/(exp(z)+exp(-z)) = %e"
,z,y,e);
}
-------------------- Output -------------------------
z = -3.1415927e+00
tanh(z) = 9.9627208e-01
(exp(z) - exp(-z))/(exp(z)+exp(-z)) = -9.9627208e-01
=================================================================
Dr. Valery Fine /LCTA Telex 911621 dubna su
Fax (+7 095) 975 23 81
Joint Inst. for Nuclear Res. Email: fine AT main1 DOT jinr DOT dubna DOT su
Head Post Office, PO Box 79 fine AT vxcern DOT cern DOT ch
Moscow, 101000
Russia
- Raw text -