The hyperbolic tangent, denoted \tanh, is a mathematical function defined as the ratio of the hyperbolic sine to the hyperbolic cosine: \tanh(x) = \frac{\sinh(x)}{\cosh(x)}. It maps real numbers to the open interval \((-1, 1)\) and is an odd, sigmoid-shaped function that approaches \(-1\) as \(x \to -\infty\) and \(+1\) as \(x \to +\infty\). In applied mathematics, \tanh appears in solutions to differential equations, neural network activation functions, signal processing, and fluid dynamics.
1 Definition and basic properties
1.1 Definition in terms of exponentials
Using the exponential definitions of the hyperbolic functions, \(\sinh(x) = \frac{e^x - e^{-x}}{2}\) and \(\cosh(x) = \frac{e^x + e^{-x}}{2}\), the hyperbolic tangent can be expressed as
\[ \tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}} = \frac{e^{2x} - 1}{e^{2x} + 1}. \]
This form is convenient for numerical evaluation and for deriving limits.
1.2 Domain and range
The function \(\tanh(x)\) is defined for all real numbers \(x\); its domain is \(\mathbb{R}\). The range is the open interval \((-1, 1)\); no real input yields an output of exactly \(\pm 1\), though these values are approached asymptotically.
1.3 Parity (odd function)
\(\tanh\) is an odd function: \(\tanh(-x) = -\tanh(x)\) for all \(x\). This property follows directly from the exponential definition, as the numerator changes sign while the denominator remains unchanged.
1.4 Limits and asymptotes
The limits at \(\pm\infty\) are:
\[ \lim_{x \to +\infty} \tanh(x) = 1, \qquad \lim_{x \to -\infty} \tanh(x) = -1. \]
The horizontal lines \(y = 1\) and \(y = -1\) are asymptotes. There are no vertical asymptotes.
2 Mathematical identities and relationships
2.1 Relationship to other hyperbolic functions
By definition, \(\tanh(x) = \frac{\sinh(x)}{\cosh(x)}\). It also relates to the hyperbolic secant via \(\operatorname{sech}(x) = \frac{1}{\cosh(x)}\) and the hyperbolic cotangent: \(\coth(x) = \frac{1}{\tanh(x)}\) for \(x \neq 0\). Additionally, the identity \(\cosh^2(x) - \sinh^2(x)=1\) gives \(1 - \tanh^2(x) = \operatorname{sech}^2(x)\).
2.2 Addition formulas
The addition formula for \(\tanh\) is:
\[ \tanh(x + y) = \frac{\tanh(x) + \tanh(y)}{1 + \tanh(x)\tanh(y)}. \]
This follows directly from the addition formulas for \(\sinh\) and \(\cosh\).
2.3 Double- and half-angle formulas
The double-angle formula is:
\[ \tanh(2x) = \frac{2\tanh(x)}{1 + \tanh^2(x)}. \]
The half-angle formula for hyperbolic functions is expressed using square roots:
\[ \tanh\left(\frac{x}{2}\right) = \frac{\sinh(x)}{\cosh(x) + 1} = \frac{\cosh(x) - 1}{\sinh(x)}. \]
2.4 Relationship to trigonometric functions (via imaginary argument)
Using Euler’s formulas for hyperbolic functions, the hyperbolic tangent relates to the ordinary tangent by:
\[ \tanh(ix) = i \tan(x), \qquad \tan(ix) = i \tanh(x), \]
where \(i = \sqrt{-1}\). This relationship shows that the hyperbolic functions are trigonometric functions with imaginary arguments.
3 Calculus of tanh
3.1 Derivative
The derivative of \(\tanh(x)\) is:
\[ \frac{d}{dx} \tanh(x) = \operatorname{sech}^2(x) = 1 - \tanh^2(x). \]
This result follows from the quotient rule and the identity \(\frac{d}{dx}\sinh(x) = \cosh(x)\), \(\frac{d}{dx}\cosh(x) = \sinh(x)\). The derivative is always positive, confirming that \(\tanh\) is strictly increasing.
3.2 Indefinite integral
The indefinite integral is:
\[ \int \tanh(x) \, dx = \ln(\cosh(x)) + C, \]
since \(\frac{d}{dx}\ln(\cosh(x)) = \tanh(x)\). Alternatively, because \(\cosh(x) \ge 1\), the absolute value is often omitted.
3.3 Series expansion (Maclaurin series)
| The Maclaurin series for \(\tanh(x)\) converges for \( | x | < \frac{\pi}{2}\) and is given by: |
|---|
\[ \tanh(x) = x - \frac{x^3}{3} + \frac{2x^5}{15} - \frac{17x^7}{315} + \cdots = \sum_{n=1}^{\infty} \frac{2^{2n}(2^{2n}-1) B_{2n}}{(2n)!} x^{2n-1}, \]
where \(B_{2n}\) are Bernoulli numbers. All even-order terms vanish because the function is odd.
3.4 Integral representations
Several integral representations exist, including:
\[ \tanh(x) = \int_0^\infty \frac{\sin(xt)}{\sinh\left(\frac{\pi t}{2}\right)} \, dt, \qquad x > 0, \]
| and for \( | x | < 1\), |
|---|
\[ \tanh^{-1}(x) = \int_0^x \frac{dt}{1 - t^2}. \]
These arise from Fourier and Laplace transforms.
4 Applications in applied mathematics
4.1 Neural networks and machine learning
4.1.1 Activation function in deep learning
In artificial neural networks, \(\tanh\) is a common activation function in hidden layers. Its output, centered at zero with range \((-1,1)\), helps mitigate bias shifting compared to the logistic sigmoid. It provides a smooth, differentiable nonlinearity essential for backpropagation.
4.1.2 Comparison with logistic sigmoid
The logistic sigmoid \(\sigma(x) = \frac{1}{1+e^{-x}}\) outputs values in \((0,1)\), while \(\tanh\) outputs in \((-1,1)\). Because \(\tanh\) is symmetric about zero, it often leads to faster convergence in hidden layers, as the mean activation is closer to zero. However, both functions suffer from vanishing gradients in very deep networks, leading to the adoption of ReLU-based activations.
4.2 Differential equations
4.2.1 Solutions of the Korteweg–de Vries equation
The Korteweg–de Vries (KdV) equation, describing shallow water waves, admits soliton solutions of the form
\[ u(x,t) = -2\, \operatorname{sech}^2(x - ct) = -2\left[1 - \tanh^2(x - ct)\right], \]
which can be expressed using \(\tanh\). The \(\tanh\) function also appears in the traveling wave solutions of the sine-Gordon equation and nonlinear Schrödinger equation.
4.2.2 Traveling wave solutions in fluid dynamics
In fluid dynamics, the \(\tanh\) profile describes smooth velocity transitions, e.g., in shear layers. A common model is \(u(y) = \tanh(y)\), representing a symmetric mixing layer between two parallel flows of different velocities.
4.3 Signal processing
4.3.1 Soft clipping and nonlinear distortion
In audio signal processing, \(\tanh\) is used as a soft-clipping function to emulate analog distortion. It smoothly saturates large input amplitudes, producing a soft-knee compression that preserves signal harmonics while reducing harshness. Unlike hard clipping, the \(\tanh\) curve is continuous and differentiable.
4.4 Statistics and probability
4.4.1 Link function in generalized linear models
In statistics, the inverse hyperbolic tangent, \(\operatorname{arctanh}(p) = \frac{1}{2}\ln\left(\frac{1+p}{1-p}\right)\), serves as the link function for models where the response is bounded in \((-1,1)\), e.g., correlation coefficients or certain proportions. It transforms the bounded variable to an unbounded linear predictor.