Python math.asinh() Examples

The following are 30 code examples for showing how to use math.asinh(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module math , or try the search function .

Example 1
Project: ironpython2   Author: IronLanguages   File: test_math.py    License: Apache License 2.0 6 votes vote down vote up
def test_math_subclass(self):
        """verify subtypes of float/long work w/ math functions"""
        import math
        class myfloat(float): pass
        class mylong(long): pass

        mf = myfloat(1)
        ml = mylong(1)

        for x in math.log, math.log10, math.log1p, math.asinh, math.acosh, math.atanh, math.factorial, math.trunc, math.isinf:
            try:
                resf = x(mf)
            except ValueError:
                resf = None
            try:
                resl = x(ml)
            except ValueError:
                resl = None
            self.assertEqual(resf, resl) 
Example 2
Project: pyth   Author: isaacg1   File: macros.py    License: MIT License 6 votes vote down vote up
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 3
Project: ironpython3   Author: IronLanguages   File: test_math.py    License: Apache License 2.0 6 votes vote down vote up
def test_math_subclass(self):
        """verify subtypes of float/long work w/ math functions"""
        import math
        class myfloat(float): pass
        class mylong(long): pass

        mf = myfloat(1)
        ml = mylong(1)

        for x in math.log, math.log10, math.log1p, math.asinh, math.acosh, math.atanh, math.factorial, math.trunc, math.isinf:
            try:
                resf = x(mf)
            except ValueError:
                resf = None
            try:
                resl = x(ml)
            except ValueError:
                resl = None
            self.assertEqual(resf, resl) 
Example 4
Project: tensor   Author: calston   File: generator.py    License: MIT License 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 5
Project: pymap3d   Author: geospace-code   File: latitude.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def geodetic2isometric_point(geodetic_lat: float, ell: Ellipsoid = None, deg: bool = True) -> float:
    geodetic_lat, ell = sanitize(geodetic_lat, ell, deg)

    e = ell.eccentricity

    if abs(geodetic_lat - pi / 2) <= 1e-9:
        isometric_lat = inf
    elif abs(-geodetic_lat - pi / 2) <= 1e-9:
        isometric_lat = -inf
    else:
        isometric_lat = asinh(tan(geodetic_lat)) - e * atanh(e * sin(geodetic_lat))
        # same results
        # a1 = e * sin(geodetic_lat)
        # y = (1 - a1) / (1 + a1)
        # a2 = pi / 4 + geodetic_lat / 2
        # isometric_lat = log(tan(a2) * (y ** (e / 2)))
        # isometric_lat = log(tan(a2)) + e/2 * log((1-e*sin(geodetic_lat)) / (1+e*sin(geodetic_lat)))

    return degrees(isometric_lat) if deg else isometric_lat 
Example 6
Project: pyh3   Author: buzzfeed   File: h3math.py    License: MIT License 5 votes vote down vote up
def compute_radius(H_p):
    return K * math.asinh(math.sqrt(H_p / (2 * math.pi * K * K))) 
Example 7
Project: ironpython2   Author: IronLanguages   File: test_math.py    License: Apache License 2.0 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: ironpython2   Author: IronLanguages   File: test_regressions.py    License: Apache License 2.0 5 votes vote down vote up
def test_gh1284(self):
        import math
        self.assertEqual(round(math.asinh(4.),12),round(math.log(math.sqrt(17.)+4.),12))
        self.assertEqual(round(math.asinh(.4),12),round(math.log(math.sqrt(1.16)+.4),12))
        self.assertEqual(round(math.asinh(-.5),12),round(math.log(math.sqrt(1.25)-.5),12))
        self.assertEqual(round(math.asinh(-6.),12),round(math.log(math.sqrt(37.)-6.),12)) 
Example 9
Project: Finance-Python   Author: alpha-miner   File: testAccumulatorsArithmetic.py    License: MIT License 5 votes vote down vote up
def testAsinhFunction(self):
        ma5 = MovingAverage(5, 'close')
        holder = Asinh(ma5)

        for i, close in enumerate(self.sampleClose):
            data = {'close': close}
            ma5.push(data)
            holder.push(data)

            expected = math.asinh(ma5.result())
            calculated = holder.result()
            self.assertAlmostEqual(calculated, expected, 12, "at index {0:d}\n"
                                                             "expected:   {1:f}\n"
                                                             "calculated: {2:f}".format(i, expected, calculated)) 
Example 10
Project: BinderFilter   Author: dxwu   File: test_math.py    License: MIT License 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 11
Project: oss-ftp   Author: aliyun   File: test_math.py    License: MIT License 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 12
Project: ufora   Author: ufora   File: pure_math.py    License: Apache License 2.0 5 votes vote down vote up
def __call__(self, val):
        if val < 1.0:
            raise ValueError("math domain error")

        return __inline_fora(
            """fun(@unnamed_args:(val), *args) {
                   PyFloat(math.asinh(val.@m))
                   }"""
            )(val) 
Example 13
Project: ufora   Author: ufora   File: MathTestCases.py    License: Apache License 2.0 5 votes vote down vote up
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 14
Project: hask   Author: billpmurphy   File: Num.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 15
Project: hask   Author: billpmurphy   File: Num.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def asinh(x):
    """
    asinh :: Floating a => a -> a
    """
    return Floating[x].asinh(x) 
Example 16
Project: Fluid-Designer   Author: Microvellum   File: test_math.py    License: GNU General Public License v3.0 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: ironpython3   Author: IronLanguages   File: test_math.py    License: Apache License 2.0 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 18
Project: ironpython3   Author: IronLanguages   File: test_regressions.py    License: Apache License 2.0 5 votes vote down vote up
def test_gh1284(self):
        import math
        self.assertEqual(round(math.asinh(4.),12),round(math.log(math.sqrt(17.)+4.),12))
        self.assertEqual(round(math.asinh(.4),12),round(math.log(math.sqrt(1.16)+.4),12))
        self.assertEqual(round(math.asinh(-.5),12),round(math.log(math.sqrt(1.25)-.5),12))
        self.assertEqual(round(math.asinh(-6.),12),round(math.log(math.sqrt(37.)-6.),12)) 
Example 19
Project: pyACA   Author: alexanderlerch   File: ToolFreq2Bark.py    License: MIT License 5 votes vote down vote up
def ToolFreq2Bark(fInHz, cModel = 'Schroeder'):
    def acaSchroeder_scalar(f):
        return 7 * math.asinh(f/650)
    def acaTerhardt_scalar(f):
        return 13.3 * math.atan(0.75 * f/1000)
    def acaZwicker_scalar(f):
        return 13 * math.atan(0.76 * f/1000) + 3.5 * math.atan(f/7500)
    def acaTraunmuller_scalar(f):
        return 26.81/(1+1960./f) - 0.53

    f = np.asarray(fInHz)
    if f.ndim == 0:
        if cModel == 'Terhardt':
            return acaTerhardt_scalar(f)
        elif cModel == 'Zwicker':
            return acaZwicker_scalar(f)
        elif cModel == 'Traunmuller':
            return acaTraunmuller_scalar(f)
        else:
            return acaSchroeder_scalar(f)

    fBark = np.zeros(f.shape)
    if cModel == 'Terhardt':
        for k,fi in enumerate(f):
            fBark[k] =  acaTerhardt_scalar(fi)
    elif cModel == 'Zwicker':
        for k,fi in enumerate(f):
            fBark[k] =  acaZwicker_scalar(fi)
    elif cModel == 'Traunmuller':
        for k,fi in enumerate(f):
            fBark[k] =  acaTraunmuller_scalar(fi)
    else:
        for k,fi in enumerate(f):
            fBark[k] =  acaSchroeder_scalar(fi)
            
    return (fBark) 
Example 20
Project: PyFlow   Author: wonderworks-software   File: MathLib.py    License: Apache License 2.0 5 votes vote down vote up
def asinh(x=('FloatPin', 0.0)):
        '''Return the inverse hyperbolic sine of x.'''
        return math.asinh(x) 
Example 21
Project: gcblue   Author: gcblue   File: test_math.py    License: BSD 3-Clause "New" or "Revised" License 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 22
Project: hdfm   Author: KYDronePilot   File: us_map.py    License: GNU General Public License v3.0 5 votes vote down vote up
def render(self):
        # Open US map.
        us_map = Image.open(MAP_FILE)
        # Convert latitudes to a linear form.
        self.lat1 = AreaMap.LAT_MAX - math.asinh(math.tan(math.radians(self.lat1)))
        self.lat2 = AreaMap.LAT_MAX - math.asinh(math.tan(math.radians(self.lat2)))
        # Calculate x-coords using a ratio of a known location on the map.
        x1 = (self.lon1 + 130.781250) * 7162 / 39.34135
        x2 = (self.lon2 + 130.781250) * 7162 / 39.34135
        # Use another ratio of a known location to find the latitudes.
        den = AreaMap.LAT_MAX - AreaMap.REF_LAT
        y1 = self.lat1 * 3565 / den
        y2 = self.lat2 * 3565 / den
        # Crop the map.
        cropped = us_map.crop((
            int(x1),
            int(y1),
            int(x2),
            int(y2)
        ))
        # Resize to 900x900, convert to right format, and save.
        self.map = cropped.resize((900, 900))
        self.map = self.map.convert('RGBA')
        name = '{0}.png'.format(self.area_id)
        self.map.save(os.path.join(MAPS, name))

    # Get an area map for the predefined area. 
Example 23
Project: Project-New-Reign---Nemesis-Main   Author: ShikyoKira   File: test_math.py    License: GNU General Public License v3.0 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 24
Project: Emoji-Tools   Author: MitchTalmadge   File: perimeterPen.py    License: GNU General Public License v3.0 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 25
Project: hyperbolic   Author: cduck   File: Hypercycle.py    License: MIT License 5 votes vote down vote up
def fromHypercycleOffset(cls, hcycle, offset, unit=Circle(0,0,1)):
        dh = offset #dh = math.asinh(offset/2)
        if isinstance(hcycle.projShape, Circle):
            # May throw if bad geometry
            x1, y1, x2, y2 = intersection.circleCircle(hcycle.projShape, unit)
            cx, cy = hcycle.projShape.cx, hcycle.projShape.cy
            r, cw = hcycle.projShape.r, hcycle.projShape.cw
            if cw:
                x1, y1, x2, y2 = x2, y2, x1, y1
            rc = math.hypot(cx, cy)
            deMid = rc - r
            dhMid = 2 * math.atanh(deMid)
            sign = -1 if cw else 1
            t = math.tanh((dhMid + sign*dh)/2)
            xOff, yOff = t * cx / rc, t * cy / rc
        else:
            # May throw if bad geometry
            x1, y1, x2, y2 = intersection.lineCircle(hcycle.projShape, unit)
            lineAng = math.atan2(y2-y1, x2-x1)
            mx, my = (x1+x2)/2, (y1+y2)/2  # Midpoint
            if util.nearZero(mx) and util.nearZero(my):
                ang = math.atan2(y2-y1, x2-x1) + math.pi/2
            else:
                ang = math.atan2(my, mx)
            # Test if the line goes clockwise around the origin
            cw = (ang - lineAng) % (math.pi*2) < math.pi
            rm = math.hypot(mx, my)
            deMid = rm
            dhMid = 2 * math.atanh(deMid)
            sign = 1 if cw else -1
            t = math.tanh((dhMid + sign*dh)/2)
            xOff, yOff = t * math.cos(ang), t * math.sin(ang)
        return cls.fromPoints(x1, y1, x2, y2, xOff, yOff, segment=False, excludeMid=False) 
Example 26
Project: CTFCrackTools-V2   Author: Acmesec   File: test_math.py    License: GNU General Public License v3.0 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 27
Project: uproot-methods   Author: scikit-hep   File: TLorentzVector.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def eta(self):
        return math.asinh(self.z / math.sqrt(self.x**2 + self.y**2)) 
Example 28
Project: openmaptiles-tools   Author: openmaptiles   File: utils.py    License: MIT License 5 votes vote down vote up
def deg2num(lat_deg, lon_deg, zoom):
    lat_rad = math.radians(lat_deg)
    n = 2.0 ** zoom
    tile_x = int((lon_deg + 180.0) / 360.0 * n)
    tile_y = int((1.0 - math.asinh(math.tan(lat_rad)) / math.pi) / 2.0 * n)
    return tile_x, tile_y 
Example 29
Project: hyper-engine   Author: maxim5   File: sugar.py    License: Apache License 2.0 5 votes vote down vote up
def asinh(node): return merge([node], math.asinh) 
Example 30
Project: android_universal   Author: bkerler   File: test_math.py    License: MIT License 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)))