y=tanhx Graph of the Hyperbolic Tangent y=tanhx
The hyperbolic tangent function y=tanhx is defined as the ratio of the hyperbolic sine to the hyperbolic cosine1.
tanhx=coshxsinhx=ex+e−xex−e−x It is the hyperbolic counterpart of the ordinary tangent tanx.
Domain and range
- The domain is all real numbers
- The range is the open interval (−1,1)
- It increases monotonically
- It is an odd function
The denominator coshx is always at least 1 and never 0, so the function is defined for every real number. Where tanx had asymptotes and a range covering the whole line, tanhx is smooth and bounded.
Symmetry
Since tanh(−x)=−tanhx, the function is odd and its graph is symmetric about the origin.
Monotonicity
The derivative is as follows.
dxdtanhx=sech2x=1−tanh2x 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 1, and flattens toward both ends, producing a smooth S-shaped curve.
The second derivative is −2tanhxsech2x, which changes sign only at the origin. The single inflection point is (0,0), and it is also the center of symmetry.
Asymptotes and notable values
| x | tanhx |
|---|
| →−∞ | →−1 |
| 0 | 0 |
| 1 | ≈0.7616 |
| 2 | ≈0.9640 |
| 3 | ≈0.9951 |
| →+∞ | →1 |
The lines y=1 and y=−1 are horizontal asymptotes, and the curve never crosses them. By x=3 the value already exceeds 0.995, so the saturation is very quick.
Relation to the sigmoid
It is tied to the logistic sigmoid σ(x)=1+e−x1 by the following identity2.
tanhx=2σ(2x)−1 Compressing the sigmoid horizontally by a factor of 21, doubling it vertically and lowering it by 1 gives tanh. The only difference is whether the range is (0,1) or (−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
- Hyperbolic functions, Wikipedia
- Logistic function, Wikipedia