Skip Menu |

This queue is for tickets about the Math-Trig CPAN distribution.

Report information
The Basics
Id: 104644
Status: new
Priority: 0/
Queue: Math-Trig

People
Owner: Nobody in particular
Requestors: peter.john.acklam [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Poor numerical accuracy in sinh()
When x ≈ 0, sinh(x) ≈ x. The following should return approximately 1e-16, but it returns 0: $ perl -MMath::Trig -wle 'print sinh(1e-16)' 0 Python gets it right … $ python3 -c 'import math; print(math.sinh(1e-16))' 1e-16
The same goes for tanh(). $ perl -MMath::Trig -wle 'print tanh(1e-16)' 0 Again, Python gets it right: $ python3 -c 'import math; print(math.tanh(1e-16))' 1e-16
asinh() has the same problem: $ perl -MMath::Trig -wle 'print asinh(1e-18)' 0 $ python3 -c 'import math; print(math.asinh(1e-18))' 1e-18 as does atanh(): $ perl -MMath::Trig -wle 'print atanh(1e-18)' 0 $ python3 -c 'import math; print(math.atanh(1e-18))' 1e-18 All of the functions sinh(), asinh(), tan(), and atanh() are approximately equal to x, when x is close to zero. It seems that with Math::Trig, these functions return zero even in cases where a more accurate result is well within the numerical range supported by Perl scalars.