Python cmath.atanh() Examples
The following are 16
code examples of cmath.atanh().
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
cmath
, or try the search function
.
Example #1
Source File: test_cmath.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def testTanhSign(self): for z in complex_zeros: self.assertComplexIdentical(cmath.tanh(z), z) # The algorithm used for atan and atanh makes use of the system # log1p function; If that system function doesn't respect the sign # of zero, then atan and atanh will also have difficulties with # the sign of complex zeros.
Example #2
Source File: test_cmath.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def testAtanhSign(self): for z in complex_zeros: self.assertComplexIdentical(cmath.atanh(z), z)
Example #3
Source File: test_cmath.py From ironpython3 with Apache License 2.0 | 5 votes |
def testTanhSign(self): for z in complex_zeros: self.assertComplexIdentical(cmath.tanh(z), z) # The algorithm used for atan and atanh makes use of the system # log1p function; If that system function doesn't respect the sign # of zero, then atan and atanh will also have difficulties with # the sign of complex zeros.
Example #4
Source File: test_cmath.py From ironpython3 with Apache License 2.0 | 5 votes |
def testAtanhSign(self): for z in complex_zeros: self.assertComplexIdentical(cmath.atanh(z), z)
Example #5
Source File: math_functions.py From jhTAlib with GNU General Public License v3.0 | 5 votes |
def ATANH(df, price='Close'): """ Inverse Hyperbolic Tangent Returns: list of floats = jhta.ATANH(df, price='Close') """ return [cmath.atanh(df[price][i]).real for i in range(len(df[price]))]
Example #6
Source File: test_cmath.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def testTanhSign(self): for z in complex_zeros: self.assertComplexIdentical(cmath.tanh(z), z) # The algorithm used for atan and atanh makes use of the system # log1p function; If that system function doesn't respect the sign # of zero, then atan and atanh will also have difficulties with # the sign of complex zeros.
Example #7
Source File: test_cmath.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def testAtanhSign(self): for z in complex_zeros: self.assertComplexIdentical(cmath.atanh(z), z)
Example #8
Source File: test_cmath_jy.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_atanh(self): self.assertAlmostEqual(complex(0.11750, 1.40992), cmath.atanh(complex(3, 4)))
Example #9
Source File: eos.py From thermo with MIT License | 5 votes |
def main_derivatives_and_departures(T, P, V, b, delta, epsilon, a_alpha, da_alpha_dT, d2a_alpha_dT2, quick=True): if quick: x0 = V - b x1 = V*V + V*delta + epsilon x3 = R*T x4 = 1./(x0*x0) x5 = 2.*V + delta x6 = 1./(x1*x1) x7 = a_alpha*x6 x8 = P*V x9 = delta*delta x10 = -4.*epsilon + x9 x11 = x10**-0.5 x12 = 2.*x11*catanh(x11*x5).real x13 = x10**-0.5 x14 = V + delta*0.5 x15 = 2.*epsilon*x13 x16 = x13*x9*0.5 dP_dT = R/x0 - da_alpha_dT/x1 dP_dV = -x3*x4 + x5*x7 d2P_dT2 = -d2a_alpha_dT2/x1 d2P_dV2 = -2.*a_alpha*x5*x5*x6/x1 + 2.*x7 + 2.*x3*x4/x0 d2P_dTdV = -R*x4 + da_alpha_dT*x5*x6 H_dep = x12*(T*da_alpha_dT - a_alpha) - x3 + x8 S_dep = -R*log((V*x3/(x0*x8))**2)*0.5 + da_alpha_dT*x12 # Consider Real part of the log only via log(x**2)/2 = Re(log(x)) Cv_dep = -T*d2a_alpha_dT2*x13*(-log(((x14 - x15 + x16)/(x14 + x15 - x16))**2)*0.5) # Consider Real part of the log only via log(x**2)/2 = Re(log(x)) else: dP_dT = R/(V - b) - da_alpha_dT/(V**2 + V*delta + epsilon) dP_dV = -R*T/(V - b)**2 - (-2*V - delta)*a_alpha/(V**2 + V*delta + epsilon)**2 d2P_dT2 = -d2a_alpha_dT2/(V**2 + V*delta + epsilon) d2P_dV2 = 2*(R*T/(V - b)**3 - (2*V + delta)**2*a_alpha/(V**2 + V*delta + epsilon)**3 + a_alpha/(V**2 + V*delta + epsilon)**2) d2P_dTdV = -R/(V - b)**2 + (2*V + delta)*da_alpha_dT/(V**2 + V*delta + epsilon)**2 H_dep = P*V - R*T + 2*(T*da_alpha_dT - a_alpha)*catanh((2*V + delta)/sqrt(delta**2 - 4*epsilon)).real/sqrt(delta**2 - 4*epsilon) S_dep = -R*log(V) + R*log(P*V/(R*T)) + R*log(V - b) + 2*da_alpha_dT*catanh((2*V + delta)/sqrt(delta**2 - 4*epsilon)).real/sqrt(delta**2 - 4*epsilon) Cv_dep = -T*(sqrt(1/(delta**2 - 4*epsilon))*log(V - delta**2*sqrt(1/(delta**2 - 4*epsilon))/2 + delta/2 + 2*epsilon*sqrt(1/(delta**2 - 4*epsilon))) - sqrt(1/(delta**2 - 4*epsilon))*log(V + delta**2*sqrt(1/(delta**2 - 4*epsilon))/2 + delta/2 - 2*epsilon*sqrt(1/(delta**2 - 4*epsilon))))*d2a_alpha_dT2 return [dP_dT, dP_dV, d2P_dT2, d2P_dV2, d2P_dTdV, H_dep, S_dep, Cv_dep]
Example #10
Source File: test_cmath_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_atanh(self): self.assertAlmostEqual(complex(0.11750, 1.40992), cmath.atanh(complex(3, 4)))
Example #11
Source File: test_functions.py From altanalyze with Apache License 2.0 | 5 votes |
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
Example #12
Source File: test_functions.py From altanalyze with Apache License 2.0 | 5 votes |
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)
Example #13
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 #14
Source File: test_functions.py From altanalyze with Apache License 2.0 | 5 votes |
def test_atanh(): mp.dps = 15 assert atanh(0) == 0 assert atanh(0.5).ae(0.54930614433405484570) assert atanh(-0.5).ae(-0.54930614433405484570) assert atanh(1) == inf assert atanh(-1) == -inf assert isnan(atanh(nan)) assert isinstance(atanh(1), mpf) assert isinstance(atanh(-1), mpf) # Limits at infinity jpi2 = j*pi/2 assert atanh(inf).ae(-jpi2) assert atanh(-inf).ae(jpi2) assert atanh(mpc(inf,-1)).ae(-jpi2) assert atanh(mpc(inf,0)).ae(-jpi2) assert atanh(mpc(inf,1)).ae(jpi2) assert atanh(mpc(1,inf)).ae(jpi2) assert atanh(mpc(0,inf)).ae(jpi2) assert atanh(mpc(-1,inf)).ae(jpi2) assert atanh(mpc(-inf,1)).ae(jpi2) assert atanh(mpc(-inf,0)).ae(jpi2) assert atanh(mpc(-inf,-1)).ae(-jpi2) assert atanh(mpc(-1,-inf)).ae(-jpi2) assert atanh(mpc(0,-inf)).ae(-jpi2) assert atanh(mpc(1,-inf)).ae(-jpi2)
Example #15
Source File: test_cmath_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_atanh(self): self.assertAlmostEqual(complex(0.11750, 1.40992), cmath.atanh(complex(3, 4)))
Example #16
Source File: test_functions.py From altanalyze with Apache License 2.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