Python cmath.acosh() Examples

The following are 6 code examples of cmath.acosh(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cmath , or try the search function .
Example #1
Source File: math_functions.py    From jhTAlib with GNU General Public License v3.0 5 votes vote down vote up
def ACOSH(df, price='Close'):
    """
    Inverse Hyperbolic Cosine
    Returns: list of floats = jhta.ACOSH(df, price='Close')
    """
    return [cmath.acosh(df[price][i]).real for i in range(len(df[price]))] 
Example #2
Source File: test_cmath_jy.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_acosh(self):
        self.assertAlmostEqual(complex(2.30551, 0.93681),
                               cmath.acosh(complex(3, 4))) 
Example #3
Source File: test_cmath_jy.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_acosh(self):
        self.assertAlmostEqual(complex(2.30551, 0.93681),
                               cmath.acosh(complex(3, 4))) 
Example #4
Source File: test_functions.py    From altanalyze with Apache License 2.0 5 votes vote down vote up
def test_areal_inverses():
    assert asin(mpf(0)) == 0
    assert asinh(mpf(0)) == 0
    assert acosh(mpf(1)) == 0
    assert isinstance(asin(mpf(0.5)), mpf)
    assert isinstance(asin(mpf(2.0)), mpc)
    assert isinstance(acos(mpf(0.5)), mpf)
    assert isinstance(acos(mpf(2.0)), mpc)
    assert isinstance(atanh(mpf(0.1)), mpf)
    assert isinstance(atanh(mpf(1.1)), mpc)

    random.seed(1)
    for i in range(50):
        x = random.uniform(0, 1)
        assert asin(mpf(x)).ae(math.asin(x))
        assert acos(mpf(x)).ae(math.acos(x))

        x = random.uniform(-10, 10)
        assert asinh(mpf(x)).ae(cmath.asinh(x).real)
        assert isinstance(asinh(mpf(x)), mpf)
        x = random.uniform(1, 10)
        assert acosh(mpf(x)).ae(cmath.acosh(x).real)
        assert isinstance(acosh(mpf(x)), mpf)
        x = random.uniform(-10, 0.999)
        assert isinstance(acosh(mpf(x)), mpc)

        x = random.uniform(-1, 1)
        assert atanh(mpf(x)).ae(cmath.atanh(x).real)
        assert isinstance(atanh(mpf(x)), mpf)

    dps = mp.dps
    mp.dps = 300
    assert isinstance(asin(0.5), mpf)
    mp.dps = 1000
    assert asin(1).ae(pi/2)
    assert asin(-1).ae(-pi/2)
    mp.dps = dps 
Example #5
Source File: test_functions.py    From altanalyze with Apache License 2.0 5 votes vote down vote up
def test_complex_inverse_functions():
    for (z1, z2) in random_complexes(30):
        # apparently cmath uses a different branch, so we
        # can't use it for comparison
        assert sinh(asinh(z1)).ae(z1)
        #
        assert acosh(z1).ae(cmath.acosh(z1))
        assert atanh(z1).ae(cmath.atanh(z1))
        assert atan(z1).ae(cmath.atan(z1))
        # the reason we set a big eps here is that the cmath
        # functions are inaccurate
        assert asin(z1).ae(cmath.asin(z1), rel_eps=1e-12)
        assert acos(z1).ae(cmath.acos(z1), rel_eps=1e-12)
        one = mpf(1)
    for i in range(-9, 10, 3):
        for k in range(-9, 10, 3):
            a = 0.9*j*10**k + 0.8*one*10**i
            b = cos(acos(a))
            assert b.ae(a)
            b = sin(asin(a))
            assert b.ae(a)
    one = mpf(1)
    err = 2*10**-15
    for i in range(-9, 9, 3):
        for k in range(-9, 9, 3):
            a = -0.9*10**k + j*0.8*one*10**i
            b = cosh(acosh(a))
            assert b.ae(a, err)
            b = sinh(asinh(a))
            assert b.ae(a, err) 
Example #6
Source File: test_cmath_jy.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_acosh(self):
        self.assertAlmostEqual(complex(2.30551, 0.93681),
                               cmath.acosh(complex(3, 4)))