# 1.8: Trigonometric Integrals

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

Integrals of polynomials of the trigonometric functions $$\sin x\text{,}$$ $$\cos x\text{,}$$ $$\tan x$$ and so on, are generally evaluated by using a combination of simple substitutions and trigonometric identities. There are of course a very large number 1 of trigonometric identities, but usually we use only a handful of them. The most important three are:

##### Equation 1.8.1
\begin{align*} \sin^2 x +\cos^2 x &= 1 \end{align*}
##### Equation 1.8.2
\begin{align*} \sin(2x)&=2\sin x\cos x \end{align*}
##### Equation 1.8.3
\begin{align*} \cos(2x)&=\cos^2 x - \sin^2 x\\ &=2\cos^2 x - 1\\ &=1-2\sin^2 x \end{align*}

Notice that the last two lines of Equation 1.8.3 follow from the first line by replacing either $$\sin^2x$$ or $$\cos^2x$$ using Equation 1.8.1. It is also useful to rewrite these last two lines:

##### Equation 1.8.4
\begin{align*} \sin^2 x &= \frac{1-\cos(2x)}{2} \end{align*}
##### Equation 1.8.5
\begin{align*} \cos^2 x &= \frac{1+\cos(2x)}{2} \end{align*}

These last two are particularly useful since they allow us to rewrite higher powers of sine and cosine in terms of lower powers. For example:

\begin{align*} \sin^4(x) &= \left[ \frac{1-\cos(2x)}{2} \right]^2 &\text{by Equation }{\text{1.8.4}}\\ &= \frac{1}{4} - \frac{1}{2} \cos(2x) + \frac{1}{4}\underbrace{\cos^2(2x)}_{\text{do it again}} & \text{use Equation }{\text{1.8.5}}\\ &= \frac{1}{4} - \frac{1}{2} \cos(2x) + \frac{1}{8}\left(1 + \cos(4x) \right)\\ &= \frac{3}{8} - \frac{1}{2} \cos(2x) + \frac{1}{8}\cos(4x) \end{align*}

So while it was hard to integrate $$\sin^4(x)$$ directly, the final expression is quite straightforward (with a little substitution rule).

There are many such tricks for integrating powers of trigonometric functions. Here we concentrate on two families

\begin{align*} \int \sin^mx \cos^nx \, d{x} &&\text{and}&& \int \tan^mx \sec^nx \, d{x} \end{align*}

for integer $$n,m\text{.}$$ The details of the technique depend on the parity of $$n$$ and $$m$$ — that is, whether $$n$$ and $$m$$ are even or odd numbers.

## Integrating $$\int \sin^m x\cos^n x\, d{x}$$

### One of $$n$$ and $$m$$ is odd

Consider the integral $$\int \sin^2x \cos x\, d{x}\text{.}$$ We can integrate this by substituting $$u=\sin x$$ and $$\, d{u}=\cos x \, d{x}\text{.}$$ This gives

\begin{align*} \int \sin^2x \cos x\, d{x} &= \int u^2 \, d{u}\\ &= \frac{1}{3}u^3+C = \frac{1}{3}\sin^3x +C \end{align*}

This method can be used whenever $$n$$ is an odd integer.

• Substitute $$u=\sin x$$ and $$\, d{u}=\cos x\, d{x}\text{.}$$
• This leaves an even power of cosines — convert them using $$\cos^2x = 1-\sin^2x = 1-u^2\text{.}$$

Here is an example.

##### Example 1.8.6 $$\int \sin^2 x\cos^3 x\, d{x}$$

Start by factoring off one power of $$\cos x$$ to combine with $$dx$$ to get $$\cos x\, d{x}=\, d{u}\text{.}$$

\begin{align*} \int \sin^2 x\cos^3 x\, d{x} &= \int \underbrace{\sin^2 x}_{=u^2}\underbrace{\cos^2 x}_{=1-u^2}\ \underbrace{\cos x\, d{x}}_{=\, d{u}} & \text{set $u=\sin x$}\\ &= \int u^2\ (1-u^2)\, d{u}\\ &=\frac{u^3}{3}-\frac{u^5}{5}+C\\ &=\frac{\sin^3x}{3}-\frac{\sin^5x}{5}+C \end{align*}

Of course if $$m$$ is an odd integer we can use the same strategy with the roles of $$\sin x$$ and $$\cos x$$ exchanged. That is, we substitute $$u=\cos x\text{,}$$ $$\, d{u}=-\sin x\, d{x}$$ and $$\sin^2 x=1-\cos^2x=1-u^2\text{.}$$

### Both $$n$$ and $$m$$ are even

If $$m$$ and $$n$$ are both even, the strategy is to use the trig identities 1.8.4 and 1.8.5 to get back to the $$m$$ or $$n$$ odd case. This is typically more laborious than the previous case we studied. Here are a couple of examples that arise quite commonly in applications.

##### Example 1.8.7 $$\int \cos^2 x\, d{x}$$

By 1.8.5

$\int \cos^2 x\, d{x} = \frac{1}{2}\int \big[1+\cos(2x)\big]\, d{x} = \frac{1}{2} \Big[x+\frac{1}{2}\sin(2x)\Big] + C \nonumber$

##### Example 1.8.8 $$\int \cos^4 x\, d{x}$$

First we'll prepare the integrand $$\cos^4x$$ for easy integration by applying 1.8.5 a couple times. We have already used 1.8.5 once to get

\begin{gather*} \cos^2 x = \frac{1}{2} \big[1+\cos(2x)\big] \end{gather*}

Squaring it gives

\begin{gather*} \cos^4 x = \frac{1}{4} \big[1+\cos(2x)\big]^2 = \frac{1}{4}+\frac{1}{2}\cos(2x)+\frac{1}{4}\cos^2(2x) \end{gather*}

Now by 1.8.5 a second time

\begin{align*} \cos^4 x &= \frac{1}{4}+\frac{1}{2}\cos(2x)+\frac{1}{4}\ \frac{1+\cos(4x)}{2}\\ &=\frac{3}{8}+\frac{1}{2}\cos(2x)+\frac{1}{8}\cos(4x) \end{align*}

Now it's easy to integrate

\begin{align*} \int \cos^4 x\, d{x} &= \frac{3}{8}\int dx+\frac{1}{2}\int\cos(2x)\, d{x}+\frac{1}{8}\int\cos(4x)\, d{x}\\ &= \frac{3}{8}x+\frac{1}{4}\sin(2x)+\frac{1}{32}\sin(4x) + C \end{align*}

##### Example 1.8.9 $$\int \cos^2x \sin^2x\, d{x}$$

Here we apply both 1.8.4 and 1.8.5.

\begin{align*} \int \cos^2x \sin^2x\, d{x} &= \frac{1}{4} \int \big[1+\cos(2x)\big] \big[1-\cos(2x)\big] \, d{x}\\ &= \frac{1}{4} \int \big[ 1-\cos^2(2x) \big] \, d{x}\\ \end{align*}

We can then apply 1.8.5 again

\begin{align*} &= \frac{1}{4} \int \big[ 1- \frac{1}{2}\left(1+ \cos(4x)\right) \big] \, d{x}\\ &= \frac{1}{8}\int \big[1 - \cos(4x)\big] \, d{x}\\ &= \frac{1}{8}x -\frac{1}{32}\sin(4x) +C \end{align*}

Oof! We could also have done this one using 1.8.2 to write the integrand as $$\sin^2(2x)$$ and then used 1.8.4 to write it in terms of $$\cos(4x)\text{.}$$

##### Example 1.8.10 $$\int_0^\pi \cos^2 x\, d{x}$$ and $$\int_0^\pi \sin^2 x\, d{x}$$

Of course we can compute the definite integral $$\int_0^\pi \cos^2 x\, d{x}$$ by using the antiderivative for $$\cos^2 x$$ that we found in Example 1.8.7. But here is a trickier way to evaluate that integral, and also the integral $$\int_0^\pi \sin^2 x\, d{x}$$ at the same time, very quickly without needing the antiderivative of Example 1.8.7.

Solution

• Observe that $$\int_0^\pi \cos^2 x\, d{x}$$ and $$\int_0^\pi \sin^2 x\, d{x}$$ are equal because they represent the same area — look at the graphs below — the darkly shaded regions in the two graphs have the same area and the lightly shaded regions in the two graphs have the same area.
• Consequently,

\begin{align*} \int_0^\pi \cos^2 x\, d{x} = \int_0^\pi \sin^2 x\, d{x} &= \frac{1}{2}\bigg[\int_0^\pi \sin^2 x\, d{x} +\int_0^\pi \cos^2 x\, d{x}\bigg]\\ &=\frac{1}{2}\int_0^\pi \big[\sin^2 x+ \cos^2 x\big]\, d{x}\\ &= \frac{1}{2}\int_0^\pi dx\\ &=\frac{\pi}{2} \end{align*}

## Integrating $$\int \tan^m x\sec^n x\, d{x}$$

The strategy for dealing with these integrals is similar to the strategy that we used to evaluate integrals of the form $$\int \sin^m x\cos^n x\, d{x}$$ and again depends on the parity of the exponents $$n$$ and $$m\text{.}$$ It uses 2

\begin{align*} \frac{d}{dx}\tan x &= \sec^2 x & \frac{d}{dx}\sec x &= \sec x\,\tan x & 1+\tan^2x &= \sec^2 x \end{align*}

We split the methods for integrating $$\int \tan^m x\sec^n x\, d{x}$$ into 5 cases which we list below. These will become much more clear after an example (or two).

1. When $$m$$ is odd and any $$n$$ — rewrite the integrand in terms of $$\sin x$$ and $$\cos x\text{:}$$

\begin{align*} \tan^m x\,\sec^n x\, d{x} &=\left(\frac{\sin x}{\cos x}\right)^m \left(\frac{1}{\cos x}\right)^n\, d{x}\\ &=\frac{\sin^{m-1}x}{\cos^{n+m}x}\ \sin x\, d{x} \end{align*}

and then substitute $$u=\cos x\text{,}$$ $$\, d{u} = -\sin x\, d{x}\text{,}$$ $$\sin^2x = 1-\cos^2x=1-u^2\text{.}$$ See Examples 1.8.11 and 1.8.12.
2. Alternatively, if $$m$$ is odd and $$n \geq 1$$ move one factor of $$\sec x\,\tan x$$ to the side so that you can see $$\sec x\,\tan x\, d{x}$$ in the integral, and substitute $$u=\sec x\text{,}$$ $$\, d{u}=\sec x\,\tan x\,\, d{x}$$ and $$\tan^2 x = \sec^2 x-1=u^2-1\text{.}$$ See Example 1.8.13.
3. If $$n$$ is even with $$n\ge 2\text{,}$$ move one factor of $$\sec^2 x$$ to the side so that you can see $$\sec^2 x\, d{x}$$ in the integral, and substitute $$u=\tan x\text{,}$$ $$\, d{u}=\sec^2 x\,\, d{x}$$ and $$\sec^2 x = 1+\tan^2 x=1+u^2\text{.}$$ See Example 1.8.14.
4. When $$m$$ is even and $$n=0$$ — that is the integrand is just an even power of tangent — we can still use the $$u=\tan x$$ substitution, after using $$\tan^2x = \sec^2 x - 1$$ (possibly more than once) to create a $$\sec^2 x\text{.}$$ See Example 1.8.16.
5. This leaves the case $$n$$ odd and $$m$$ even. There are strategies like those above for treating this case. But they are more complicated and also involve more tricks (that basically have to be memorized). Examples using them are provided in the optional section entitled “Integrating $$\sec x\text{,}$$ $$\csc x\text{,}$$ $$\sec^3 x$$ and $$\csc^3 x$$”, below. A more straight forward strategy uses another technique called “partial fractions”. We shall return to this strategy after we have learned about partial fractions. See Example 1.10.5 and 1.10.6 in Section 1.10.

### $$m$$ is odd — odd power of tangent

In this case we rewrite the integrand in terms of sine and cosine and then substitute $$u=\cos x, \, d{u}=-\sin x \, d{x}\text{.}$$

##### Example 1.8.11 $$\int \tan x\, d{x}$$

Solution

• Write the integrand $$\tan x=\frac{1}{\cos x}\sin x\text{.}$$
• Now substitute $$u=\cos x\text{,}$$ $$\, d{u}=-\sin x\,\, d{x}$$ just as we did in treating integrands of the form $$\sin^mx\,\cos^nx$$ with $$m$$ odd.

\begin{align*} \int \tan x\,\, d{x} &=\int \frac{1}{\cos x}\sin x\,\, d{x} \qquad\qquad\qquad \text{substitute $u=\cos x$}\\ &=\int \frac{1}{u} \cdot(-1) \, d{u}\\ &=-\log|u|+C\\ &=-\log\left|\cos x\right|+C \qquad\qquad \text{can also write in terms of secant}\\ &=\log\left|\cos x\right|^{-1}+C =\log\left|\sec x\right|+C \end{align*}

##### Example 1.8.12 $$\int \tan^3 x\, d{x}$$

Solution

• Write the integrand $$\tan^3 x=\frac{\sin^2x}{\cos^3 x}\sin x\text{.}$$
• Again substitute $$u=\cos x\text{,}$$ $$\, d{u}=-\sin x\,\, d{x}\text{.}$$ We rewrite the remaining even powers of $$\sin x$$ using $$\sin^2x=1-\cos^2x=1-u^2\text{.}$$
• Hence

\begin{align*} \int \tan^3 x\,\, d{x} &=\int \frac{\sin^2x}{\cos^3x}\sin x\,\, d{x} \qquad \text{substitute $u=\cos x$}\\ &=\int \frac{1-u^2}{u^3} (-1) \, d{u}\\ &=\frac{u^{-2}}{2}+\log|u|+C\\ &=\frac{1}{2 \cos^2 x}+\log\left|\cos x\right|+C \qquad \text{rewrite in terms of secant}\\ &= \frac{1}{2}\sec^2 x - \log\left|\sec x\right|+C \end{align*}

### $$m$$ is odd and $$n\geq 1$$ — odd power of tangent and at least one secant

Here we collect a factor of $$\tan x \sec x$$ and then substitute $$u = \sec x$$ and $$\, d{u} = \sec x \tan x \, d{x}\text{.}$$ We can then rewrite any remaining even powers of $$tan x$$ in terms of $$\sec x$$ using $$\tan^2x = \sec^2 x-1=u^2-1\text{.}$$

##### Example 1.8.13 $$\int \tan^3 x\sec^4 x\, d{x}$$

Solution

• Start by factoring off one copy of $$\sec x\tan x$$ and combine it with $$dx$$ to form $$\sec x\tan x\, d{x}\text{,}$$ which will be $$\, d{u}\text{.}$$
• Now substitute $$u=\sec x\text{,}$$ $$\, d{u}=\sec x\tan x\, d{x}$$ and $$\tan^2x = \sec^2 x-1=u^2-1\text{.}$$
• This gives

\begin{align*} \int \tan^3x \sec^4 x\, d{x} &= \int \underbrace{\tan^2 x}_{u^2-1}\ \underbrace{\sec^3 x}_{u^3}\ \underbrace{\sec x\tan x\, d{x}}_{\, d{u}}\\ &= \int \big[u^2-1]u^3\, d{u}\\ &=\frac{u^6}{6}-\frac{u^4}{4}+C\\ &=\frac{1}{6}\sec^6 x-\frac{1}{4}\sec^4 x + C \end{align*}

### $$n\geq 2$$ is even — a positive even power of secant

In the previous case we substituted $$u = \sec x\text{,}$$ while in this case we substitute $$u=\tan x\text{.}$$ When we do this we write $$\, d{u}=\sec^2 x \, d{x}$$ and then rewrite any remaining even powers of $$\sec x$$ as powers of $$\tan x$$ using $$\sec^2x = 1+\tan^2x=1+u^2\text{.}$$

##### Example 1.8.14 $$\int \sec^4 x\, d{x}$$

Solution

• Factor off one copy of $$\sec^2 x$$ and combine it with $$dx$$ to form $$\sec^2 x\, d{x}\text{,}$$ which will be $$\, d{u}\text{.}$$
• Then substitute $$u=\tan x\text{,}$$ $$\, d{u}=\sec^2 x\, d{x}$$ and rewrite any remaining even powers of $$\sec x$$ as powers of $$\tan x=u$$ using $$\sec^2x = 1+\tan^2 x=1+u^2\text{.}$$
• This gives

\begin{align*} \int \sec^4 x\, d{x} &= \int \underbrace{\sec^2 x}_{1+u^2}\ \underbrace{\sec^2 x\, d{x}}_{\, d{u}}\\ &= \int \big[1+u^2]\, d{u}\\ &=u+\frac{u^3}{3}+C\\ &=\tan x+\frac{1}{3}\tan^3 x + C \end{align*}

##### Example 1.8.15 $$\int \tan^3 x\sec^4x \, d{x}$$ — redux

Solution

Let us revisit this example using this slightly different approach.

• Factor off one copy of $$\sec^2 x$$ and combine it with $$dx$$ to form $$\sec^2 x\, d{x}\text{,}$$ which will be $$\, d{u}\text{.}$$
• Then substitute $$u=\tan x\text{,}$$ $$\, d{u}=\sec^2 x\, d{x}$$ and rewrite any remaining even powers of $$\sec x$$ as powers of $$\tan x=u$$ using $$\sec^2x = 1+\tan^2 x=1+u^2\text{.}$$
• This gives

\begin{align*} \int \tan^3x \sec^4 x\, d{x} &= \int \underbrace{\tan^3x}_{u^3} \underbrace{\sec^2 x}_{1+u^2}\ \underbrace{\sec^2 x\, d{x}}_{\, d{u}}\\ &= \int \big[u^3+u^5]\, d{u}\\ &=\frac{u^4}{4}+ \frac{u^6}{6} + C\\ &=\frac{1}{4}\tan^4 x+\frac{1}{6}\tan^6 x + C \end{align*}

• This is not quite the same as the answer we got above in Example 1.8.13. However we can show they are (nearly) equivalent. To do so we substitute $$v=\sec x$$ and $$\tan^2x=\sec^2x-1 = v^2-1\text{:}$$

\begin{align*} \frac{1}{6}\tan^6x + \frac{1}{4}\tan^4x &= \frac{1}{6} (v^2-1)^3 + \frac{1}{4}(v^2-1)^2\\ &= \frac{1}{6} (v^6-3v^4+3v^2-1) + \frac{1}{4} (v^4-2v^2+1)\\ &= \frac{v^6}{6} - \frac{v^4}{2} + \frac{v^2}{2} - \frac{1}{6} + \frac{v^4}{4} - \frac{v^2}{2} + \frac{1}{4}\\ &= \frac{v^6}{6} -\frac{v^4}{4} + 0 \cdot v^2 + \left(\frac{1}{4}-\frac{1}{6}\right)\\ &= \frac{1}{6}\sec^6x - \frac{1}{4}\sec^4x + \frac{1}{12}. \end{align*}

So while $$\frac{1}{6}\tan^6x + \frac{1}{4}\tan^4x \neq \frac{1}{6}\sec^6x - \frac{1}{4}\sec^4x\text{,}$$ they only differ by a constant. Hence both are valid antiderivatives of $$\tan^3 x\sec^4x\text{.}$$

### $$m$$ is even and $$n=0$$ — even powers of tangent

We integrate this by setting $$u=\tan x\text{.}$$ For this to work we need to pull one factor of $$\sec^2x$$ to one side to form $$\, d{u}=\sec^2x\, d{x}\text{.}$$ To find this factor of $$\sec^2x$$ we (perhaps repeatedly) apply the identity $$\tan^2x=\sec^2x-1\text{.}$$

##### Example 1.8.16 $$\int \tan^4 x\, d{x}$$

Solution

• There is no $$\sec^2x$$ term present, so we try to create it from $$\tan^4x$$ by using $$\tan^2x = \sec^2 x - 1\text{.}$$

\begin{align*} \tan^4 x &= \tan^2 x \cdot \tan^2 x\\ &= \tan^2 x\big[\sec^2 x - 1\big]\\ &=\tan^2x\sec^2 x-\underbrace{\tan^2 x}_{\sec^2x-1}\\ & = \tan^2x\sec^2 x-\sec^2 x + 1 \end{align*}

• Now we can substitute $$u=\tan x\text{,}$$ $$\, d{u}=\sec^2 x\, d{x}\text{.}$$

\begin{align*} \int \tan^4 x\, d{x} & =\int \underbrace{\tan^2x}_{u^2}\ \underbrace{\sec^2 x\, d{x}}_{\, d{u}} - \int\underbrace{\sec^2 x\, d{x}}_{\, d{u}} + \int\, d{x}\\ &= \int u^2\, d{u} -\int \, d{u} + \int\, d{x}\\ &=\frac{u^3}{3}-u+x+C\\ &=\frac{\tan^3x}{3}-\tan x +x +C \end{align*}

##### Example 1.8.17 $$\int \tan^8x \, d{x}$$

Solution

Let us try the same approach.

• First pull out a factor of $$\tan^2x$$ to create a $$\sec^2x$$ factor: \begin{align*} \tan^8x &= \tan^6x \cdot \tan^2x\\ &= \tan^6x \cdot \big[ \sec^2x - 1\big]\\ &= \tan^6x \sec^2x - \tan^6x\\ \end{align*}

The first term is now ready to be integrated, but we need to reapply the method to the second term:

\begin{align*} &= \tan^6x \sec^2x - \tan^4x\cdot\big[ \sec^2x - 1\big]\\ &= \tan^6x \sec^2x - \tan^4x \sec^2x + \tan^4x \qquad \text{do it again}\\ &= \tan^6x \sec^2x - \tan^4x \sec^2x + \tan^2x\cdot\big[ \sec^2x - 1\big]\\ &=\tan^6x \sec^2x - \tan^4x \sec^2x + \tan^2x \sec^2x - \tan^2x \qquad \text{and again}\\ &=\tan^6x \sec^2x - \tan^4x \sec^2x + \tan^2x \sec^2x - \big[\sec^2x-1\big] \end{align*}
• Hence

\begin{align*} &\int \tan^8x \, d{x}\\ &\hskip0.25in= \int\left[ \tan^6x \sec^2x - \tan^4x \sec^2x + \tan^2x \sec^2x -\sec^2x +1 \right]\, d{x}\\ &\hskip0.25in= \int \left[\tan^6x -\tan^4x +\tan^2x - 1\right]\sec^2x\, d{x} + \int \, d{x}\\ &\hskip0.25in= \int \left[u^6 - u^4 +u^2 - 1\right]\, d{u} + x +C\\ &\hskip0.25in= \frac{u^7}{7} - \frac{u^5}{5} + \frac{u^3}{3} - u + x +C\\ &\hskip0.25in=\frac{1}{7}\tan^7x - \frac{1}{5}\tan^5x + \frac{1}{3}\tan^3x - \tan x + x +C \end{align*}

Indeed this example suggests that for integer $$k\geq 0\text{:}$$

\begin{align*} \int \tan^{2k}x \, d{x} &= \frac{1}{2k-1}\tan^{2k-1}(x) - \frac{1}{2k-3}\tan^{2k-3}x + \cdots \\ &\hskip1.0in - (-1)^k \tan x + (-1)^k x +C \end{align*}

This last example also shows how we might integrate an odd power of tangent:

##### Example 1.8.18 $$\int \tan^7 x$$

Solution

• Pull out a factor of $$\tan^2x$$ to create a factor of $$\sec^2x\text{:}$$

\begin{align*} \tan^7x &= \tan^5x \cdot \tan^2x\\ &= \tan^5x \cdot \big[ \sec^2x - 1\big]\\ &= \tan^5x \sec^2x - \tan^5x \qquad \text{do it again}\\ &= \tan^5x \sec^2x - \tan^3x \cdot \big[ \sec^2x - 1\big]\\ &= \tan^5x \sec^2x - \tan^3x \sec^2x + \tan^3x \qquad\text{and again}\\ &= \tan^5x \sec^2x - \tan^3x \sec^2x + \tan x \big[ \sec^2x - 1\big]\\ &= \tan^5x \sec^2x - \tan^3x \sec^2x + \tan x \sec^2x - \tan x \end{align*}

• Now we can substitute $$u=\tan x$$ and $$\, d{u}=\sec^2x \, d{x}$$ and also use the result from Example 1.8.11 to take care of the last term: \begin{align*} \int \tan^7x\, d{x} &= \int \big[\tan^5x \sec^2x - \tan^3x \sec^2x + \tan x \sec^2x\big] \, d{x}\\ &\hskip2in- \int \tan x \, d{x}\\ \end{align*}

Now factor out the common $$\sec^2x$$ term and integrate $$\tan x$$ via Example 1.8.11

\begin{align*} &= \int \big[ \tan^5x - \tan^3x +\tan x\big]\sec x\, d{x} - \log|\sec x| +C\\ &= \int \big[ u^5 - u^3 + u \big]\, d{u} - \log|\sec x| +C\\ &= \frac{u^6}{6} - \frac{u^4}{4} + \frac{u^2}{2} - \log|\sec x| +C\\ &= \frac{1}{6}\tan^6x - \frac{1}{4}\tan^4x +\frac{1}{2}\tan^2x - \log|\sec x| + C \end{align*}

This example suggests that for integer $$k\geq 0\text{:}$$

\begin{align*} \int \tan^{2k+1}x \, d{x} &= \frac{1}{2k}\tan^{2k}(x) - \frac{1}{2k-2}\tan^{2k-2}x + \cdots\\ &\hskip0.25in - (-1)^k \frac{1}{2} \tan^2 x + (-1)^k \log|\sec x| +C \end{align*}

Of course we have not considered integrals involving powers of $$\cot x$$ and $$\csc x\text{.}$$ But they can be treated in much the same way as $$\tan x$$ and $$\sec x$$ were.

## Optional — Integrating $$\sec x\text{,}$$ $$\csc x\text{,}$$ $$\sec^3 x$$ and $$\csc^3 x$$

As noted above, when $$n$$ is odd and $$m$$ is even, one can use similar strategies as to the previous cases. However the computations are often more involved and more tricks need to be deployed. For this reason we make this section optional — the computations are definitely non-trivial. Rather than trying to construct a coherent “method” for this case, we instead give some examples to give the idea of what to expect.

##### Example 1.8.19 $$\int \sec x\, d{x}$$ — by trickery

Solution

There is a very sneaky trick to compute this integral.

• The standard trick for this integral is to multiply the integrand by $$1=\frac{\sec x+\tan x}{\sec x+\tan x}$$

\begin{align*} \sec x &= \sec x\ \frac{\sec x+\tan x}{\sec x+\tan x} = \frac{\sec^2x + \sec x \tan x}{\sec x+\tan x} \end{align*}

• Notice now that the numerator of this expression is exactly the derivative its denominator. Hence we can substitute $$u=\sec x+\tan x$$ and $$\, d{u} = (\sec x\tan x+\sec^2 x)\,\, d{x}\text{.}$$
• Hence

\begin{align*} \int \sec x\, d{x} &=\int \sec x\ \frac{\sec x+\tan x}{\sec x+\tan x}\, d{x} =\int \frac{\sec^2 x+\sec x\tan x}{\sec x+\tan x}\, d{x}\\ &=\int \frac{1}{u}\, d{u}\\ &=\log |u|+C\\ &=\log|\sec x+\tan x|+C \end{align*}

• The above trick appears both totally unguessable and very hard to remember. Fortunately, there is a simple way 3 to recover the trick. Here it is.
• The goal is to guess a function whose derivative is $$\sec x\text{.}$$
• So get out a table of derivatives and look for functions whose derivatives at least contain $$\sec x\text{.}$$ There are two:

\begin{align*} \frac{d}{dx}\tan x &= \sec^2 x\\ \frac{d}{dx}\sec x &= \tan x\,\sec x \end{align*}

• Notice that if we add these together we get

\begin{align*} \frac{d}{dx}\big(\sec x+\tan x\big) &=(\sec x+\tan x)\sec x & \implies\\ \frac{\frac{d}{dx}\big(\sec x+\tan x\big)}{\sec x+\tan x}&=\sec x \end{align*}

• We've done it! The right hand side is $$\sec x$$ and the left hand side is the derivative of $$\log|\sec x+\tan x|\text{.}$$

There is another method for integrating $$\int \sec x\, d{x}\text{,}$$ that is more tedious, but more straight forward. In particular, it does not involve a memorized trick. We first use the substitution $$u=\sin x\text{,}$$ $$\, d{u}=\cos x\,\, d{x}\text{,}$$ together with $$\cos^2 x = 1-\sin^2x=1-u^2\text{.}$$ This converts the integral into

\begin{align*} \int \sec x\, d{x} &= \int\frac{1}{\cos x}\, d{x} = \int\frac{\cos x\ \, d{x}}{\cos^2 x} \\ &= \int \frac{\, d{u}}{1-u^2}\bigg|_{u=\sin x} \end{align*}

The integrand $$\frac{1}{1-u^2}$$ is a rational function, i.e. a ratio of two polynomials. There is a procedure, called the method of partial fractions, that may be used to integrate any rational function. We shall learn about it in Section 1.10 “Partial Fractions”. The detailed evaluation of the integral $$\int \sec x\,\, d{x}=\int\frac{\, d{u}}{1-u^2}$$ by the method of partial fractions is presented in Example 1.10.5 below.

In addition, there is a standard trick for evaluating $$\int\frac{\, d{u}}{1-u^2}$$ that allows us to avoid going through the whole partial fractions algorithm.

##### Example 1.8.20 $$\int \sec x\, d{x}$$ — by more trickery

Solution

\begin{align*} \int \sec x\, d{x} &= \int \frac{\, d{u}}{1-u^2}\bigg|_{u=\sin x} \end{align*}

The trick uses the obervations that

• $$\frac{1}{1-u^2}=\frac{1+u-u}{1-u^2}=\frac{1}{1-u}-\frac{u}{1-u^2}$$
• $$\frac{1}{1-u}$$ has antiderivative $$-\log(1-u)$$ (for $$u\lt 1$$)
• The derivative $$\dfrac{d}{du}(1-u^2)=-2u$$ of the denominator of $$\frac{u}{1-u^2}$$ is the same, up to a factor of $$-2\text{,}$$ as the numerator of $$\frac{u}{1-u^2}\text{.}$$ So we can easily evaluate the integral of $$\frac{u}{1-u^2}$$ by substituting $$v=1-u^2\text{,}$$ $$\, d{v}=-2u\,\, d{u}\text{.}$$

\begin{gather*} \int \frac{u\,\, d{u}}{1-u^2} = \int \frac{\frac{\, d{v}}{-2}}{v}\bigg|_{v=1-u^2} =-\frac{1}{2}\log(1-u^2)+C \end{gather*}

Combining these observations gives

\begin{align*} \int \sec x\, d{x} &=\bigg[\int \frac{\, d{u}}{1-u^2}\bigg]_{u=\sin x} =\bigg[\int\frac{1}{1-u}\, d{u} -\int\frac{u}{1-u^2}\, d{u}\bigg]_{u=\sin x}\\ &=\Big[-\log(1-u)+\frac{1}{2}\log(1-u^2)+C\Big]_{u=\sin x}\\ &=-\log(1-\sin x)+\frac{1}{2}\log(1-\sin^2 x)+C\\ &=-\log(1-\sin x)+\frac{1}{2}\log(1-\sin x)+\frac{1}{2}\log(1+\sin x)+C\\ &=\frac{1}{2}\log\frac{1+\sin x}{1-\sin x}+C \end{align*}

Example 1.8.20 has given the answer

\begin{gather*} \int \sec x\, d{x} =\frac{1}{2}\log\frac{1+\sin x}{1-\sin x}+C \end{gather*}

which appears to be different than the answer in Example 1.8.19. But they are really the same since

\begin{align*} &\frac{1+\sin x}{1-\sin x} =\frac{(1+\sin x)^2}{1-\sin^2 x} =\frac{(1+\sin x)^2}{\cos^2 x}\\ \implies\ &\frac{1}{2}\log \frac{1+\sin x}{1-\sin x} =\frac{1}{2}\log\frac{(1+\sin x)^2}{\cos^2 x} =\log\Big|\frac{\sin x+1}{\cos x}\Big| =\log|\tan x+\sec x| \end{align*}

Oof!

##### Example 1.8.21 $$\int \csc x\, d{x}$$ — by the $$u=\tan\frac{x}{2}$$ substitution

Solution

The integral $$\int \csc x\, d{x}$$ may also be evaluated by both the methods above. That is either

• by multiplying the integrand by a cleverly chosen $$1=\frac{\cot x-\csc x}{\cot x-\csc x}$$ and then substituting $$u=\cot x -\csc x\text{,}$$ $$\, d{u} = (-\csc^2 x+\csc x \cot x)\,\, d{x}\text{,}$$ or
• by substituting $$u=\cos x\text{,}$$ $$\, d{u}=-\sin x\,\, d{x}$$ to give $$\int \csc x\, d{x}=-\int\frac{\, d{u}}{1-u^2}$$ and then using the method of partial fractions.

These two methods give the answers

\begin{gather} \int \csc x\, d{x}=\log|\cot x-\csc x|+C =-\frac{1}{2}\log \frac{1+\cos x}{1-\cos x}+C\label{eq_INTcscInt}\tag{$$\star$$} \end{gather}

In this example, we shall evaluate $$\int\csc x\, d{x}$$ by yet a third method, which can be used to integrate rational functions  4 A rational function of $$\sin x$$ and $$\cos x$$ is a ratio with both the numerator and denominator being finite sums of terms of the form $$a\sin^m x\cos^n x\text{,}$$ where $$a$$ is a constant and $$m$$ and $$n$$ are positive integers. of $$\sin x$$ and $$\cos x\text{.}$$

• This method uses the substitution

\begin{align*} x&=2\arctan u & \text{i.e. } u &=\tan\frac{x}{2} & \text{and } \, d{x}&=\frac{2}{1+u^2}\, d{u} \end{align*}

— a half-angle substitution.
• To express $$\sin x$$ and $$\cos x$$ in terms of $$u\text{,}$$ we first use the double angle trig identities (Equations 1.8.2 and 1.8.3 with $$x \mapsto \frac{x}{2}$$) to express $$\sin x$$ and $$\cos x$$ in terms of $$\sin\frac{x}{2}$$ and $$\cos\frac{x}{2}\text{:}$$

\begin{align*} \sin x &= 2 \sin\frac{x}{2} \cos\frac{x}{2}\\ \cos x &= \cos^2 \frac{x}{2} - \sin^2\frac{x}{2} \end{align*}

• We then use the triangle

to express $$\sin\frac{x}{2}$$ and $$\cos\frac{x}{2}$$ in terms of $$u\text{.}$$ The bottom and right hand sides of the triangle have been chosen so that $$\tan\frac{x}{2}=u\text{.}$$ This tells us that

\begin{align*} \sin \frac{x}{2} &= \frac{u}{\sqrt{1+u^2}} & \cos \frac{x}{2} &= \frac{1}{\sqrt{1+u^2}} \end{align*}

• This in turn implies that:

\begin{align*} \sin x&=2\sin\frac{x}{2}\cos\frac{x}{2} =2\frac{u}{\sqrt{1+u^2}}\frac{1}{\sqrt{1+u^2}} =\frac{2u}{1+u^2}\\ \cos x&=\cos^2\frac{x}{2}-\sin^2\frac{x}{2} =\frac{1}{1+u^2}-\frac{u^2}{1+u^2} =\frac{1-u^2}{1+u^2} \end{align*}

Oof!
• Let's use this substitution to evaluate $$\int \csc x\,\, d{x}\text{.}$$

\begin{align*} \int \csc x\, d{x} &=\int \frac{1}{\sin x}\, d{x} =\int \frac{1+u^2}{2u}\ \frac{2}{1+u^2}\, d{u} =\int \frac{1}{u}\, d{u}\\ &=\log|u|+C =\log\Big|\tan\frac{x}{2}\Big|+C \end{align*}

To see that this answer is really the same as that in ($$\star$$), note that

\begin{gather*} \cot x-\csc x =\frac{\cos x-1}{\sin x} =\frac{-2\sin^2(x/2)}{2\sin(x/2)\cos(x/2)} =-\tan\frac{x}{2} \end{gather*}

##### Example 1.8.22 $$\int \sec^3 x\, d{x}$$ — by trickery

Solution

The standard trick used to evaluate $$\int \sec^3 x\, d{x}$$ is integration by parts.

• Set $$u=\sec x\text{,}$$ $$\, d{v}=\sec^2 x\, d{x}\text{.}$$ Hence $$\, d{u}=\sec x\tan x\, d{x}\text{,}$$ $$v=\tan x$$ and

\begin{align*} \int \sec^3 x\, d{x} &=\int \underbrace{\sec x}_{u}\ \underbrace{\sec^2 x\, d{x}}_{dv}\\ &=\underbrace{\sec x}_{u}\ \underbrace{\tan x}_{v} -\int \underbrace{\tan x}_{v}\ \underbrace{\sec x\tan x\, d{x}}_{\, d{u}} \end{align*}

• Since $$\tan^2 x+1=\sec^2 x\text{,}$$ we have $$\tan^2 x=\sec^2 x-1$$ and

\begin{align*} \int \sec^3 x\, d{x} &=\sec x\ \tan x -\int [\sec^3 x-\sec x]\, d{x}\\ &=\sec x\ \tan x +\log|\sec x+\tan x|+C -\int \sec^3 x\, d{x} \end{align*}

where we used $$\int \sec x\, d{x} = \log|\sec x+\tan x|+C\text{,}$$ which we saw in Example 1.8.19.
• Now moving the $$\int \sec^3 x\, d{x}$$ from the right hand side to the left hand side

\begin{align*} 2\int \sec^3 x\, d{x} &=\sec x\tan x +\log|\sec x+\tan x|+C & \text{and so}\\ \int \sec^3 x\, d{x} &=\frac{1}{2} \sec x\tan x +\frac{1}{2}\log|\sec x+\tan x|+C \end{align*}

for a new arbitrary constant $$C$$ (which is just one half the old one).

The integral $$\int \sec^3\, d{x}$$ can also be evaluated by two other methods.

• Substitute $$u=\sin x\text{,}$$ $$\, d{u}=\cos x\, d{x}$$ to convert $$\int\sec^3 x\, d{x}$$ into $$\int\frac{\, d{u}}{{[1-u^2]}^2}$$ and evaluate the latter using the method of partial fractions. This is done in Example 1.10.6 in Section 1.10.
• Use the $$u=\tan\frac{x}{2}$$ substitution. We use this method to evaluate $$\int\csc^3 x\, d{x}$$ in Example 1.8.23, below.
##### Example 1.8.23 $$\int \csc^3 x\, d{x}$$ – by the $$u=\tan\frac{x}{2}$$ substitution

Solution

Let us use the half-angle substitution that we introduced in Example 1.8.21.

• In this method we set

• The integral then becomes

\begin{align*} \int \csc^3 x\, d{x} &=\int \frac{1}{\sin^3 x}\, d{x}\\ &=\int {\Big(\frac{1+u^2}{2u}\Big)}^3\ \frac{2}{1+u^2}\, d{u}\\ &=\frac{1}{4}\int \frac{1+2u^2+u^4}{u^3}\, d{u}\\ &=\frac{1}{4}\Big\{\frac{u^{-2}}{-2}+2\log|u|+\frac{u^2}{2}\Big\}+C\\ &=\frac{1}{8}\Big\{-\cot^2\frac{x}{2}+4\log\Big|\tan\frac{x}{2}\Big| +\tan^2\frac{x}{2}\Big\}+C \end{align*}

Oof!
• This is a perfectly acceptable answer. But if you don't like the $$\frac{x}{2}$$'s, they may be eliminated by using

\begin{align*} \tan^2\frac{x}{2}-\cot^2\frac{x}{2} &=\frac{\sin^2\frac{x}{2}}{\cos^2\frac{x}{2}} -\frac{\cos^2\frac{x}{2}}{\sin^2\frac{x}{2}}\\ &=\frac{\sin^4\frac{x}{2}-\cos^4\frac{x}{2}} {\sin^2\frac{x}{2}\cos^2\frac{x}{2}}\\ &=\frac{\big(\sin^2\frac{x}{2}-\cos^2\frac{x}{2}\big) \big(\sin^2\frac{x}{2}+\cos^2\frac{x}{2}\big)} {\sin^2\frac{x}{2}\cos^2\frac{x}{2}}\\ &=\frac{\sin^2\frac{x}{2}-\cos^2\frac{x}{2}} {\sin^2\frac{x}{2}\cos^2\frac{x}{2}} \qquad \text{since $\sin^2\frac{x}{2}+\cos^2\frac{x}{2}=1$}\\ &=\frac{-\cos x}{\frac{1}{4}\sin^2x} \qquad\qquad\quad \text{by }{\text{1.8.2}}\text{ and }{\text{1.8.3}} \end{align*}

and

So we may also write

\begin{gather*} \int \csc^3 x\, d{x} =-\frac{1}{2}\cot x\csc x +\frac{1}{2}\log|\csc x-\cot x|+C \end{gather*}

That last optional section was a little scary — let's get back to something a little easier.

## Exercises

Recall that we are using $$\log x$$ to denote the logarithm of $$x$$ with base $$e\text{.}$$ In other courses it is often denoted $$\ln x\text{.}$$

##### 1

Suppose you want to evaluate $$\displaystyle\int_0^{\pi/4} \sin x \cos^n x \, d{x}$$ using the substitution $$u=\cos x\text{.}$$ Which of the following need to be true for your substitution to work?

1. $$n$$ must be even
2. $$n$$ must be odd
3. $$n$$ must be an integer
4. $$n$$ must be positive
5. $$n$$ can be any real number
##### 2

Evaluate $$\displaystyle\int \sec^n x \tan x \, d{x}\text{,}$$ where $$n$$ is a strictly positive integer.

##### 3

Derive the identity $$\tan^2 x +1 = \sec^2 x$$ from the easier-to-remember identity $$\sin^2x+\cos^2 x =1\text{.}$$

###### Stage 2

Questions 4 through 10 deal with powers of sines and cosines. Review Section 1.8.1 in the notes for integration strategies.

Questions 12 through 21 deal with powers of tangents and secants. Review Section 1.8.2 in the notes for strategies.

##### 4 (✳)

Evaluate $$\displaystyle\int\cos^3x\,\, d{x}\text{.}$$

##### 5 (✳)

Evaluate $$\displaystyle\int_0^\pi\cos^2x\,\, d{x}\text{.}$$

##### 6 (✳)

Evaluate $$\displaystyle\int\sin^{36}t\,\cos^3t\,\, d{t}\text{.}$$

##### 7

Evaluate $$\displaystyle\int \dfrac{\sin^3 x}{\cos ^4 x} \, d{x}\text{.}$$

##### 8

Evaluate $$\displaystyle\int_0^{\pi/3} \sin^{4}x \, d{x}\text{.}$$

##### 9

Evaluate $$\displaystyle\int \sin^{5}x \, d{x}\text{.}$$

##### 10

Evaluate $$\displaystyle\int \sin^{1.2}x\cos x \, d{x}\text{.}$$

##### 11

Evaluate $$\displaystyle\int \tan x \sec^2 x \, d{x}\text{.}$$

##### 12 (✳)

Evaluate $$\displaystyle\int \tan^3 x \sec^5x \,\, d{x}\text{.}$$

##### 13 (✳)

Evaluate $$\displaystyle\int\sec^4x\,\tan^{46}x\,\, d{x}\text{.}$$

##### 14

Evaluate $$\displaystyle\int \tan^3 x \sec^{1.5} x \, d{x}\text{.}$$

##### 15

Evaluate $$\displaystyle\int \tan^3x\sec^2x \, d{x}\text{.}$$

##### 16

Evaluate $$\displaystyle\int \tan^4 x \sec^2 x \, d{x}\text{.}$$

##### 17

Evaluate $$\displaystyle\int \tan^3 x \sec^{-0.7}x \, d{x}\text{.}$$

##### 18

Evaluate $$\displaystyle\int \tan^5 x \, d{x}\text{.}$$

##### 19

Evaluate $$\displaystyle\int_0^{\pi/6} \tan^6 x \, d{x}\text{.}$$

##### 20

Evaluate $$\displaystyle\int_0^{\pi/4} \tan^8 x \sec^4 x \, d{x}\text{.}$$

##### 21

Evaluate $$\displaystyle\int \tan x \sqrt{\sec x} \, d{x}\text{.}$$

##### 22

Evaluate $$\displaystyle\int \sec^{8}\theta \tan^{e}\theta \, d{\theta}\text{.}$$

##### 23 (✳)

A reduction formula.

1. Let $$n$$ be a positive integer with $$n\ge 2\text{.}$$ Derive the reduction formula

$\int\tan^n(x)\,\, d{x}=\frac{\tan^{n-1}(x)}{n-1} -\int\tan^{n-2}(x)\,\, d{x}. \nonumber$

2. Calculate $$\displaystyle\int_0^{\pi/4}\tan^6(x)\,\, d{x}\text{.}$$
##### 24

Evaluate $$\displaystyle\int \tan^5 x \cos^2 x \, d{x}\text{.}$$

##### 25

Evaluate $$\displaystyle\int \frac{1}{\cos^2 \theta}\, d{\theta}\text{.}$$

##### 26

Evaluate $$\displaystyle\int \cot x\, d{x}\text{.}$$

##### 27

Evaluate $$\displaystyle\int e^x\sin(e^x)\cos(e^x) \, d{x}\text{.}$$

##### 28

Evaluate $$\displaystyle\int \sin(\cos x)\sin^3 x \, d{x}\text{.}$$

##### 29

Evaluate $$\displaystyle\int x\sin x \cos x \, d{x}\text{.}$$

1. The more pedantic reader could construct an infinite list of them.
2. You will need to memorise the derivatives of tangent and secant. However there is no need to memorise $$1+\tan^2x = \sec^2 x\text{.}$$ To derive it very quickly just divide $$\sin^2 x+\cos^2 x = 1$$ by $$\cos^2 x\text{.}$$
3. We thank Serban Raianu for bringing this to our attention.

This page titled 1.8: Trigonometric Integrals is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Joel Feldman, Andrew Rechnitzer and Elyse Yeager via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.