The math.sinh(x) function computes the hyperbolic sine of a real numeric value x. Defined by the exponential formula sinh(x) = (ex − e−x) / 2, the function is continuous and strictly increasing across its entire real domain (−∞, +∞), returning an unbounded floating-point number in (−∞, +∞).
Exact Inverse: Reverses the inverse hyperbolic sine math.asinh() (math.sinh(math.asinh(y)) == y for all real numbers). Unlike circular trigonometry, the parameter x is a dimensionless real number, not an angle in degrees or radians.
The math.sinh() function is part of Python's standard math module:
import math
result = math.sinh(x)
| Parameter | Type | Description |
|---|---|---|
x |
float or int |
Required. A real number representing the hyperbolic parameter. |
| Return Value | float |
The hyperbolic sine of x, spanning from −∞ to +∞. |
OverflowError |
Exception | Raised when |x| exceeds ~710.475 (where sinh(x) exceeds ~1.79 × 10308). |
TypeError |
Exception | Raised when passing non-numeric types (e.g. strings or lists). |
Because sinh(x) is an odd function, it possesses origin symmetry: sinh(-x) == -sinh(x), with sinh(0.0) == 0.0:
import math
# Origin value
print("sinh(0.0): ", math.sinh(0.0)) # Output: 0.0
# Odd Symmetry: sinh(-x) == -sinh(x)
print("sinh(1.0): ", round(math.sinh(1.0), 6)) # Output: 1.175201
print("sinh(-1.0):", round(math.sinh(-1.0), 6)) # Output: -1.175201
print("sinh(2.0): ", round(math.sinh(2.0), 6)) # Output: 3.626860
print("sinh(-2.0):", round(math.sinh(-2.0), 6)) # Output: -3.626860
Output:
sinh(0.0): 0.0
sinh(1.0): 1.175201
sinh(-1.0): -1.175201
sinh(2.0): 3.626860
sinh(-2.0): -3.626860
Verifying the exponential definition (math.exp(x) - math.exp(-x)) / 2 using math.exp():
def formula_sinh(x):
return (math.exp(x) - math.exp(-x)) / 2.0
val = 3.5
print("math.sinh(3.5): ", math.sinh(val))
print("formula_sinh(3.5):", formula_sinh(val))
print("Matches? ", math.isclose(math.sinh(val), formula_sinh(val)))
Output:
math.sinh(3.5): 16.54262931534938
formula_sinh(3.5): 16.54262931534938
Matches? True
Hyperbolic functions mirror circular trigonometry through specific signs and hyperbolic formulas:
cosh²(x) − sinh²(x) = 1sinh(2x) = 2 · sinh(x) · cosh(x)math.tanh(x) = sinh(x) / cosh(x)import math
x = 1.5
sinh_2x = math.sinh(2 * x)
double_angle = 2 * math.sinh(x) * math.cosh(x)
print("sinh(2x): ", sinh_2x)
print("2*sinh*cosh: ", double_angle)
print("Identity hold?", math.isclose(sinh_2x, double_angle))
Output:
sinh(2x): 10.017874927409903
2*sinh*cosh: 10.017874927409903
Identity hold? True
Circular math.sin() models circular periodic rotations, whereas hyperbolic math.sinh() models open geometric growth along hyperbolas:
| Property | Circular math.sin(x) |
Hyperbolic math.sinh(x) |
|---|---|---|
| Geometric Locus | Unit Circle: x2 + y2 = 1 |
Unit Hyperbola: x2 − y2 = 1 |
| Domain | (−∞, +∞) |
(−∞, +∞) |
| Range | Bounded: [−1.0, 1.0] |
Unbounded: (−∞, +∞) |
| Periodicity | Periodic: Repeats every 2π radians | Non-periodic: Monotonically increases |
| Input Units | Angle in radians | Dimensionless real parameter |
| Physical Applications | Oscillations, sound waves, pendulums | Fluid wave profiles, catenary cables, heat flow |
As |x| grows large, sinh(x) approaches (sgn(x) × e|x|) / 2. When |x| exceeds 710.4758, the computed float exceeds IEEE 754 limits, raising an OverflowError:
import math
print("sinh(100): ", math.sinh(100)) # 1.344058e+43
print("sinh(710): ", math.sinh(710)) # 1.116937e+308
try:
math.sinh(711)
except OverflowError as err:
print("sinh(711) OverflowError:", err)
Output:
sinh(100): 1.3440585709080678e+43
sinh(710): 1.1169371077717462e+308
sinh(711) OverflowError: math range error
We can graph the smooth, origin-symmetric curve using Matplotlib:
import math
import matplotlib.pyplot as plt
x_vals = [i * 0.1 - 5.0 for i in range(0, 101)] # -5.0 to +5.0
y_vals = [math.sinh(x) for x in x_vals]
plt.plot(x_vals, y_vals, label="y = sinh(x)", color="#0b8043", linewidth=2)
plt.axvline(0.0, linewidth=1, color="gray", linestyle="--")
plt.axhline(0.0, linewidth=1, color="gray", linestyle="--")
plt.title("Hyperbolic Sine: y = sinh(x)")
plt.xlabel("x")
plt.ylabel("sinh(x)")
plt.grid(True, linestyle=":", alpha=0.6)
plt.legend()
plt.show()
In coastal engineering and ocean fluid dynamics (Airy wave theory), the vertical velocity w(z) of water particles at vertical elevation z (where z = 0 is the surface and z = -d is the seafloor of total depth d) is governed by hyperbolic sine:
Where W0 is the vertical particle velocity amplitude at the ocean surface, and k is the wave number (2π / wavelength). Crucially, at the solid seabed (z = -d), z + d = 0, yielding sinh(0) = 0, satisfying the impermeable seabed boundary condition. Let's build an Airy wave velocity model verified with assertions:
import math
def vertical_particle_velocity(surface_velocity, depth_z, water_depth_d, wave_number_k):
"""
Calculates vertical velocity of water particles at elevation z:
w(z) = W_0 * sinh(k * (z + d)) / sinh(k * d)
z lies in [-d, 0], with z=0 at surface and z=-d at seabed.
"""
if water_depth_d <= 0 or wave_number_k <= 0:
raise ValueError("Water depth and wave number must be strictly positive.")
if depth_z > 0.0 or depth_z < -water_depth_d:
raise ValueError("Elevation z must lie within [-water_depth_d, 0.0].")
numerator = math.sinh(wave_number_k * (depth_z + water_depth_d))
denominator = math.sinh(wave_number_k * water_depth_d)
return round(surface_velocity * (numerator / denominator), 4)
# Unit Assertions
# 1. At the surface (z = 0): velocity equals surface_velocity
assert vertical_particle_velocity(1.5, 0.0, 20.0, 0.1) == 1.5
# 2. At the seabed (z = -d = -20.0): velocity is exactly 0.0
assert vertical_particle_velocity(1.5, -20.0, 20.0, 0.1) == 0.0
# 3. At mid-depth (z = -10.0): velocity decays according to hyperbolic profile
mid_v = vertical_particle_velocity(1.5, -10.0, 20.0, 0.1)
assert mid_v == 0.4859
# Out-of-bounds error verification
try:
vertical_particle_velocity(1.5, 5.0, 20.0, 0.1) # Above surface
assert False, "Should raise ValueError"
except ValueError:
pass
print("Surface velocity (z=0m): ", vertical_particle_velocity(2.0, 0.0, 30.0, 0.08), "m/s")
print("Mid-depth (z=-15m): ", vertical_particle_velocity(2.0, -15.0, 30.0, 0.08), "m/s")
print("Seabed velocity (z=-30m): ", vertical_particle_velocity(2.0, -30.0, 30.0, 0.08), "m/s")
print("All wave mechanics velocity assertions passed successfully!")
Open in Google Colab View on GitHub
Run all math.sinh() examples interactively, verify odd symmetry, test the double-angle identity sinh(2x) = 2·sinh·cosh, and model coastal ocean wave mechanics in Google Colab.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.