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


Python cmath.atan方法代碼示例

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


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

示例1: _SA_partial_horiz_torispherical_head_int_1

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [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: _SA_partial_horiz_torispherical_head_int_2

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [as 別名]
def _SA_partial_horiz_torispherical_head_int_2(y, t2, s, c1):
    y2 = y*y
    try:
        x10 = (t2 - y2)**0.5
    except:
        x10 = (t2 - y2+0.0j)**0.5
    try:
        # Some tiny heights make the square root slightly under 0
        x = ((c1 - y2 + (s+s)*x10)**0.5).real
    except:
        # Python 2 compat - don't take the square root of a negative number with no complex part
        x = ((c1 - y2 + (s+s)*x10 + 0.0j)**0.5).real
    try:
        x0 = t2 - y2
        x1 = s*x10
        t10 = x1 + x1 + s*s + x0
        x3 = t10 - x*x
        x4 = x3**0.5
        ans = x4*(t2*t10/(x0*x3))**0.5*catan(x/x4).real
    except:
        ans = 0.0
#     ans = sqrt((t2* (s**2+t2-x**2+2.0*s* sqrt(t2-x**2)))/((t2-x**2)* (s**2+t2-x**2+2 *s* sqrt(t2-x**2)-y**2)))* sqrt(s**2+t2-x**2+2 *s* sqrt(t2-x**2)-y**2) *atan(y/sqrt(s**2+t2-x**2+2 *s* sqrt(t2-x**2)-y**2))
    return ans.real 
開發者ID:CalebBell,項目名稱:fluids,代碼行數:25,代碼來源:geometry.py

示例3: test_atan

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [as 別名]
def test_atan():
    mp.dps = 15
    assert atan(-2.3).ae(math.atan(-2.3))
    assert atan(1e-50) == 1e-50
    assert atan(1e50).ae(pi/2)
    assert atan(-1e-50) == -1e-50
    assert atan(-1e50).ae(-pi/2)
    assert atan(10**1000).ae(pi/2)
    for dps in [25, 70, 100, 300, 1000]:
        mp.dps = dps
        assert (4*atan(1)).ae(pi)
    mp.dps = 15
    pi2 = pi/2
    assert atan(mpc(inf,-1)).ae(pi2)
    assert atan(mpc(inf,0)).ae(pi2)
    assert atan(mpc(inf,1)).ae(pi2)
    assert atan(mpc(1,inf)).ae(pi2)
    assert atan(mpc(0,inf)).ae(pi2)
    assert atan(mpc(-1,inf)).ae(-pi2)
    assert atan(mpc(-inf,1)).ae(-pi2)
    assert atan(mpc(-inf,0)).ae(-pi2)
    assert atan(mpc(-inf,-1)).ae(-pi2)
    assert atan(mpc(-1,-inf)).ae(-pi2)
    assert atan(mpc(0,-inf)).ae(-pi2)
    assert atan(mpc(1,-inf)).ae(pi2) 
開發者ID:nsalomonis,項目名稱:altanalyze,代碼行數:27,代碼來源:test_functions.py

示例4: testTanhSign

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [as 別名]
def testTanhSign(self):
        for z in complex_zeros:
            self.assertComplexIdentical(cmath.tanh(z), z)

    # The algorithm used for atan and atanh makes use of the system
    # log1p function; If that system function doesn't respect the sign
    # of zero, then atan and atanh will also have difficulties with
    # the sign of complex zeros. 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:10,代碼來源:test_cmath.py

示例5: testAtanSign

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [as 別名]
def testAtanSign(self):
        for z in complex_zeros:
            self.assertComplexIdentical(cmath.atan(z), z) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:5,代碼來源:test_cmath.py

示例6: ATAN

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

示例7: B0

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [as 別名]
def B0(s, mq):
    if s==0.:
        return -2.
    if 4*mq**2/s == 1.:
        return 0.
    # to select the right branch of the complex arctangent, need to
    # interpret m^2 as m^2-i\epsilon
    iepsilon = 1e-8j
    return -2*sqrt(4*(mq**2-iepsilon)/s - 1) * atan(1/sqrt(4*(mq**2-iepsilon)/s - 1))

# (30), (31) of hep-ph/0106067v2 
開發者ID:flav-io,項目名稱:flavio,代碼行數:13,代碼來源:qcdf.py

示例8: h

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [as 別名]
def h(s, mq, mu):
  """Fermion loop function as defined e.g. in eq. (11) of hep-ph/0106067v2."""
  if mq == 0.:
      return 8/27. + (4j*pi)/9. + (8 * log(mu))/9. - (4 * log(s))/9.
  if s == 0.:
      return -4/9. * (1 + log(mq**2/mu**2))
  z = 4 * mq**2/s
  if z > 1:
      A = atan(1/sqrt(z-1))
  else:
      A = log((1+sqrt(1-z))/sqrt(z)) - 1j*pi/2.
  return (-4/9. * log(mq**2/mu**2) + 8/27. + 4/9. * z
          -4/9. * (2 + z) * sqrt(abs(z - 1)) * A) 
開發者ID:flav-io,項目名稱:flavio,代碼行數:15,代碼來源:matrixelements.py

示例9: acot

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [as 別名]
def acot(x):
    return pi/2.-atan(x) 
開發者ID:flav-io,項目名稱:flavio,代碼行數:4,代碼來源:matrixelements.py

示例10: test_atan

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

示例11: test_complex_inverse_functions

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [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

示例12: test_cmath_matches_math

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [as 別名]
def test_cmath_matches_math(self):
        # check that corresponding cmath and math functions are equal
        # for floats in the appropriate range

        # test_values in (0, 1)
        test_values = [0.01, 0.1, 0.2, 0.5, 0.9, 0.99]

        # test_values for functions defined on [-1., 1.]
        unit_interval = test_values + [-x for x in test_values] + \
            [0., 1., -1.]

        # test_values for log, log10, sqrt
        positive = test_values + [1.] + [1./x for x in test_values]
        nonnegative = [0.] + positive

        # test_values for functions defined on the whole real line
        real_line = [0.] + positive + [-x for x in positive]

        test_functions = {
            'acos' : unit_interval,
            'asin' : unit_interval,
            'atan' : real_line,
            'cos' : real_line,
            'cosh' : real_line,
            'exp' : real_line,
            'log' : positive,
            'log10' : positive,
            'sin' : real_line,
            'sinh' : real_line,
            'sqrt' : nonnegative,
            'tan' : real_line,
            'tanh' : real_line}

        for fn, values in test_functions.items():
            float_fn = getattr(math, fn)
            complex_fn = getattr(cmath, fn)
            for v in values:
                z = complex_fn(v)
                self.rAssertAlmostEqual(float_fn(v), z.real)
                self.assertEqual(0., z.imag)

        # test two-argument version of log with various bases
        for base in [0.5, 2., 10.]:
            for v in positive:
                z = cmath.log(v, base)
                self.rAssertAlmostEqual(math.log(v, base), z.real)
                self.assertEqual(0., z.imag) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:49,代碼來源:test_cmath.py

示例13: test_perturbation_rounding

# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import atan [as 別名]
def test_perturbation_rounding():
    mp.dps = 100
    a = pi/10**50
    b = -pi/10**50
    c = 1 + a
    d = 1 + b
    mp.dps = 15
    assert exp(a) == 1
    assert exp(a, rounding='c') > 1
    assert exp(b, rounding='c') == 1
    assert exp(a, rounding='f') == 1
    assert exp(b, rounding='f') < 1
    assert cos(a) == 1
    assert cos(a, rounding='c') == 1
    assert cos(b, rounding='c') == 1
    assert cos(a, rounding='f') < 1
    assert cos(b, rounding='f') < 1
    for f in [sin, atan, asinh, tanh]:
        assert f(a) == +a
        assert f(a, rounding='c') > a
        assert f(a, rounding='f') < a
        assert f(b) == +b
        assert f(b, rounding='c') > b
        assert f(b, rounding='f') < b
    for f in [asin, tan, sinh, atanh]:
        assert f(a) == +a
        assert f(b) == +b
        assert f(a, rounding='c') > a
        assert f(b, rounding='c') > b
        assert f(a, rounding='f') < a
        assert f(b, rounding='f') < b
    assert ln(c) == +a
    assert ln(d) == +b
    assert ln(c, rounding='c') > a
    assert ln(c, rounding='f') < a
    assert ln(d, rounding='c') > b
    assert ln(d, rounding='f') < b
    assert cosh(a) == 1
    assert cosh(b) == 1
    assert cosh(a, rounding='c') > 1
    assert cosh(b, rounding='c') > 1
    assert cosh(a, rounding='f') == 1
    assert cosh(b, rounding='f') == 1 
開發者ID:nsalomonis,項目名稱:altanalyze,代碼行數:45,代碼來源:test_functions.py


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