Mathwords logoMathwords

Hyperbolic Tangent — Definition, Formula & Examples

Hyperbolic tangent is the ratio of hyperbolic sine to hyperbolic cosine, written as tanh(x)\tanh(x). It outputs values strictly between 1-1 and 11, producing an S-shaped curve that serves as a smooth, bounded alternative to the identity function.

The hyperbolic tangent function is defined as tanh(x)=sinh(x)cosh(x)=exexex+ex\tanh(x) = \dfrac{\sinh(x)}{\cosh(x)} = \dfrac{e^x - e^{-x}}{e^x + e^{-x}} for all xRx \in \mathbb{R}. It is an odd function with horizontal asymptotes at y=1y = 1 and y=1y = -1.

Key Formula

tanh(x)=exexex+ex\tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}
Where:
  • xx = Any real number (the input to the function)
  • ee = Euler's number, approximately 2.71828

How It Works

To evaluate tanh(x)\tanh(x), compute exe^x and exe^{-x}, then form the ratio exexex+ex\frac{e^x - e^{-x}}{e^x + e^{-x}}. The result always lies in the open interval (1,1)(-1, 1). As xx \to \infty, the negative exponential exe^{-x} vanishes and tanh(x)1\tanh(x) \to 1. Symmetrically, tanh(x)1\tanh(x) \to -1 as xx \to -\infty. The derivative is ddxtanh(x)=sech2(x)=1tanh2(x)\frac{d}{dx}\tanh(x) = \operatorname{sech}^2(x) = 1 - \tanh^2(x), which peaks at x=0x = 0 and decays toward zero for large x|x|.

Worked Example

Problem: Evaluate tanh(1)\tanh(1) using the exponential definition.
Step 1: Compute the exponentials.
e12.71828,e10.36788e^1 \approx 2.71828, \quad e^{-1} \approx 0.36788
Step 2: Form the numerator and denominator.
\text{Numerator: } 2.71828 - 0.36788 = 2.35040$$$$\text{Denominator: } 2.71828 + 0.36788 = 3.08616
Step 3: Divide to get the result.
tanh(1)=2.350403.086160.76159\tanh(1) = \frac{2.35040}{3.08616} \approx 0.76159
Answer: tanh(1)0.7616\tanh(1) \approx 0.7616

Visualization

Why It Matters

The hyperbolic tangent is one of the most widely used activation functions in neural networks and deep learning, where its bounded output and smooth gradient help with signal propagation. In physics, tanh\tanh describes velocity addition in special relativity (rapidity) and the profile of magnetic domain walls.

Common Mistakes

Mistake: Confusing tanh(x)\tanh(x) with tan(x)\tan(x), especially their ranges and definitions.
Correction: tan(x)\tan(x) is a trigonometric function with range (,)(-\infty, \infty) and periodic vertical asymptotes, while tanh(x)\tanh(x) is defined via exponentials and is bounded between 1-1 and 11 with no asymptotes or discontinuities.