# Derivative of tanh x: Formula, Proof and Examples

> The derivative of tanh x is sech² x, which equals 1 − tanh² x. See the quotient rule proof, chain rule examples, a graph and the arctanh derivative.

Source: https://practicecalculus.com/derivatives/tanh-x
Updated: 2026-11-06

$$ \frac{d}{dx}\,\tanh x = \operatorname{sech}^2 x $$

## At a glance

- **Derivative:** $\operatorname{sech}^2 x = \dfrac{1}{\cosh^2 x}$
- **Equivalent form:** $1 - \tanh^2 x$
- **Definition:** $\tanh x = \dfrac{\sinh x}{\cosh x}$
- **Range of tanh x:** $(-1, 1)$
- **Inverse derivative:** $\dfrac{d}{dx}\operatorname{artanh} x = \dfrac{1}{1 - x^2}$ for $\lvert x\rvert < 1$

## Key takeaways

- The derivative of $\tanh x$ is $\operatorname{sech}^2 x = \frac{1}{\cosh^2 x}$.
- The same thing can be written as $1 - \tanh^2 x$, which is handy in differential equations and neural networks.
- The proof uses the quotient rule and the identity $\cosh^2 x - \sinh^2 x = 1$.
- The slope is $1$ at $x = 0$ and shrinks toward $0$ as $\tanh x$ levels off at $\pm 1$.

The **derivative of $\tanh x$ is $\operatorname{sech}^2 x$**, which you can also write as $1 - \tanh^2 x$.

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

Here $\operatorname{sech} x = \frac{1}{\cosh x}$, so $\operatorname{sech}^2 x = \frac{1}{\cosh^2 x}$.

## Proof with the quotient rule

Write $\tanh x = \frac{\sinh x}{\cosh x}$ and use the [quotient rule](/rules/quotient-rule), with the [derivative of sinh x](/derivatives/sinh-x) being $\cosh x$ and the [derivative of cosh x](/derivatives/cosh-x) being $\sinh x$:

$$\frac{d}{dx}\,\frac{\sinh x}{\cosh x} = \frac{\cosh x\cdot\cosh x - \sinh x\cdot\sinh x}{\cosh^2 x} = \frac{\cosh^2 x - \sinh^2 x}{\cosh^2 x}$$

The hyperbolic identity $\cosh^2 x - \sinh^2 x = 1$ simplifies the top:

$$\frac{d}{dx}\tanh x = \frac{1}{\cosh^2 x} = \operatorname{sech}^2 x$$

Splitting the fraction instead gives the other form: $\frac{\cosh^2 x}{\cosh^2 x} - \frac{\sinh^2 x}{\cosh^2 x} = 1 - \tanh^2 x$.

## Graph of tanh x and its derivative

```graph
title: 'Graph of y = tanh x and its derivative y = sech² x'
caption: 'The hyperbolic tangent is an S-shaped curve between $-1$ and $1$. Its slope is $1$ at the origin and fades to $0$ on both sides.'
x: [-4, 4]
y: [-1.5, 1.5]
functions:
  - expr: tanh(x)
    label: y = tanh x
  - expr: 1/cosh(x)^2
    label: y = sech² x (derivative)
    dashed: true
  - expr: 1
    label: y = 1
    dashed: true
  - expr: -1
    label: y = −1
    dashed: true
points:
  - [0, 0, '(0, 0)']
  - [0, 1, 'slope 1']
```

The derivative is always positive, so $\tanh x$ always increases. But it never reaches $\pm 1$; those are horizontal asymptotes. Compare the [derivative of arctan x](/derivatives/arctan-x), another S-curve with slope $1$ at the origin, though arctan approaches its asymptotes much more slowly.

## Comparing tan and tanh

| Function | Derivative | In terms of itself |
| --- | --- | --- |
| $\tan x$ | $\sec^2 x$ | $1 + \tan^2 x$ |
| $\tanh x$ | $\operatorname{sech}^2 x$ | $1 - \tanh^2 x$ |

The sign flip comes from the identities: $\sec^2 x = 1 + \tan^2 x$ but $\operatorname{sech}^2 x = 1 - \tanh^2 x$.

## Chain rule version and examples

$$\frac{d}{dx}\tanh u = \operatorname{sech}^2 u\cdot u'$$

**Example 1.** $\frac{d}{dx}\tanh(2x) = 2\operatorname{sech}^2(2x)$.

**Example 2.** $\frac{d}{dx}\tanh(x^2) = 2x\operatorname{sech}^2(x^2)$.

**Example 3: a log.** $\frac{d}{dx}\ln(\cosh x) = \frac{\sinh x}{\cosh x} = \tanh x$. So $\int\tanh x\,dx = \ln(\cosh x) + C$.

**Example 4: a value.** At $x = 1$, $\tanh 1 \approx 0.7616$, so the slope is $1 - 0.7616^2 \approx 0.420$.

## Where 1 − tanh² x shows up

In machine learning, $\tanh$ is a common activation function. Training needs its derivative many times, and $1 - \tanh^2 x$ lets a program reuse the value of $\tanh x$ it already computed instead of evaluating $\cosh x$.

## Derivative of artanh x

For $\lvert x\rvert < 1$, set $\tanh y = x$. Then $(1 - \tanh^2 y)\,y' = 1$, so

$$\frac{d}{dx}\operatorname{artanh} x = \frac{1}{1 - x^2}$$

## Common mistakes

1. **Writing $\sec^2 x$.** That is the derivative of the circular tangent.
2. **Writing $1 + \tanh^2 x$.** The hyperbolic version has a minus sign.
3. **Forgetting the inside derivative.** $\frac{d}{dx}\tanh(3x) = 3\operatorname{sech}^2(3x)$.

The [hyperbolic functions](/functions/hyperbolic-functions) page covers $\operatorname{sech}$, $\operatorname{csch}$ and $\coth$ as well.

## Frequently asked questions

### What is the derivative of tanh x?

The derivative of $\tanh x$ is $\operatorname{sech}^2 x$, which also equals $1 - \tanh^2 x$.

### What is the derivative of tanh(2x)?

By the chain rule it is $2\operatorname{sech}^2(2x)$.

### Why is the derivative of tanh written as 1 − tanh² x?

Because $\operatorname{sech}^2 x = 1 - \tanh^2 x$. Divide $\cosh^2 x - \sinh^2 x = 1$ by $\cosh^2 x$ to see it. This form lets you compute the slope from the value of $\tanh x$ alone.

### What is the derivative of arctanh x?

For $\lvert x\rvert < 1$, $\frac{d}{dx}\operatorname{artanh} x = \frac{1}{1 - x^2}$.
