NumPy Hyperbolic Functions
sinh, cosh and tanh are related to exponentials rather than circular angle geometry. Their inverse functions also have their own domains.
How it works
These functions appear in some differential equations, geometry and model transformations. They do not need degree-to-radian conversion in the way a degree-based angle does. The identity cosh squared minus sinh squared equals one is a useful numerical check for moderate values. Very large inputs can overflow, and subtracting large nearly related values can lose precision, so an identity is not a guarantee of stable computation at every magnitude.
Run the code
Select Try in playground to preload the complete code into the NumPy editor. Nothing executes on import; choose Run when ready. The first execution loads the local Pyodide runtime and NumPy package. Each ordinary run starts fresh, with no access to this page’s cookies or personal files. In-memory streams and temporary virtual files belong to the runtime, not your PC.
For local work, use a separate virtual environment and run python hyperbolic.py. Download the complete source. The reviewed local environment uses Python 3.12.14 and NumPy 2.5.4; the browser uses Pyodide 0.27.7 with NumPy 2.0.2. Compatible examples are checked in both. See the environment setup. No Apache or database server is required.
Example
import numpy as np
x = np.array([0., 0.5, 1.])
identity = np.cosh(x) ** 2 - np.sinh(x) ** 2
print(np.allclose(identity, 1., atol=1e-12))
print(np.isclose(np.arctanh(np.tanh(0.5)), 0.5))
Expected result
True True
Both checks use moderate inputs and tolerances suited to the fixture. They demonstrate a mathematical relationship without promising that arbitrary extreme values are safe or that a hyperbolic transform is appropriate for every dataset.
Use NumPy’s official reference for precise contracts, supported versions and numerical limitations.