y=sech2xy = \operatorname{sech}^2 x

Graph of the Function y=sech2xy = \operatorname{sech}^2 x

y=sech2xy = \operatorname{sech}^2 x is the hyperbolic secant squared. Since the derivative of tanhx\tanh x 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<y10 < y \leq 1
  • The maximum 11 is attained at x=0x = 0
  • It is an even function

From coshx1\cosh x \geq 1 we get 0<sechx10 < \operatorname{sech} x \leq 1, and squaring keeps the values in the same range.

The derivative of the hyperbolic tangent

Differentiating tanhx=sinhxcoshx\tanh x = \dfrac{\sinh x}{\cosh x} with the quotient rule produces this function.

ddxtanhx=cosh2xsinh2xcosh2x=1cosh2x=sech2x\begin{align*} \frac{d}{dx}\tanh x &= \frac{\cosh^2 x - \sinh^2 x}{\cosh^2 x} \\ &= \frac{1}{\cosh^2 x} = \operatorname{sech}^2 x \end{align*}

So this function is the slope of tanhx\tanh x itself. The way tanh\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=2sech2xtanhxy' = -2\operatorname{sech}^2 x \tanh x. Since sech2x\operatorname{sech}^2 x is positive, the sign comes from tanhx-\tanh x: the function increases for x<0x < 0 and decreases for x>0x > 0. The maximum, both local and global, is at (0,1)(0, 1).

Inflection points

Using sech2x=1tanh2x\operatorname{sech}^2 x = 1 - \tanh^2 x, the second derivative can be written as follows.

y=(6tanh2x2)sech2xy'' = (6\tanh^2 x - 2)\operatorname{sech}^2 x

The sign changes when tanh2x=13\tanh^2 x = \dfrac{1}{3}, that is at x=±artanh13±0.658x = \pm\operatorname{artanh}\dfrac{1}{\sqrt{3}} \approx \pm 0.658. The value there is 113=231 - \dfrac{1}{3} = \dfrac{2}{3}, a tidy fraction for the height of an inflection point. The curve is concave down between them and concave up outside.

xxyyPosition
0011maximum
±0.658\approx \pm 0.65823\dfrac{2}{3}inflection point
±1\pm 10.4200\approx 0.4200the skirt of the hump
±2\pm 20.0707\approx 0.0707all but flat

Decay

For large x|x| we have sechx2ex\operatorname{sech} x \approx 2e^{-|x|}, so the decay is exponential.

y4e2xy \approx 4e^{-2|x|}

The xx-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\tanh x itself, so the integral over the whole line is as follows.

sech2xdx=tanh()tanh()=2\int_{-\infty}^{\infty} \operatorname{sech}^2 x\,dx = \tanh(\infty) - \tanh(-\infty) = 2

Hence 12sech2x\dfrac{1}{2}\operatorname{sech}^2 x is a probability density. Indeed 1+tanhx2=11+e2x\dfrac{1 + \tanh x}{2} = \dfrac{1}{1 + e^{-2x}}, 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)=c2sech2c2(xct)u(x, t) = \frac{c}{2}\operatorname{sech}^2\frac{\sqrt{c}}{2}(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 18341834.

Applications

In quantum mechanics a potential of the form sech2x-\operatorname{sech}^2 x 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\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.

  1. Soliton, Wikipedia
  2. Vanishing gradient problem, Wikipedia