Home Python math Functions cosh() Python math.cosh() Function Definition math.cosh(x) returns the hyperbolic cosine of x: mathematically (e ** x + e ** (-x)) / 2, always returning a float at least 1.0.
It describes the shape of a hanging chain or power line (a catenary). It is an even function (cosh(-x) == cosh(x)) with minimum 1.0 at x = 0.
math.cosh() is a function in Python's standard math module: import it with import math and call math.cosh(...), or import the name directly with from math import cosh.
Syntax Import math and pass a real number.
import math
val = math.cosh(x) Call What it does math.cosh(0)Returns 1.0 (global minimum). math.cosh(1)Returns approximately 1.543080.... math.cosh(float("-inf"))Returns inf (always positive). math.cosh(1000)Raises OverflowError: result exceeds float range.
Use math.acosh() (requiring x >= 1) for the positive inverse of math.cosh().
Function signatures math.cosh(x, /)
# returns: float hyperbolic cosine (e**x + e**(-x)) / 2 Parameters Parameter Description xRequired positional real number (int or float).
Return Value Return Value Description floatHyperbolic cosine >= 1.0; returns inf for both inf and -inf.
Python Examples 1. Hanging cable curve 2. Even symmetry and min 3. Infinity and overflow Example 1 — Plot a Hanging Cable Catenary Profile Evaluate height a * math.cosh(x / a) symmetrically across span offsets.
import math
a = 10.0
for x in [-10.0, -5.0, 0.0, 5.0, 10.0]:
y = a * math.cosh(x / a)
print(f"x={x:>5.1f} -> height={y:.4f}") x=-10.0 -> height=15.4308
x= -5.0 -> height=11.2763
x= 0.0 -> height=10.0000
x= 5.0 -> height=11.2763
x= 10.0 -> height=15.4308 How It Works Lowest point at center. At x = 0.0, cosh(0) equals 1.0, leaving base height 10.0000.Symmetric cable towers. Left and right distances match identically because cosh is an even function.Unit parameter ratio. At x = 10.0, cosh(1.0) gives height 15.4308.Example 2 — Verify Even Symmetry and Minimum Value One Check that math.cosh(-x) matches math.cosh(x) and never drops below 1.0.
import math
print(math.cosh(0))
for val in [0.25, 2.0, 4.5]:
print(math.cosh(-val) == math.cosh(val), math.cosh(val) >= 1.0) 1.0
True True
True True
True True How It Works Exact minimum. At zero, (e**0 + e**0) / 2 returns 1.0.Sign invariance. Negating any positive or negative input leaves cosh untouched.Lower bound invariant. For all real inputs, hyperbolic cosine stays greater than or equal to 1.0.Example 3 — Check Positive Infinity and Finite Overflow Limits See math.cosh(float("-inf")) return positive inf while math.cosh(800) overflows.
import math
print(math.cosh(float("inf")), math.cosh(float("-inf")))
try:
math.cosh(800)
except OverflowError:
print("cosh(800) raises OverflowError") inf inf
cosh(800) raises OverflowError How It Works Both infinities give +inf. Whether x approaches +inf or -inf, one exponential term grows without bound.Finite overflow caught. Passing finite 800 exceeds IEEE 754 float limits and raises OverflowError.NaN propagates silently. Unlike finite overflow, infinite inputs never raise.Frequently Asked Questions What is the minimum value of math.cosh(x)? 1.0, reached at x = 0.0. For all real x, math.cosh(x) >= 1.0.
Why does math.cosh(float("-inf")) return positive inf? Because cosh(x) = (e**x + e**(-x)) / 2, and as x goes to -inf, e**(-x) goes to +inf.
When does math.cosh(x) raise OverflowError? For finite x with |x| larger than roughly 710.4758.
How do I invert math.cosh(x)? Call math.acosh(y) for y >= 1.0, which recovers |x|.
Does math.cosh() work on complex numbers? No. Use cmath.cosh(z) for complex inputs.
Next: math.degrees() Convert angle x from radians to degrees.
degrees() → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
11 people found this page helpful
Helpful Share Copy link Suggestion