Tanh Calculator

Enter a real number x to compute the hyperbolic tangent tanh(x), along with sinh(x), cosh(x), and the derivative sech²(x).

Quick Facts

Definition
tanh(x) = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ)
Equivalently, tanh(x) = sinh(x) / cosh(x).
Range
−1 < tanh(x) < 1
Approaches ±1 as x → ±∞ but never reaches it.
Derivative
d/dx tanh(x) = 1 − tanh²(x) = sech²(x)
Always positive, so tanh is strictly increasing.

Your Results

Calculated
tanh(x)
-
Hyperbolic tangent of x
sinh(x)
-
Hyperbolic sine of x
cosh(x)
-
Hyperbolic cosine of x
sech²(x)
-
Derivative of tanh(x) at x, = 1 − tanh²(x)

Ready

Enter a value for x, then press Calculate.

Formula and Method for the Tanh Calculator

The hyperbolic tangent, tanh(x), is defined in terms of the natural exponential function: tanh(x) = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ). It can also be written as the ratio of two other hyperbolic functions, tanh(x) = sinh(x) / cosh(x), where sinh(x) = (eˣ − e⁻ˣ)/2 and cosh(x) = (eˣ + e⁻ˣ)/2. Unlike the trigonometric tangent, tanh(x) is defined for every real number x and is bounded — its output always lies strictly between −1 and 1.

How the calculation works

Enter any real number for x (there is no domain restriction — positive, negative, zero, and very large magnitudes are all valid). The calculator computes eˣ and e⁻ˣ internally to get sinh(x) and cosh(x), then divides them to get tanh(x) = sinh(x)/cosh(x). It also reports the derivative of tanh at that point, sech²(x) = 1/cosh²(x) = 1 − tanh²(x), which describes the instantaneous slope of the tanh curve. Use the decimal-places selector to control how many digits are shown in each result.

Common mistakes

  • Confusing tanh with tan: tanh(x) is the hyperbolic tangent (built from eˣ), while tan(x) is the trigonometric tangent (built from sine and cosine of an angle) — they are different functions with different ranges.
  • Expecting values outside (−1, 1): tanh(x) can never equal or exceed ±1 for a finite x; if you need a result outside that range, tanh is the wrong function.
  • Forgetting the sign symmetry: tanh is an odd function, so tanh(−x) = −tanh(x). A negative x always gives a negative result.

Real-world applications

  • Neural networks use tanh as a zero-centered activation function, since tanh(x) = 2·sigmoid(2x) − 1 squashes any real input into (−1, 1).
  • Electrical engineering uses tanh in transmission-line and hyperbolic-geometry equations, such as modeling voltage decay along a lossy line.
  • Physics and statistical mechanics use tanh to describe saturation behavior, such as magnetization approaching a limit in the Langevin/Brillouin models.
  • Special relativity uses tanh (and its inverse, artanh) to relate rapidity to velocity as a fraction of the speed of light.

Frequently Asked Questions

What is the formula for tanh(x)?
The hyperbolic tangent is defined as tanh(x) = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ), which is equivalent to sinh(x) / cosh(x). For example, tanh(1) ≈ 0.761594.
What is the range of tanh(x)?
tanh(x) always produces a value strictly between −1 and 1. As x approaches +∞, tanh(x) approaches 1; as x approaches −∞, tanh(x) approaches −1. It never actually reaches either bound for a finite x.
What is the derivative of tanh(x)?
The derivative of tanh(x) is 1 − tanh²(x), which equals sech²(x), or 1/cosh²(x). This derivative is always positive, so tanh(x) is strictly increasing for every real x.
How is tanh related to the sigmoid function?
tanh(x) is a rescaled and shifted sigmoid function: tanh(x) = 2·sigmoid(2x) − 1. Both are S-shaped (sigmoid) curves used as neural-network activation functions, but tanh is zero-centered with range (−1, 1) while the logistic sigmoid has range (0, 1).