# Python math.asinh() Examples

The following are code examples for showing how to use math.asinh(). 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
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
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 3
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 4
 Project: pyblish-win   Author: pyblish   File: test_math.py    GNU Lesser General Public License v3.0 5 votes
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: hepaccelerate   Author: hepaccelerate   File: backend_cuda.py    BSD 3-Clause "New" or "Revised" License 5 votes
def cartesian_to_spherical_devfunc(px, py, pz, e):
pt = math.sqrt(px**2 + py**2)
eta = math.asinh(pz / pt)
phi = math.atan2(py, px)
mass = math.sqrt(e**2 - px**2 - py**2 - pz**2)
return pt, eta, phi, mass
Example 6
 Project: NiujiaoDebugger   Author: MrSrc   File: test_math.py    GNU General Public License v3.0 5 votes
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
return K * math.asinh(math.sqrt(H_p / (2 * math.pi * K * K)))
Example 8
def asinh(x):
"NOT_RPYTHON"
absx = abs(x)
if not isfinite(x):
return x
if absx < _2_to_m28:
return x
if absx > _2_to_p28:
w = math.log(absx) + _ln2
elif absx > 2.:
w = math.log(2. * absx + 1. / (math.sqrt(x * x + 1.) + absx))
else:
t = x * x
w = log1p(absx + t / (1. + math.sqrt(1. + t)))
return copysign(w, x)
Example 9
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
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 11
 Project: Blockly-rduino-communication   Author: technologiescollege   File: test_math.py    GNU General Public License v3.0 5 votes
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
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 13
 Project: cqp-sdk-for-py37-native   Author: crud-boy   File: test_math.py    GNU General Public License v2.0 5 votes
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 14
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
def __call__(self, val):
if val < 1.0:
raise ValueError("math domain error")

return __inline_fora(
"""fun(@unnamed_args:(val), *args) {
PyFloat(math.asinh([email protected]))
}"""
)(val)
Example 16
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 17
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 18
def asinh(x):
"""
asinh :: Floating a => a -> a
"""
return Floating[x].asinh(x)
Example 19
def ASINH(number):
number = utils.parse_number(number)
if isinstance(number, error.XLError):
return number
return math.asinh(number)
Example 20
 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,
"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 21
 Project: battsimpy   Author: matthewpklein   File: full1d_testing.py    GNU General Public License v3.0 5 votes
def test_getEdgeEtas( basepath, confname ) :

path = basepath+'battsimpy/'+confname
RunInput = cfr.conf_data

# Initialize the model
f1d = full_1d.FULL_1D( RunInput )
p = f1d.pars

#
T0 = 298.15
#    io = [10., 1.]
aFRT_n, aFRT_p = 0.5*p.Faraday / ( p.R*T0 ), 0.5*p.Faraday / ( p.R*T0 )
Rf = 0.0
eta1  , etaNm1 = (1./aFRT_n) * math.asinh( p.Faraday/(2*io[0])*j_rxn0 ),  (1./aFRT_n) * math.asinh( p.Faraday/(2*io[-1])*j_rxnN )

eta0, etaN = f1d.getEdgeEtas( io, aFRT_n, aFRT_p, Rf, j_rxn0, j_rxnN, eta1, etaNm1 )

x = [eta0, eta1, etaNm1, etaN]
names = ['eta0', 'eta1', 'etaNm1', 'etaN']
for i,mat in enumerate(x) :
print '#########################################'
print '~~~  ', names[i], '  ~~~'
print mat
print
Example 22
def asinh(x=('FloatPin', 0.0)):
'''Return the inverse hyperbolic sine of x.'''
return math.asinh(x)
Example 23
def asinh(x):
if isinstance(x, LineValue): lx = x.get_value()
else: lx = x
if lx == NAN: return LineValue(NAN)
return LineValue(math.asinh(lx))
Example 24
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 25
def ARCSINH(x):    return (asinh(x))
Example 26
 Project: hdfm   Author: KYDronePilot   File: us_map.py    GNU General Public License v3.0 5 votes
def render(self):
# Open US map.
us_map = Image.open(MAP_FILE)
# Convert latitudes to a linear form.
# 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 27
 Project: Project-New-Reign---Nemesis-Main   Author: ShikyoKira   File: test_math.py    GNU General Public License v3.0 5 votes
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 28
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 29
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 30
 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
# 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("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 31
 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
# 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("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 32
 Project: DIMEpy   Author: AberystwythSystemsBiology   File: spectrumList.py    GNU General Public License v3.0 4 votes
def transform(self, method: str = "log10") -> None:
"""
Method to conduct sample independent intensity transformation.

Arguments:
method (str): The transformation method to use.

Currently supported transformation methods are:
*'log10' (default)
*'cube'
*'nlog'
*'log2'
*'glog'
*'sqrt'
*'ihs'
"""

def _transform(spec: Spectrum):
i = spec.intensities

if method.upper() == "LOG10":
spec._intensities = np.log10(i)
elif method.upper() == "CUBE":
spec._intensities = i**(1. / 3)
elif method.upper() == "NLOG":
spec._intensities = np.log(i)
elif method.upper() == "LOG2":
spec._intensities = np.log2(i)
elif method.upper() == "GLOG":
m = np.min(i) / 10
spec._intensities = np.log2(i + np.sqrt(i**2 + m**2)) / 2
elif method.upper() == "SQRT":
spec._intensities = np.sqrt(i)
elif method.upper() == "IHS":
spec._intensities = np.array([math.asinh(x) for x in i])

if self.transformed == False:
for spec in self._list:
_transform(spec)
self.transformed = True
else:
raise ValueError(
"It looks like you've already transformed this data.")