Python math.asinh() Examples

The following are code examples for showing how to use math.asinh(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: duct   Author: ducted   File: generator.py    (license) View Source Project 6 votes vote down vote up
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 2
Project: otRebuilder   Author: Pal3love   File: bezierTools.py    (MIT License) View Source Project 5 votes vote down vote up
def _intSecAtan(x):
    # In : sympy.integrate(sp.sec(sp.atan(x)))
    # Out: x*sqrt(x**2 + 1)/2 + asinh(x)/2
    return x * math.sqrt(x**2 + 1)/2 + math.asinh(x)/2 
Example 3
Project: PyGLM   Author: Zuzu-Typ   File: reciprocal.py    (license) View Source Project 5 votes vote down vote up
def acsch(x):
	if type(x) in dtypes:
		return math.asinh(1. / x)

	return functor1(acsch, x) 
Example 4
Project: zippy   Author: securesystemslab   File: test_math.py    (license) View Source Project 5 votes vote down vote up
def testAsinh(self):
        self.assertRaises(TypeError, math.asinh)
        self.ftest('asinh(0)', math.asinh(0), 0)
        self.ftest('asinh(1)', math.asinh(1), 0.88137358701954305)
        self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
        self.assertEqual(math.asinh(INF), INF)
        self.assertEqual(math.asinh(NINF), NINF)
        self.assertTrue(math.isnan(math.asinh(NAN))) 
Example 5
Project: oil   Author: oilshell   File: test_math.py    (license) View Source Project 5 votes vote down vote up
def testAsinh(self):
        self.assertRaises(TypeError, math.asinh)
        self.ftest('asinh(0)', math.asinh(0), 0)
        self.ftest('asinh(1)', math.asinh(1), 0.88137358701954305)
        self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
        self.assertEqual(math.asinh(INF), INF)
        self.assertEqual(math.asinh(NINF), NINF)
        self.assertTrue(math.isnan(math.asinh(NAN))) 
Example 6
Project: python2-tracer   Author: extremecoders-re   File: test_math.py    (license) View Source Project 5 votes vote down vote up
def testAsinh(self):
        self.assertRaises(TypeError, math.asinh)
        self.ftest('asinh(0)', math.asinh(0), 0)
        self.ftest('asinh(1)', math.asinh(1), 0.88137358701954305)
        self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
        self.assertEqual(math.asinh(INF), INF)
        self.assertEqual(math.asinh(NINF), NINF)
        self.assertTrue(math.isnan(math.asinh(NAN))) 
Example 7
Project: web_ctp   Author: molebot   File: test_math.py    (license) View Source Project 5 votes vote down vote up
def testAsinh(self):
        self.assertRaises(TypeError, math.asinh)
        self.ftest('asinh(0)', math.asinh(0), 0)
        self.ftest('asinh(1)', math.asinh(1), 0.88137358701954305)
        self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
        self.assertEqual(math.asinh(INF), INF)
        self.assertEqual(math.asinh(NINF), NINF)
        self.assertTrue(math.isnan(math.asinh(NAN))) 
Example 8
Project: hyper-engine   Author: maxim5   File: sugar.py    (license) View Source Project 5 votes vote down vote up
def asinh(node): return merge([node], math.asinh) 
Example 9
Project: pefile.pypy   Author: cloudtracer   File: test_math.py    (license) View Source Project 5 votes vote down vote up
def testAsinh(self):
        self.assertRaises(TypeError, math.asinh)
        self.ftest('asinh(0)', math.asinh(0), 0)
        self.ftest('asinh(1)', math.asinh(1), 0.88137358701954305)
        self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
        self.assertEqual(math.asinh(INF), INF)
        self.assertEqual(math.asinh(NINF), NINF)
        self.assertTrue(math.isnan(math.asinh(NAN))) 
Example 10
Project: ouroboros   Author: pybee   File: cmath.py    (license) View Source Project 5 votes vote down vote up
def acos(x):
    _acos_special = [
        [3*pi/4+infj, pi+infj, pi+infj, pi-infj, pi-infj, 3*pi/4-infj, nan+infj],
        [pi/2+infj, None, None, None, None, pi/2-infj, nan+nanj],
        [pi/2+infj, None, None, None, None, pi/2-infj, pi/2+nanj],
        [pi/2+infj, None, None, None, None, pi/2-infj, pi/2+nanj],
        [pi/2+infj, None, None, None, None, pi/2-infj, nan+nanj],
        [pi/4+infj, infj, infj, 0.0-infj, 0.0-infj, pi/4-infj, nan+infj],
        [nan+infj, nan+nanj, nan+nanj, nan+nanj, nan+nanj, nan-infj, nan+nanj]
    ]

    z = _make_complex(x)

    if not isfinite(z):
        return _acos_special[_special_type(z.real)][_special_type(z.imag)]

    if abs(z.real) > _LARGE_DOUBLE or abs(z.imag) > _LARGE_DOUBLE:
        if z.real < 0:
            imag = -math.copysign(math.log(math.hypot(z.real/2, z.imag/2)) +
                                  2 * _LOG_2, z.imag)
        else:
            imag = math.copysign(math.log(math.hypot(z.real/2, z.imag/2)) +
                                 2 * _LOG_2, -z.imag)
        return complex(math.atan2(abs(z.imag), z.real), imag)

    s1 = sqrt(complex(1.0 - z.real, -z.imag))
    s2 = sqrt(complex(1.0 + z.real, z.imag))
    return complex(2 * math.atan2(s1.real, s2.real),
                   math.asinh(s2.real*s1.imag - s2.imag*s1.real)) 
Example 11
Project: ouroboros   Author: pybee   File: cmath.py    (license) View Source Project 5 votes vote down vote up
def asin(x):
    z = _make_complex(x)
    z = asinh(complex(-z.imag, z.real))
    return complex(z.imag, -z.real) 
Example 12
Project: ouroboros   Author: pybee   File: cmath.py    (license) View Source Project 5 votes vote down vote up
def acosh(x):
    z = _make_complex(x)

    if abs(z.real) > _LARGE_DOUBLE or abs(z.imag) > _LARGE_DOUBLE:
        return complex(math.log(math.hypot(z.real/2, z.imag/2)) + 2*_LOG_2,
                       math.atan2(z.imag, z.real))

    s1 = sqrt(complex(z.real-1, z.imag))
    s2 = sqrt(complex(z.real+1, z.imag))
    return complex(math.asinh(s1.real*s2.real + s1.imag*s2.imag),
                   2*math.atan2(s1.imag, s2.real)) 
Example 13
Project: ouroboros   Author: pybee   File: cmath.py    (license) View Source Project 5 votes vote down vote up
def asinh(x):
    _asinh_special = [
        [-inf-1j*pi/4, complex(-float("inf"), -0.0), complex(-float("inf"), -0.0),
            complex(-float("inf"), 0.0), complex(-float("inf"), 0.0), -inf+1j*pi/4, -inf+nanj],
        [-inf-1j*pi/2, None, None, None, None, -inf+1j*pi/2, nan+nanj],
        [-inf-1j*pi/2, None, None, None, None, -inf+1j*pi/2, nan+nanj],
        [inf-1j*pi/2, None, None, None, None, inf+1j*pi/2, nan+nanj],
        [inf-1j*pi/2, None, None, None, None, inf+1j*pi/2, nan+nanj],
        [inf-1j*pi/4, complex(float("inf"), -0.0), complex(float("inf"), -0.0),
            inf, inf, inf+1j*pi/4, inf+nanj],
        [inf+nanj, nan+nanj, complex(float("nan"), -0.0), nan, nan+nanj, inf+nanj, nan+nanj]
    ]

    z = _make_complex(x)

    if not isfinite(z):
        return _asinh_special[_special_type(z.real)][_special_type(z.imag)]

    if abs(z.real) > _LARGE_DOUBLE or abs(z.imag) > _LARGE_DOUBLE:
        if z.imag >= 0:
            real = math.copysign(math.log(math.hypot(z.imag/2, z.real/2)) +
                                 2 * _LOG_2, z.real)
        else:
            real = -math.copysign(math.log(math.hypot(z.imag/2, z.real/2)) +
                                  2 * _LOG_2, -z.real)
        return complex(real, math.atan2(z.imag, abs(z.real)))

    s1 = sqrt(complex(1+z.imag, -z.real))
    s2 = sqrt(complex(1-z.imag, z.real))
    return complex(math.asinh(s1.real*s2.imag-s2.real*s1.imag),
                   math.atan2(z.imag, s1.real*s2.real - s1.imag*s2.imag)) 
Example 14
Project: ouroboros   Author: pybee   File: test_math.py    (license) View Source Project 5 votes vote down vote up
def testAsinh(self):
        self.assertRaises(TypeError, math.asinh)
        self.ftest('asinh(0)', math.asinh(0), 0)
        self.ftest('asinh(1)', math.asinh(1), 0.88137358701954305)
        self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
        self.assertEqual(math.asinh(INF), INF)
        self.assertEqual(math.asinh(NINF), NINF)
        self.assertTrue(math.isnan(math.asinh(NAN))) 
Example 15
Project: ndk-python   Author: gittor   File: test_math.py    (license) View Source Project 5 votes vote down vote up
def testAsinh(self):
        self.assertRaises(TypeError, math.asinh)
        self.ftest('asinh(0)', math.asinh(0), 0)
        self.ftest('asinh(1)', math.asinh(1), 0.88137358701954305)
        self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
        self.assertEqual(math.asinh(INF), INF)
        self.assertEqual(math.asinh(NINF), NINF)
        self.assertTrue(math.isnan(math.asinh(NAN))) 
Example 16
Project: kbe_server   Author: xiaohaoppy   File: test_math.py    (license) View Source Project 5 votes vote down vote up
def testAsinh(self):
        self.assertRaises(TypeError, math.asinh)
        self.ftest('asinh(0)', math.asinh(0), 0)
        self.ftest('asinh(1)', math.asinh(1), 0.88137358701954305)
        self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
        self.assertEqual(math.asinh(INF), INF)
        self.assertEqual(math.asinh(NINF), NINF)
        self.assertTrue(math.isnan(math.asinh(NAN))) 
Example 17
Project: femtocode   Author: diana-hep   File: test_libstandard.py    (license) View Source Project 5 votes vote down vote up
def test_asinh(self):
        self.assertEqual(session.source("Test", x=real(3.14, 6.5)).type("asinh(x)"), real(math.asinh(3.14), math.asinh(6.5)))
        self.assertEqual(session.source("Test", x=real(3.14, almost(6.5))).type("asinh(x)"), real(math.asinh(3.14), almost(math.asinh(6.5))))
        self.assertEqual(session.source("Test", x=real(3.14, inf)).type("asinh(x)"), real(math.asinh(3.14), inf))
        self.assertEqual(session.source("Test", x=real(3.14, almost(inf))).type("asinh(x)"), real(math.asinh(3.14), almost(inf)))
        self.assertEqual(session.source("Test", x=real).type("asinh(x)"), real)
        self.assertEqual(session.source("Test", x=extended).type("asinh(x)"), extended)
        for entry in numerical.toPython(y = "y", a = "asinh(y)").submit():
            self.assertEqual(entry.a, math.asinh(entry.y)) 
Example 18
Project: pyomo   Author: Pyomo   File: expr.py    (license) View Source Project 5 votes vote down vote up
def asinh(arg):
    return generate_intrinsic_function_expression(arg, 'asinh', math.asinh) 
Example 19
Project: bge-logic-nodes-add-on   Author: thepgi   File: bgelogic.py    (license) View Source Project 4 votes vote down vote up
def __init__(self):
        ParameterCell.__init__(self)
        self.a = None
        self.b = None
        self.c = None
        self.d = None
        self.formula = ""
        self._previous_values = [None, None, None, None]
        self._formula_globals = globals();
        self._formula_locals = {
            "exp":math.exp,
            "pow":math.pow,
            "log":math.log,
            "log10":math.log10,
            "acos":math.acos,
            "asin":math.asin,
            "atan":math.atan,
            "atan2":math.atan2,
            "cos":math.cos,
            "hypot":math.hypot,
            "sin":math.sin,
            "tan":math.tan,
            "degrees":math.degrees,
            "radians":math.radians,
            "acosh":math.acosh,
            "asinh":math.asinh,
            "atanh":math.atanh,
            "cosh":math.cosh,
            "sinh":math.sinh,
            "tanh":math.tanh,
            "pi":math.pi,
            "e":math.e,
            "ceil":math.ceil,
            "sign":ParameterMathFun.signum,
            "abs":math.fabs,
            "floor":math.floor,
            "mod":math.fmod,
            "sqrt":math.sqrt,
            "curt":ParameterMathFun.curt,
            "str":str,
            "int":int,
            "float":float
        } 
Example 20
Project: SparseArray   Author: INGEOTEC   File: test_sparse_array.py    (license) View Source Project 4 votes vote down vote up
def test_one():
    from math import sin, cos, tan, asin, acos, atan
    from math import sinh, cosh, tanh, asinh, acosh, atanh
    from math import exp, expm1, log, log10, log1p, sqrt, lgamma
    from math import fabs, ceil, floor, trunc, erf, erfc
    try:
        from math import log2
    except ImportError:
        def log2(x):
            return log(x) / log(2)

    def wrapper(f, v):
        try:
            return f(v)
        except ValueError:
            if f == sqrt:
                return float('nan')
            if v >= 0:
                return float('inf')
            else:
                return -float('inf')

    def compare(a, b):
        if isfinite(a) and isfinite(b):
            return assert_almost_equals(a, b)
        return str(a) == str(b)

    for f in [sin, cos, tan, asin, acos, atan,
              sinh, cosh, tanh, asinh, acosh, atanh,
              exp, expm1, log, log2, log10, log1p, sqrt,
              lgamma,
              fabs, ceil, floor, trunc,
              erf, erfc]:
        for p in [0.5, 1]:
            a = random_lst(p=p)
            b = SparseArray.fromlist(a)
            c = getattr(b, f.__name__)()
            res = [wrapper(f, x) for x in a]
            index = [k for k, v in enumerate(res) if v != 0]
            res = [x for x in res if x != 0]
            print(f, p, c.non_zero, len(res))
            assert c.non_zero == len(res)
            [assert_almost_equals(v, w) for v, w in zip(index,
                                                        c.index)]
            [compare(v, w) for v, w in zip(res,
                                           c.data)]