Quick answer:
$$\frac{d}{dx}\tan x = \sec^2 x = \frac{1}{\cos^2 x}$$
An equivalent form that is often handy is \( 1 + \tan^2 x \), because \( \sec^2 x = 1 + \tan^2 x \). Below you will find two proofs, a picture of why the slope behaves the way it does, seven worked examples and the mistakes that cost the most points on tests.
Why it works: the intuition
Start near \( x = 0 \). For small angles, \( \tan x \) is almost exactly \( x \), so the graph leaves the origin with slope 1. That matches \( \sec^2 0 = 1 \).
Now move toward \( x = \frac{\pi}{2} \). The tangent is sine divided by cosine, and the cosine in the denominator shrinks toward zero. Dividing by a tiny number makes \( \tan x \) shoot upward, and the graph gets steeper and steeper until it hits the vertical asymptote. The factor \( \frac{1}{\cos^2 x} \) captures exactly that blow-up.
The form \( 1 + \tan^2 x \) gives an even simpler picture: the slope of the tangent curve depends only on its current height. Wherever the graph is at height \( y \), its slope is \( 1 + y^2 \). At height 0 the slope is 1, at height 1 it is 2, at height 3 it is 10. The higher (or lower) the curve, the steeper it climbs.
Proof with the quotient rule
Write tangent as a quotient, \( \tan x = \frac{\sin x}{\cos x} \), and apply the quotient rule. The top derivative is \( \cos x \) and the bottom derivative is \( -\sin x \):
$$\begin{aligned} \frac{d}{dx}\frac{\sin x}{\cos 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} \end{aligned}$$
The Pythagorean identity \( \sin^2 x + \cos^2 x = 1 \) turns the top into 1:
$$\frac{d}{dx}\tan x = \frac{1}{\cos^2 x} = \sec^2 x$$
If instead you split the fraction as \( \frac{\cos^2 x}{\cos^2 x} + \frac{\sin^2 x}{\cos^2 x} \), you get the other form, \( 1 + \tan^2 x \), directly.
Proof from the limit definition
You can also go straight from the definition. The subtraction identity for tangent can be written as \( \tan A - \tan B = \frac{\sin(A - B)}{\cos A\cos B} \). With \( A = x + h \) and \( B = x \):
$$\begin{aligned} \frac{\tan(x+h) - \tan x}{h} &= \frac{\sin h}{h}\cdot\frac{1}{\cos(x+h)\cos x} \end{aligned}$$
As \( h \to 0 \), the first factor goes to 1 (the famous limit of sin x / x) and the second goes to \( \frac{1}{\cos^2 x} \). The product is \( \sec^2 x \), matching the first proof.
What the result tells you
Because \( \sec^2 x \ge 1 \) wherever it is defined, the slope of \( \tan x \) is always at least 1. The tangent function is increasing on every interval between its vertical asymptotes at \( x = \frac{\pi}{2} + k\pi \). At \( x = 0 \) the slope is exactly 1, and it grows without bound as \( x \) approaches an asymptote. At the asymptotes themselves neither \( \tan x \) nor its derivative exists.
Chain rule: derivative of tan(g(x))
When something other than plain \( x \) sits inside the tangent, the chain rule adds the derivative of the inside:
$$\frac{d}{dx}\tan\big(g(x)\big) = \sec^2\big(g(x)\big)\cdot g'(x)$$
Example 1: \( \tan(3x) \) gives \( 3\sec^2(3x) \). The inside \( 3x \) has derivative 3, so the graph is three times as steep as \( \tan x \) at matching points.
Example 2: \( \tan(x^2) \) gives \( 2x\sec^2(x^2) \). Notice the inside stays as \( x^2 \) inside the secant; only the factor \( 2x \) is new.
Example 3: \( \tan^2 x \). Here the outer function is squaring, and the tangent is the inside:
$$\frac{d}{dx}\tan^2 x = 2\tan x\cdot\sec^2 x$$
Example 4: \( x\tan x \). By the product rule, \( \tan x + x\sec^2 x \).
Example 5 (three layers): \( \tan^3(2x) \). Work from the outside in. The cube gives \( 3\tan^2(2x) \), the tangent gives \( \sec^2(2x) \), and the \( 2x \) gives 2:
$$\frac{d}{dx}\tan^3(2x) = 6\tan^2(2x)\sec^2(2x)$$
Example 6: \( \ln(\tan x) \) on \( 0 < x < \frac{\pi}{2} \). The log rule says derivative of the inside over the inside:
$$\frac{\sec^2 x}{\tan x} = \frac{1}{\sin x\cos x} = \frac{2}{\sin 2x}$$
The last step uses \( 2\sin x\cos x = \sin 2x \), so the answer can also be written \( 2\csc 2x \).
Evaluating at a point
Find the slope of \( y = \tan x \) at \( x = \frac{\pi}{4} \). Since \( \cos\frac{\pi}{4} = \frac{\sqrt 2}{2} \), we get \( \sec^2\frac{\pi}{4} = \frac{1}{1/2} = 2 \). The tangent line there is \( y - 1 = 2\left(x - \frac{\pi}{4}\right) \). The height-based form agrees: at height \( \tan\frac{\pi}{4} = 1 \) the slope is \( 1 + 1^2 = 2 \).
Example 7: a related rates problem
A camera sits 100 m from a rocket launch pad and tilts up to follow the rocket. If \( h \) is the rocket’s height and \( \theta \) the camera angle, then \( \tan\theta = \frac{h}{100} \). Differentiate both sides with respect to time:
$$\sec^2\theta\,\frac{d\theta}{dt} = \frac{1}{100}\,\frac{dh}{dt}$$
When the rocket is 100 m up and rising at 20 m/s, \( \theta = \frac{\pi}{4} \) and \( \sec^2\theta = 2 \), so the camera must turn at \( \frac{20}{100\cdot 2} = 0.1 \) radians per second. This pattern appears constantly in related rates problems.
The cotangent partner
Cotangent is the reciprocal of tangent, \( \cot x = \frac{\cos x}{\sin x} \), and the same quotient rule argument works for it. The top derivative is \( -\sin x \) and the bottom derivative is \( \cos x \), so the numerator becomes \( -\sin^2 x - \cos^2 x = -1 \):
$$\frac{d}{dx}\cot x = -\frac{1}{\sin^2 x} = -\csc^2 x$$
Comparing the two results is a good way to remember both. Tangent turns into secant squared; cotangent turns into cosecant squared with a minus sign, because cotangent falls on every branch while tangent rises.
Using the derivative to estimate values
A derivative also lets you estimate values without a calculator. The tangent line at \( x = \frac{\pi}{4} \) is \( y = 1 + 2\left(x - \frac{\pi}{4}\right) \), so a small step of 0.01 radians past \( \frac{\pi}{4} \) should raise \( \tan x \) by about \( 2 \times 0.01 \):
$$\tan\left(\frac{\pi}{4} + 0.01\right) \approx 1.02$$
The slope of 2 at that point tells you the output changes about twice as fast as the input. Near \( x = 0 \) the slope is 1, which is where the familiar small-angle estimate \( \tan x \approx x \) comes from. Close to an asymptote the slope is huge, so tiny input errors create big output errors; that is worth knowing whenever you measure angles near 90 degrees.
All six trig derivatives at a glance
| Function | Derivative |
|---|---|
| \( \sin x \) | \( \cos x \) |
| \( \cos x \) | \( -\sin x \) |
| \( \tan x \) | \( \sec^2 x \) |
| \( \sec x \) | \( \sec x\tan x \) |
| \( \csc x \) | \( -\csc x\cot x \) |
| \( \cot x \) | \( -\csc^2 x \) |
A memory trick: the three “co-” functions get a minus sign.
Common mistakes
- Swapping with secant. \( \sec x\tan x \) is the derivative of \( \sec x \), not of \( \tan x \). The correct answer for tangent is \( \sec^2 x \).
- Losing the inside derivative. \( \frac{d}{dx}\tan(5x) \) is \( 5\sec^2(5x) \), not \( \sec^2(5x) \).
- Confusing \( \tan^2 x \) with \( \tan(x^2) \). The first is \( (\tan x)^2 \) with derivative \( 2\tan x\sec^2 x \); the second has derivative \( 2x\sec^2(x^2) \).
- Working in degrees. The formula assumes radians. If \( x \) is in degrees, the chain rule adds a factor: the derivative of \( \tan(x^\circ) \) is \( \frac{\pi}{180}\sec^2(x^\circ) \).
- Evaluating at an asymptote. At \( x = \frac{\pi}{2} \), \( \tan x \) is undefined, so there is no slope to compute there.
Where it’s used
Reading the result backwards gives \( \int\sec^2 x\,dx = \tan x + C \), covered in the integral of sec²x. Tangent derivatives also drive trig substitution with \( x = \tan\theta \), angle problems in physics and surveying, and the derivative of arctangent, which is found by inverting this very result.
Tangent also shows up any time a slope is described by an angle. A line that makes angle \( \theta \) with the horizontal has slope \( \tan\theta \), so asking how fast that slope changes as the angle turns is a question about \( \sec^2\theta \). The same idea explains why a ramp or roof gets dramatically steeper for each extra degree once it is already close to vertical: the derivative grows without bound near 90 degrees.
Try it yourself
Type any tangent expression below to see the rules applied step by step, or use the full derivative calculator for longer expressions.
Step-by-step solver·Exact symbolic engine
Interactive Calculus Problem Solver
Derivatives, antiderivatives, definite and improper integrals, and limits. Every answer comes with the rules used, and antiderivatives are verified by differentiating them back.
Input syntax
- Powers
x^2, rootssqrt(x),cbrt(x), absolute value|x| - Implicit multiplication works:
3x sin(2x) sin cos tan sec csc cot,asin acos atan,sinh cosh tanhe^xorexp(x);ln(x)andlog(x)are both the natural log- Constants
piande; bounds acceptinfand-inf
Practice problems
Try these before checking the answers.
- \( \frac{d}{dx}\tan(5x) \)
- \( \frac{d}{dx}\tan\sqrt{x} \)
- \( \frac{d}{dx}\,e^x\tan x \)
- \( \frac{d}{dx}\tan(2x + 1) \)
- \( \frac{d}{dx}\frac{\tan x}{x} \)
- \( \frac{d}{dx}\,\sin x\tan x \)
Answers: (1) \( 5\sec^2(5x) \); (2) \( \frac{\sec^2\sqrt x}{2\sqrt x} \); (3) \( e^x\tan x + e^x\sec^2 x \); (4) \( 2\sec^2(2x+1) \); (5) \( \frac{x\sec^2 x - \tan x}{x^2} \); (6) \( \sin x + \sin x\sec^2 x \).
FAQ
Is the derivative of tan x equal to sec x tan x?
No. \( \sec x\tan x \) is the derivative of \( \sec x \). The derivative of \( \tan x \) is \( \sec^2 x \). See the derivative of sec x.
What is the second derivative of tan x?
Differentiate \( \sec^2 x \) with the chain rule: \( 2\sec x\cdot\sec x\tan x = 2\sec^2 x\tan x \).
What is the integral of tan x?
\( \int\tan x\,dx = -\ln|\cos x| + C \). The full derivation is in integral of tan x.
Is sec²x the same as 1 + tan²x?
Yes, wherever both are defined. Divide \( \sin^2 x + \cos^2 x = 1 \) by \( \cos^2 x \) to get the identity, so either form is a correct derivative.
Why is the derivative of tan x never negative?
Because it is a square, \( \frac{1}{\cos^2 x} \), and in fact it is never less than 1. That is why the tangent graph rises on every branch.
Further reading
- Paul’s Online Notes: Derivatives of Trig Functions — the two key trig limits and derivations of all six trig derivatives, with practice.
- Paul’s Online Notes: Product and Quotient Rule — a refresher on the quotient rule used in the main proof.
Calculators for this topic
Keep learning
Implicit Differentiation: Step-by-Step Method with Examples
How to find dy/dx when y isn’t isolated. A 4-step implicit differentiation method with circle, x³+y³=6xy and trig examples, plus tangent lines.
Chain Rule Explained: Formula, Steps and 8 Examples
The chain rule differentiates composite functions: d/dx f(g(x)) = f'(g(x))·g'(x). Clear steps, 8 worked examples and the most common mistakes.

