practicecalculus
Trigonometric integrals

Integral of tan² x: Formula, Derivation and Examples

The integral of tan² x is tan x - x + C. See how the identity tan² x = sec² x - 1 does all the work, plus tan²(ax), tan³ x and definite integral examples.

Trigonometric integrals Updated 2 min read

At a glance

\int \tan^2 x\,dx = \tan x - x + C
Antiderivative
\tan x - x + C
Identity used
\tan^2 x = \sec^2 x - 1
From 0 to π/4
1 - \dfrac{\pi}{4} \approx 0.215
Linear form
\int\tan^2(ax)\,dx = \dfrac{\tan(ax)}{a} - x + C
Cotangent partner
\int\cot^2 x\,dx = -\cot x - x + C
On this page
  1. Graph of tan² x and its antiderivative
  2. Derivation, step by step
  3. Check by differentiating
  4. Definite integrals
  5. Substitution variants
  6. Higher powers of tan
  7. Common mistakes

The integral of \tan^2 x is \tan x - x + C. One identity turns it into two integrals you already know.

\int \tan^2 x\,dx = \tan x - x + C

Graph of tan² x and its antiderivative

Area under y = tan² x from 0 to π/4, with the antiderivative y = tan x - x
The shaded area is 1 - \frac{\pi}{4} \approx 0.215. The dashed antiderivative is flat at the origin, because \tan^2 0 = 0, and never decreases.

Derivation, step by step

  1. Start from the Pythagorean identity \sin^2 x + \cos^2 x = 1. Divide by \cos^2 x to get \tan^2 x + 1 = \sec^2 x.
  2. Rearrange: \tan^2 x = \sec^2 x - 1.
  3. Substitute: \displaystyle\int\tan^2 x\,dx = \int\sec^2 x\,dx - \int 1\,dx.
  4. Use the integral of sec² x, \tan x, and the integral of a constant, x.
  5. Combine: \tan x - x + C.

Check by differentiating

\frac{d}{dx}(\tan x - x) = \sec^2 x - 1 = \tan^2 x \checkmark

Definite integrals

\int_0^{\pi/4}\tan^2 x\,dx = \left(\tan\frac{\pi}{4} - \frac{\pi}{4}\right) - 0 = 1 - \frac{\pi}{4} \approx 0.215
\int_0^{\pi/3}\tan^2 x\,dx = \sqrt{3} - \frac{\pi}{3} \approx 0.685

Since \tan^2 x is even, \int_{-\pi/4}^{\pi/4}\tan^2 x\,dx = 2 - \frac{\pi}{2}.

Substitution variants

\int\tan^2(ax + b)\,dx = \frac{1}{a}\tan(ax + b) - x + C

Note that only the \tan term gets the factor \frac{1}{a}. The -x comes from integrating the constant 1, which has no inside function.

Example 1. \int\tan^2(3x)\,dx = \frac{1}{3}\tan(3x) - x + C.

Example 2. \int\tan^2\frac{x}{2}\,dx = 2\tan\frac{x}{2} - x + C.

Higher powers of tan

The identity \tan^2 x = \sec^2 x - 1 is the key to every power of \tan x.

Example 3: tan³ x.

\int\tan^3 x\,dx = \int\tan x(\sec^2 x - 1)\,dx = \int\tan x\sec^2 x\,dx - \int\tan x\,dx

The first piece is \frac{\tan^2 x}{2} with u = \tan x. The second is the integral of tan x. So

\int\tan^3 x\,dx = \frac{\tan^2 x}{2} - \ln\lvert\sec x\rvert + C

Example 4: tan² x sec² x. Here u = \tan x works directly: \int\tan^2 x\sec^2 x\,dx = \frac{\tan^3 x}{3} + C. This is the one case where \frac{\tan^3 x}{3} is the right answer, because the \sec^2 x factor is present.

Example 5: tan⁴ x. \tan^4 x = \tan^2 x(\sec^2 x - 1) = \tan^2 x\sec^2 x - \tan^2 x, so

\int\tan^4 x\,dx = \frac{\tan^3 x}{3} - \tan x + x + C

Common mistakes

  1. Answering \frac{\tan^3 x}{3}. That needs a \sec^2 x factor. Check: its derivative is \tan^2 x\sec^2 x.
  2. Answering \sec^2 x or \ln^2\lvert\sec x\rvert. Neither differentiates back to \tan^2 x.
  3. Getting the identity backwards. It is \sec^2 x - 1, not 1 - \sec^2 x. Test at x = \frac{\pi}{4}: \tan^2 = 1 and \sec^2 - 1 = 2 - 1 = 1.
  4. Dividing -x by a in \int\tan^2(ax)\,dx.

Practise on trig integral problems.

Practice it now

Powers of sine and cosine

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 integral of tan² x?

It is \tan x - x + C.

What is the integral of tan² x from 0 to π/4?

It is \left(1 - \frac{\pi}{4}\right) - 0 = 1 - \frac{\pi}{4} \approx 0.215.

What is the integral of tan²(2x)?

It is \frac{1}{2}\tan(2x) - x + C.

What is the integral of tan³ x?

Write \tan^3 x = \tan x\sec^2 x - \tan x. The answer is \frac{\tan^2 x}{2} - \ln\lvert\sec x\rvert + C.

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.