AP Calculus AB and BC

Derivative of tan x: Answer, Proof, and Mistakes

The derivative of tan x is sec^2 x, which equals 1/cos^2 x. It holds everywhere tan x is defined, meaning every x except odd multiples of pi/2 (where cos x = 0). You get it by applying the quotient rule to tan x = sin x / cos x, using the Pythagorean identity sin^2 x + cos^2 x = 1.

ddx[tan⁡x]=sec⁡2x\frac{d}{dx}\left[\tan x\right] = \sec^2 x

The proof, by the quotient rule

Rewrite the tangent as a quotient of sine and cosine, then differentiate with the quotient rule. Recall that ddx[sin⁡x]=cos⁡x\frac{d}{dx}[\sin x] = \cos x and ddx[cos⁡x]=−sin⁡x\frac{d}{dx}[\cos x] = -\sin x.

ddx[tan⁡x]=ddx[sin⁡xcos⁡x]=cos⁡x⋅cos⁡x−sin⁡x⋅(−sin⁡x)cos⁡2x\frac{d}{dx}\left[\tan x\right] = \frac{d}{dx}\left[\frac{\sin x}{\cos x}\right] = \frac{\cos x \cdot \cos x - \sin x \cdot (-\sin x)}{\cos^2 x}

The two negatives in −sin⁡x⋅(−sin⁡x)-\sin x \cdot (-\sin x) make a positive, so the numerator becomes cos⁡2x+sin⁡2x\cos^2 x + \sin^2 x, which equals 11 by the Pythagorean identity.

=cos⁡2x+sin⁡2xcos⁡2x=1cos⁡2x=sec⁡2x= \frac{\cos^2 x + \sin^2 x}{\cos^2 x} = \frac{1}{\cos^2 x} = \sec^2 x

Same answer, two forms

sec⁡2x\sec^2 x means (sec⁡x)2(\sec x)^2, and since sec⁡x=1cos⁡x\sec x = \frac{1}{\cos x}, that is exactly 1cos⁡2x\frac{1}{\cos^2 x}. Both forms name the same result. It holds only where cos⁡x≠0\cos x \neq 0, so it excludes x=π2+nπx = \frac{\pi}{2} + n\pi, the odd multiples of π2\frac{\pi}{2} where tan⁡x\tan x is undefined.

Where it shows up on the AP exam

The College Board lists this derivative directly in Unit 2, Topic 2.10, Finding the Derivatives of Tangent, Cotangent, Secant, and/or Cosecant Functions. Unit 2, Differentiation: Definition and Fundamental Properties, makes up 10 to 15% of the AB exam and 5 to 10% of BC.

The derivation leans on Topic 2.9, The Quotient Rule, and the ingredients come from Topic 2.7, Derivatives of cos x, sin x, e^x, and ln x. On the exam you rarely differentiate a bare tan⁡x\tan x; it usually sits inside a composite that needs the chain rule from Unit 3, Topic 3.1.

  • Chain-rule composites such as tan⁡(3x)\tan(3x) or tan⁡(x2)\tan(x^2), where the answer is sec⁡2(u)\sec^2(u) times u′u' for inside function uu.
  • Related rates and motion problems where an angle changes, so a tan⁡\tan term is differentiated with respect to time.
  • Tangent-line and slope questions that ask for f′f' at a point when ff contains tan⁡x\tan x.
  • Free-response work that expects you to recognize sec⁡2x\sec^2 x instantly, without pausing to re-derive it.

Common mistakes

MistakeWhy it is wrong
Writing ddx[tan⁡x]=sec⁡xtan⁡x\frac{d}{dx}[\tan x] = \sec x \tan xThat is the derivative of sec⁡x\sec x, not tan⁡x\tan x. The tangent gives sec⁡2x\sec^2 x.
ddx[tan⁡(3x)]=sec⁡2(3x)\frac{d}{dx}[\tan(3x)] = \sec^2(3x)The chain rule is missing. The inner derivative makes it 3sec⁡2(3x)3\sec^2(3x).
Reading sec⁡2x\sec^2 x as sec⁡(x2)\sec(x^2)sec⁡2x\sec^2 x means (sec⁡x)2(\sec x)^2, a squared output, not a squared input.
Numerator cos⁡2x−sin⁡2x\cos^2 x - \sin^2 xA sign slip. Since ddx[cos⁡x]=−sin⁡x\frac{d}{dx}[\cos x] = -\sin x, the term is −sin⁡x⋅(−sin⁡x)=+sin⁡2x-\sin x \cdot (-\sin x) = +\sin^2 x, so the sum gives 11.
Using the formula at x=π2x = \frac{\pi}{2}Both tan⁡x\tan x and sec⁡2x\sec^2 x are undefined there. Check the domain before you evaluate.

Chain-rule composites, quick practice

Every composite follows one pattern: differentiate the outer tangent to sec⁡2(u)\sec^2(u), then multiply by u′u', the derivative of the inside function uu.

ddx[tan⁡(5x)]=sec⁡2(5x)⋅5=5sec⁡2(5x)\frac{d}{dx}\left[\tan(5x)\right] = \sec^2(5x) \cdot 5 = 5\sec^2(5x)
ddx[tan⁡(x2+1)]=sec⁡2(x2+1)⋅2x=2xsec⁡2(x2+1)\frac{d}{dx}\left[\tan(x^2 + 1)\right] = \sec^2(x^2 + 1) \cdot 2x = 2x\sec^2(x^2 + 1)

For a product such as xtan⁡xx\tan x, pair this with the product rule: ddx[xtan⁡x]=tan⁡x+xsec⁡2x\frac{d}{dx}[x\tan x] = \tan x + x\sec^2 x.

Check yourself, not just the answer

Type derivatives and get graded on mathematical equivalence, with rule-level hints when you miss, in the Derivative Practice Checker.

Frequently asked questions

Is the derivative of tan⁡x\tan x sec⁡2x\sec^2 x or 1cos⁡2x\frac{1}{\cos^2 x}?

Both, because they are the same expression. Since sec⁡x=1cos⁡x\sec x = \frac{1}{\cos x}, squaring gives sec⁡2x=1cos⁡2x\sec^2 x = \frac{1}{\cos^2 x}. Use whichever form fits the rest of your work.

Why is the derivative of tan⁡x\tan x always positive?

Wherever it is defined, sec⁡2x=1cos⁡2x\sec^2 x = \frac{1}{\cos^2 x} is 11 divided by a nonzero square, so it is always positive, never zero or negative. And since cos⁡2x≤1\cos^2 x \leq 1, dividing 11 by it gives sec⁡2x≥1\sec^2 x \geq 1. Either way the slope is positive, which is the calculus reason tan⁡x\tan x is increasing on every interval between its asymptotes.

What is the second derivative of tan⁡x\tan x?

Differentiate sec⁡2x\sec^2 x with the chain rule: ddx[(sec⁡x)2]=2sec⁡x⋅sec⁡xtan⁡x=2sec⁡2xtan⁡x\frac{d}{dx}[(\sec x)^2] = 2\sec x \cdot \sec x \tan x = 2\sec^2 x \tan x.

Where is tan⁡x\tan x not differentiable?

At the odd multiples of π2\frac{\pi}{2}, that is x=π2+nπx = \frac{\pi}{2} + n\pi for any integer nn. There cos⁡x=0\cos x = 0, so tan⁡x\tan x has a vertical asymptote and is not even defined, let alone differentiable.