當前位置: 首頁>>代碼示例>>Python>>正文


Python cmath.acos方法代碼示例

本文整理匯總了Python中cmath.acos方法的典型用法代碼示例。如果您正苦於以下問題:Python cmath.acos方法的具體用法?Python cmath.acos怎麽用?Python cmath.acos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cmath的用法示例。


在下文中一共展示了cmath.acos方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _SA_partial_horiz_torispherical_head_int_1

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import acos [as 別名]
def _SA_partial_horiz_torispherical_head_int_1(x, b, c):
    x0 = x*x
    x1 = b - x0
    x2 = x1**0.5
    x3 = -b + x0
    x4 = c*c
    try:
        x5 = (x1 - x4)**-0.5
    except:
        x5 = (x1 - x4+0j)**-0.5
    x6 = x3 + x4
    x7 = b**0.5
    try:
        x3_pow = x3**(-1.5)
    except:
        x3_pow = (x3+0j)**(-1.5)
    ans = (x*cacos(c/x2) + x3_pow*x5*(-c*x1*csqrt(-x6*x6)*catan(x*x2/(csqrt(x3)*csqrt(x6)))
        + x6*x7*csqrt(-x1*x1)*catan(c*x*x5/x7))/csqrt(-x6/x1))
    return ans.real 
開發者ID:CalebBell,項目名稱:fluids,代碼行數:21,代碼來源:geometry.py

示例2: ACOS

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import acos [as 別名]
def ACOS(df, price='Close'):
    """
    Arc Cosine
    Returns: list of floats = jhta.ACOS(df, price='Close')
    """
    return [cmath.acos(df[price][i]).real for i in range(len(df[price]))] 
開發者ID:joosthoeks,項目名稱:jhTAlib,代碼行數:8,代碼來源:math_functions.py

示例3: test_acos

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import acos [as 別名]
def test_acos(self):
        self.assertAlmostEqual(complex(0.936812, -2.30551),
                               cmath.acos(complex(3, 4))) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:5,代碼來源:test_cmath_jy.py

示例4: test_areal_inverses

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import acos [as 別名]
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 
開發者ID:nsalomonis,項目名稱:altanalyze,代碼行數:39,代碼來源:test_functions.py

示例5: test_complex_inverse_functions

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import acos [as 別名]
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) 
開發者ID:nsalomonis,項目名稱:altanalyze,代碼行數:32,代碼來源:test_functions.py


注:本文中的cmath.acos方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。