brython-dev / brython

Brython (Browser Python) is an implementation of Python 3 running in the browser
BSD 3-Clause "New" or "Revised" License
6.39k stars 510 forks source link

math.acosh(1e155) #1590

Closed clairvoyante closed 3 years ago

clairvoyante commented 3 years ago

CPython 3.9.1:

Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from math import acosh
>>> acosh(1e155)
357.593836594637
>>>

Brython 3.9.1 :

Brython 3.9.1 on Netscape 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75
>>> from math import acosh
>>> acosh(1e155)
inf
>>> 
clairvoyante commented 3 years ago

In https://www.netlib.org/fdlibm/e_acosh.c (CPython use it also when acosh() is missing) :

 *      acosh(x) := log(x)+ln2, if x is large; else
 *      acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
 *      acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.