[Rd] Hyperbolic tangent different results on Windows and Mac

Rodrigo Zepeda rzepeda17 at gmail.com
Fri Mar 17 19:56:06 CET 2017


Dear all,

We seem to have found a "strange" behaviour in the hyperbolic tangent
function tanh on Windows.
When running tanh(356 + 0i) the Windows result is NaN + 0.i while on Mac
the result is 1 + 0i. It doesn't seem to be a floating point error because
on Mac it is possible to run arbitrarily large numbers (say tanh(
999999677873648767519238192348124812341234182374817239847812738481234871823+0i)
) and still get 1 + 0i as result. This seems to be related to the imaginary
part as tanh(356) returns 1 in both Windows and Mac.

We have obtained those results in:
1) Mac with El Capitan v 10.11.6 *processor: 2.7 GHz Intel Core i5*
- 2) Mac with Sierra v 10.12.3 *processor: 3.2 GHz Intel Core i5*
- 3) Windows 10 Home v 1607 *processor: Intel Core m3-SY30 CPU@ 0.90 GHz
1.51 GHz*
- 4) Windows 7 Home Premium Service Pack 1 *processor: Intel Core i5-2410M
CPU @2.30 GHz 2.30GHz.*

​In all cases we are using R version 3.3.3 (64 bits)​

- *Does anybody have a clue on why is this happening?*
-
​PS: We have previously posted this issue in Stack Overflow (
http://stackoverflow.com/questions/42847414/hyperbolic-tangent-in-r-throws-nan-in-windows-but-not-in-mac).
A comment suggests it is related to a glibc bug.

​
​Thanks,​
Rod

	[[alternative HTML version deleted]]



More information about the R-devel mailing list