math.atanh(x) returns the inverse hyperbolic tangent of x as a float, undoing math.tanh().
It accepts numbers strictly between -1 and 1 (the open interval (-1, 1)). Passing 1.0, -1.0, or anything beyond them raises ValueError.
math.atanh() is a function in Python's standard math module: import it with import math and call math.atanh(...), or import the name directly with from math import atanh.
Syntax
Import math and pass a value strictly inside (-1, 1).
python
import math
z = math.atanh(r)
Call
What it does
math.atanh(0)
Returns 0.0.
math.atanh(0.5)
Returns approximately 0.549306....
math.atanh(1)
Raises ValueError: endpoint 1 is excluded.
math.atanh(-1.5)
Raises ValueError: outside (-1, 1).
Notice that unlike math.asin() and math.acos() (which allow 1 and -1), math.atanh() excludes both endpoints because atanh(±1) diverges to infinity.
Function signatures
python
math.atanh(x, /)
# returns: float inverse hyperbolic tangent for -1 < x < 1
Parameters
Parameter
Description
x
Required positional number (int or float) strictly greater than -1 and strictly less than 1.
Return Value
Return Value
Description
float
Real inverse hyperbolic tangent of x; returns -0.0 for -0.0 and nan for nan.
Python Examples
Example 1 — Apply Fisher z-Transform to Correlation Scores
Map correlation coefficients in (-1, 1) onto an unbounded scale using math.atanh(r).
python
import math
for r in [-0.9, -0.5, 0.0, 0.5, 0.9]:
z = math.atanh(r)
print(f"r={r:+4.1f} -> z={z:+7.4f}")
Direct statistics shortcut. Fisher's z-transform 0.5 * ln((1 + r) / (1 - r)) is mathematically identical to math.atanh(r).
Stretches near ±1. Correlations near 0.9 expand to 1.4722 while small values stay close to r.
Symmetric around zero. Negative and positive correlations mirror each other cleanly.
Example 2 — Verify Round-Trip Inversion With math.tanh()
Confirm math.atanh(math.tanh(z)) recovers z and check math.log1p() equivalence.
python
import math
for z in [-0.7, 0.0, 0.7]:
recovered = math.atanh(math.tanh(z))
print(f"{z:+4.1f} -> {recovered:+4.1f} close={math.isclose(recovered, z)}")