本文整理汇总了Python中math.sinh函数的典型用法代码示例。如果您正苦于以下问题:Python sinh函数的具体用法?Python sinh怎么用?Python sinh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sinh函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testHyperbolic
def testHyperbolic(self):
self.assertEqual(math.sinh(5), hyperbolic.sineh_op(5))
self.assertEqual(math.cosh(5), hyperbolic.cosineh_op(5))
self.assertEqual(math.tanh(5), hyperbolic.tangenth_op(5))
self.assertEqual(1. / math.sinh(5), hyperbolic.cosecanth_op(5))
self.assertEqual(1. / math.cosh(5), hyperbolic.secanth_op(5))
self.assertEqual(1. / math.tanh(5), hyperbolic.cotangenth_op(5))
示例2: heisenT
def heisenT(beta):
# Following notation of Xiang (http://arxiv.org/pdf/1201.1144v4.pdf)
W=np.array([[math.sqrt(math.cosh(beta)), math.sqrt(math.sinh(beta))],
[math.sqrt(math.cosh(beta)), -math.sqrt(math.sinh(beta))]])
#T=np.einsum("au,ad,al,ar->udlr",W,W,W,W)
T=np.einsum("al,ar->lr",W,W)
return T
示例3: sinh
def sinh(x):
""" Return the hyperbolic sine of x. """
if math.isinf(x.real) or math.isinf(x.imag):
# need to raise DomainError if y is +/- infinity and x is not
# a NaN and not -infinity
if math.isinf(x.imag) and not math.isnan(x.real):
raise ValueError("math domain error")
if math.isinf(x.real) and -_INF < x.imag < _INF and x.imag != .0:
if x.real > 0:
_real = math.copysign(_INF, cos(x.imag))
_imag = math.copysign(_INF, sin(x.imag))
else:
_real = -math.copysign(_INF, cos(x.imag))
_imag = math.copysign(_INF, sin(x.imag))
return complex(_real, _imag)
return _SPECIAL_VALUE(x,_sinh_special_values)
if math.fabs(x.real) > _CM_LOG_LARGE_DOUBLE:
x_minus_one = x.real - math.copysign(1.0, x.real)
_real = math.cos(x.imag)*math.sinh(x.imag)*math.e
_imag = math.sin(x.imag)*math.cosh(x.imag)*math.e
else:
_real = math.cos(x.imag)*math.sinh(x.real)
_imag = math.sin(x.imag)*math.cosh(x.real)
if math.isinf(_real) or math.isinf(_imag):
raise OverflowError()
return complex(_real, _imag)
示例4: cosh
def cosh(x):
"""Return the hyperbolic cosine of x."""
# special treatment for cosh(+/-inf + iy) if y is not a NaN
if isinf(x):
if -_INF < x.imag < _INF and x.imag != .0:
if x.real > 0:
_real = math.copysign(_INF, math.cos(x.imag))
_imag = math.copysign(_INF, math.sin(x.imag))
else:
_real = math.copysign(_INF, math.cos(x.imag))
_imag = -math.copysign(_INF, math.sin(x.imag))
return complex(_real,_imag)
else:
# need to raise math domain error if y is +/- infinity and x is not a NaN
if x.imag != .0 and not math.isnan(x.real):
raise ValueError("math domain error")
return _SPECIAL_VALUE(x,_cosh_special_values)
if math.fabs(x.real) > _CM_LOG_LARGE_DOUBLE:
# deal correctly with cases where cosh(x.real) overflows but
# cosh(z) does not.
x_minus_one = x.real - math.copysign(1.0, x.real)
_real = cos(x.imag) * math.cosh(x_minus_one) * math.e
_imag = sin(x.imag) * math.sinh(x_minus_one) * math.e
else:
_real = math.cos(x.imag) * math.cosh(x.real)
_imag = math.sin(x.imag) * math.sinh(x.real)
ret = complex(_real, _imag)
# detect overflow
if isinf(ret):
raise OverflowError()
return ret
示例5: laplace_Dirichlet_analytic
def laplace_Dirichlet_analytic(Ttop, x, y):
""" Function that calculates the analytic solution to the laplace heat equation
d^2(T)/dx^2 + d^2(T)/dy^2 = 0
with Dirichlet boundary conditions:
T(x, 0) = 0
T(0, y) = 0 y<1.5
T(1, y) = 0 y<1.5
T(x, 1.5) = Ttop
on a square grid with xmax = 1 and ymax= 1
Args:
Ttop(float): Temperature at top, T(x, 1.5)
x(float): x-coordinate
y(float): y-coordinate
Returns:
T(float): Temperature at T(x, y)
"""
sum = 0
for n in range(1,50, 1):
lambdan = pi*n
An = 2*((-1)**(n+1)+1)/(lambdan*sinh(1.5*lambdan))
term = An*sinh(lambdan*y )*sin(lambdan*x)
sum += term
return Ttop*sum
示例6: to_wgs84
def to_wgs84(x, y, twd67=False):
'''
The formula is based on
"https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system"
'''
if twd67:
x, y = twd67_to_twd97(x, y)
x /= 1000.0 # m to km
y /= 1000.0 # m to km
xi = (y - N0) / (k0 * A)
eta = (x - E0) / (k0 * A)
xip = (xi -
b1 * math.sin(2 * xi) * math.cosh(2 * eta) -
b2 * math.sin(4 * xi) * math.cosh(4 * eta) -
b3 * math.sin(6 * xi) * math.cosh(6 * eta))
etap = (eta -
b1 * math.cos(2 * xi) * math.sinh(2 * eta) -
b2 * math.cos(4 * xi) * math.sinh(4 * eta) -
b3 * math.cos(6 * xi) * math.sinh(6 * eta))
chi = math.asin(math.sin(xip) / math.cosh(etap))
lat = math.degrees(
chi +
d1 * math.sin(2 * chi) +
d2 * math.sin(4 * chi) +
d3 * math.sin(6 * chi))
lon = lon0 + math.degrees(
math.atan(math.sinh(etap) / math.cos(xip)))
return (lat, lon)
示例7: c_sinh
def c_sinh(x, y):
# special treatment for sinh(+/-inf + iy) if y is finite and nonzero
if not isfinite(x) or not isfinite(y):
if isinf(x) and isfinite(y) and y != 0.:
if x > 0:
real = copysign(INF, math.cos(y))
imag = copysign(INF, math.sin(y))
else:
real = -copysign(INF, math.cos(y))
imag = copysign(INF, math.sin(y))
r = (real, imag)
else:
r = sinh_special_values[special_type(x)][special_type(y)]
# need to raise ValueError if y is +/- infinity and x is not
# a NaN
if isinf(y) and not isnan(x):
raise ValueError("math domain error")
return r
if fabs(x) > CM_LOG_LARGE_DOUBLE:
x_minus_one = x - copysign(1., x)
real = math.cos(y) * math.sinh(x_minus_one) * math.e
imag = math.sin(y) * math.cosh(x_minus_one) * math.e
else:
real = math.cos(y) * math.sinh(x)
imag = math.sin(y) * math.cosh(x)
if isinf(real) or isinf(imag):
raise OverflowError("math range error")
return real, imag
示例8: exact_fn
def exact_fn ( x ):
#
## EXACT_FN evaluates the exact solution.
#
from math import sinh
value = x - sinh ( x ) / sinh ( 1.0 )
return value
示例9: tri_angles
def tri_angles(L):
ans = [0, 0, 0]
for i in xrange(3):
top = math.cosh(L[i])*math.cosh(L[(i+2)%3]) - math.cosh( L[(i+1)%3] )
bottom = math.sinh(L[i])*math.sinh(L[(i+2)%3])
ans[i] = math.acos(top/bottom)
return ans
示例10: test_funcs_multi
def test_funcs_multi(self):
pi = math.pi
# sin family
self.assertQuantity(data.sin(Quantity( (0,pi/2), (2,2))), (0,1), (2,0))
self.assertQuantity(data.sinh(Quantity((0,1), (2,2))), (0, math.sinh(1)), (2, math.cosh(1)*2))
self.assertQuantity(data.asin(Quantity((0,0.5), (2,2))), (0,math.asin(0.5)), (2,2/math.sqrt(1-0.5**2)))
self.assertQuantity(data.asinh(Quantity((0,1), (2,2))), (0,math.asinh(1)), (2,2/math.sqrt(1+1**2)))
# cos family
self.assertQuantity(data.cos(Quantity((0,pi/2), (2,2))), (1,0), (0,-2))
self.assertQuantity(data.cosh(Quantity((0,1), (2,2))), (1,math.cosh(1)), (0,math.sinh(1)*2))
self.assertQuantity(data.acos(Quantity((0,0.5), (2,2))), (math.acos(0),math.acos(0.5)), (-2,-2/math.sqrt(1-0.5**2)))
self.assertQuantity(data.acosh(Quantity((2,3), (2,2))), (math.acosh(2), math.acosh(3)), (2/math.sqrt(2**2-1),2/math.sqrt(3**2-1)))
# tan family
self.assertQuantity(data.tan(Quantity((0,1), (2,2))), (0,math.tan(1)), (2,2/math.cos(1)**2))
self.assertQuantity(data.tanh(Quantity((0,1), (2,2))), (0,math.tanh(1)), (2,2/math.cosh(1)**2))
self.assertQuantity(data.atan(Quantity((0,1), (2,2))), (0, math.atan(1)), (2,2/(1+1**2)))
self.assertQuantity(data.atan2(Quantity((0,1), (2,2)), Quantity((1,1), (0,0))), (0,math.atan(1)), (2,2/(1+1**2)))
self.assertQuantity(data.atanh(Quantity((0,0.5), (2,2))), (0,math.atanh(0.5)), (2,2/(1-0.5**2)))
#misc
self.assertQuantity(data.sqrt(Quantity((1,4), (2,2))), (1,2), (1,1/2))
self.assertQuantity(data.exp(Quantity((1,4), (2,2))), (math.e, math.e**4), (2 * math.e,2*math.e**4))
self.assertQuantity(data.log(Quantity((1,4), (2,2))), (0, math.log(4)), (2,1/2))
示例11: gridToGeodetic
def gridToGeodetic(self, north, east):
"""
Transformation from grid coordinates to geodetic coordinates.
@param north (corresponds to X in RT 90 and N in SWEREF 99.)
@param east (corresponds to Y in RT 90 and E in SWEREF 99.)
@return (latitude, longitude)
"""
if (self._initialized == False):
return None
deg_to_rad = math.pi / 180
lambda_zero = self._central_meridian * deg_to_rad
xi = (north - self._false_northing) / (self._scale * self._a_roof)
eta = (east - self._false_easting) / (self._scale * self._a_roof)
xi_prim = xi - \
self._delta1*math.sin(2.0*xi) * math.cosh(2.0*eta) - \
self._delta2*math.sin(4.0*xi) * math.cosh(4.0*eta) - \
self._delta3*math.sin(6.0*xi) * math.cosh(6.0*eta) - \
self._delta4*math.sin(8.0*xi) * math.cosh(8.0*eta)
eta_prim = eta - \
self._delta1*math.cos(2.0*xi) * math.sinh(2.0*eta) - \
self._delta2*math.cos(4.0*xi) * math.sinh(4.0*eta) - \
self._delta3*math.cos(6.0*xi) * math.sinh(6.0*eta) - \
self._delta4*math.cos(8.0*xi) * math.sinh(8.0*eta)
phi_star = math.asin(math.sin(xi_prim) / math.cosh(eta_prim))
delta_lambda = math.atan(math.sinh(eta_prim) / math.cos(xi_prim))
lon_radian = lambda_zero + delta_lambda
lat_radian = phi_star + math.sin(phi_star) * math.cos(phi_star) * \
(self._Astar + \
self._Bstar*math.pow(math.sin(phi_star), 2) + \
self._Cstar*math.pow(math.sin(phi_star), 4) + \
self._Dstar*math.pow(math.sin(phi_star), 6))
lat = lat_radian * 180.0 / math.pi
lon = lon_radian * 180.0 / math.pi
return (lat, lon)
示例12: c_cosh
def c_cosh(x, y):
if not isfinite(x) or not isfinite(y):
if isinf(x) and isfinite(y) and y != 0.:
if x > 0:
real = copysign(INF, math.cos(y))
imag = copysign(INF, math.sin(y))
else:
real = copysign(INF, math.cos(y))
imag = -copysign(INF, math.sin(y))
r = (real, imag)
else:
r = cosh_special_values[special_type(x)][special_type(y)]
# need to raise ValueError if y is +/- infinity and x is not
# a NaN
if isinf(y) and not isnan(x):
raise ValueError("math domain error")
return r
if fabs(x) > CM_LOG_LARGE_DOUBLE:
# deal correctly with cases where cosh(x) overflows but
# cosh(z) does not.
x_minus_one = x - copysign(1., x)
real = math.cos(y) * math.cosh(x_minus_one) * math.e
imag = math.sin(y) * math.sinh(x_minus_one) * math.e
else:
real = math.cos(y) * math.cosh(x)
imag = math.sin(y) * math.sinh(x)
if isinf(real) or isinf(imag):
raise OverflowError("math range error")
return real, imag
示例13: tileGeometry
def tileGeometry(self, x, y, z):
n = 2.0 ** z
xmin = x / n * 360.0 - 180.0
xmax = (x + 1) / n * 360.0 - 180
ymin = math.degrees(math.atan(math.sinh(math.pi * (1 - 2 * y / n))))
ymax = math.degrees(math.atan(math.sinh(math.pi * (1 - 2 * (y + 1) / n))))
return QgsGeometry.fromRect(QgsRectangle(xmin, ymin, xmax, ymax))
示例14: sinh
def sinh(self, other=None):
# Return hiperbolic sine of interval
if other != None:
intv = IReal(self, other)
else:
if type(self) == float or type(self) == str:
intv = IReal(self)
else:
intv = self
if math.sinh(intv.inf) > math.sinh(intv.sup):
inf = max(intv.inf, intv.sup)
sup = min(intv.inf, intv.sup)
else:
inf = intv.inf
sup = intv.sup
ireal.rounding.set_mode(1)
ireal.rounding.set_mode(-1)
ireal.rounding.set_mode(-1)
new_inf = math.sinh(inf)
ireal.rounding.set_mode(1)
new_sup = max(float(IReal('%.16f' % math.sinh(sup)).sup), float(IReal('%.20f' % math.sinh(sup)).sup))
return IReal(new_inf, new_sup)
示例15: to_latlon
def to_latlon(northings, eastings, altitude):
f = 1/298.257223563
n = f / (2 - f)
n_0 = 0.0
k_0 = 0.9996
e_0 = 500.
a = 6378.137 #km
big_a = (a / (1 + n)) * (1 + (n**2 / 4) + (n**4 / 64)) #approximately
alpha_1 = .5 * n - (2. / 3.) * n**2 + (5. / 16.) * n**3
alpha_2 = (13./48.) * n**2 - (3./5.) * n**3
alpha_3 = (61./240.) * n**3
beta_1 = (1./2.) * n - (2. / 3.) * n**2 + (37./96.) * n**3
beta_2 = (1./48.) * n**2 + (1. / 15.) * n**3
beta_3 = (17. /480.) * n**3
delta_1 = 2. * n - (2./3.) * n**2 - 2* n**3
delta_2 = (7./3.) * n**2 - (8. / 5.) * n**3
delta_3 = (56./15.) * n**3
psi = (n - n_0) / (k_0 * big_a)
eta = (e - e_0) / (k_0 * big_a)
psi_prime = psi - ((beta_1 * sin(2. * 1 * eta) * cosh(2. * 1 * eta)) +
(beta_2 * sin(2. * 2 * eta) * cosh(2. * 2 * eta)) + (beta_3 * sin(2. * 3 * eta) * cosh(2. * 3 * eta)))
eta_prime = eta - ((beta_1 * cos(2. * 1 * psi) * sinh(2. * 1 * eta)) +
(beta_2 * cos(2. * 2 * psi) * sinh(2. * 2 * eta)) + (beta_3 * cos(2. * 3 * psi) * sinh(2. * 3 * eta)))
sigma_prime = 1. - ((2. * 1 * beta_1 * cos(2. * 1 * psi) * cosh(2. * 1 * eta)) +
(2. * 2 * beta_2 * cos(2. * 2 * psi) * cosh(2. * 2 * eta)) + (2. * 3 * beta_3 * cos(2. * 3 * psi) * cosh(2. * 3 * eta)))
tau_prime = ((2. * 1 * beta_1 * sin(2. * 1 * psi) * sinh(2. * 1 * eta)) +
(2. * 2 * beta_2 * sin(2. * 2 * psi) * sinh(2. * 2 * eta)) + (2. * 3 * beta_3 * sin(2. * 3 * psi) * sinh(2. * 3 * eta)))
chi = asin (sin(psi_prime)/cosh(eta_prime))
phi = chi + (delta_1 * sin(2. * 1 * chi)) + (delta_2 * sin(2. * 2 * chi)) + (delta_3 * sin(2. * 3 * chi))
lambda_0 = 0
lambdu = 0
k = 0
gamma = 0
return None