Worked example · Derivatives
The derivative of tan x
The slope of tan x is sec² x, which is never less than 1 and grows without bound near the asymptotes. Drag the secant to see both.
The derivative of tan x is sec² x, which can also be written 1 + tan² x or 1/cos² x. It is defined wherever tan x is, that is, everywhere except the odd multiples of π/2.
All three forms are the same function, and each is useful: sec² x is what derivative tables print[1], 1/cos² x shows where the derivative blows up, and 1 + tan² x shows at a glance that it is never less than 1. This page proves the rule, reads it off the graph, works the chain-rule cases and then uses tan x to show something most calculators get wrong. The secant-and-tangent picture behind every derivative is explained in the chapter on the derivative.
Proof by the quotient rule
Write tan x = sin x / cos x and use the quotient rule with (sin x)′ = cos x and (cos x)′ = −sin x:
The Pythagorean identity cos² x + sin² x = 1 does all the work in the last step. Dividing that same identity by cos² x gives 1 + tan² x = sec² x, the third form in equation (1). There is also a proof straight from the limit definition, using the addition formula for tan(x + h) and the limit sin h/h → 1, but it arrives at the same place with more algebra.
Reading sec² x off the graph
Three features of the tangent graph each match a feature of sec² x. The curve rises everywhere, so its derivative is positive everywhere. The curve is steepest near the asymptotes, where it shoots off to ±∞, and cos x → 0 there, so 1/cos² x grows without bound. The curve has an inflection point at 0, where it is flattest, and sec² 0 = 1 is the minimum. Because tan x repeats every π, so does its derivative: the slope at x + π equals the slope at x.
The chain-rule cases
| function | derivative | check at a point |
|---|---|---|
| tan(3x) | 3 sec²(3x) | at 0.2: 3/cos² 0.6 ≈ 4.4041 |
| tan² x | 2 tan x sec² x | at π/4: 2 · 1 · 2 = 4 |
| tan(x²) | 2x sec²(x²) | at 0: 0 |
| x tan x | tan x + x sec² x | at 0: 0 |
| ln|cos x| | −tan x | the reason ∫ tan x dx = −ln|cos x| + C |
The most common slip is in tan² x, which means (tan x)²: the outer function is squaring, so the chain rule gives 2 tan x times the inner derivative sec² x. Writing sec⁴ x or 2 sec x confuses the two layers. The chapter on the chain rule has a figure that makes the two layers visible as two stretches.
Near the poles, where calculators go wrong
At x = 1.5 the exact slope is 1/cos² 1.5 ≈ 199.85. The point is only 0.07 from the asymptote at π/2 ≈ 1.5708. Now try the textbook numerical recipe, the symmetric difference quotient with a step of 0.1:
The answer has the right size and the wrong sign. The point 1.6 lies on the other side of the asymptote, on the next branch of the curve, so the "secant" joins two different pieces of the graph. A smaller step fixes this particular case, but no fixed step is safe: move the point closer to π/2 and any given step eventually straddles the pole. This is a real failure of real software. An earlier version of the calculator on this site, which started from a step proportional to the size of x, reported about −256 ± 199 here, an error bar that did not even contain the true value.
The calculator at the top of this page avoids the trap by not relying on a secant at all: it applies the rule (tan u)′ = sec² u · u′ to the formula and evaluates it at the point, with a bound on the rounding error. Its numerical check extrapolates the difference quotients to zero step (Ridders' method[2]) from the left, from the right and symmetrically, shrinking the starting step when they disagree. At 1.5 it returns 199.8500445265, with an error bound far below the last digit shown. The rounding error that limits how small the step may go is the subject of the numerical section of the chapter on the derivative[3].
The other trigonometric derivatives follow the same pattern: (cot x)′ = −csc² x, (sec x)′ = sec x tan x and (csc x)′ = −csc x cot x, each by the quotient rule[1]. Their inverses, arcsin, arccos and arctan, are on the Derivatives of the inverse trig functions page.