# Trigonometric Integrals

In this section, we'll revisit u-substitution, but specifically for trigonometric functions.

Specifically, we'll solve problems of the form $\int \sin^m x\ \cos^n x\ dx$ and $\int \sec^m x\ \tan^n x\ dx.$

To do all the examples in this section, we'll need to review some trig identities, as well as trig derivatives, but before we do, we'll start with a few simple examples.

Evaluate $\displaystyle\int \sin^2 x\ \cos x \ dx$.

### Solution

If we let $u=\sin x$, then $du = \cos x\ dx$, so \begin{aligned} \int \sin^2 x\ \cos x \ dx &= \int u^2 \ du\ &= \dfrac{1}{3}u^3 + C\ &= \ans{\dfrac{1}{3}\sin^3 x + C} \end{aligned}

Evaluate $\displaystyle\int \dfrac{\sin x}{\cos^4 x}\ dx$.

### Solution

This time, let $u=\cos x$ so that $du = -\sin x \ dx$, or $-du = \sin x \ dx$.

Then \begin{aligned} \int \dfrac{\sin x}{\cos^4 x} \ dx &= \int -\dfrac{1}{u^4} \ du\ &= \int -u^{-4}\ du\ &= \dfrac{1}{3}u^{-3} + C\ &= \ans{\dfrac{1}{3 \cos^3 x} + C} \end{aligned}

Evaluate $\displaystyle\int \tan x\ dx$.

### Solution

Once we rewrite $\tan x$ as $\dfrac{\sin x}{\cos x}$, this problem looks a lot like the previous one.

We can let $u=\cos x$ again, so that $-du = \sin x \ dx$: \begin{aligned} \int \tan x\ dx = \int \dfrac{\sin x}{\cos x} \ dx &= \int -\dfrac{1}{u} \ du\ &= -\ln u + C\ &= \ans{-\ln |\cos x| + C} \end{aligned}

Before we do more examples, let's review a few trigonometric identities.

## Reviewing Identities

The most important trigonometric identity of all is $\sin^2 x + \cos^2 x = 1$

Dividing that identity by $\cos^2 x$ gives another variation: $\tan^2 x + 1 = \sec^2 x$

Besides that, we need the half-angle identities: \begin{aligned} \sin^2 x &= \dfrac{1}{2}-\dfrac{1}{2}\cos(2x)\ \cos^2 x &= \dfrac{1}{2}+\dfrac{1}{2}\cos(2x) \end{aligned}

Finally, recall the following derivatives: \begin{aligned} \dfrac{d}{dx}[\sec x] &= \sec x \tan x\ \dfrac{d}{dx}[\tan x] &= \sec^2 x \end{aligned}

## $\displaystyle\int \sin^m x\ \cos^n x\ dx$

In this form, $u$ will either be the sine or cosine function; we just need to figure out which one.

Take a look at the first examples we did: we want $du$ to be the one that appears once. For instance, to evaluate $\int \sin^2 x\ \cos x\ dx$ we would want $\cos x$ to be $du$, so we'd let $u=\sin x$. On the other hand, to evaluate $\int \sin x\ \cos^2 x\ dx$ we would let $u=\cos x$ so that $du$ would involve $\sin x$.

What about $\int \sin^3 x\ \cos^2 x\ dx?$

If $u=\sin x$ and $du=\cos x\ dx$, there would be a leftover $\cos x$ after substituting, which is a problem. On the other hand, if $u=\cos x$ and $-du = \sin x \ dx$, after substituting we'd have $\int -\sin^2 x\ u^2\ du$

We can deal with this leftover $\sin^2 x$ by using the identity $\sin^2 x + \cos^2 x = 1$ $\int -(1-\cos^2 x) u^2\ du = \int -(1-u^2)u^2\ du$

Finally, we can integrate this: \begin{aligned} \int -u^2+u^4\ du &= -\dfrac{1}{3}u^3+\dfrac{1}{5}u^5 + C\ &= -\dfrac{1}{3}\cos^3 x + \dfrac{1}{5}\cos^5 x + C \end{aligned}

Evaluate $\displaystyle\int \sin^2 x\ \cos^3 x\ dx$.

### Solution

Following what we just saw, we want to split off a single $\cos x$ - that'll serve as $du$ eventually, and the leftover $\cos^2 x$ can be replaced with $1-\sin^2 x$. \begin{aligned} \int \sin^2 x\ \cos^3 x\ dx &= \int \sin^2 x\ \cos^2 x\ \cos x\ dx\ &= \int \sin^2 x\ (1-\sin^2 x)\ \cos x\ dx \end{aligned}

Now let $u=\sin x$ so that $du = \cos x \ dx$. \begin{aligned} \int \sin^2 x\ (1-\sin^2 x)\ \cos x\ dx &= \int u^2(1-u^2)\ du\ &= \int u^2-u^4\ du\ &= \dfrac{1}{3}u^3 - \dfrac{1}{5}u^5 + C\ &= \ans{\dfrac{1}{3}\sin^3 x - \dfrac{1}{5}\sin^5 x + C} \end{aligned}

Evaluate $\displaystyle\int \sin^3 x\ dx$.

### Solution

This time, split off a $\sin x$; the remaining $\sin^2 x$ can be rewritten in terms of $\cos x$ and we'll make $u=\cos x$.

\begin{aligned} \int \sin^3 x\ dx &= \int \sin^2 x\ \sin x\ dx\ &= \int (1-\cos^2 x) \ \sin x\ dx\ &= \int -(1-u^2)\ du\ &= \int -1+u^2\ du\ &= -u + \dfrac{1}{3}u^3 + C\ &= \ans{-\cos x + \dfrac{1}{3}\cos^3 x + C} \end{aligned}

### Conclusion: how to integrate $\displaystyle\int \sin^m x\ \cos^n x\ dx$

• If one of the powers ($m$ or $n$) is odd:
• Split off one copy of that function ($\sin$ or $\cos$)
• Use $\sin^2 x + \cos^2 x = 1$ to rewrite everything else in terms of the other function
• Use u-substitution to integrate (the one you split off will be part of $du$)
• If both powers are even
• Use half-angle identities to rewrite everything in terms of $\cos (2x)$
• Use u-substitution to integrate, with $u=2x$

## Even Powers

Evaluate $\displaystyle\int \cos^2 x\ dx$.

### Solution

This one only has an even power, so we need to use a half-angle identity. Remember that $\cos^2 x = \dfrac{1}{2} + \dfrac{1}{2}\cos(2x),$ so we can rewrite the integral as $\int \dfrac{1}{2} + \dfrac{1}{2}\cos(2x)\ dx.$

The first part we can deal with directly, and for the second part, we can use u-substitution, with $u=2x$. Since $\int \cos (2x)\ dx = \dfrac{1}{2}\sin (2x),$ we can get the final answer:

\begin{aligned} \int \cos^2 x\ dx &= \int \dfrac{1}{2} + \dfrac{1}{2}\cos (2x) \ dx\ &= \ans{\dfrac{1}{2}x + \dfrac{1}{4}\sin(2x) + C} \end{aligned}

1. $\displaystyle\int \sin^3 x\ \cos^2 x\ dx$

2. Let $u=\cos x \longrightarrow -du = \sin x\ dx$

\begin{aligned} \int \sin^3 x \ \cos^2 x \ dx &= \int \sin^2 x \ \cos^2 x \ \sin x \ dx\ &= \int (1-\cos^2 x) \ \cos^2 x \ \sin x \ dx\ &= \int -(1-u^2)u^2\ du\ &= \int -u^2+u^4\ du\ &= -\dfrac{1}{3}u^3 + \dfrac{1}{5}u^5 + C\ &= \ans{-\dfrac{1}{3}\cos^3 x + \dfrac{1}{5}\cos^5 x + C} \end{aligned}

3. $\displaystyle\int \cos^5 (\pi x)\ dx$

4. Let $u=\sin (\pi x) \longrightarrow \dfrac{1}{\pi}du = \cos (\pi x)\ dx$

\begin{aligned} \int \cos^5 (\pi x) \ dx &= \int \cos^2 (\pi x) \ \cos^2 (\pi x) \ \cos (\pi x) \ dx\ &= \int (1-\sin^2 (\pi x)) (1-\sin^2 (\pi x)) \ \cos (\pi x) \ dx\ &= \int \dfrac{1}{\pi}(1-u^2)(1-u^2)\ du\ &= \int \dfrac{1}{pi}-\dfrac{2}{\pi}u^2+\dfrac{1}{\pi}u^4\ du\ &= \dfrac{1}{\pi}u - \dfrac{2}{3\pi}u^3 + \dfrac{1}{5\pi}u^5 + C\ &= \ans{\dfrac{1}{\pi}\sin(\pi x) - \dfrac{2}{3\pi} \sin^3 (\pi x) + \dfrac{1}{5\pi}\sin^5 (\pi x) + C} \end{aligned}

5. $\displaystyle\int \sin^2 x\ \cos^2 x\ dx$

6. \begin{aligned} \int \sin^2 x\ \cos^2 x\ dx &= \int \left(\dfrac{1}{2} - \dfrac{1}{2}\cos(2x)\right)\left(\dfrac{1}{2} + \dfrac{1}{2}\cos(2x)\right)\ dx\ &= \int \dfrac{1}{4} - \dfrac{1}{4}\cos^2(2x)\ dx\ &= \int \dfrac{1}{4} - \dfrac{1}{4}\left(\dfrac{1}{2} + \dfrac{1}{2}\cos(4x)\right)\ dx\ &= \int \dfrac{1}{8} - \dfrac{1}{8}\cos(4x)\ dx\ &= \ans{\dfrac{1}{8}x - \dfrac{1}{32} \sin (4x) + C} \end{aligned}

7. $\displaystyle\int \sin^2 (2\theta)\ d\theta$

8. \begin{aligned} \int \sin^2 (2\theta)\ d\theta &= \int \dfrac{1}{2} - \dfrac{1}{2} \cos (4\theta)\ d\theta\ &= \ans{\dfrac{1}{2}\theta - \dfrac{1}{8} \sin (4\theta) + C} \end{aligned}

## $\displaystyle\int \tan^m x\ \sec^n x\ dx$

These examples will work similarly. Just like sine and cosine are a matched pair of derivatives, secant and tangent match each other's derivatives: \begin{aligned} \dfrac{d}{dx}[\sec x] &= \sec x \ \tan x\ \dfrac{d}{dx}[\tan x] &= \sec^2 x \end{aligned}

We're either going to make $u=\sec x$, in which case $du = \sec x \ \tan x \ dx$, or we'll make $u=\tan x$, so that $du = \sec^2 x$.

Thus, we'll either split off $\sec x \ \tan x$ or $\sec^2 x$ to serve as $du$, then rewrite the rest of the integral in terms of the appropriate function.

This boils down to the following:

### Conclusion: how to integrate $\displaystyle\int \tan^m x \ \sec^n x \ dx$

• If $n$ is even:

• Let $u=\tan x$ and $du = \sec^2 x \ dx$
• Pull out $\sec^2 x$ and rewrite everything else in terms of $\tan x$ by using the identity $\tan^2 x = \sec^2 x - 1$
• If $m$ is odd:

• Let $u = \sec x$ and $du = \sec x \ \tan x \ dx$
• Pull out $\sec x \ \tan x$ and rewrite everything else in terms of $\sec x$ by using the identity $\sec^2 x = 1 + \tan^2 x$
• Otherwise, try rewriting the integral in terms of sine and cosine functions.

Evaluate $\displaystyle\int \tan^6 x \ \sec^4 x\ dx$.

### Solution

The power of secant is even, so let $u=\tan x \longrightarrow du = \sec^2 x \ dx$.

\begin{aligned} \int \tan^6 x \ \sec^4 x \ dx &= \int \tan^6 x \ \sec^2 x \ \sec^2 x \ dx\ &= \int \tan^6 x \ (1+\tan^2 x) \ \sec^2 x \ dx\ &= \int u^6(1+u^2) \ du\ &= \int u^6 + u^8 \ du\ &= \dfrac{1}{7}u^7 + \dfrac{1}{9}u^9 + C\ &= \ans{\dfrac{1}{7}\tan^7 x + \dfrac{1}{9}\tan^9 x + C} \end{aligned}

Evaluate $\displaystyle\int \sec^2 x \ \tan x \ dx$.

This one has both an even power of secant and an odd power of tangent, so we can actually solve it either way.

### Solution 1

Let $u=\tan x$, so $du=\sec^2 x\ dx$. \begin{aligned} \int \sec^2 x \ \tan x \ dx &= \int u \ du\ &= \dfrac{1}{2}u^2 + C\ &= \ans{\dfrac{1}{2}\tan^2 x + C} \end{aligned}

### Solution 2

Let $u = \sec x$, so $du = \sec x \ \tan x \ dx$. \begin{aligned} \int \sec^2 x \ \tan x \ dx &= \int u \ du\ &= \dfrac{1}{2}u^2 + C\ &= \ans{\dfrac{1}{2}\sec^2 x + C} \end{aligned}

That's odd: we got two different answers, but if we did everything correctly, both solutions should end up with the same answer. So what's the deal?

Remember, based on the identity $1 + \tan^2 x = \sec^2 x$ the only difference between $\tan^2 x$ and $\sec^2 x$ is a constant. The arbitrary constants in the answers absorb that difference.

1. $\displaystyle\int \tan^5 x \ \sec^7 x \ dx$

2. Let $u=\sec x \longrightarrow du = \sec x \ \tan x \ dx$ \begin{aligned} \int \tan^5 x \ \sec^7 x \ dx &= \int \tan^4 x \ \sec^6 x \ \sec x \ \tan x \ dx\ &= \int (\sec^2 x - 1)^2 \ \sec^6 x \ \sec x \ \tan x \ dx\ &= \int (u^2-1)^2 u^6 \ du\ &= \int u^{10}-2u^8+u^6 \ du\ &= \dfrac{1}{11}u^{11} - \dfrac{2}{9}u^9 + \dfrac{1}{7}u^7 + C\ &= \ans{\dfrac{1}{11}\sec^{11} x - \dfrac{2}{9}\sec^9 x + \dfrac{1}{7}\sec^7 x + C} \end{aligned}

3. $\displaystyle\int \tan^5 x \ \sec^4 x \ dx$

4. Let $u=\tan x \longrightarrow du = \sec^2 x \ dx$ \begin{aligned} \int \tan^5 x \ \sec^4 x \ dx &= \int \tan^5 x \ \sec^2 x \ \sec^2 x \ dx\ &= \int \tan^5 x \ (\tan^2 x + 1) \ \sec^2 x \ dx\ &= \int u^5(u^2+1) \ du\ &= \int u^7+u^5 \ du\ &= \dfrac{1}{8}u^{8} + \dfrac{1}{6}u^6 + C\ &= \ans{\dfrac{1}{8}\tan^{8} x + \dfrac{1}{6}\tan^6 x + C} \end{aligned}

5. $\displaystyle\int \sec^6 t \ dt$

6. Let $u=\tan t \longrightarrow du = \sec^2 t \ dt$ \begin{aligned} \int \sec^6 t \ dt &= \int \sec^4 t \ \sec^2 t \ dt\ &= \int (\tan^2 t + 1)^2 \ \sec^2 t \ dt\ &= \int (u^2+1)^2 \ du\ &= \int u^4+2u^2+1 \ du\ &= \dfrac{1}{5}u^{5} + \dfrac{2}{3}u^3 + u + C\ &= \ans{\dfrac{1}{5}\tan^{5} t + \dfrac{2}{3}\tan^3 t + \tan t + C} \end{aligned}