octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gcc-4.2.2 - wrong result of tanh - was (Re: octave-2.9.17 from source -


From: juras
Subject: gcc-4.2.2 - wrong result of tanh - was (Re: octave-2.9.17 from source - make check fails - please help!)
Date: Tue, 13 Nov 2007 05:53:56 -0800 (PST)

I quoting myself - forgive me :-)

juras wrote:
> 
> However test_arth fails:
>  ***** test
>  x = [pi/2*i, 3*pi/2*i];
>  v = [0, 0];
>  assert(all (abs (coth (x) - v) < sqrt (eps)));
> !!!!! test failed
> error: assert (all (abs (coth (x) - v) < sqrt (eps))) failed
> 
> There must be something wrong with tanh: (coth is defined in m-file as
> 1/tanh)
> octave:3> tanh(pi/2*i)
> ans = NaN + Infi
> 
> and the answer should be:
> 0+Infi
> 
> 

It seems again to be an issue in gcc:

include <complex>
#include <iostream>

int main()
{
  std::complex<double> x,y,ch,sh,z,z2;
  x=std::complex<double>(0,M_PI*0.5);
  y=std::tanh(x);
  ch=std::cosh(x);
  sh=std::sinh(x);
  z=sh/ch;
  z2=sh; z2/=ch;
  std::cout<<"x="<<x<<", tanh(x)  = "<<y<<std::endl;
  std::cout<<"x="<<x<<", sinh(x)  = "<<sh<<std::endl;
  std::cout<<"x="<<x<<", cosh(x)  = "<<ch<<std::endl;
  std::cout<<"x="<<x<<", sinh/cosh= "<<z<<std::endl;
  std::cout<<"x="<<x<<", sh/=ch   = "<<z2<<std::endl;
  std::cout<<"x="<<x<<", sh/ch2   = "<<(sinh(x)/cosh(x))<<std::endl;

  return 0;
}

gives the result:

address@hidden:~/download/numerics/test$ make tanh
g++     tanh.cc   -o tanh
address@hidden:~/download/numerics/test$ ./tanh
x=(0,1.5708), tanh(x)  = (nan,inf)
x=(0,1.5708), sinh(x)  = (0,1)
x=(0,1.5708), cosh(x)  = (6.12303e-17,0)
x=(0,1.5708), sinh/cosh= (0,1.63318e+16)
x=(0,1.5708), sh/=ch   = (0,1.63318e+16)
x=(0,1.5708), sh/ch2   = (0,1.63318e+16)
address@hidden:~/download/numerics/test$   

Do you have similar problems? Please comment!

-- 
View this message in context: 
http://www.nabble.com/octave-2.9.17-from-source---make-check-fails---please-help%21-tf4796444.html#a13726099
Sent from the Octave - Maintainers mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]