y=sech2x is the hyperbolic secant squared. Since the derivative of tanhx is exactly this, it appears everywhere as the bell shape that emerges when a sigmoid is differentiated.
Domain and range
The domain is all real numbers
The range is 0<y≤1
The maximum 1 is attained at x=0
It is an even function
From coshx≥1 we get 0<sechx≤1, and squaring keeps the values in the same range.
The derivative of the hyperbolic tangent
Differentiating tanhx=coshxsinhx with the quotient rule produces this function.
dxdtanhx=cosh2xcosh2x−sinh2x=cosh2x1=sech2x
So this function is the slope of tanhx itself. The way tanh rises most steeply near the origin and flattens at both ends appears here directly as the shape of the hump.
Monotonicity and extremum
The derivative is y′=−2sech2xtanhx. Since sech2x is positive, the sign comes from −tanhx: the function increases for x<0 and decreases for x>0. The maximum, both local and global, is at (0,1).
Inflection points
Using sech2x=1−tanh2x, the second derivative can be written as follows.
y′′=(6tanh2x−2)sech2x
The sign changes when tanh2x=31, that is at x=±artanh31≈±0.658. The value there is 1−31=32, a tidy fraction for the height of an inflection point. The curve is concave down between them and concave up outside.
x
y
Position
0
1
maximum
≈±0.658
32
inflection point
±1
≈0.4200
the skirt of the hump
±2
≈0.0707
all but flat
Decay
For large ∣x∣ we have sechx≈2e−∣x∣, so the decay is exponential.
y≈4e−2∣x∣
The x-axis is a horizontal asymptote. The fall is not as steep as a Gaussian, but it is quick enough.
Integral and a probability density
The antiderivative is tanhx itself, so the integral over the whole line is as follows.
∫−∞∞sech2xdx=tanh(∞)−tanh(−∞)=2
Hence 21sech2x is a probability density. Indeed 21+tanhx=1+e−2x1, so it is the density of the distribution whose cumulative function is a logistic function.
Solitons
The KdV equation, which describes waves on shallow water, has the following travelling-wave solution1.
u(x,t)=2csech22c(x−ct)
This solitary wave, which advances at a constant speed without changing shape, is a soliton, and its cross-section is exactly this graph. The formula also shows that a faster soliton is taller and narrower. It is the theoretical form of the wave that would not change, observed by Russell on a canal in 1834.
Applications
In quantum mechanics a potential of the form −sech2x can be solved exactly and has the special property of reflecting no waves at all. In machine learning, the gradient of a network using tanh as its activation function is this very function, so one can see with the eye why the gradient falls exponentially for large inputs, the phenomenon known as the vanishing gradient2.