本文整理汇总了Python中cmath.asinh方法的典型用法代码示例。如果您正苦于以下问题:Python cmath.asinh方法的具体用法?Python cmath.asinh怎么用?Python cmath.asinh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmath
的用法示例。
在下文中一共展示了cmath.asinh方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ASINH
# 需要导入模块: import cmath [as 别名]
# 或者: from cmath import asinh [as 别名]
def ASINH(df, price='Close'):
"""
Inverse Hyperbolic Sine
Returns: list of floats = jhta.ASINH(df, price='Close')
"""
return [cmath.asinh(df[price][i]).real for i in range(len(df[price]))]
示例2: test_asinh
# 需要导入模块: import cmath [as 别名]
# 或者: from cmath import asinh [as 别名]
def test_asinh(self):
self.assertAlmostEqual(complex(2.29991, 0.917617),
cmath.asinh(complex(3, 4)))
示例3: test_areal_inverses
# 需要导入模块: import cmath [as 别名]
# 或者: from cmath import asinh [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
示例4: test_invhyperb_inaccuracy
# 需要导入模块: import cmath [as 别名]
# 或者: from cmath import asinh [as 别名]
def test_invhyperb_inaccuracy():
mp.dps = 15
assert (asinh(1e-5)*10**5).ae(0.99999999998333333)
assert (asinh(1e-10)*10**10).ae(1)
assert (asinh(1e-50)*10**50).ae(1)
assert (asinh(-1e-5)*10**5).ae(-0.99999999998333333)
assert (asinh(-1e-10)*10**10).ae(-1)
assert (asinh(-1e-50)*10**50).ae(-1)
assert asinh(10**20).ae(46.744849040440862)
assert asinh(-10**20).ae(-46.744849040440862)
assert (tanh(1e-10)*10**10).ae(1)
assert (tanh(-1e-10)*10**10).ae(-1)
assert (atanh(1e-10)*10**10).ae(1)
assert (atanh(-1e-10)*10**10).ae(-1)
示例5: test_complex_inverse_functions
# 需要导入模块: import cmath [as 别名]
# 或者: from cmath import asinh [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)
示例6: test_perturbation_rounding
# 需要导入模块: import cmath [as 别名]
# 或者: from cmath import asinh [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