Reference · Math
math.sinh
signature
math.sinh(num) -> floatWhat it does
The hyperbolic sine of a number, as a float, as Python's math.sinh: (e^x - e^-x) / 2.
It takes any number, but grows like math.exp, so a large one overflows. Its inverse
is math.asinh.
Examples
print(math.sinh(0), math.sinh(1), math.sinh(-1))print(math.sinh(2), math.asinh(math.sinh(2)))output
0.0 1.1752011936438014 -1.17520119364380143.626860407847019 2.0Edge cases
- The function is odd:
math.sinh(-x)is-math.sinh(x). 710is about the largest input that fits a float;711is a range error, and so is-711.infgivesinf,-infgives-inf,NaNgivesNaN.math.tanh(x)ismath.sinh(x) / math.cosh(x).
print(math.sinh(-2) == -math.sinh(2))print(math.isfinite(math.sinh(710)), math.isfinite(math.sinh(-710)))print(math.sinh(math.inf), math.sinh(-math.inf), math.sinh(math.nan))print(math.tanh(1) == math.sinh(1) / math.cosh(1))output
truetrue trueinf -inf NaNtrueErrors
A result past the largest float is a runtime error (a range error), not an error
value: it stops the request, and ?? does not catch it. A value that is not a number
is a runtime error too.
this one fails
print(math.sinh(711))output
line 1: `math.sinh`: math range error (711)this one fails
print(math.sinh(-711))output
line 1: `math.sinh`: math range error (-711)Chaining
print(1 | math.sinh)print([0, 1, 2] | map(math.sinh))output
1.1752011936438014[0.0, 1.1752011936438014, 3.626860407847019]See also
math.cosh, math.tanh, math.asinh, math.exp, math.sin
Thread
Thread 0 posts
On math.sinh(): questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.
Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo