Derivative of tanh(x)

The derivative of the hyperbolic tangent is $\dfrac{d}{dx}\tanh x = \operatorname{sech}^2 x = 1 - \tanh^2 x = \dfrac{1}{\cosh^2 x}$. All three forms are equal.

$$ \frac{d}{dx}\left(\tanh x\right) = 1-\tanh^2 x $$

See the derivative of tanh(x) step by step in the calculator →

📈 Graph of tanh(x) and its derivative

Graph of tanh(x) (solid) and its derivative (dashed) −4−3−2−101234−1.5−1−0.500.511.5 f(x) = tanh xf′(x) = 1 − tanh² x
tanh is an S-shaped curve between $-1$ and $1$. Its derivative is a bell-shaped curve with maximum $1$ at $x=0$ and decays quickly to $0$ – the function is almost flat for $|x| > 3$.

🔍 Why is the derivative of tanh(x) equal to $1-\tanh^2 x$?

Write $\tanh x = \frac{\sinh x}{\cosh x}$ and use the quotient rule together with $\cosh^2 x - \sinh^2 x = 1$:

$$ (\tanh x)' = \frac{\cosh x\cosh x - \sinh x\sinh x}{\cosh^2 x} = \frac{1}{\cosh^2 x} = 1 - \frac{\sinh^2 x}{\cosh^2 x} = 1 - \tanh^2 x. $$

The form $1-\tanh^2 x$ expresses the derivative through the function value itself. That is why tanh is used as an activation function in neural networks: once $\tanh x$ is computed, the slope costs one multiplication.

🔗 Derivative of tanh(x) with an inner function

If the argument is a function $u(x)$, the chain rule adds the inner derivative:

$$ \frac{d}{dx}\tanh\big(u(x)\big) = u'(x)\,\operatorname{sech}^2\big(u(x)\big) $$

✏️ Worked examples

FunctionDerivativeNote
$\tanh(2x)$$2\operatorname{sech}^2(2x)$ steps →
$\tanh(x^2)$$2x\operatorname{sech}^2(x^2)$ steps →
$x\tanh x$$\tanh x + x\operatorname{sech}^2 x$Product rule. steps →
$\tanh^2 x$$2\tanh x\operatorname{sech}^2 x$Power rule with chain rule. steps →

⚠️ Common mistakes

Writing $1+\tanh^2 x$ – that is the derivative of $\tan x$, not of $\tanh x$.

Confusing $\operatorname{sech}^2 x$ with $\sec^2 x$.

❓ Frequently asked questions

Is the derivative of tanh(x) equal to 1 − tanh²(x)?

Yes. $\frac{d}{dx}\tanh x = 1-\tanh^2 x = \operatorname{sech}^2 x$.

What is the maximum slope of tanh(x)?

$1$, at $x = 0$.

What is the second derivative of tanh(x)?

$-2\tanh x\,\operatorname{sech}^2 x$.