当前位置: 首页>>代码示例>>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;未经允许,请勿转载。