y=tanhxy = \tanh x

Graph of the Hyperbolic Tangent y=tanhxy = \tanh x

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

tanhx=sinhxcoshx=exexex+ex\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 tanx\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 coshx\cosh x is always at least 11 and never 00, so the function is defined for every real number. Where tanx\tan x had asymptotes and a range covering the whole line, tanhx\tanh x is smooth and bounded.

Symmetry

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

Monotonicity

The derivative is as follows.

ddxtanhx=sech2x=1tanh2x\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 2tanhxsech2x-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

xxtanhx\tanh x
\to -\infty1\to -1
0000
110.7616\approx 0.7616
220.9640\approx 0.9640
330.9951\approx 0.9951
+\to +\infty1\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+ex\sigma(x) = \dfrac{1}{1 + e^{-x}} by the following identity2.

tanhx=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