Derivative of tan(x)

The derivative of the tangent is $\dfrac{d}{dx}\tan x = \sec^2 x = \dfrac{1}{\cos^2 x} = 1+\tan^2 x$. It exists wherever $\tan x$ is defined, i.e. for $x \neq \frac{\pi}{2} + k\pi$.

$$ \frac{d}{dx}\left(\tan x\right) = \sec^2 x $$

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

📈 Graph of tan(x) and its derivative

Graph of tan(x) (solid) and its derivative (dashed) −π−π/20π/2π−4−3−2−101234 f(x) = tan xf′(x) = sec² x
Between two asymptotes, tan increases from $-\infty$ to $+\infty$. Accordingly $\sec^2 x$ is always at least $1$; it equals $1$ at the zeros of tan ($x = k\pi$) and grows without bound near the asymptotes.

🔍 Why is the derivative of tan(x) equal to $\sec^2 x$?

Use $\tan x = \frac{\sin x}{\cos x}$ and the quotient rule:

$$ (\tan x)' = \frac{\cos x\cdot\cos x - \sin x\cdot(-\sin x)}{\cos^2 x} = \frac{\cos^2 x + \sin^2 x}{\cos^2 x}. $$

Simplifying the numerator with $\sin^2x+\cos^2x = 1$ gives $\frac{1}{\cos^2 x} = \sec^2 x$; dividing it term by term instead gives $1 + \tan^2 x$.

🔗 Derivative of tan(x) with an inner function

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

$$ \frac{d}{dx}\tan\big(u(x)\big) = u'(x)\sec^2\big(u(x)\big) $$

✏️ Worked examples

FunctionDerivativeNote
$\tan(3x)$$3\sec^2(3x)$ steps →
$\tan(x^2)$$2x\sec^2(x^2)$ steps →
$\tan^2 x$$2\tan x\sec^2 x$Power of a function. steps →
$x\tan x$$\tan x + x\sec^2 x$Product rule. steps →

⚠️ Common mistakes

Writing $\sec x$ instead of $\sec^2 x$.

Confusing $\tan^{-1} x$ (arctan) with $\cot x$.

❓ Frequently asked questions

Is the derivative of tan(x) sec²(x) or 1/cos²(x)?

Both – they are the same function, and also equal to $1+\tan^2 x$.

What is the second derivative of tan(x)?

$2\sec^2 x\tan x$ – see the derivative of sec²(x).

Why is tan(x) always increasing?

Its derivative $\sec^2 x$ is a square that is never smaller than $1$, so the slope is positive everywhere on its domain.