---
title: Trigonometric Integrals and Substitution
module: Techniques of Integration
moduleNumber: 7
lessonNumber: 2
order: 702
summary: >
  Two related techniques. Trigonometric integrals evaluate powers and products
  of sine, cosine, tangent, and secant by splitting off one factor and
  converting the rest with a Pythagorean identity, or by dropping even powers
  with half-angle formulas. Trigonometric substitution runs the idea in reverse:
  replace x by a sine, tangent, or secant to clear a radical, integrate, then
  read the answer back off a reference triangle.
topics: [Techniques of Integration]
sources:
  - book: Stewart
    ref: "Ch. 7 — Techniques of Integration; §7.2 Trigonometric Integrals, §7.3 Trigonometric Substitution"
---

The Pythagorean identity $\sin^2 x + \cos^2 x = 1$ and its relatives let sine and
cosine trade places, and trade with tangent and secant. Two techniques exploit
this. The first evaluates integrals that are already trigonometric by rewriting
the integrand until a substitution appears. The second introduces a
trigonometric variable to remove a radical from an algebraic integrand.

## Powers of sine and cosine

For $\int \sin^m x \cos^n x\,\d x$, use that the derivative of
$\sin x$ is $\cos x$ and vice versa: one saved factor becomes the $\d u$ of a
substitution while the rest converts to the other function.

### One odd power

If the power of cosine is odd, split off a single $\cos x$ and convert the
remaining even power with $\cos^2 x = 1 - \sin^2 x$; then substitute
$u = \sin x$. For $\int \cos^3 x\,\d x$,

$$
\int \cos^3 x\,\d x = \int \cos^2 x \cdot \cos x\,\d x = \int (1 - \sin^2 x)\cos x\,\d x.
$$

With $u = \sin x$, $\d u = \cos x\,\d x$,

$$
\int (1 - u^2)\,\d u = u - \tfrac{1}{3}u^3 + C = \sin x - \tfrac{1}{3}\sin^3 x + C.
$$

The same move handles a mix. For $\int \sin^5 x \cos^2 x\,\d x$ the sine power is
odd, so save one $\sin x$ and convert $\sin^4 x = (1 - \cos^2 x)^2$; substitute
$u = \cos x$, $\d u = -\sin x\,\d x$:

$$
\int (1 - \cos^2 x)^2 \cos^2 x \sin x\,\d x = -\int (1 - u^2)^2 u^2\,\d u = -\tfrac{1}{3}\cos^3 x + \tfrac{2}{5}\cos^5 x - \tfrac{1}{7}\cos^7 x + C.
$$

### Both powers even

When both powers are even, no single saved factor helps. Drop the exponent with
the half-angle identities

$$
\sin^2 x = \tfrac{1}{2}(1 - \cos 2x), \qquad \cos^2 x = \tfrac{1}{2}(1 + \cos 2x).
$$

For $\int \sin^2 x\,\d x = \tfrac{1}{2}\int (1 - \cos 2x)\,\d x = \tfrac{1}{2}\bigl(x - \tfrac{1}{2}\sin 2x\bigr) + C$.
A fourth power needs the identity twice. Writing $\sin^4 x = (\sin^2 x)^2$,

$$
\int \sin^4 x\,\d x = \tfrac{1}{4}\int (1 - \cos 2x)^2\,\d x = \tfrac{1}{4}\int \Bigl(\tfrac{3}{2} - 2\cos 2x + \tfrac{1}{2}\cos 4x\Bigr)\,\d x = \tfrac{1}{4}\Bigl(\tfrac{3}{2}x - \sin 2x + \tfrac{1}{8}\sin 4x\Bigr) + C,
$$

where the leftover $\cos^2 2x$ was reduced by a second half-angle step.

$$
% caption: An even power of sine averages to a constant: $\sin^2 x$ oscillates about its mean $\tfrac12$, so its integral contributes a term linear in $x$ plus a bounded oscillation.
\begin{tikzpicture}[scale=1.0,>=stealth,font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->,black] (-0.3,0) -- (6.9,0) node[right,black]{$x$};
\draw[->,black] (0,-0.3) -- (0,2.6) node[above,black]{$y$};
\draw[black,dashed] (0,1.0) -- (6.6,1.0);
\node[black,anchor=east,font=\footnotesize] at (-0.05,1.0){$\frac{1}{2}$};
\draw[acc,very thick] (0,0) .. controls (0.5,1.0) and (1.1,2.0) .. (1.57,2.0) .. controls (2.0,2.0) and (2.6,1.0) .. (3.14,0) .. controls (3.7,1.0) and (4.2,2.0) .. (4.71,2.0) .. controls (5.2,2.0) and (5.8,1.0) .. (6.28,0);
\node[acc,anchor=south,font=\footnotesize] at (1.57,2.06){$y=\sin^2x$};
\end{tikzpicture}
$$

$$
% caption: Routing $\int \sin^m x\cos^n x\,dx$: an odd power lets you save one factor and substitute; all-even powers force the half-angle identities.
\begin{tikzpicture}[>=stealth,font=\small,
  node distance=6mm,
  box/.style={draw,minimum width=34mm,minimum height=12mm,align=center,font=\footnotesize},
  root/.style={draw,draw=acc,minimum width=40mm,minimum height=12mm,align=center,font=\footnotesize}]
\definecolor{acc}{HTML}{4A6FA5}
\node[root] (r) at (0,0) {$\displaystyle\int \sin^m x\cos^n x\,dx$};
\node[box] (odd) at (-4.6,-2.4) {cosine power odd:\\save $\cos x$, put $u=\sin x$};
\node[box] (odd2) at (0,-2.4) {sine power odd:\\save $\sin x$, put $u=\cos x$};
\node[box] (even) at (4.6,-2.4) {both even:\\half-angle identities};
\draw[->,black,thick] (r) -- (odd);
\draw[->,black,thick] (r) -- (odd2);
\draw[->,black,thick] (r) -- (even);
\end{tikzpicture}
$$

> **Definition (Strategy for $\int \sin^m x\cos^n x\,\d x$).** If a power is odd,
> save one factor of that function, convert the remaining even power with
> $\sin^2 x + \cos^2 x = 1$, and substitute for the other function. If both
> powers are even, apply the half-angle identities to lower the exponents, then
> repeat.

## Powers of tangent and secant

The same tactic works for $\int \tan^m x \sec^n x\,\d x$, using
$\dfrac{\d}{\d x}\tan x = \sec^2 x$ and $\dfrac{\d}{\d x}\sec x = \sec x \tan x$ and the
identity $\sec^2 x = 1 + \tan^2 x$.

- **Even power of secant.** Save $\sec^2 x$, convert the rest to tangent, and
  substitute $u = \tan x$. For $\int \tan^6 x \sec^4 x\,\d x$,
  $$
  \int \tan^6 x (1 + \tan^2 x)\sec^2 x\,\d x = \int (u^6 + u^8)\,\d u = \tfrac{1}{7}\tan^7 x + \tfrac{1}{9}\tan^9 x + C.
  $$
- **Odd power of tangent.** Save $\sec x \tan x$, convert the remaining even
  power of tangent with $\tan^2 x = \sec^2 x - 1$, and substitute $u = \sec x$.

> **Worked example.** Evaluate $\int \tan^5 x \sec^7 x\,\d x$.
>
> Separating $\sec^2 x$ would leave $\sec^5 x$, which resists conversion. Instead
> save $\sec x \tan x$ and turn the even power $\tan^4 x = (\sec^2 x - 1)^2$ into
> secants, then substitute $u = \sec x$:
>
> $$
> \int \tan^4 x \sec^6 x (\sec x \tan x)\,\d x = \int (u^2 - 1)^2 u^6\,\d u = \int (u^{10} - 2u^8 + u^6)\,\d u.
> $$
>
> Integrating and restoring $u = \sec x$,
>
> $$
> \int \tan^5 x \sec^7 x\,\d x = \frac{1}{11}\sec^{11} x - \frac{2}{9}\sec^9 x + \frac{1}{7}\sec^7 x + C.
> $$

Two standard results are needed as building blocks. Integrating $\tan x$ gives a
logarithm, and secant is handled by a multiply-and-substitute trick:

$$
\int \tan x\,\d x = \ln|\sec x| + C, \qquad \int \sec x\,\d x = \ln|\sec x + \tan x| + C.
$$

The secant formula follows by multiplying the integrand by
$(\sec x + \tan x)/(\sec x + \tan x)$: the numerator becomes exactly the
derivative of the denominator. When an odd power of secant appears alone,
integration by parts produces a cyclic integral. For $\int \sec^3 x\,\d x$, take
$u = \sec x$, $\d v = \sec^2 x\,\d x$:

$$
\int \sec^3 x\,\d x = \sec x \tan x - \int \sec x \tan^2 x\,\d x = \sec x \tan x - \int \sec^3 x\,\d x + \int \sec x\,\d x,
$$

which solves to

$$
\int \sec^3 x\,\d x = \tfrac{1}{2}\bigl(\sec x \tan x + \ln|\sec x + \tan x|\bigr) + C.
$$

### Products of different frequencies

For $\int \sin mx \cos nx\,\d x$ and its cousins, the product-to-sum identities turn
a product into a sum of single trigonometric terms:

$$
\sin A \cos B = \tfrac{1}{2}\bigl[\sin(A-B) + \sin(A+B)\bigr],
$$

with matching identities for $\sin A \sin B$ and $\cos A \cos B$. For
$\int \sin 4x \cos 5x\,\d x = \tfrac{1}{2}\int (-\sin x + \sin 9x)\,\d x = \tfrac{1}{2}\bigl(\cos x - \tfrac{1}{9}\cos 9x\bigr) + C$.

| Integrand | First move | Then substitute |
| --- | --- | --- |
| $\sin^m x \cos^n x$, one power odd | save that factor, convert the rest | $u = $ the other function |
| $\sin^m x \cos^n x$, both even | half-angle identities | lower exponents, repeat |
| $\tan^m x \sec^n x$, $n$ even | save $\sec^2 x$ | $u = \tan x$ |
| $\tan^m x \sec^n x$, $m$ odd | save $\sec x \tan x$ | $u = \sec x$ |
| $\sin mx \cos nx$ (different frequencies) | product-to-sum identity | integrate term by term |

## Trigonometric substitution

Radicals of the form $\sqrt{a^2 - x^2}$, $\sqrt{a^2 + x^2}$, and
$\sqrt{x^2 - a^2}$ block both substitution and parts. Replacing $x$ by a
trigonometric function of a new variable clears the root through a Pythagorean
identity. The substitution runs backward from the usual direction: the old
variable $x$ becomes a function of the new one, called an **inverse
substitution**.

For $\sqrt{a^2 - x^2}$, set $x = a\sin\theta$ with
$-\tfrac{\pi}{2} \le \theta \le \tfrac{\pi}{2}$. Then

$$
\sqrt{a^2 - x^2} = \sqrt{a^2 - a^2\sin^2\theta} = \sqrt{a^2\cos^2\theta} = a\cos\theta,
$$

with $\cos\theta \ge 0$ on that interval, so the radical disappears. The
restriction on $\theta$ makes the substitution one-to-one, matching the range of
the inverse function needed to return to $x$.

> **Definition (Trigonometric substitutions).** To clear a quadratic radical,
> substitute according to its form, choosing $\theta$ in the range that makes
> the substitution invertible:
>
> - $\sqrt{a^2 - x^2}$: let $x = a\sin\theta$, using $1 - \sin^2\theta = \cos^2\theta$.
> - $\sqrt{a^2 + x^2}$: let $x = a\tan\theta$, using $1 + \tan^2\theta = \sec^2\theta$.
> - $\sqrt{x^2 - a^2}$: let $x = a\sec\theta$, using $\sec^2\theta - 1 = \tan^2\theta$.

Each substitution corresponds to a right triangle whose sides encode the
relation between $x$, $a$, and the radical. After integrating in $\theta$, the
triangle converts $\theta$ and every trigonometric function of it back to $x$.

$$
% caption: The three reference triangles. Each labels the two legs and hypotenuse so any function of the angle can be read directly in terms of $x$ and $a$.
\begin{tikzpicture}[>=stealth,font=\small]
\definecolor{acc}{HTML}{4A6FA5}
% triangle 1: sqrt(a^2 - x^2), x = a sin t
\begin{scope}[xshift=0cm]
  \draw[black,very thick] (0,0) -- (3,0) -- (3,2) -- cycle;
  \draw[black] (0.55,0) arc (0:33.7:0.55);
  \node[black,font=\footnotesize] at (0.95,0.2){$\theta$};
  \node[black,font=\footnotesize,anchor=north] at (1.5,0){$\sqrt{a^2-x^2}$};
  \node[black,font=\footnotesize,anchor=west] at (3,1){$x$};
  \node[black,font=\footnotesize,anchor=south east] at (1.5,1.05){$a$};
  \node[acc,font=\footnotesize] at (1.5,-0.8){$x=a\sin\theta$};
\end{scope}
% triangle 2: sqrt(a^2 + x^2), x = a tan t
\begin{scope}[xshift=5.2cm]
  \draw[black,very thick] (0,0) -- (3,0) -- (3,2) -- cycle;
  \draw[black] (0.55,0) arc (0:33.7:0.55);
  \node[black,font=\footnotesize] at (0.95,0.2){$\theta$};
  \node[black,font=\footnotesize,anchor=north] at (1.5,0){$a$};
  \node[black,font=\footnotesize,anchor=west] at (3,1){$x$};
  \node[black,font=\footnotesize,anchor=south east] at (1.5,1.05){$\sqrt{a^2+x^2}$};
  \node[acc,font=\footnotesize] at (1.5,-0.8){$x=a\tan\theta$};
\end{scope}
% triangle 3: sqrt(x^2 - a^2), x = a sec t
\begin{scope}[xshift=10.4cm]
  \draw[black,very thick] (0,0) -- (3,0) -- (3,2) -- cycle;
  \draw[black] (0.55,0) arc (0:33.7:0.55);
  \node[black,font=\footnotesize] at (0.95,0.2){$\theta$};
  \node[black,font=\footnotesize,anchor=north] at (1.5,0){$a$};
  \node[black,font=\footnotesize,anchor=west] at (3,1){$\sqrt{x^2-a^2}$};
  \node[black,font=\footnotesize,anchor=south east] at (1.5,1.05){$x$};
  \node[acc,font=\footnotesize] at (1.5,-0.8){$x=a\sec\theta$};
\end{scope}
\end{tikzpicture}
$$

### A sine substitution

The substitution mirrors the geometry of a circle: $x = a\sin\theta$ makes $x$ the
side opposite $\theta$, $a$ the hypotenuse (the radius), and $\sqrt{a^2 - x^2}$ the
adjacent side.

$$
% caption: The sine substitution read off a circle of radius $a$: with $x=a\sin\theta$, the opposite leg is $x$, the hypotenuse is the radius $a$, and the horizontal leg is $\sqrt{a^2-x^2}=a\cos\theta$.
\begin{tikzpicture}[scale=1.0,>=stealth,font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->,black] (-0.3,0) -- (4.3,0) node[right,black]{$x$};
\draw[->,black] (0,-0.3) -- (0,4.2) node[above,black]{$y$};
\draw[black,dashed] (3.6,0) arc (0:90:3.6);
\coordinate (O) at (0,0);
\coordinate (Q) at (2.4,0);
\coordinate (P) at (2.4,2.68);
\draw[acc,very thick] (O) -- (P);
\draw[acc,very thick] (Q) -- (P);
\draw[black] (O) -- (Q);
\draw[black] (2.15,0) -- (2.15,0.25) -- (2.4,0.25);
\draw[black] (0.62,0) arc (0:48:0.62);
\fill[acc] (P) circle (1.8pt);
\node[acc,anchor=west,font=\footnotesize] at (2.48,1.4){$x$};
\node[acc,anchor=south east,font=\footnotesize] at (1.25,1.4){$a$};
\node[black,font=\footnotesize,anchor=north] at (1.2,-0.04){adjacent};
\end{tikzpicture}
$$

> **Worked example.** Evaluate $\displaystyle\int \frac{\sqrt{9 - x^2}}{x^2}\,\d x$.
>
> The radical matches $\sqrt{a^2 - x^2}$ with $a = 3$, so set $x = 3\sin\theta$,
> $\d x = 3\cos\theta\,\d\theta$, and $\sqrt{9 - x^2} = 3\cos\theta$:
>
> $$
> \int \frac{3\cos\theta}{9\sin^2\theta}\,3\cos\theta\,\d\theta = \int \frac{\cos^2\theta}{\sin^2\theta}\,\d\theta = \int \cot^2\theta\,\d\theta = \int (\csc^2\theta - 1)\,\d\theta = -\cot\theta - \theta + C.
> $$
>
> The reference triangle for $\sin\theta = x/3$ has opposite $x$, hypotenuse $3$,
> adjacent $\sqrt{9 - x^2}$, so $\cot\theta = \sqrt{9 - x^2}/x$ and
> $\theta = \sin^{-1}(x/3)$:
>
> $$
> \int \frac{\sqrt{9 - x^2}}{x^2}\,\d x = -\frac{\sqrt{9 - x^2}}{x} - \sin^{-1}\!\Bigl(\frac{x}{3}\Bigr) + C.
> $$

### A tangent substitution

A denominator with $\sqrt{x^2 + a^2}$ calls for $x = a\tan\theta$.

> **Worked example.** Evaluate $\displaystyle\int \frac{\d x}{x^2\sqrt{x^2 + 4}}$.
>
> Set $x = 2\tan\theta$, so $\d x = 2\sec^2\theta\,\d\theta$ and
> $\sqrt{x^2 + 4} = 2\sec\theta$:
>
> $$
> \int \frac{2\sec^2\theta}{4\tan^2\theta \cdot 2\sec\theta}\,\d\theta = \frac{1}{4}\int \frac{\sec\theta}{\tan^2\theta}\,\d\theta = \frac{1}{4}\int \frac{\cos\theta}{\sin^2\theta}\,\d\theta.
> $$
>
> Substituting $u = \sin\theta$ gives $\tfrac{1}{4}\int u^{-2}\,\d u = -\tfrac{1}{4}\csc\theta$.
> The reference triangle for $\tan\theta = x/2$ has $\csc\theta = \sqrt{x^2+4}/x$, so
>
> $$
> \int \frac{\d x}{x^2\sqrt{x^2 + 4}} = -\frac{\sqrt{x^2 + 4}}{4x} + C.
> $$

### A secant substitution

For $\displaystyle\int \frac{\d x}{\sqrt{x^2 - a^2}}$ with $a > 0$, set
$x = a\sec\theta$, $\d x = a\sec\theta\tan\theta\,\d\theta$, and
$\sqrt{x^2 - a^2} = a\tan\theta$:

$$
\int \frac{a\sec\theta\tan\theta}{a\tan\theta}\,\d\theta = \int \sec\theta\,\d\theta = \ln|\sec\theta + \tan\theta| + C.
$$

The triangle gives $\sec\theta = x/a$ and $\tan\theta = \sqrt{x^2 - a^2}/a$, so

$$
\int \frac{\d x}{\sqrt{x^2 - a^2}} = \ln\bigl|x + \sqrt{x^2 - a^2}\bigr| + C,
$$

after absorbing the constant $-\ln a$ into $C$. Not every quadratic radical needs
trigonometry: $\int x/\sqrt{x^2 + 4}\,\d x$ has the extra $x$ that makes the plain
substitution $u = x^2 + 4$ simpler. Reach for a trigonometric substitution only
when the direct one fails.

### Completing the square

A radical like $\sqrt{3 - 2x - x^2}$ is not yet in standard form, but completing
the square turns it into one:

$$
3 - 2x - x^2 = 4 - (x + 1)^2.
$$

The substitution $u = x + 1$ reduces $\sqrt{4 - (x+1)^2}$ to $\sqrt{4 - u^2}$,
which then takes $u = 2\sin\theta$. Completing the square routes any
$\sqrt{ax^2 + bx + c}$ into one of the three standard radicals.

> **Worked example.** Evaluate $\displaystyle\int \frac{x}{\sqrt{3 - 2x - x^2}}\,\d x$.
>
> Complete the square, then shift with $u = x + 1$ (so $x = u - 1$, $\d x = \d u$):
>
> $$
> \int \frac{x}{\sqrt{4 - (x+1)^2}}\,\d x = \int \frac{u - 1}{\sqrt{4 - u^2}}\,\d u = \int \frac{u}{\sqrt{4 - u^2}}\,\d u - \int \frac{\d u}{\sqrt{4 - u^2}}.
> $$
>
> The first integral is a plain substitution $w = 4 - u^2$, giving $-\sqrt{4 - u^2}$;
> the second is the arcsine form $\sin^{-1}(u/2)$. Restoring $u = x + 1$,
>
> $$
> \int \frac{x}{\sqrt{3 - 2x - x^2}}\,\d x = -\sqrt{3 - 2x - x^2} - \sin^{-1}\!\Bigl(\frac{x + 1}{2}\Bigr) + C.
> $$

### The area of an ellipse

Trigonometric substitution recovers the area of an ellipse
$\dfrac{x^2}{a^2} + \dfrac{y^2}{b^2} = 1$. Solving for $y$ in the first quadrant
gives $y = \tfrac{b}{a}\sqrt{a^2 - x^2}$, and by symmetry the total area is four
times the first-quadrant piece:

$$
A = 4\int_0^a \frac{b}{a}\sqrt{a^2 - x^2}\,\d x.
$$

Substituting $x = a\sin\theta$ (so $\d x = a\cos\theta\,\d\theta$) and changing the
limits to $\theta = 0$ and $\theta = \tfrac{\pi}{2}$,

$$
A = 4ab\int_0^{\pi/2} \cos^2\theta\,\d\theta = 4ab \cdot \frac{\pi}{4} = \pi ab.
$$

Setting $a = b = r$ gives the area of a circle, $\pi r^2$.

$$
% caption: The first-quadrant quarter of the ellipse; $x=a\sin\theta$ sweeps the angle from $0$ to $\pi/2$, and the shaded quarter integrates to $\tfrac14\pi ab$.
\begin{tikzpicture}[scale=1.0,>=stealth,font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\fill[acc!10] (0,0) -- (3.6,0) arc (0:90:3.6 and 2.4) -- (0,0);
\draw[->,black] (-0.3,0) -- (4.3,0) node[right,black]{$x$};
\draw[->,black] (0,-0.3) -- (0,3.1) node[above,black]{$y$};
\draw[acc,very thick] (3.6,0) arc (0:90:3.6 and 2.4);
\node[below,black] at (3.6,0){$a$};
\node[left,black] at (0,2.4){$b$};
\draw[black,dashed] (0,0) -- (2.55,1.70);
\draw[black] (0.5,0) arc (0:33.7:0.5);
\node[black,font=\footnotesize] at (0.85,0.18){$\theta$};
\end{tikzpicture}
$$

## Which technique

Trigonometric integrals and trigonometric substitution run in opposite
directions. The first removes trigonometric functions by converting an
integrand to a polynomial in $\sin x$ or $\tan x$; the second introduces
trigonometric functions to remove a radical. Both use the same three
Pythagorean identities, read in whichever direction the integrand requires.
Ratios of polynomials, the remaining large class of elementary integrands, yield
to the
[partial-fraction method](/calculus/techniques-of-integration/partial-fractions-and-integration-strategy).[^trigint][^trigsub]

[^trigint]: **Stewart**, _Calculus_, §7.2 — Trigonometric Integrals: the odd/even-power strategies for sine and cosine, the tangent-secant cases, and the product-to-sum identities.
[^trigsub]: **Stewart**, _Calculus_, §7.3 — Trigonometric Substitution: the three inverse substitutions, the reference-triangle back-substitution, and completing the square.
