delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/05/24/09:03:02

Date: 24 May 93 12:35:00 +0003 (GMT+3:00)
From: "Fine-62701 219828" <fine AT main1 DOT jinr DOT dubna DOT su>
Subject: Bug in tanh() from libm.a coming with DJGPP stuff!
To: "djgpp" <djgpp AT sun DOT soe DOT clarkson DOT edu>

  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 -


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