The math.acosh(x) function computes the inverse hyperbolic cosine (area hyperbolic cosine) of a real numeric value x. Because forward hyperbolic cosine (math.cosh()) produces values strictly greater than or equal to 1.0, math.acosh(x) is defined only for x ≥ 1.0, returning a non-negative floating-point number in the range [0.0, +∞).
Exact Inverse: Reverses forward hyperbolic cosine (math.cosh(math.acosh(x)) == x for all x ≥ 1.0). Passing any value x < 1.0 raises a ValueError: math domain error.
The math.acosh() function is part of Python's standard math module and requires no external third-party installations:
import math
math.acosh(x)
| Component | Type | Description |
|---|---|---|
x |
int or float |
Required. A real number ≥ 1.0 representing the hyperbolic ratio. |
| Return Value | float |
The principal non-negative inverse hyperbolic cosine value in [0.0, +∞). |
ValueError |
Exception | Raised when x < 1.0 (e.g. math.acosh(0.9) or negative numbers). |
TypeError |
Exception | Raised when passing non-numeric data types such as strings or lists. |
At the minimum boundary x = 1.0, the output is exactly 0.0 because cosh(0) = 1.0. As x increases, acosh(x) grows smoothly and monotonically:
import math
print("acosh(1.0): ", math.acosh(1.0))
print("acosh(1.5): ", round(math.acosh(1.5), 6))
print("acosh(2.0): ", round(math.acosh(2.0), 6))
print("acosh(5.0): ", round(math.acosh(5.0), 6))
print("acosh(10): ", round(math.acosh(10), 6))
Output:
acosh(1.0): 0.0
acosh(1.5): 0.962424
acosh(2.0): 1.316958
acosh(5.0): 2.292432
acosh(10): 2.993223
math.acos), the return value of math.acosh() is not an angle in radians or degrees. It represents a dimensionless hyperbolic growth parameter (or hyperbolic angle). Never pass its output to math.degrees().
Mathematically, all inverse hyperbolic functions can be expressed explicitly using the natural logarithm. For any real number x ≥ 1.0, the principal branch of inverse hyperbolic cosine is defined as:
We can verify that Python's math.acosh(x) produces outputs identical to this formula using math.log(), math.sqrt(), and math.isclose():
import math
def formula_acosh(x):
return math.log(x + math.sqrt(x**2 - 1))
sample_inputs = [1.0, 1.25, 2.0, 7.5, 25.0, 100.0]
print(f"{'x':>7} | {'math.acosh(x)':>15} | {'formula_acosh(x)':>16} | Match?")
print("-" * 52)
for val in sample_inputs:
built_in = math.acosh(val)
calc = formula_acosh(val)
is_match = math.isclose(built_in, calc, rel_tol=1e-12)
print(f"{val:7.2f} | {built_in:15.8f} | {calc:16.8f} | {is_match}")
Output:
x | math.acosh(x) | formula_acosh(x) | Match?
----------------------------------------------------
1.00 | 0.00000000 | 0.00000000 | True
1.25 | 0.69314718 | 0.69314718 | True
2.00 | 1.31695790 | 1.31695790 | True
7.50 | 2.70119853 | 2.70119853 | True
25.00 | 3.91182391 | 3.91182391 | True
100.00 | 5.29829237 | 5.29829237 | True
math.acosh() over manual formulas? When x is very close to 1.0 (such as x = 1.00000001), evaluating x**2 - 1 in standard floating-point arithmetic suffers from catastrophic cancellation (loss of significant digits). The C-level implementation of math.acosh() employs specialized series expansions to maintain full IEEE 754 precision near the boundary.
Because the real hyperbolic cosine curve has a global minimum at cosh(0) = 1.0, there is no real number whose hyperbolic cosine is less than 1.0. Consequently, passing any argument strictly less than 1.0 (including 0.999, 0, or negative numbers) raises a ValueError:
import math
invalid_inputs = [0.99, 0.0, -1.5]
for val in invalid_inputs:
try:
result = math.acosh(val)
except ValueError as err:
print(f"Input {val:5.2f} -> ValueError: {err}")
Output:
Input 0.99 -> ValueError: math domain error
Input 0.00 -> ValueError: math domain error
Input -1.50 -> ValueError: math domain error
In robust production applications, always guard input values by validating the lower boundary before calling math.acosh():
def safe_acosh(x, fallback=0.0):
if x < 1.0:
return fallback
return math.acosh(x)
print("Safe acosh(0.85):", safe_acosh(0.85)) # 0.0
print("Safe acosh(1.85):", safe_acosh(1.85)) # 1.22359...
While the real-valued math module enforces the domain x ≥ 1.0, in complex analysis the inverse hyperbolic cosine is defined across all complex numbers. Python provides the companion cmath module for complex number evaluations:
import math
import cmath
val = 0.5
# math module raises ValueError
try:
math.acosh(val)
except ValueError as e:
print("math.acosh(0.5): ", e)
# cmath module returns a complex number: 0 + 1.0471975511965976j (pi / 3 radians imaginary)
c_result = cmath.acosh(val)
print("cmath.acosh(0.5):", c_result)
print("Imaginary part equals pi / 3?", math.isclose(c_result.imag, math.pi / 3))
Output:
math.acosh(0.5): math domain error
cmath.acosh(0.5): 1.0471975511965976j
Imaginary part equals pi / 3? True
Learners often confuse circular inverse cosine (math.acos) with hyperbolic inverse cosine (math.acosh). The two functions serve completely different mathematical and physical purposes:
| Property | Circular math.acos(x) |
Hyperbolic math.acosh(x) |
|---|---|---|
| Geometric Locus | Unit Circle: x2 + y2 = 1 |
Unit Hyperbola: x2 − y2 = 1 |
| Allowed Domain | Closed interval: [-1.0, 1.0] |
Semi-infinite: [1.0, +∞) |
| Output Range | [0, π] radians (0° to 180°) |
[0.0, +∞) (pure dimensionless growth) |
| Represents Angles? | Yes (converts to degrees via math.degrees) |
No (dimensionless hyperbolic parameter) |
| Logarithmic Form | Complex logarithmic relation | Real logarithmic relation: ln(x + √(x2 − 1)) |
| Inverse Pair | math.cos() |
math.cosh() |
We can visualize the inverse hyperbolic cosine curve starting at (1.0, 0.0) and rising steadily as x increases using Matplotlib:
import math
import matplotlib.pyplot as plt
x_vals = [1.0 + i * 0.2 for i in range(0, 96)] # 1.0 to 20.0
y_vals = [math.acosh(x) for x in x_vals]
plt.plot(x_vals, y_vals, label="y = acosh(x)", color="#1a73e8", linewidth=2)
plt.axvline(1.0, color="red", linestyle="--", label="Domain Boundary (x = 1.0)")
plt.title("Inverse Hyperbolic Cosine: y = acosh(x)")
plt.xlabel("x (Domain: [1.0, +inf))")
plt.ylabel("acosh(x)")
plt.grid(True, linestyle=":", alpha=0.6)
plt.legend()
plt.show()
In structural engineering and overhead power line design, a flexible cable suspended between two pylons hangs under its own weight in a curve known as a catenary. The height profile is governed by:
Where a is the catenary scaling parameter (ratio of horizontal tension to cable weight per unit length), and y is the vertical coordinate of the cable at horizontal distance x from the vertex. Because y / a ≥ 1.0, we use math.acosh() to calculate the horizontal position x given the height y and scaling parameter a.
import math
def catenary_horizontal_distance(cable_height, catenary_param_a):
"""
Calculates horizontal distance x from vertex of a catenary cable:
x = a * acosh(y / a)
"""
if catenary_param_a <= 0:
raise ValueError("Catenary parameter 'a' must be strictly positive.")
ratio = cable_height / catenary_param_a
if ratio < 1.0:
raise ValueError("Cable height cannot be less than catenary vertex parameter 'a'.")
return round(catenary_param_a * math.acosh(ratio), 4)
# Unit Assertions
assert catenary_horizontal_distance(50.0, 50.0) == 0.0 # Vertex (x = 0)
assert catenary_horizontal_distance(75.0, 50.0) == 48.1212
assert catenary_horizontal_distance(100.0, 50.0) == 65.8479
# Boundary error handling check
try:
catenary_horizontal_distance(40.0, 50.0) # ratio 0.8 < 1.0
assert False, "Should raise ValueError"
except ValueError:
pass
cable_h = 85.0
param_a = 60.0
dist_x = catenary_horizontal_distance(cable_h, param_a)
print(f"Cable at height {cable_h}m (a={param_a}m): x = {dist_x}m from center")
print("All catenary parameter assertions passed successfully!")
Open in Google Colab View on GitHub
Run all math.acosh() examples interactively, test domain boundary conditions, verify logarithmic equivalence, and execute catenary curve physics calculations 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.