Python math.cosh() Examples
The following are 30
code examples of math.cosh().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
math
, or try the search function
.
Example #1
Source File: ScTrigoOp.py From Sorcar with GNU General Public License v3.0 | 6 votes |
def post_execute(self): out = {} if (self.inputs["Operation 1"].default_value == "SIN"): if (self.inputs["Operation 2"].default_value == "NONE"): out["Value"] = math.sin(self.inputs["X"].default_value) elif (self.inputs["Operation 2"].default_value == "HB"): out["Value"] = math.sinh(self.inputs["X"].default_value) elif (self.inputs["Operation 2"].default_value == "INV"): out["Value"] = math.asin(max(min(self.inputs["X"].default_value, 1), -1)) elif (self.inputs["Operation 1"].default_value == "COS"): if (self.inputs["Operation 2"].default_value == "NONE"): out["Value"] = math.cos(self.inputs["X"].default_value) elif (self.inputs["Operation 2"].default_value == "HB"): out["Value"] = math.cosh(self.inputs["X"].default_value) elif (self.inputs["Operation 2"].default_value == "INV"): out["Value"] = math.acos(max(min(self.inputs["X"].default_value, 1), -1)) elif (self.inputs["Operation 1"].default_value == "TAN"): if (self.inputs["Operation 2"].default_value == "NONE"): out["Value"] = math.tan(self.inputs["X"].default_value) elif (self.inputs["Operation 2"].default_value == "HB"): out["Value"] = math.tanh(self.inputs["X"].default_value) elif (self.inputs["Operation 2"].default_value == "INV"): out["Value"] = math.atan(self.inputs["X"].default_value) return out
Example #2
Source File: torsion.py From Structural-Engineering with 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 #3
Source File: torsion.py From Structural-Engineering with 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 #4
Source File: macros.py From pyth with MIT License | 6 votes |
def trig(a, b=' '): if is_num(a) and isinstance(b, int): funcs = [math.sin, math.cos, math.tan, math.asin, math.acos, math.atan, math.degrees, math.radians, math.sinh, math.cosh, math.tanh, math.asinh, math.acosh, math.atanh] return funcs[b](a) if is_lst(a): width = max(len(row) for row in a) padded_matrix = [list(row) + (width - len(row)) * [b] for row in a] transpose = list(zip(*padded_matrix)) if all(isinstance(row, str) for row in a) and isinstance(b, str): normalizer = ''.join else: normalizer = list norm_trans = [normalizer(padded_row) for padded_row in transpose] return norm_trans return unknown_types(trig, ".t", a, b)
Example #5
Source File: torsion.py From Structural-Engineering with 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 #6
Source File: torsion.py From Structural-Engineering with 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
Source File: generator.py From tensor with 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 #8
Source File: test_math.py From Project-New-Reign---Nemesis-Main with 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 #9
Source File: Tile.py From hyperbolic with MIT License | 5 votes |
def makeRegular(p, q=None, innerDeg=None, er=None, hr=None, skip=1): assert (q is not None) + (innerDeg is not None) + (er is not None) + (hr is not None) == 1, \ 'Specify exactly one of q, innerDeg, er, or hr' # Calculate innerRad if innerDeg is not None: q = 360/innerDeg innerRad = math.radians(innerDeg) elif q is not None: innerRad = math.pi*2/q else: if hr is None: hr = radialEuclidToPoincare(er) thDiv2 = math.pi / p innerRad = 2 * math.atan(1 / (math.tan(thDiv2) * math.cosh(hr))) # Calculate r if q is None: if er is None: pointConstruct = Point.fromHPolar r = hr else: pointConstruct = Point.fromPolarEuclid r = er else: r = hypPolyEdgeConstruct(p, q) pointConstruct = Point.fromPolarEuclid # Calculate polygon vertices verts = [ pointConstruct(r, deg=skip*i*360/p) for i in range(p) ] return Tile(verts)
Example #10
Source File: test_functions.py From altanalyze with Apache License 2.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 #11
Source File: test_math.py From CTFCrackTools with 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 #12
Source File: test_math.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testCosh(self): self.assertRaises(TypeError, math.cosh) self.ftest('cosh(0)', math.cosh(0), 1) self.ftest('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert self.assertEqual(math.cosh(INF), INF) self.assertEqual(math.cosh(NINF), INF) self.assertTrue(math.isnan(math.cosh(NAN)))
Example #13
Source File: test_math.py From android_universal with 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 #14
Source File: test_math.py From android_universal with MIT License | 5 votes |
def testCosh(self): self.assertRaises(TypeError, math.cosh) self.ftest('cosh(0)', math.cosh(0), 1) self.ftest('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert self.assertEqual(math.cosh(INF), INF) self.assertEqual(math.cosh(NINF), INF) self.assertTrue(math.isnan(math.cosh(NAN)))
Example #15
Source File: sugar.py From hyper-engine with Apache License 2.0 | 5 votes |
def cosh(node): return merge([node], math.cosh)
Example #16
Source File: test_functions.py From altanalyze with Apache License 2.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 #17
Source File: test_functions.py From altanalyze with Apache License 2.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 #18
Source File: test_functions.py From altanalyze with Apache License 2.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 #19
Source File: torsion.py From Structural-Engineering with 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 #20
Source File: test_math.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def testCosh(self): self.assertRaises(TypeError, math.cosh) self.ftest('cosh(0)', math.cosh(0), 1) self.ftest('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert self.assertEqual(math.cosh(INF), INF) self.assertEqual(math.cosh(NINF), INF) self.assertTrue(math.isnan(math.cosh(NAN)))
Example #21
Source File: test_math.py From gcblue with BSD 3-Clause "New" or "Revised" 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 #22
Source File: test_math.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def testCosh(self): self.assertRaises(TypeError, math.cosh) self.ftest('cosh(0)', math.cosh(0), 1) self.ftest('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert self.assertEqual(math.cosh(INF), INF) self.assertEqual(math.cosh(NINF), INF) self.assertTrue(math.isnan(math.cosh(NAN)))
Example #23
Source File: MathLib.py From PyFlow with Apache License 2.0 | 5 votes |
def cosh(x=('FloatPin', 0.0), Result=(REF, ('BoolPin', False))): '''Return the hyperbolic cosine of `x`.''' try: Result(True) return math.cosh(x) except: Result(False) return -1
Example #24
Source File: default_gaussian.py From pennylane with Apache License 2.0 | 5 votes |
def two_mode_squeezing(r, phi): """Two-mode squeezing. Args: r (float): squeezing magnitude phi (float): rotation parameter Returns: array: symplectic transformation matrix """ cp = math.cos(phi) sp = math.sin(phi) ch = math.cosh(r) sh = math.sinh(r) S = np.array( [ [ch, cp * sh, 0, sp * sh], [cp * sh, ch, sp * sh, 0], [0, sp * sh, ch, -cp * sh], [sp * sh, 0, -cp * sh, ch], ] ) return S
Example #25
Source File: default_gaussian.py From pennylane with Apache License 2.0 | 5 votes |
def squeezing(r, phi): """Squeezing in the phase space. Args: r (float): squeezing magnitude phi (float): rotation parameter Returns: array: symplectic transformation matrix """ cp = math.cos(phi) sp = math.sin(phi) ch = math.cosh(r) sh = math.sinh(r) return np.array([[ch - cp * sh, -sp * sh], [-sp * sh, ch + cp * sh]])
Example #26
Source File: cv.py From pennylane with Apache License 2.0 | 5 votes |
def _heisenberg_rep(p): R = _rotation(p[1], bare=True) S = math.sinh(p[0]) * np.diag([1, -1]) U = math.cosh(p[0]) * np.identity(5) U[0, 0] = 1 U[1:3, 3:5] = S @ R.T U[3:5, 1:3] = S @ R.T return U
Example #27
Source File: torsion.py From Structural-Engineering with 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 #28
Source File: torsion.py From Structural-Engineering with 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 H = self.H z = z_in if 0 <= z_in <= (alpha*l): thet = ((T*a) / ((H+1.0)*G*J))*\ ((((H*((1.0/m.sinh(l/a))+m.sinh((alpha*l)/a)-(m.cosh((alpha*l)/a)/m.tanh(l/a))))+ \ (m.sinh((alpha*l)/a) - (m.cosh((alpha*l)/a)/m.tanh(l/a)) + (1.0/m.tanh(l/a))))* \ (m.cosh(z/a)-1.0)) - \ m.sinh(z/a) + \ (z/a)) else: thet = (T*a / ((1+(1/H))*G*J))*\ ((m.cosh((alpha*l)/a) - 1.0/(H*m.sinh(l/a)) +\ (m.cosh((alpha*l)/a)-m.cosh(l/a)+((l/a)*m.sinh(l/a))) / m.sinh(l/a)) +\ m.cosh(z/a)*\ ((1.0-m.cosh((alpha*l)/a))/(H*m.tanh(l/a)) +\ (1.0-(m.cosh((alpha*l)/a)*m.cosh(l/a)))/m.sinh(l/a)) +\ m.sinh(z/a)*\ (((m.cosh((alpha*l)/a)-1.0)/H) + m.cosh((alpha*l)/a)) -\ (z/a)) return thet
Example #29
Source File: torsion.py From Structural-Engineering with 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 #30
Source File: torsion.py From Structural-Engineering with 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