From fd04402466427b76648af49f135f805fa8210979 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Thu, 1 Feb 2024 05:08:22 +0300 Subject: [PATCH] Support asinh/acosh/atanh in the fp context --- mpmath/ctx_fp.py | 3 +++ mpmath/libfp.py | 4 ++++ mpmath/tests/test_fp.py | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/mpmath/ctx_fp.py b/mpmath/ctx_fp.py index 0db5e715..6590be0a 100644 --- a/mpmath/ctx_fp.py +++ b/mpmath/ctx_fp.py @@ -125,6 +125,9 @@ class FPContext(StandardBaseContext): cosh = staticmethod(libfp.cosh) sinh = staticmethod(libfp.sinh) tanh = staticmethod(libfp.tanh) + acosh = staticmethod(libfp.acosh) + asinh = staticmethod(libfp.asinh) + atanh = staticmethod(libfp.atanh) gamma = staticmethod(libfp.gamma) rgamma = staticmethod(libfp.rgamma) fac = factorial = staticmethod(libfp.factorial) diff --git a/mpmath/libfp.py b/mpmath/libfp.py index d03edc4d..c6d56664 100644 --- a/mpmath/libfp.py +++ b/mpmath/libfp.py @@ -64,6 +64,10 @@ cosh = _mathfun_real(math.cosh, cmath.cosh) sinh = _mathfun_real(math.sinh, cmath.sinh) tanh = _mathfun_real(math.tanh, cmath.tanh) +acosh = _mathfun(math.acosh, cmath.acosh) +asinh = _mathfun(math.asinh, cmath.asinh) +atanh = _mathfun_real(math.atanh, cmath.atanh) + floor = _mathfun_real(math.floor, lambda z: complex(math.floor(z.real), math.floor(z.imag))) ceil = _mathfun_real(math.ceil, diff --git a/mpmath/tests/test_fp.py b/mpmath/tests/test_fp.py index ef623e4f..6a211231 100644 --- a/mpmath/tests/test_fp.py +++ b/mpmath/tests/test_fp.py @@ -112,6 +112,11 @@ def test_fp_cospi_sinpi(): assert ae(fp.sinpi(-0.7+2j), (-216.6116802292079471 - 157.37650009392034693j)) assert ae(fp.cospi(-0.7+2j), (-157.37759774921754565 + 216.61016943630197336j)) +def test_fp_asinh_acosh_atanh(): + assert ae(fp.asinh(0), 0.0) + assert ae(fp.acosh(1), 0.0) + assert ae(fp.atanh(0), 0.0) + def test_fp_expj(): assert ae(fp.expj(0), (1.0 + 0.0j)) assert ae(fp.expj(1), (0.5403023058681397174 + 0.84147098480789650665j))