bugGNU Octave - Bugs: bug #56511, tanh returns NaN for certain...

 
 

bug #56511: tanh returns NaN for certain complex values in Windows under version 5.1.0 and 4.2.2 but not in Linux under 4.2.2.

Submitter:  None
Submitted:  Mon 17 Jun 2019 10:37:23 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Wont Fix Assigned to:  None
Originator Name:  Brian Borchers Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 25 Jul 2019 06:59:16 PM UTC, comment #8: 

Yeah, that looks like the root issue in MinGW.

Mike Miller <mtmiller>
Group Member
Thu 25 Jul 2019 06:37:43 PM UTC, comment #7: 

Or bug, that noone has commented on:
https://sourceforge.net/p/mingw-w64/bugs/598/

John Donoghue <lostbard>
Group Member
Thu 25 Jul 2019 06:26:58 PM UTC, comment #6: 

Perhaps related to an issue seen in R as well:

https://sourceforge.net/p/mingw-w64/mailman/message/35747206/

John Donoghue <lostbard>
Group Member
Thu 25 Jul 2019 01:01:47 AM UTC, comment #5: 

@Brian - gcc and g++ 7.4.0 for MinGW. All the details on how Octave is built for Windows are available in https://hg.octave.org/mxe-octave.

Mike Miller <mtmiller>
Group Member
Wed 24 Jul 2019 04:57:09 PM UTC, comment #4: 

Posted to the mailing list by Brian:

So what compiler and implementation of the standard library is being used in the Windows build?  The tanh function has worked correctly for decades in the Linux environment with gcc/g++ and associated libraries.

John W. Eaton <jwe>
Group administrator
Thu 20 Jun 2019 05:42:37 PM UTC, comment #3: 

Octave calls the standard library function 'std::tanh(std::complex)'.

https://en.cppreference.com/w/cpp/numeric/complex/tanh

If this function returns a value on Windows that you think is incorrect, this should probably be investigated in GCC or in the Windows system libraries. We generally do not try to reinvent standard system library functions in Octave.

If you can show that a C++ program can call std::tanh with a complex argument and return a different value from what Octave returns, then there may be a bug in Octave and we can reopen this.

Mike Miller <mtmiller>
Group Member
Tue 18 Jun 2019 10:19:36 PM UTC, comment #2: 

On linux i see this:



octave:26> tanh(366+1.0e-6*i)
ans =   1.0000e+00 + 4.9407e-324i
octave:27> tanh(367+1.0e-6*i)
ans =  1


Dmitri.

Dmitri A. Sergatskov <dasergatskov>
Tue 18 Jun 2019 09:20:29 PM UTC, comment #1: 

Confirmed with dev octave-6.0.0.

A little trying out:

>> tanh(355+1.0e-6*i)
ans =   1.0000e+00 + 1.7905e-314i
>> tanh(356+1.0e-6*i)
ans =  NaN


I've seen this before with Fortran libraries a long time ago, then it was related to the (underlying) exp() library function but that is very probably not related here.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 17 Jun 2019 10:37:23 PM UTC, original submission:  

Under Octave 5.1.0 in Windows 10, I get:


>> tanh(4000+1.0e-6*i)
ans =     NaN


I also got the same result under 4.2.2 in Windows 10.

Under 4.2.2 in Linux, I get the correct answer:


>> tanh(4000+1.0e-6*i)
ans =     1.0000e+00


Many other complex values with large (in absolute value) real parts give similar results.  e.g. try -4000+1.0e-6*i. 

I realize that this may well be due to a bug in an upstream math library rather than Octave itself. It may be relatively simple to work around this bug by providing appropriate limiting values in these extreme cases.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-20 mtmiller StatusConfirmed Wont Fix
        Open/ClosedOpen Closed
    2019-06-18 philipnienhuis StatusNone Confirmed
        Release5.1.0 dev

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code