# Python math.sinh() Examples

The following are code examples for showing how to use math.sinh(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
 Project: orbitx   Author: OCESS   File: orbit_projection.py    MIT License 6 votes
```def __init__(self):
self._visible = False

# There are two cases that we care about for a 2-body orbit, elliptical
# or hyperbolic. Make a graphic for either case.
self._ring = vpython.ring(
axis=vpython.vector(0, 0, 1), visible=False)

# Since vpython doesn't have a hyperbola primitive, we make one ourself
# by generating a bunch of points along a hyperbola. Look at this graph
# https://www.desmos.com/calculator/dbhsftzyjc
# or put the following into wolframalpha.com
# parametric graph sinh(t), cosh(t) from t = -asinh(1e2) to asinh(1e2)
hyperbola_points: List[vpython.vector] = []
start_t = -math.asinh(self.POINTS_IN_HYPERBOLA)
for i in range(0, self.POINTS_IN_HYPERBOLA + 1):
t = start_t + abs(start_t) * 2 * i / self.POINTS_IN_HYPERBOLA
hyperbola_points.append(vpython.vector(
math.sinh(t), math.cosh(t), 0))

self._hyperbola = vpython.curve(
hyperbola_points, axis=vpython.vector(1, 1, 0),
up=vpython.vec(-1, 0, 0))
self._hyperbola.visible = False ```
Example 2
 Project: duct   Author: ducted   File: generator.py    MIT License 6 votes
```def get(self):
self.x += self.config.get('dx', 0.1)

val = eval(self.config.get('function', 'sin(x)'), {
'sin': math.sin,
'sinh': math.sinh,
'cos': math.cos,
'cosh': math.cosh,
'tan': math.tan,
'tanh': math.tanh,
'asin': math.asin,
'acos': math.acos,
'atan': math.atan,
'asinh': math.asinh,
'acosh': math.acosh,
'atanh': math.atanh,
'log': math.log,
'abs': abs,
'e': math.e,
'pi': math.pi,
'x': self.x
})

return self.createEvent('ok', 'Sine wave', val) ```
Example 3
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 6 votes
```def thetappp(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in
theta_tripleprime = (-(T*m.cosh(z/a)) + T*m.sinh(z/a)*m.tanh(l/(2*a)))/(G*J*a**2)

return theta_tripleprime

#Case 3 - Concentrated Torque at alpha*l with Pinned Ends
#T = Applied Concentrated Torsional Moment, Kip-in
#G = Shear Modulus of Elasticity, Ksi, 11200 for steel
#J = Torsinal Constant of Cross Section, in^4
#l = Span Lenght, in
#a = Torsional Constant
#alpa = load application point/l ```
Example 4
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 6 votes
```def thetappp(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
alpha = self.alpha
z = z_in
if 0 <= z_in <= (alpha*l):
theta_tripleprime = -((T*m.cosh(z/a)*(m.cosh((l*alpha)/a) - m.sinh((l*alpha)/a)/m.tanh(l/a)))/(G*J*a**2))
else:
theta_tripleprime = (T*(m.cosh(z/a)/m.tanh(l/a) - m.sinh(z/a))*m.sinh((l*alpha)/a))/(G*J*a**2)
return theta_tripleprime

#Case 4 - Uniformly Distributed Torque with Pinned Ends
#t = Distributed torque, Kip-in / in
#G = Shear Modulus of Elasticity, Ksi, 11200 for steel
#J = Torsinal Constant of Cross Section, in^4
#l = Span Lenght, in
#a = Torsional Constant ```
Example 5
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 6 votes
```def thetappp(self,z_in):
t = self.t_k_inpin
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in
theta_tripleprime = (t*(-1 + (l*(m.cosh(z/a)/m.sinh(l/a)))/a))/(G*J*l)

return theta_tripleprime

#Case 6 - Concentrated Torque at alpha*l with Fixed Ends
#T = Applied Concentrated Torsional Moment, Kip-in
#G = Shear Modulus of Elasticity, Ksi, 11200 for steel
#J = Torsinal Constant of Cross Section, in^4
#l = Span Lenght, in
#a = Torsional Constant
#alpa = load application point/l ```
Example 6
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 6 votes
```def thetappp(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
alpha = self.alpha
H = self.H
z = z_in

if 0 <= z_in <= (alpha*l):
theta_tripleprime = -((T*(m.cosh(z/a)/a**2 + ((-1.0 + (1.0 + H)*(m.cosh((l*alpha)/a))/m.tanh(l/a))*m.sinh(z/a))/a**2 - (H*(m.sinh(z/a)/m.sinh(l/a)))/a**2 - (m.sinh(z/a)*m.sinh((l*alpha)/a))/a**2 - (H*m.sinh(z/a)*m.sinh((l*alpha)/a))/a**2))/(G*(1.0 + H)*J))
else:
theta_tripleprime = 0
return theta_tripleprime
#Test Area ```
Example 7
 Project: pyblish-win   Author: pyblish   File: test_math.py    GNU Lesser General Public License v3.0 5 votes
```def testSinh(self):
self.assertRaises(TypeError, math.sinh)
self.ftest('sinh(0)', math.sinh(0), 0)
self.ftest('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1)
self.ftest('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0)
self.assertEqual(math.sinh(INF), INF)
self.assertEqual(math.sinh(NINF), NINF)
self.assertTrue(math.isnan(math.sinh(NAN))) ```
Example 8
 Project: python.math.expression.parser.pymep   Author: sbesada   File: complex.py    Apache License 2.0 5 votes
```def __sin__(self):
return Complex(math.sin(self.real) * math.cosh(self.imag), math.cos(self.real) * math.sinh(self.imag)) ```
Example 9
 Project: python.math.expression.parser.pymep   Author: sbesada   File: complex.py    Apache License 2.0 5 votes
```def __cos__(self):
return Complex(math.cos(self.real) * math.cosh(self.imag), -math.sin(self.real) * math.sinh(self.imag)) ```
Example 10
 Project: python.math.expression.parser.pymep   Author: sbesada   File: complex.py    Apache License 2.0 5 votes
```def __sinh__(self):
return Complex(math.sinh(self.real) * math.cos(self.imag), math.cosh(self.real) * math.sin(self.imag)) ```
Example 11
 Project: python.math.expression.parser.pymep   Author: sbesada   File: complex.py    Apache License 2.0 5 votes
```def __cosh__(self):
return Complex(math.cosh(self.real) * math.cos(self.imag), math.sinh(self.real) * math.sin(self.imag)) ```
Example 12
 Project: hepaccelerate   Author: hepaccelerate   File: cpu_kernels.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def spherical_to_cartesian(p4):
pt = p4[0]
eta = p4[1]
phi = p4[2]
mass = p4[3]

px = pt * math.cos(phi)
py = pt * math.sin(phi)
pz = pt * math.sinh(eta)
e = math.sqrt(px**2 + py**2 + pz**2 + mass**2)

p4[0] = px
p4[1] = py
p4[2] = pz
p4[3] = e ```
Example 13
 Project: hepaccelerate   Author: hepaccelerate   File: full_analysis.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def compute_inv_mass_kernel(offsets, pts, etas, phis, masses, mask_events, mask_objects, out_inv_mass, out_pt_total):
for iev in numba.prange(offsets.shape[0]-1):
if mask_events[iev]:
start = np.uint64(offsets[iev])
end = np.uint64(offsets[iev + 1])

px_total = np.float32(0.0)
py_total = np.float32(0.0)
pz_total = np.float32(0.0)
e_total = np.float32(0.0)

for iobj in range(start, end):
if mask_objects[iobj]:
pt = pts[iobj]
eta = etas[iobj]
phi = phis[iobj]
mass = masses[iobj]

px = pt * np.cos(phi)
py = pt * np.sin(phi)
pz = pt * np.sinh(eta)
e = np.sqrt(px**2 + py**2 + pz**2 + mass**2)

px_total += px
py_total += py
pz_total += pz
e_total += e

inv_mass = np.sqrt(-(px_total**2 + py_total**2 + pz_total**2 - e_total**2))
pt_total = np.sqrt(px_total**2 + py_total**2)
out_inv_mass[iev] = inv_mass
out_pt_total[iev] = pt_total ```
Example 14
 Project: hepaccelerate   Author: hepaccelerate   File: full_analysis.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def compute_inv_mass_cudakernel(offsets, pts, etas, phis, masses, mask_events, mask_objects, out_inv_mass, out_pt_total):
xi = cuda.grid(1)
xstride = cuda.gridsize(1)
for iev in range(xi, offsets.shape[0]-1, xstride):
if mask_events[iev]:
start = np.uint64(offsets[iev])
end = np.uint64(offsets[iev + 1])

px_total = np.float32(0.0)
py_total = np.float32(0.0)
pz_total = np.float32(0.0)
e_total = np.float32(0.0)

for iobj in range(start, end):
if mask_objects[iobj]:
pt = pts[iobj]
eta = etas[iobj]
phi = phis[iobj]
mass = masses[iobj]

px = pt * math.cos(phi)
py = pt * math.sin(phi)
pz = pt * math.sinh(eta)
e = math.sqrt(px**2 + py**2 + pz**2 + mass**2)

px_total += px
py_total += py
pz_total += pz
e_total += e

inv_mass = math.sqrt(-(px_total**2 + py_total**2 + pz_total**2 - e_total**2))
pt_total = math.sqrt(px_total**2 + py_total**2)
out_inv_mass[iev] = inv_mass
out_pt_total[iev] = pt_total ```
Example 15
 Project: hepaccelerate   Author: hepaccelerate   File: cuda_kernels.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def spherical_to_cartesian(p4):
pt = p4[0]
eta = p4[1]
phi = p4[2]
mass = p4[3]

px = pt * math.cos(phi)
py = pt * math.sin(phi)
pz = pt * math.sinh(eta)
e = math.sqrt(px**2 + py**2 + pz**2 + mass**2)

p4[0] = px
p4[1] = py
p4[2] = pz
p4[3] = e ```
Example 16
 Project: hepaccelerate   Author: hepaccelerate   File: backend_cuda.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def spherical_to_cartesian_devfunc(pt, eta, phi, mass):
px = pt * math.cos(phi)
py = pt * math.sin(phi)
pz = pt * math.sinh(eta)
e = math.sqrt(px**2 + py**2 + pz**2 + mass**2)
return px, py, pz, e ```
Example 17
 Project: NiujiaoDebugger   Author: MrSrc   File: test_math.py    GNU General Public License v3.0 5 votes
```def testSinh(self):
self.assertRaises(TypeError, math.sinh)
self.ftest('sinh(0)', math.sinh(0), 0)
self.ftest('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1)
self.ftest('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0)
self.assertEqual(math.sinh(INF), INF)
self.assertEqual(math.sinh(NINF), NINF)
self.assertTrue(math.isnan(math.sinh(NAN))) ```
Example 18
 Project: pyh3   Author: buzzfeed   File: h3math.py    MIT License 5 votes
```def compute_delta_theta(r, rp, phi):
return math.atan(math.tanh(r / K) /
(math.sinh(rp / K) * math.sinh(phi))) ```
Example 19
 Project: pyh3   Author: buzzfeed   File: h3math.py    MIT License 5 votes
```def compute_delta_phi(r, rp):
return math.atan(math.tanh(r / K) / math.sinh(rp / K)) ```
Example 20
 Project: rpython-lang-scheme   Author: tomoh1r   File: rcomplex.py    MIT License 5 votes
```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 ```
Example 21
 Project: rpython-lang-scheme   Author: tomoh1r   File: rcomplex.py    MIT License 5 votes
```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 ```
Example 22
 Project: rpython-lang-scheme   Author: tomoh1r   File: rcomplex.py    MIT License 5 votes
```def c_sin(r, i):
# sin(z) = -i sinh(iz)
sr, si = c_sinh(-i, r)
return si, -sr ```
Example 23
 Project: ironpython2   Author: IronLanguages   File: test_math.py    Apache License 2.0 5 votes
```def testSinh(self):
self.assertRaises(TypeError, math.sinh)
self.ftest('sinh(0)', math.sinh(0), 0)
self.ftest('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1)
self.ftest('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0)
self.assertEqual(math.sinh(INF), INF)
self.assertEqual(math.sinh(NINF), NINF)
self.assertTrue(math.isnan(math.sinh(NAN))) ```
Example 24
 Project: visma   Author: aerospaceresearch   File: hyperbolic.py    GNU General Public License v3.0 5 votes
```def __init__(self):
super().__init__()
self.value = 'sinh' ```
Example 25
 Project: visma   Author: aerospaceresearch   File: hyperbolic.py    GNU General Public License v3.0 5 votes
```def calculate(self, val):
return self.coefficient * ((math.sinh(val))**self.power) ```
Example 26
 Project: Blockly-rduino-communication   Author: technologiescollege   File: test_math.py    GNU General Public License v3.0 5 votes
```def testSinh(self):
self.assertRaises(TypeError, math.sinh)
self.ftest('sinh(0)', math.sinh(0), 0)
self.ftest('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1)
self.ftest('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0)
self.assertEqual(math.sinh(INF), INF)
self.assertEqual(math.sinh(NINF), NINF)
self.assertTrue(math.isnan(math.sinh(NAN))) ```
Example 27
 Project: cqp-sdk-for-py37-native   Author: crud-boy   File: test_math.py    GNU General Public License v2.0 5 votes
```def testSinh(self):
self.assertRaises(TypeError, math.sinh)
self.ftest('sinh(0)', math.sinh(0), 0)
self.ftest('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1)
self.ftest('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0)
self.assertEqual(math.sinh(INF), INF)
self.assertEqual(math.sinh(NINF), NINF)
self.assertTrue(math.isnan(math.sinh(NAN))) ```
Example 28
 Project: nanopores   Author: mitschabaude   File: diff_bulk.py    MIT License 5 votes
```def Cn(l):
alpha = acosh(l/r)
s = 0.
for n in range(1, 100):
n = float(n)
K = n*(n+1)/(2*n-1)/(2*n+3)
s += K*((2*sinh((2*n+1)*alpha)+(2*n+1)*sinh(2*alpha))/(4*(sinh((n+.5)*alpha))**2-(2*n+1)**2*(sinh(alpha))**2) - 1)
return 1./((4./3.)*sinh(alpha)*s) ```
Example 29
 Project: nanopores   Author: mitschabaude   File: diff_bulk.py    MIT License 5 votes
```def Cn(l,rMolecule):
alpha=acosh(l/rMolecule)
sum = 0.
for n in range(1,100):
sum+=float(n*(n+1))/float((2*n-1))/float((2*n+3))*((2*sinh((2*n+1)*alpha)+(2*n+1)*sinh(2*alpha))/(4*(sinh((n+.5)*alpha))**2-(2*n+1)**2*(sinh(alpha))**2)-1)
return 1./((4./3.)*sinh(alpha)*sum) ```
Example 30
 Project: oss-ftp   Author: aliyun   File: test_math.py    MIT License 5 votes
```def testSinh(self):
self.assertRaises(TypeError, math.sinh)
self.ftest('sinh(0)', math.sinh(0), 0)
self.ftest('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1)
self.ftest('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0)
self.assertEqual(math.sinh(INF), INF)
self.assertEqual(math.sinh(NINF), NINF)
self.assertTrue(math.isnan(math.sinh(NAN))) ```
Example 31
 Project: data-preppy   Author: gurgeh   File: convert_coords.py    Apache License 2.0 5 votes
```def grid_to_geodetic(x, y):
e2 = flattening * (2.0 - flattening)
n = flattening / (2.0 - flattening)
a_roof = axis / (1.0 + n) * (1.0 + n * n / 4.0 + n * n * n * n / 64.0)
delta1 = n / 2.0 - 2.0 * n * n / 3.0 + 37.0 * n * n * n / 96.0 - n * n * n * n / 360.0
delta2 = n * n / 48.0 + n * n * n / 15.0 - 437.0 * n * n * n * n / 1440.0
delta3 = 17.0 * n * n * n / 480.0 - 37 * n * n * n * n / 840.0
delta4 = 4397.0 * n * n * n * n / 161280.0

Astar = e2 + e2 * e2 + e2 * e2 * e2 + e2 * e2 * e2 * e2
Bstar = -(7.0 * e2 * e2 + 17.0 * e2 * e2 * e2 + 30.0 * e2 * e2 * e2 * e2) / 6.0
Cstar = (224.0 * e2 * e2 * e2 + 889.0 * e2 * e2 * e2 * e2) / 120.0
Dstar = -(4279.0 * e2 * e2 * e2 * e2) / 1260.0

deg_to_rad = math.pi / 180
lambda_zero = central_meridian * deg_to_rad
xi = (x - false_northing) / (scale * a_roof)
eta = (y - false_easting) / (scale * a_roof)
xi_prim = xi - delta1 * math.sin(2.0 * xi) * math.cosh(2.0 * eta) - \
delta2 * math.sin(4.0 * xi) * math.cosh(4.0 * eta) - \
delta3 * math.sin(6.0 * xi) * math.cosh(6.0 * eta) - \
delta4 * math.sin(8.0 * xi) * math.cosh(8.0 * eta)
eta_prim = eta - \
delta1 * math.cos(2.0 * xi) * math.sinh(2.0 * eta) - \
delta2 * math.cos(4.0 * xi) * math.sinh(4.0 * eta) - \
delta3 * math.cos(6.0 * xi) * math.sinh(6.0 * eta) - \
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) * \
(Astar +
Bstar * math.pow(math.sin(phi_star), 2) +
Cstar * math.pow(math.sin(phi_star), 4) +
Dstar * math.pow(math.sin(phi_star), 6))

return lat_radian * 180.0 / math.pi, lon_radian * 180.0 / math.pi ```
Example 32
 Project: ufora   Author: ufora   File: pure_math.py    Apache License 2.0 5 votes
```def __call__(self, val):
return __inline_fora(
"""fun(@unnamed_args:(val), *args) {
PyFloat(math.sinh([email protected]))
}"""
)(val) ```
Example 33
 Project: ufora   Author: ufora   File: MathTestCases.py    Apache License 2.0 5 votes
```def test_pure_python_math_module(self):
vals = [1, -.5, 1.5, 0, 0.0, -2, -2.2, .2]

# not being tested: math.asinh, math.atanh, math.lgamma, math.erfc, math.acos
def f():
functions = [
math.sqrt, math.cos, math.sin, math.tan, math.asin, math.atan,
math.acosh, math.cosh, math.sinh, math.tanh, math.ceil,
math.erf, math.exp, math.expm1, math.factorial, math.floor,
math.log, math.log10, math.log1p
]
tr = []
for idx1 in range(len(vals)):
v1 = vals[idx1]
for funIdx in range(len(functions)):
function = functions[funIdx]
try:
tr = tr + [function(v1)]
except ValueError as ex:
pass

return tr

r1 = self.evaluateWithExecutor(f)
r2 = f()
self.assertGreater(len(r1), 100)
self.assertTrue(numpy.allclose(r1, r2, 1e-6)) ```
Example 34
 Project: hask   Author: billpmurphy   File: Num.py    BSD 2-Clause "Simplified" License 5 votes
```def make_instance(typeclass, cls, pi, exp, sqrt, log, pow, logBase, sin,
tan, cos, asin, atan, acos, sinh, tanh, cosh, asinh, atanh, acosh):
attrs = {"pi":pi, "exp":exp, "sqrt":sqrt, "log":log, "pow":pow,
"logBase":logBase, "sin":sin, "tan":tan, "cos":cos,
"asin":asin, "atan":atan, "acos":acos, "sinh":sinh,
"tanh":tanh, "cosh":cosh, "asinh":asinh, "atanh":atanh,
"acosh":acosh}
build_instance(Floating, cls, attrs)
return ```
Example 35
 Project: hask   Author: billpmurphy   File: Num.py    BSD 2-Clause "Simplified" License 5 votes
```def sinh(x):
"""
sinh :: Floating a => a -> a
"""
return Floating[x].sinh(x) ```
Example 36
 Project: hotxlfp   Author: aidhound   File: mathtrig.py    MIT License 5 votes
```def SINH(number):
number = utils.parse_number(number)
if isinstance(number, error.XLError):
return number
return math.sinh(number) ```
Example 37
 Project: PyTUN   Author: SJ-Ang   File: PyTUN.py    GNU General Public License v3.0 5 votes
```def S(V_max,E):
S = math.sinh(((V_max-E)) / (TEMPERATURE*k))
return S ```
Example 38
 Project: Python-iBeacon-Scan   Author: NikNitro   File: test_functions.py    GNU General Public License v3.0 5 votes
```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)) ```
Example 39
 Project: Python-iBeacon-Scan   Author: NikNitro   File: test_functions.py    GNU General Public License v3.0 5 votes
```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)) ```
Example 40
 Project: Python-iBeacon-Scan   Author: NikNitro   File: test_functions.py    GNU General Public License v3.0 5 votes
```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) ```
Example 41
 Project: Python-iBeacon-Scan   Author: NikNitro   File: test_functions.py    GNU General Public License v3.0 5 votes
```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)) ```
Example 42
 Project: NLP.py   Author: PythonOptimizers   File: sparse_vector_class.py    GNU Lesser General Public License v3.0 5 votes
```def sinh(a):
"""Elementwise hyperbolic sine."""
if not isSparseVector(a):
raise TypeError("Argument must be a SparseVector")
rv = SparseVector(a.n, {})
for k in a.values.keys():
rv.values[k] = math.sinh(a.values[k])
return rv ```
Example 43
 Project: social_ethosa   Author: Ethosa   File: BotWrapper.py    GNU Lesser General Public License v3.0 5 votes
```def calc(self, text):
"""calculator

Arguments:
text {[str]} -- [example for calculation]

Returns:
[str] -- [result]
"""
self.count_use += 1
text = text.replace("^", "**")  # ''.join(i for i in text if i in self.validate_for_calc)
glb = {
"pi": math.pi, "e": math.e,
"sin": math.sin, "cos": math.cos,
"factorial": math.factorial, "ceil": math.ceil,
"floor": math.floor, 'exit': lambda *args: " ".join(args),
"pow": math.pow, "log": math.log,
"sqrt": math.sqrt, "tan": math.tan,
"arccos": math.acos, "arcsin": math.asin,
"arctan": math.atan, "degrees": math.degrees,
"radians": math.radians, "sinh": math.sinh,
"cosh": math.cosh, "tanh": math.tanh,
"arccosh": math.acosh, "arcsinh": math.asinh,
"arctanh": math.atanh, 'print': lambda *args: " ".join(args)
}
return eval(text, glb, {}) ```
Example 44
 Project: titus2   Author: animator   File: pfamath.py    Apache License 2.0 5 votes
```def genpy(self, paramTypes, args, pos):
return "math.sinh({0})".format(*args) ```
Example 45
 Project: titus2   Author: animator   File: pfamath.py    Apache License 2.0 5 votes
```def __call__(self, state, scope, pos, paramTypes, x):
return math.sinh(x) ```
Example 46
 Project: siren   Author: ozsolarwind   File: getmap.py    GNU Affero General Public License v3.0 5 votes
```def mercatorToLat(self, mercatorY):
return(math.degrees(math.atan(math.sinh(mercatorY)))) ```
Example 47
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def theta(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in

thet = ((T*a) / (G*J))*((m.tanh(l/(2*a))*m.cosh(z/a))-(m.tanh(l/(2*a)))+(z/a)-(m.sinh(z/a)))

return thet ```
Example 48
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def thetap(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in
theta_prime = (T - T*m.cosh(z/a) + T*m.sinh(z/a)*m.tanh(l/(2*a)))/(G*J)

return theta_prime ```
Example 49
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def thetapp(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in
theta_doubleprime = (-(T*m.sinh(z/a)) + T*m.cosh(z/a)*m.tanh(l/(2*a)))/(a*G*J)

return theta_doubleprime ```
Example 50
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def theta(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
alpha = self.alpha
z = z_in

if 0 <= z_in <= (alpha*l):
thet = ((T*l) / (G*J))*(((1.0-alpha)*(z/l))+(((a/l)*((m.sinh((alpha*l)/a)/m.tanh(l/a)) - m.cosh((alpha*l)/a)))*m.sinh(z/a)))
else:
thet = ((T*l) / (G*J))*(((l-z)*(alpha/l))+((a/l)*(((m.sinh((alpha*l)/a) / m.tanh(l/a))*m.sinh(z/a)) - (m.sinh((alpha*l)/a)*m.cosh(z/a)))))

return thet ```
Example 51
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def thetapp(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
alpha = self.alpha
z = z_in
if 0 <= z_in <= (alpha*l):
theta_doubleprime = -((T*m.sinh(z/a)*(m.cosh((l*alpha)/a) - m.sinh((l*alpha)/a)/m.tanh(l/a)))/(a*G*J))
else:
theta_doubleprime = (T*(-1.0*m.cosh(z/a) + m.sinh(z/a)/m.tanh(l/a))*m.sinh((l*alpha)/a))/(a*G*J)
return theta_doubleprime ```
Example 52
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def theta(self,z_in):
t = self.t_k_inpin
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in

thet = ((t*a**2) / (G*J))*(((l**2 / (2*a**2))*((z/l) - ((z**2)/(l**2))))+m.cosh(z/a)-(m.tanh(l/(2*a))*m.sinh(z/a))-1.0)

return thet ```
Example 53
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def thetap(self,z_in):
t = self.t_k_inpin
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in
theta_prime = (t*(l - 2*z + 2*a*m.sinh(z/a) - 2*a*m.cosh(z/a)*m.tanh(l/(2*a))))/(2*G*J)

return theta_prime ```
Example 54
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def thetapp(self,z_in):
t = self.t_k_inpin
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in
theta_doubleprime = (t*(-1 + m.cosh(z/a) - m.sinh(z/a)*m.tanh(l/(2*a))))/(G*J)

return theta_doubleprime ```
Example 55
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def theta(self,z_in):
t = self.t_k_inpin
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in

thet = ((t*l**2) / (G*J))*((z/(6*l)) + ((a**2)/(l**2)*((m.sinh(z/a)/m.sinh(l/a))-(z/l)))-((z**3)/(6*l**3)))

return thet ```
Example 56
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def thetap(self,z_in):
t = self.t_k_inpin
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in
theta_prime = (t*(-6.0*a**2 + l**2 - 3*z**2 + 6*a*l*(m.cosh(z/a)/m.sinh(l/a))))/(6*G*J*l)

return theta_prime ```
Example 57
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def thetapp(self,z_in):
t = self.t_k_inpin
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
z = z_in
theta_doubleprime = (t*(-1.0*z + l*(m.sinh(z/a)/m.sinh(l/a))))/(G*J*l)

return theta_doubleprime ```
Example 58
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def __init__(self, T_k_in, G_ksi, J_in4, l_in, a, alpha):
self.T_k_in = T_k_in
self.G_ksi = G_ksi
self.J_in4 = J_in4
self.l_in = l_in
self.a = a
self.alpha = alpha
self.H = (((1.0-m.cosh((alpha*l)/a)) / m.tanh(l/a)) + ((m.cosh((alpha*l)/a)-1.0) / m.sinh(l/a)) + m.sinh((alpha*l)/a) - ((alpha*l)/a)) / \
(((m.cosh(l/a)+(m.cosh((alpha*l)/a)*m.cosh(l/a))-m.cosh((alpha*l)/a)-1.0)/m.sinh(l/a))+((l/a)*(alpha-1.0))-m.sinh((alpha*l)/a)) ```
Example 59
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def thetap(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
alpha = self.alpha
H = self.H
z = z_in

if 0 <= z_in <= (alpha*l):
theta_prime = (-1.0*T*(-1.0 + m.cosh(z/a) + (-1.0 + (1.0 + H)*m.cosh((l*alpha)/a))*(m.sinh(z/a)/m.tanh(l/a)) - 1.0*H*(m.sinh(z/a)/m.sinh(l/a)) - 1.0*m.sinh(z/a)*m.sinh((l*alpha)/a) - 1.0*H*m.sinh(z/a)*m.sinh((l*alpha)/a)))/(G*(1.0 + H)*J)
else:
theta_prime = 0
return theta_prime ```
Example 60
 Project: Structural-Engineering   Author: buddyd16   File: torsion.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def thetapp(self,z_in):
T = self.T_k_in
G = self.G_ksi
J = self.J_in4
l = self.l_in
a = self.a
alpha = self.alpha
H = self.H
z = z_in

if 0 <= z_in <= (alpha*l):
theta_doubleprime = -((T*((m.cosh(z/a)*(-1.0 + (1.0 + H)*(m.cosh((l*alpha)/a))/m.tanh(l/a)))/a - (H*(m.cosh(z/a)/m.sinh(l/a)))/a + m.sinh(z/a)/a - (m.cosh(z/a)*m.sinh((l*alpha)/a))/a - (H*m.cosh(z/a)*m.sinh((l*alpha)/a))/a))/(G*(1.0 + H)*J))
else:
theta_doubleprime = 0
return theta_doubleprime ```
Example 61
 Project: PyFlow   Author: wonderworks-software   File: MathLib.py    Apache License 2.0 5 votes
```def sinh(x=('FloatPin', 0.0), Result=(REF, ('BoolPin', False))):
'''Return the hyperbolic sine of `x`.'''
try:
Result(True)
return math.sinh(x)
except:
Result(False)
return -1 ```
Example 62
 Project: scikit-hep   Author: scikit-hep   File: vectors.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def setptetaphim(self, pt, eta, phi, m):
""" Set the transverse momentum, the pseudorapidity, the angle phi and the mass."""
px, py, pz = pt*cos(phi), pt*sin(phi), pt*sinh(eta)
self.setpxpypzm(px,py,pz,m) ```
Example 63
 Project: scikit-hep   Author: scikit-hep   File: vectors.py    BSD 3-Clause "New" or "Revised" License 5 votes
```def setptetaphie(self, pt, eta, phi, e):
""" Set the transverse momentum, the pseudorapidity, the angle phi and the energy."""
px, py, pz = pt*cos(phi), pt*sin(phi), pt*sinh(eta)
self.setpxpypze(px,py,pz,e) ```
Example 64
 Project: m-stp   Author: MukeunKim   File: core.py    MIT License 5 votes
```def sinh(x):
if isinstance(x, LineValue): lx = x.get_value()
else: lx = x
if lx == NAN: return LineValue(NAN)
return LineValue(math.sinh(lx)) ```
Example 65
 Project: femtocode   Author: diana-hep   File: test_libstandard.py    Apache License 2.0 5 votes
```def test_map_realistic(self):
nonflat.define(mumass = "0.105658").toPython(mass = """
muons.map(mu1 => muons.map({mu2 =>

p1x = mu1.pt * cos(mu1.phi);
p1y = mu1.pt * sin(mu1.phi);
p1z = mu1.pt * sinh(mu1.eta);
E1 = sqrt(p1x**2 + p1y**2 + p1z**2 + mumass**2);

p2x = mu2.pt * cos(mu2.phi);
p2y = mu2.pt * sin(mu2.phi);
p2z = mu2.pt * sinh(mu2.eta);
E2 = sqrt(p2x**2 + p2y**2 + p2z**2 + mumass**2);

px = p1x + p2x;
py = p1y + p2y;
pz = p1z + p2z;
E = E1 + E2;

if E**2 - px**2 - py**2 - pz**2 >= 0:
sqrt(E**2 - px**2 - py**2 - pz**2)
else:
None

}))
""").submit()

########################################################## Core math ```
Example 66
 Project: femtocode   Author: diana-hep   File: test_libstandard.py    Apache License 2.0 5 votes
```def test_sinh(self):
self.assertEqual(session.source("Test", x=real(3.14, 6.5)).type("sinh(x)"), real(math.sinh(3.14), math.sinh(6.5)))
self.assertEqual(session.source("Test", x=real(3.14, almost(6.5))).type("sinh(x)"), real(math.sinh(3.14), almost(math.sinh(6.5))))
self.assertEqual(session.source("Test", x=real(3.14, almost(inf))).type("sinh(x)"), real(math.sinh(3.14), almost(math.sinh(inf))))
self.assertEqual(session.source("Test", x=real(3.14, inf)).type("sinh(x)"), real(math.sinh(3.14), inf))
self.assertEqual(session.source("Test", x=real).type("sinh(x)"), real(almost(-inf), almost(inf)))
self.assertEqual(session.source("Test", x=extended).type("sinh(x)"), real(-inf, inf))
for entry in numerical.toPython(y = "y", a = "sinh(y)").submit():
self.assertEqual(entry.a, math.sinh(entry.y)) ```
Example 67
 Project: creamas   Author: assamite   File: primitives.py    GNU General Public License v2.0 5 votes
```def safe_sinh(x):
x = _check_hval(x)
return math.sinh(x) ```
Example 68
 Project: InventorLoader   Author: jmplonka   File: Acis.py    GNU General Public License v2.0 5 votes
`def COTH(x):       return (cosh(x)/sinh(x)) `
Example 69
 Project: InventorLoader   Author: jmplonka   File: Acis.py    GNU General Public License v2.0 5 votes
`def CSCH(x):       return (1/sinh(x)) `
Example 70
 Project: InventorLoader   Author: jmplonka   File: Acis.py    GNU General Public License v2.0 5 votes
`def SINH(x):       return (sinh(x)) `
Example 71
 Project: papermap   Author: sgraaf   File: utils.py    GNU General Public License v3.0 5 votes
```def y_to_lat(y: Union[float, int], zoom: int) -> float:
"""
Converts y (tile number) to latitude given zoom level

Args:
y (float / int): tile number
zoom (int): zoom level
"""
lat = atan(sinh(pi * (1 - 2 * y / (2 ** zoom)))) / pi * 180
return lat ```
Example 72
 Project: spectroscopy   Author: jgoodknight   File: NuclearOperator.py    MIT License 5 votes
```def sinh(self):
out = copy.copy(self)
out.surface = np.sinh(out.surface)
return out ```
Example 73
 Project: gprime   Author: GenealogyCollective   File: place.py    GNU General Public License v2.0 4 votes
```def __conv_WGS84_SWED_RT90(lat, lon):
"""
Input is lat and lon as two float numbers
Output is X and Y coordinates in RT90
as a tuple of float numbers

The code below converts to/from the Swedish RT90 koordinate
system. The converion functions use "Gauss Conformal Projection
(Transverse Marcator)" Krüger Formulas.
The constanst are for the Swedish RT90-system.
With other constants the conversion should be useful for
other geographical areas.

"""
# Some constants used for conversion to/from Swedish RT90
f = 1.0/298.257222101
e2 = f*(2.0-f)
n = f/(2.0-f)
L0 = math.radians(15.8062845294)   # 15 deg 48 min 22.624306 sec
k0 = 1.00000561024
a = 6378137.0   # meter
at = a/(1.0+n)*(1.0+ 1.0/4.0* pow(n, 2)+1.0/64.0*pow(n, 4))
FN = -667.711 # m
FE = 1500064.274 # m

#the conversion
lat_rad = math.radians(lat)
lon_rad = math.radians(lon)
A = e2
B = 1.0/6.0*(5.0*pow(e2, 2) - pow(e2, 3))
C = 1.0/120.0*(104.0*pow(e2, 3) - 45.0*pow(e2, 4))
D = 1.0/1260.0*(1237.0*pow(e2, 4))
DL = lon_rad - L0
E = A + B*pow(math.sin(lat_rad), 2) + \
C*pow(math.sin(lat_rad), 4) + \
D*pow(math.sin(lat_rad), 6)
psi = lat_rad - math.sin(lat_rad)*math.cos(lat_rad)*E
xi = math.atan2(math.tan(psi), math.cos(DL))
eta = atanh(math.cos(psi)*math.sin(DL))
B1 = 1.0/2.0*n - 2.0/3.0*pow(n, 2) + 5.0/16.0*pow(n, 3) + \
41.0/180.0*pow(n, 4)
B2 = 13.0/48.0*pow(n, 2) - 3.0/5.0*pow(n, 3) + 557.0/1440.0*pow(n, 4)
B3 = 61.0/240.0*pow(n, 3) - 103.0/140.0*pow(n, 4)
B4 = 49561.0/161280.0*pow(n, 4)
X = xi + B1*math.sin(2.0*xi)*math.cosh(2.0*eta) + \
B2*math.sin(4.0*xi)*math.cosh(4.0*eta) + \
B3*math.sin(6.0*xi)*math.cosh(6.0*eta) + \
B4*math.sin(8.0*xi)*math.cosh(8.0*eta)
Y = eta + B1*math.cos(2.0*xi)*math.sinh(2.0*eta) + \
B2*math.cos(4.0*xi)*math.sinh(4.0*eta) + \
B3*math.cos(6.0*xi)*math.sinh(6.0*eta) + \
B4*math.cos(8.0*xi)*math.sinh(8.0*eta)
X = X*k0*at + FN
Y = Y*k0*at + FE
return (X, Y) ```
Example 74
 Project: gprime   Author: GenealogyCollective   File: place.py    GNU General Public License v2.0 4 votes
```def __conv_SWED_RT90_WGS84(X, Y):
"""
Input is X and Y coordinates in RT90 as float
Output is lat and long in degrees, float as tuple
"""
# Some constants used for conversion to/from Swedish RT90
f = 1.0/298.257222101
e2 = f*(2.0-f)
n = f/(2.0-f)
L0 = math.radians(15.8062845294)   # 15 deg 48 min 22.624306 sec
k0 = 1.00000561024
a = 6378137.0   # meter
at = a/(1.0+n)*(1.0+ 1.0/4.0* pow(n, 2)+1.0/64.0*pow(n, 4))
FN = -667.711 # m
FE = 1500064.274 # m

xi = (X - FN)/(k0*at)
eta = (Y - FE)/(k0*at)
D1 = 1.0/2.0*n - 2.0/3.0*pow(n, 2) + 37.0/96.0*pow(n, 3) - \
1.0/360.0*pow(n, 4)
D2 = 1.0/48.0*pow(n, 2) + 1.0/15.0*pow(n, 3) - 437.0/1440.0*pow(n, 4)
D3 = 17.0/480.0*pow(n, 3) - 37.0/840.0*pow(n, 4)
D4 = 4397.0/161280.0*pow(n, 4)
xip = xi - D1*math.sin(2.0*xi)*math.cosh(2.0*eta) - \
D2*math.sin(4.0*xi)*math.cosh(4.0*eta) - \
D3*math.sin(6.0*xi)*math.cosh(6.0*eta) - \
D4*math.sin(8.0*xi)*math.cosh(8.0*eta)
etap = eta - D1*math.cos(2.0*xi)*math.sinh(2.0*eta) - \
D2*math.cos(4.0*xi)*math.sinh(4.0*eta) - \
D3*math.cos(6.0*xi)*math.sinh(6.0*eta) - \
D4*math.cos(8.0*xi)*math.sinh(8.0*eta)
psi = math.asin(math.sin(xip)/math.cosh(etap))
DL = math.atan2(math.sinh(etap), math.cos(xip))
LON = L0 + DL
A = e2 + pow(e2, 2) + pow(e2, 3) + pow(e2, 4)
B = -1.0/6.0*(7.0*pow(e2, 2) + 17*pow(e2, 3) + 30*pow(e2, 4))
C = 1.0/120.0*(224.0*pow(e2, 3) + 889.0*pow(e2, 4))
D = 1.0/1260.0*(4279.0*pow(e2, 4))
E = A + B*pow(math.sin(psi), 2) + \
C*pow(math.sin(psi), 4) + \
D*pow(math.sin(psi), 6)
LAT = psi + math.sin(psi)*math.cos(psi)*E
LAT = math.degrees(LAT)
LON = math.degrees(LON)
return LAT, LON

#-------------------------------------------------------------------------
#
# For Testing the convert function in this module, apply it as a script:
#     ==> in command line do "python PlaceUtils.py"
#
#------------------------------------------------------------------------- ```
Example 75
 Project: gprime   Author: GenealogyCollective   File: place_test.py    GNU General Public License v2.0 4 votes
```def conv_SWED_RT90_WGS84(X, Y):
"""
Input is X and Y coordinates in RT90 as float
Output is lat and long in degrees, float as tuple
"""
# Some constants used for conversion to/from Swedish RT90
f = 1.0/298.257222101
e2 = f*(2.0-f)
n = f/(2.0-f)
L0 = math.radians(15.8062845294)   # 15 deg 48 min 22.624306 sec
k0 = 1.00000561024
a = 6378137.0   # meter
at = a/(1.0+n)*(1.0+ 1.0/4.0* pow(n,2)+1.0/64.0*pow(n,4))
FN = -667.711 # m
FE = 1500064.274 # m

xi = (X - FN)/(k0*at)
eta = (Y - FE)/(k0*at)
D1 = 1.0/2.0*n - 2.0/3.0*pow(n,2) + 37.0/96.0*pow(n,3) - 1.0/360.0*pow(n,4)
D2 = 1.0/48.0*pow(n,2) + 1.0/15.0*pow(n,3) - 437.0/1440.0*pow(n,4)
D3 = 17.0/480.0*pow(n,3) - 37.0/840.0*pow(n,4)
D4 = 4397.0/161280.0*pow(n,4)
xip = xi - D1*math.sin(2.0*xi)*math.cosh(2.0*eta) - \
D2*math.sin(4.0*xi)*math.cosh(4.0*eta) - \
D3*math.sin(6.0*xi)*math.cosh(6.0*eta) - \
D4*math.sin(8.0*xi)*math.cosh(8.0*eta)
etap = eta - D1*math.cos(2.0*xi)*math.sinh(2.0*eta) - \
D2*math.cos(4.0*xi)*math.sinh(4.0*eta) - \
D3*math.cos(6.0*xi)*math.sinh(6.0*eta) - \
D4*math.cos(8.0*xi)*math.sinh(8.0*eta)
psi = math.asin(math.sin(xip)/math.cosh(etap))
DL = math.atan2(math.sinh(etap),math.cos(xip))
LON = L0 + DL
A = e2 + pow(e2,2) + pow(e2,3) + pow(e2,4)
B = -1.0/6.0*(7.0*pow(e2,2) + 17*pow(e2,3) + 30*pow(e2,4))
C = 1.0/120.0*(224.0*pow(e2,3) + 889.0*pow(e2,4))
D = 1.0/1260.0*(4279.0*pow(e2,4))
E = A + B*pow(math.sin(psi),2) + \
C*pow(math.sin(psi),4) + \
D*pow(math.sin(psi),6)
LAT = psi + math.sin(psi)*math.cos(psi)*E
LAT = math.degrees(LAT)
LON = math.degrees(LON)
return LAT, LON ```
Example 76
 Project: data_algebra   Author: WinVector   File: SQLite.py    BSD 3-Clause "New" or "Revised" License 4 votes
```def prepare_connection(self, conn):
# https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.create_function
conn.create_function("is_bad", 1, _check_scalar_bad)
# math fns
conn.create_function("acos", 1, math.acos)
conn.create_function("acosh", 1, math.acosh)
conn.create_function("asin", 1, math.asin)
conn.create_function("asinh", 1, math.asinh)
conn.create_function("atan", 1, math.atan)
conn.create_function("atanh", 1, math.atanh)
conn.create_function("ceil", 1, math.ceil)
conn.create_function("cos", 1, math.cos)
conn.create_function("cosh", 1, math.cosh)
conn.create_function("degrees", 1, math.degrees)
conn.create_function("erf", 1, math.erf)
conn.create_function("erfc", 1, math.erfc)
conn.create_function("exp", 1, math.exp)
conn.create_function("expm1", 1, math.expm1)
conn.create_function("fabs", 1, math.fabs)
conn.create_function("factorial", 1, math.factorial)
conn.create_function("floor", 1, math.floor)
conn.create_function("frexp", 1, math.frexp)
conn.create_function("gamma", 1, math.gamma)
conn.create_function("isfinite", 1, math.isfinite)
conn.create_function("isinf", 1, math.isinf)
conn.create_function("isnan", 1, math.isnan)
conn.create_function("lgamma", 1, math.lgamma)
conn.create_function("log", 1, math.log)
conn.create_function("log10", 1, math.log10)
conn.create_function("log1p", 1, math.log1p)
conn.create_function("log2", 1, math.log2)
conn.create_function("modf", 1, math.modf)
conn.create_function("radians", 1, math.radians)
conn.create_function("sin", 1, math.sin)
conn.create_function("sinh", 1, math.sinh)
conn.create_function("sqrt", 1, math.sqrt)
conn.create_function("tan", 1, math.tan)
conn.create_function("tanh", 1, math.tanh)
conn.create_function("trunc", 1, math.trunc)
conn.create_function("atan2", 2, math.atan2)
conn.create_function("copysign", 2, math.copysign)
conn.create_function("fmod", 2, math.fmod)
conn.create_function("gcd", 2, math.gcd)
conn.create_function("hypot", 2, math.hypot)
conn.create_function("isclose", 2, math.isclose)
conn.create_function("ldexp", 2, math.ldexp)
conn.create_function("pow", 2, math.pow) ```
Example 77
 Project: data_algebra   Author: WinVector   File: SQLite.py    BSD 3-Clause "New" or "Revised" License 4 votes
```def prepare_connection(self, conn):
# https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.create_function
conn.create_function("is_bad", 1, _check_scalar_bad)
# math fns
conn.create_function("acos", 1, math.acos)
conn.create_function("acosh", 1, math.acosh)
conn.create_function("asin", 1, math.asin)
conn.create_function("asinh", 1, math.asinh)
conn.create_function("atan", 1, math.atan)
conn.create_function("atanh", 1, math.atanh)
conn.create_function("ceil", 1, math.ceil)
conn.create_function("cos", 1, math.cos)
conn.create_function("cosh", 1, math.cosh)
conn.create_function("degrees", 1, math.degrees)
conn.create_function("erf", 1, math.erf)
conn.create_function("erfc", 1, math.erfc)
conn.create_function("exp", 1, math.exp)
conn.create_function("expm1", 1, math.expm1)
conn.create_function("fabs", 1, math.fabs)
conn.create_function("factorial", 1, math.factorial)
conn.create_function("floor", 1, math.floor)
conn.create_function("frexp", 1, math.frexp)
conn.create_function("gamma", 1, math.gamma)
conn.create_function("isfinite", 1, math.isfinite)
conn.create_function("isinf", 1, math.isinf)
conn.create_function("isnan", 1, math.isnan)
conn.create_function("lgamma", 1, math.lgamma)
conn.create_function("log", 1, math.log)
conn.create_function("log10", 1, math.log10)
conn.create_function("log1p", 1, math.log1p)
conn.create_function("log2", 1, math.log2)
conn.create_function("modf", 1, math.modf)
conn.create_function("radians", 1, math.radians)
conn.create_function("sin", 1, math.sin)
conn.create_function("sinh", 1, math.sinh)
conn.create_function("sqrt", 1, math.sqrt)
conn.create_function("tan", 1, math.tan)
conn.create_function("tanh", 1, math.tanh)
conn.create_function("trunc", 1, math.trunc)
conn.create_function("atan2", 2, math.atan2)
conn.create_function("copysign", 2, math.copysign)
conn.create_function("fmod", 2, math.fmod)
conn.create_function("gcd", 2, math.gcd)
conn.create_function("hypot", 2, math.hypot)
conn.create_function("isclose", 2, math.isclose)
conn.create_function("ldexp", 2, math.ldexp)
conn.create_function("pow", 2, math.pow) ```
Example 78
 Project: Python-iBeacon-Scan   Author: NikNitro   File: test_functions.py    GNU General Public License v3.0 4 votes
```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 ```
Example 79
 Project: Mechanics_Apps   Author: ChairOfStructuralMechanicsTUM   File: main.py    MIT License 4 votes
```def evolve():
# extract global variables
[t]         = glob_t.data["t"]                 # input/output
[s]         = glob_s.data["s"]                 #      /output
[D]         = glob_D.data["D"]                 # input/
[ef]        = glob_ef.data["ef"]               # input/
[damped_ef] = glob_damped_ef.data["damped_ef"] # input/
[spring]    = glob_spring.data["spring"]       # input/

[initial_displacement_value] = glob_initial_displacement_value.data["initial_displacement_value"] # input/
[initial_velocity_value]     = glob_initial_velocity_value.data["initial_velocity_value"]         # input/
[frequency_ratio_value]      = glob_frequency_ratio_value.data["frequency_ratio_value"]           # input/
[force_value]                = glob_force_value.data["force_value"]                               # input/
[excitation_frequency_value] = glob_excitation_frequency_value.data["excitation_frequency_value"] # input/

#########
k = spring.getSpringConstant

if force_value > 0:
if D == 0 and frequency_ratio_value == 1:
s_p = 0.5 * (initial_displacement_value * cos(ef*t) + initial_velocity_value/ef * sin(ef*t) + force_value/ (2*k) * (sin(ef*t) - ef*t*cos(ef*t)))
s_h = s_p
else:
# particular (steady-state) part
s_p = force_value / ( k * (pow(1-pow(frequency_ratio_value,2),2) + pow(2*D*frequency_ratio_value,2)) ) \
* ( ( 1-pow(frequency_ratio_value,2) ) * sin(excitation_frequency_value*t) - 2*D*frequency_ratio_value*cos(excitation_frequency_value*t) )
# homogeneous (transient) part
if D<1:
s_h = exp(-D*ef*t) * ( initial_displacement_value * cos(damped_ef*t) + (initial_velocity_value + initial_displacement_value * ef * D)/damped_ef * sin(damped_ef*t) ) \
+ force_value * exp(-D*ef*t) / ( k * (pow(1-pow(frequency_ratio_value,2),2) + pow(2*D*frequency_ratio_value,2)) ) \
* ( 2*D*frequency_ratio_value*cos(damped_ef*t) + ef/damped_ef * ( 2*frequency_ratio_value*pow(D,2) - frequency_ratio_value * (1-pow(frequency_ratio_value,2)) ) * sin(damped_ef*t) )
else:
print("how did we get there?") # even if this place is reached, there should be no bug
s_h = 0
play_pause_button.disabled = True
pause()

else:
if D < 1:
s_h = exp(-ef*D*t) * ( initial_displacement_value * cos(damped_ef*t) + (initial_velocity_value + initial_displacement_value * ef * D)/damped_ef * sin(damped_ef*t) )
elif D == 1:
s_h = exp(-ef*t) * ( initial_displacement_value + ( initial_velocity_value + ef * initial_displacement_value ) * t )
elif D > 1:
s_h = exp(-ef*D*t) * ( initial_displacement_value * cosh(damped_ef*t) + (initial_velocity_value + initial_displacement_value * ef * D)/damped_ef * sinh(damped_ef*t) )
s_p = 0
#########

# scale with 1/stiffness
s_p = s_p * k
s_h = s_h * k
s = s_p + s_h

move_system(-s)
displacement.stream(dict(t=[t],s=[s]))
displacement_particular.stream(dict(t=[t],s=[s_p]))
displacement_homogeneous.stream(dict(t=[t],s=[s_h]))
t+=dt

# save updated global variables
glob_t.data = dict(t = [t])
glob_s.data = dict(s = [s]) ```
Example 80
 Project: pyqha   Author: mauropalumbo75   File: thermo.py    MIT License 4 votes
```def compute_thermo(E,dos,TT):
"""
This function computes the vibrational energy, Helmholtz energy, entropy and
heat capacity in the harmonic approximation from the input numpy arrays *E*
and *dos* containing the phonon DOS(E). The calculation is done over a set of
temperatures given in input as a numpy array *TT*.
It also computes the number of phonon modes obtained from the input DOS (which
must be approximately equal to :math:`3*N`, with *N* the number of atoms per cell)
and the ZPE. The input energy and dos are expected to be in 1/cm-1.
It returns numpy arrays for the following quantities (in this order):
temperatures, vibrational energy, Helmholtz energy, entropy, heat capacity.
Plus it returns the ZPE and number of phonon modes obtained from the input DOS.
"""
if (len(dos)<3):
print ("Not enough points in the phonon DOS!")
return None

ZPE = 0.5*dos_integral(E,dos,1)
modes = dos_integral(E,dos)

EvibT = np.zeros(len(TT))
SvibT = np.zeros(len(TT))
CvibT = np.zeros(len(TT))
FvibT = np.zeros(len(TT))
for i in range(0,len(TT)):
h = 0.5*(E[2]-E[0])
arg = K_BOLTZMANN_RY*TT[i]
arg2 = 2.0 * arg
Evib = 0.0
Svib = 0.0
Cvib = 0.0
for j in range(0,len(dos)-3,3):

Evib += 3.0*E[j]/tanh(E[j]/(arg2))*dos[j]+\
3.0*E[j+1]/tanh(E[j+1]/(arg2))*dos[j+1]+\
2.0*E[j+2]/tanh(E[j+2]/(arg2))*dos[j+2]

Svib += 3.0*(E[j]/arg2/tanh(E[j]/arg2)-log(2.0*sinh(E[j]/arg2)))*dos[j]+\
3.0*(E[j+1]/arg2/tanh(E[j+1]/arg2)-log(2.0*sinh(E[j+1]/arg2)))*dos[j+1]+\
2.0*(E[j+2]/arg2/tanh(E[j+2]/arg2)-log(2.0*sinh(E[j+2]/arg2)))*dos[j+2]

try:  # avoid overflow error for arg very small
Cvib += 3.0*pow(E[j]/arg,2)/( 4.0*pow(sinh(E[j]/(arg2)),2) )*dos[j]+\
3.0*pow(E[j+1]/arg,2)/( 4.0*pow(sinh(E[j+1]/(arg2)),2) )*dos[j+1]+\
2.0*pow(E[j+2]/arg,2)/( 4.0*pow(sinh(E[j+2]/(arg2)),2) )*dos[j+2]
except:
Cvib += 0.0

EvibT[i] = h*0.5*Evib*3.0/8.0  #  h is the integration step, 0.5 comes from the equation for E,
# the factor 3.0/8.0 comes from the Simpson 3/8 rule
SvibT[i] = h*K_BOLTZMANN_RY*Svib*3.0/8.0
CvibT[i] = h*K_BOLTZMANN_RY*Cvib*3.0/8.0
FvibT = EvibT - SvibT * TT

print ()
return TT, EvibT, SvibT, CvibT, FvibT, ZPE, modes ```