Python math.cosh() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
math module

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.

python
import math

val = math.cosh(x)
CallWhat 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
python
math.cosh(x, /)
# returns: float hyperbolic cosine (e**x + e**(-x)) / 2

Parameters

ParameterDescription
xRequired positional real number (int or float).

Return Value

Return ValueDescription
floatHyperbolic cosine >= 1.0; returns inf for both inf and -inf.

Python Examples

Example 1 — Plot a Hanging Cable Catenary Profile

Evaluate height a * math.cosh(x / a) symmetrically across span offsets.

python
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}")

How It Works

  1. Lowest point at center. At x = 0.0, cosh(0) equals 1.0, leaving base height 10.0000.
  2. Symmetric cable towers. Left and right distances match identically because cosh is an even function.
  3. 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.

python
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)

How It Works

  1. Exact minimum. At zero, (e**0 + e**0) / 2 returns 1.0.
  2. Sign invariance. Negating any positive or negative input leaves cosh untouched.
  3. 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.

python
import math

print(math.cosh(float("inf")), math.cosh(float("-inf")))

try:
    math.cosh(800)
except OverflowError:
    print("cosh(800) raises OverflowError")

How It Works

  1. Both infinities give +inf. Whether x approaches +inf or -inf, one exponential term grows without bound.
  2. Finite overflow caught. Passing finite 800 exceeds IEEE 754 float limits and raises OverflowError.
  3. NaN propagates silently. Unlike finite overflow, infinite inputs never raise.

Frequently Asked Questions

1.0, reached at x = 0.0. For all real x, math.cosh(x) >= 1.0.
Because cosh(x) = (e**x + e**(-x)) / 2, and as x goes to -inf, e**(-x) goes to +inf.
For finite x with |x| larger than roughly 710.4758.
Call math.acosh(y) for y >= 1.0, which recovers |x|.
No. Use cmath.cosh(z) for complex inputs.

Next: math.degrees()

Convert angle x from radians to degrees.

degrees() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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