Python math.acosh() Function

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

Definition

math.acosh(x) returns the non-negative inverse hyperbolic cosine of x as a float, undoing math.cosh() for x >= 0.

Because cosh(y) is always at least 1.0, math.acosh(x) requires x >= 1; passing any smaller value raises ValueError.

math.acosh() is a function in Python's standard math module: import it with import math and call math.acosh(...), or import the name directly with from math import acosh.

Syntax

Import math and pass a real number x >= 1.

python
import math

y = math.acosh(x)
CallWhat it does
math.acosh(1)Returns 0.0.
math.acosh(2)Returns approximately 1.316957....
math.acosh(float("inf"))Returns inf.
math.acosh(0.5)Raises ValueError: input must be >= 1.

For inputs near 1 (like 1 + 1e-12), math.acosh() avoids precision loss that naive log(x + sqrt(x*x - 1)) formulas suffer.

Function signatures
python
math.acosh(x, /)
# returns: float inverse hyperbolic cosine >= 0 for x >= 1

Parameters

ParameterDescription
xRequired positional number (int or float) greater than or equal to 1.

Return Value

Return ValueDescription
floatNon-negative inverse hyperbolic cosine; returns inf for inf and nan for nan.

Python Examples

Example 1 — Measure Hyperbolic Distance From Unit Ratios

Evaluate math.acosh() across increasing factors starting at 1.0.

python
import math

for ratio in [1.0, 2.0, 5.0, 10.0]:
    rapidity = math.acosh(ratio)
    print(f"ratio={ratio:>4.1f} -> acosh={rapidity:.4f}")

How It Works

  1. Minimum threshold at one. Passing 1.0 yields exact 0.0000 because cosh(0) == 1.
  2. Logarithmic growth. As the ratio climbs to ten, acosh(10) settles near ln(20) = 2.9932.
  3. Always non-negative. Every output for x >= 1 is greater than or equal to zero.

Example 2 — Recover Non-Negative Values From math.cosh()

Verify that math.acosh(math.cosh(y)) returns |y| for positive and negative inputs.

python
import math

for y in [0.0, 1.5, -1.5, 4.0]:
    recovered = math.acosh(math.cosh(y))
    print(f"y={y:+4.1f} -> recovered={recovered:.1f}")

How It Works

  1. Non-negative branch. Since cosh(-1.5) == cosh(1.5), acosh() always recovers the positive value 1.5.
  2. Clean round trip. Formatting to one decimal matches the exact input magnitude.
  3. Zero stays zero. cosh(0) returns 1.0 and acosh(1.0) maps back to 0.0.

Example 3 — Catch ValueError on Inputs Less Than One

Handle invalid inputs below 1 and test positive infinity.

python
import math

print(math.acosh(float("inf")))

for bad_x in [0.99, 0.0, -5.0, float("-inf")]:
    try:
        math.acosh(bad_x)
    except ValueError:
        print(f"acosh({bad_x}) raises ValueError")

How It Works

  1. Positive infinity allowed. Positive infinity returns inf smoothly.
  2. Strict floor at 1.0. Even 0.99 falls outside the real image of cosh and raises ValueError.
  3. Negative infinity rejected. Unlike math.asinh(), -inf triggers ValueError.

Frequently Asked Questions

Any real number x >= 1 (including float("inf")). Anything less than 1 raises ValueError.
Because cosh is even (cosh(-2) == cosh(2)), acosh returns the principal non-negative branch (>= 0).
0.0, because cosh(0) is 1.
Use cmath.acosh(x) from the cmath module, which returns a complex result.
Yes. C library acosh uses log1p internally near 1 so precision is not lost.

Next: math.asin()

Return the arc sine (inverse sine) of x in radians.

asin() →

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.

9 people found this page helpful