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[tanx]=sec2x\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[sinx]=cosx\frac{d}{dx}[\sin x] = \cos x and ddx[cosx]=sinx\frac{d}{dx}[\cos x] = -\sin x.

ddx[tanx]=ddx[sinxcosx]=cosxcosxsinx(sinx)cos2x\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 sinx(sinx)-\sin x \cdot (-\sin x) make a positive, so the numerator becomes cos2x+sin2x\cos^2 x + \sin^2 x, which equals 11 by the Pythagorean identity.

=cos2x+sin2xcos2x=1cos2x=sec2x= \frac{\cos^2 x + \sin^2 x}{\cos^2 x} = \frac{1}{\cos^2 x} = \sec^2 x

Same answer, two forms

sec2x\sec^2 x means (secx)2(\sec x)^2, and since secx=1cosx\sec x = \frac{1}{\cos x}, that is exactly 1cos2x\frac{1}{\cos^2 x}. Both forms name the same result. It holds only where cosx0\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 tanx\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 tanx\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 sec2(u)\sec^2(u) times uu' 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 ff' at a point when ff contains tanx\tan x.
  • Free-response work that expects you to recognize sec2x\sec^2 x instantly, without pausing to re-derive it.

Common mistakes

MistakeWhy it is wrong
Writing ddx[tanx]=secxtanx\frac{d}{dx}[\tan x] = \sec x \tan xThat is the derivative of secx\sec x, not tanx\tan x. The tangent gives sec2x\sec^2 x.
ddx[tan(3x)]=sec2(3x)\frac{d}{dx}[\tan(3x)] = \sec^2(3x)The chain rule is missing. The inner derivative makes it 3sec2(3x)3\sec^2(3x).
Reading sec2x\sec^2 x as sec(x2)\sec(x^2)sec2x\sec^2 x means (secx)2(\sec x)^2, a squared output, not a squared input.
Numerator cos2xsin2x\cos^2 x - \sin^2 xA sign slip. Since ddx[cosx]=sinx\frac{d}{dx}[\cos x] = -\sin x, the term is sinx(sinx)=+sin2x-\sin x \cdot (-\sin x) = +\sin^2 x, so the sum gives 11.
Using the formula at x=π2x = \frac{\pi}{2}Both tanx\tan x and sec2x\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 sec2(u)\sec^2(u), then multiply by uu', the derivative of the inside function uu.

ddx[tan(5x)]=sec2(5x)5=5sec2(5x)\frac{d}{dx}\left[\tan(5x)\right] = \sec^2(5x) \cdot 5 = 5\sec^2(5x)
ddx[tan(x2+1)]=sec2(x2+1)2x=2xsec2(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 xtanxx\tan x, pair this with the product rule: ddx[xtanx]=tanx+xsec2x\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 tanx\tan x sec2x\sec^2 x or 1cos2x\frac{1}{\cos^2 x}?

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

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

Wherever it is defined, sec2x=1cos2x\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 cos2x1\cos^2 x \leq 1, dividing 11 by it gives sec2x1\sec^2 x \geq 1. Either way the slope is positive, which is the calculus reason tanx\tan x is increasing on every interval between its asymptotes.

What is the second derivative of tanx\tan x?

Differentiate sec2x\sec^2 x with the chain rule: ddx[(secx)2]=2secxsecxtanx=2sec2xtanx\frac{d}{dx}[(\sec x)^2] = 2\sec x \cdot \sec x \tan x = 2\sec^2 x \tan x.

Where is tanx\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 cosx=0\cos x = 0, so tanx\tan x has a vertical asymptote and is not even defined, let alone differentiable.