practicecalculus
Trigonometric derivatives

Derivative of tan x: Formula, Proof and Examples

The derivative of tan x is sec²x. See the quotient rule proof, the 1 + tan²x form, the chain rule for tan(u) and examples like tan(4x) and tan²x.

Trigonometric derivatives Updated 2 min read

At a glance

\frac{d}{dx}\,\tan x = \sec^2 x
Derivative
\sec^2 x for x \ne \frac{\pi}{2} + k\pi
Other forms
\dfrac{1}{\cos^2 x} = 1 + \tan^2 x
Chain rule form
\dfrac{d}{dx}\tan u = \sec^2 u \cdot u'
Slope at x = 0
\sec^2 0 = 1
Integral version
\int \sec^2 x\,dx = \tan x + C
On this page
  1. Graph of tan x and its derivative
  2. Proof with the quotient rule
  3. The chain rule version: derivative of tan(u)
  4. Worked examples
  5. How to remember it
  6. Common mistakes

The derivative of \tan x is \sec^2 x. You will also see it written \frac{1}{\cos^2 x} or 1 + \tan^2 x. All three are the same function.

\frac{d}{dx}\,\tan x = \sec^2 x

Graph of tan x and its derivative

Graph of y = tan x and its derivative y = sec²x
One branch of \tan x between its asymptotes. The slope is smallest at x = 0, where it equals 1, and grows without bound near \pm\frac{\pi}{2}.

Because \sec^2 x is never below 1, the tangent function is always increasing between asymptotes. It never has a horizontal tangent.

Proof with the quotient rule

Write \tan x = \frac{\sin x}{\cos x} and use the quotient rule:

\frac{d}{dx}\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}

The Pythagorean identity turns the top into 1:

\frac{d}{dx}\tan x = \frac{1}{\cos^2 x} = \sec^2 x

If instead you split the fraction before simplifying, \frac{\cos^2 x}{\cos^2 x} + \frac{\sin^2 x}{\cos^2 x} = 1 + \tan^2 x. That form is handy when the answer should be written in terms of \tan x alone.

The chain rule version: derivative of tan(u)

\frac{d}{dx}\,\tan u = \sec^2 u\cdot u'
Function Inside u Derivative
\tan(4x) 4x 4\sec^2(4x)
\tan(x^2) x^2 2x\sec^2(x^2)
\tan\sqrt{x} \sqrt{x} \frac{\sec^2\sqrt{x}}{2\sqrt{x}}
\tan(e^x) e^x e^x\sec^2(e^x)

Worked examples

Example 1: a power of tan. \frac{d}{dx}\tan^2 x = 2\tan x\cdot\sec^2 x. Here tan is the inside and the square is the outside.

Example 2: a product. \frac{d}{dx}(x\tan x) = \tan x + x\sec^2 x, by the product rule.

Example 3: a tangent line. At x = \frac{\pi}{4}, \tan\frac{\pi}{4} = 1 and the slope is \sec^2\frac{\pi}{4} = (\sqrt{2})^2 = 2:

y = 1 + 2\left(x - \frac{\pi}{4}\right)

Example 4: second derivative. \frac{d}{dx}\sec^2 x = 2\sec^2 x\tan x, worked out on the derivative of sec²x page. It is negative for x < 0 and positive for x > 0, so \tan x has an inflection point at the origin.

How to remember it

Tangent is the slope of a line from the origin at angle x. As the angle approaches a right angle, that slope shoots up, and so does \sec^2 x. At x = 0 the tangent graph passes through the origin at a 45 degree angle, matching a derivative of 1.

Common mistakes

  1. Writing \sec x instead of \sec^2 x. The square matters. \frac{d}{dx}\sec x = \sec x\tan x, a different result.
  2. Writing \sec^2 x\tan x. That is the derivative of \frac{1}{2}\sec^2 x, not of \tan x.
  3. Applying the formula at an asymptote. \tan x and its derivative do not exist at x = \frac{\pi}{2} + k\pi.

Reading the formula backward gives \int\sec^2 x\,dx = \tan x + C, see the integral of sec²x. For \int\tan x\,dx, see the integral of tan x.

Practice it now

Sine, cosine and tangent

Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.

Practice this lesson

Frequently asked questions

What is the derivative of tan x?

The derivative of \tan x is \sec^2 x = \frac{1}{\cos^2 x}.

Why is the derivative of tan x sec² x?

Write \tan x = \frac{\sin x}{\cos x}. The quotient rule gives \frac{\cos^2 x + \sin^2 x}{\cos^2 x} = \frac{1}{\cos^2 x} = \sec^2 x.

What is the derivative of tan(2x)?

By the chain rule, 2\sec^2(2x).

What is the derivative of tan²x?

It is 2\tan x\sec^2 x. The outer function is the square and the inner is \tan x.

Written by the PracticeCalculus team

We build interactive calculus lessons and write every page to be clear and correct. Spotted something off? Tell us and we will fix it.