本文整理匯總了Python中cmath.sinh方法的典型用法代碼示例。如果您正苦於以下問題:Python cmath.sinh方法的具體用法?Python cmath.sinh怎麽用?Python cmath.sinh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cmath
的用法示例。
在下文中一共展示了cmath.sinh方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SINH
# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import sinh [as 別名]
def SINH(df, price='Close'):
"""
Hyperbolic Sine
Returns: list of floats = jhta.SINH(df, price='Close')
"""
return [cmath.sinh(df[price][i]).real for i in range(len(df[price]))]
示例2: test_sinh
# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import sinh [as 別名]
def test_sinh(self):
self.assertAlmostEqual(complex(-6.54812, -7.61923),
cmath.sinh(complex(3, 4)))
示例3: test_trig_hyperb_basic
# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import sinh [as 別名]
def test_trig_hyperb_basic():
for x in (list(range(100)) + list(range(-100,0))):
t = x / 4.1
assert cos(mpf(t)).ae(math.cos(t))
assert sin(mpf(t)).ae(math.sin(t))
assert tan(mpf(t)).ae(math.tan(t))
assert cosh(mpf(t)).ae(math.cosh(t))
assert sinh(mpf(t)).ae(math.sinh(t))
assert tanh(mpf(t)).ae(math.tanh(t))
assert sin(1+1j).ae(cmath.sin(1+1j))
assert sin(-4-3.6j).ae(cmath.sin(-4-3.6j))
assert cos(1+1j).ae(cmath.cos(1+1j))
assert cos(-4-3.6j).ae(cmath.cos(-4-3.6j))
示例4: test_complex_functions
# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import sinh [as 別名]
def test_complex_functions():
for x in (list(range(10)) + list(range(-10,0))):
for y in (list(range(10)) + list(range(-10,0))):
z = complex(x, y)/4.3 + 0.01j
assert exp(mpc(z)).ae(cmath.exp(z))
assert log(mpc(z)).ae(cmath.log(z))
assert cos(mpc(z)).ae(cmath.cos(z))
assert sin(mpc(z)).ae(cmath.sin(z))
assert tan(mpc(z)).ae(cmath.tan(z))
assert sinh(mpc(z)).ae(cmath.sinh(z))
assert cosh(mpc(z)).ae(cmath.cosh(z))
assert tanh(mpc(z)).ae(cmath.tanh(z))
示例5: test_complex_inverse_functions
# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import sinh [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_mpcfun_real_imag
# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import sinh [as 別名]
def test_mpcfun_real_imag():
mp.dps = 15
x = mpf(0.3)
y = mpf(0.4)
assert exp(mpc(x,0)) == exp(x)
assert exp(mpc(0,y)) == mpc(cos(y),sin(y))
assert cos(mpc(x,0)) == cos(x)
assert sin(mpc(x,0)) == sin(x)
assert cos(mpc(0,y)) == cosh(y)
assert sin(mpc(0,y)) == mpc(0,sinh(y))
assert cospi(mpc(x,0)) == cospi(x)
assert sinpi(mpc(x,0)) == sinpi(x)
assert cospi(mpc(0,y)).ae(cosh(pi*y))
assert sinpi(mpc(0,y)).ae(mpc(0,sinh(pi*y)))
c, s = cospi_sinpi(mpc(x,0))
assert c == cospi(x)
assert s == sinpi(x)
c, s = cospi_sinpi(mpc(0,y))
assert c.ae(cosh(pi*y))
assert s.ae(mpc(0,sinh(pi*y)))
c, s = cos_sin(mpc(x,0))
assert c == cos(x)
assert s == sin(x)
c, s = cos_sin(mpc(0,y))
assert c == cosh(y)
assert s == mpc(0,sinh(y))
示例7: test_perturbation_rounding
# 需要導入模塊: import cmath [as 別名]
# 或者: from cmath import sinh [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