y=tanh⁡xy = \tanh x

Graph of the Hyperbolic Tangent y=tanh⁡xy = \tanh x

The hyperbolic tangent function y=tanh⁡xy = \tanh x is defined as the ratio of the hyperbolic sine to the hyperbolic cosine1.

tanh⁡x=sinh⁡xcosh⁡x=ex−e−xex+e−x\tanh x = \frac{\sinh x}{\cosh x} = \frac{e^x - e^{-x}}{e^x + e^{-x}}

It is the hyperbolic counterpart of the ordinary tangent tan⁡x\tan x.

Domain and range

  • The domain is all real numbers
  • The range is the open interval (−1,1)(-1, 1)
  • It increases monotonically
  • It is an odd function

The denominator cosh⁡x\cosh x is always at least 11 and never 00, so the function is defined for every real number. Where tan⁡x\tan x had asymptotes and a range covering the whole line, tanh⁡x\tanh x is smooth and bounded.

Symmetry

Since tanh⁡(−x)=−tanh⁡x\tanh(-x) = -\tanh x, the function is odd and its graph is symmetric about the origin.

Monotonicity

The derivative is as follows.

ddxtanh⁡x=sech⁡2x=1−tanh⁡2x\frac{d}{dx}\tanh x = \operatorname{sech}^2 x = 1 - \tanh^2 x

It is always positive, so the function is strictly increasing on the whole real line. The slope is steepest at the origin, where it equals 11, and flattens toward both ends, producing a smooth S-shaped curve.

The second derivative is −2tanh⁡x sech⁡2x-2\tanh x\,\operatorname{sech}^2 x, which changes sign only at the origin. The single inflection point is (0,0)(0, 0), and it is also the center of symmetry.

Asymptotes and notable values

xxtanh⁡x\tanh x
→−∞\to -\infty→−1\to -1
0000
11≈0.7616\approx 0.7616
22≈0.9640\approx 0.9640
33≈0.9951\approx 0.9951
→+∞\to +\infty→1\to 1

The lines y=1y = 1 and y=−1y = -1 are horizontal asymptotes, and the curve never crosses them. By x=3x = 3 the value already exceeds 0.9950.995, so the saturation is very quick.

Relation to the sigmoid

It is tied to the logistic sigmoid σ(x)=11+e−x\sigma(x) = \dfrac{1}{1 + e^{-x}} by the following identity2.

tanh⁡x=2σ(2x)−1\tanh x = 2\sigma(2x) - 1

Compressing the sigmoid horizontally by a factor of 12\dfrac{1}{2}, doubling it vertically and lowering it by 11 gives tanh⁡\tanh. The only difference is whether the range is (0,1)(0, 1) or (−1,1)(-1, 1); the shape is the same.

Applications

  • An activation function in neural networks
  • A saturating function that confines values to a range
  • A model for magnetization or for the response of a signal
  • The addition of velocities in special relativity, through rapidity
  1. Hyperbolic functions, Wikipedia
  2. Logistic function, Wikipedia