erroneous NaN from tanh if complex argument
John W. Eaton
jwe at bevo.che.wisc.edu
Mon Dec 3 14:01:47 CST 2007
On 1-Dec-2007, danny.johnson.vmail at verizon.net wrote:
| --------
| Bug report for Octave 2.9.16 configured for i686-pc-msdosmsvc
|
| Description:
| -----------
|
| Octave erroneously declares NaN when encountering exponent underflow in tanh with argument having high real absolute value and any reasonable complex part (answer should simply be +/- 1.0 real). The size of the complex part does not matter greatly; simply being non-zero causes NaN when abs{real{argument}} > about 355.5 (i.e. when the imaginary part in the result would have an exponent underflow).
|
| Note: the configuration data below may be confusing--I am running the Windows version from sourceforge.net but I brought up Cygwin in order to run this bug script. Running on AMD Athlon X2, Windows Vista Home Premium, 2GB RAM.
|
| Repeat-By:
| ---------
|
| octave.exe:34> tanh(355.5 + .1i)
| ans = 1.0000e+000 + 6.5431e-310i
|
| octave.exe:35> tanh(355.6 + .1i)
| ans = NaN
Octave calls std::tanh to perform this calculation, so I guess the bug
is actually in the std::complex class, not Octave.
GNU libstdc++ appears to also have this problem, where the definition
in the <complex> header is:
template<typename _Tp>
inline complex<_Tp>
__complex_tanh(const complex<_Tp>& __z)
{ return std::sinh(__z) / std::cosh(__z); }
jwe
More information about the Bug-octave
mailing list