Integrals involving trig functions pop up often enough that it's worth setting aside time for learning techniques specific to this class of functions.
Integrating trig functions usually involves using lots of trig identities, integration by substitution, and a dash of integration by parts.
A Common Form $$\int \sin^m x \cos^n x \, dx$$
Strategy for Integrating $\displaystyle \int \sin^m x \cos^n x \, dx$
1. If $m$ is odd, rewrite $\sin^m x$ as $\sin^{m - 1 }x \sin x$ and use the identity $\sin^2 x = 1 - \cos^2 x$ to rewrite $\sin^{m - 1} x$ in terms of $\cos x.$ Integrate using the substitution $u = \cos x.$ This substitution makes $du = -\sin x \, dx.$
2. If $n$ is odd, rewrite $\cos^n x$ as $\cos^{n -1} x \cos x$ and use the identity $\cos^2 x = 1 - \sin^2 x$ to rewrite $\cos^{n-1} x$ in terms of $\sin x$. Integrate using the substitution $u = \sin x.$ This substitution makes $du = \cos x \, dx.$ (Note: If both $n$ and $m$ are odd, either strategy 1 or strategy 2 may be used.)
3. If both $n$ and $m$ are even, use $\displaystyle \sin^2 x = \frac{1-\cos(2x)}{2}$ and $\displaystyle \cos^2 x = \frac{1+\cos(2x)}{2}.$ After applying these formulas, simplify and reapply strategies 1 through 3 as appropriate.
Example
Find the indefinite integral. $\displaystyle \int \sin^3 x \cos^2 x \, dx$
Here $m=3$ is odd, use part 1 of the above strategy.
$$
\begin{array}{lll}
\displaystyle \int \sin^3 x \cos^2 x \, dx&=\displaystyle \int \sin^2 x \cos^2 x \sin x \, dx &\mbox{}\\
&=\displaystyle \int (1-\cos^2 x) \cos^2 x \sin x \, dx &\mbox{}\\
&=\displaystyle \int (1-u^2) u^2 (-\, du) &\mbox{letting $u=\cos x$ so that $-du=\sin x \, dx$}\\
&=\displaystyle \int u^4-u^2 \, du &\mbox{}\\
&=\displaystyle \frac{1}{5}u^5-\frac{1}{3}u^3+C &\mbox{}\\
&=\displaystyle \frac{1}{5}\cos^5 x-\frac{1}{3}\cos^3 x+C &\mbox{}\\
\end{array}
$$
Example
Find the indefinite integral. $\displaystyle \int \cos^5 x \, dx$
Here $n=5$ is odd, so use part 2 of the above strategy.
$$
\begin{array}{lll}
\displaystyle \int \cos^5 x \, dx&=\displaystyle \int \cos^4 x \cos x \, dx &\mbox{}\\
&=\displaystyle \int (\cos^2 x)^2 \cos x \, dx &\mbox{}\\
&=\displaystyle \int (1-\sin^2 x)^2 \cos x \, dx &\mbox{}\\
&=\displaystyle \int (1-u^2)^2 \,du &\mbox{letting $u=\sin x$ so that $du=\cos x \,dx$}\\
&=\displaystyle \int 1-2u^2+u^4 \,du &\mbox{}\\
&=\displaystyle u-\frac{2}{3}u^3+\frac{1}{5}u^5+C &\mbox{}\\
&=\displaystyle \sin x-\frac{2}{3}\sin^3 x+\frac{1}{5}\sin^5x+C &\mbox{}\\
\end{array}
$$
Example
Find the indefinite integral. $\displaystyle \int \sin^2 x \cos^4 x \, dx$
Here $m=2$ and $n=4$ are even, so use part 3 of the above strategy.
$$
\begin{array}{lll}
\displaystyle \int \sin^2 x \cos^4 x \, dx &=\displaystyle \int \sin^2 x (\cos^2 x)^2 dx &\mbox{}\\
&=\displaystyle \int \frac{1-\cos(2x)}{2}\left(\frac{1+\cos(2x)}{2}\right)^2 dx &\mbox{}\\
&=\displaystyle \int \frac{(1-\cos(2x))(1+\cos(2x))(1+\cos(2x))}{8} dx &\mbox{}\\
&=\displaystyle \frac{1}{8}\int (1-\cos^2(2x))(1+\cos(2x)) dx &\mbox{}\\
&=\displaystyle \frac{1}{8}\int \sin^2(2x)(1+\cos(2x)) dx &\mbox{}\\
&=\displaystyle \frac{1}{8}\left(\int \sin^2(2x)\,dx+\int \sin^2(2x)\cos(2x)\,dx\right)&\mbox{}\\
&=\displaystyle \frac{1}{8}\left(\int \frac{1-\cos(4x)}2\,dx+\int u^2(\frac{1}{2}\,du)\right)&\mbox{letting $u=\sin(2x)$ so that $\frac{1}{2}du=\cos(2x)\,dx$}\\
&=\displaystyle \frac{1}{8}\cdot \frac{1}{2}\left(\int (1-\cos(w))(\frac{1}{4}dw)+\int u^2\,du\right)&\mbox{letting $w=4x$ so that $\frac{1}{4}dw=\cos(4x)\,dx$}\\
&=\displaystyle \frac{1}{16}\left(\frac{1}{4}(w-\sin(w))+\frac{1}{3}u^3+C\right)&\mbox{}\\
&=\displaystyle \frac{1}{16}\left(\frac{1}{4}(4x-\sin(4x))+\frac{1}{3}\sin^3(2x)+C\right)&\mbox{}\\
&=\displaystyle \frac{1}{16}x-\frac{1}{64}\sin(4x)+\frac{1}{48}\sin^3(2x)+C&\mbox{$\frac{1}{16}$ is "absorbed" into $C$}\\
\end{array}
$$
Integrating Powers of $\tan x$ and $\sec x$
We know how to integrate $\tan x,$ $\sec x,$ $\sec^2 x,$ and $\sec x \tan x:$ $$\int \tan x \, dx= \ln|\sec x|+C$$ $$\int \sec x \, dx= \ln|\sec x +\tan x|+C$$ $$\int \sec^2 x \, dx= \tan x+C$$ $$\int \sec x \tan x \, dx= \sec x +C$$ Using $1)$ the identities $\tan^2 x=\sec^2 x-1$ and $\sec^2 x=\tan^2 x+1,$ $2)$ integration by parts, $3)$ the above integrals, and $4)$ a little finesse, we can integrate powers $\sec x$ and $\tan x.$
Example
Find the indefinite integral. $\displaystyle \int \tan^4 x \, dx$
$$
\begin{array}{lll}
\displaystyle \int \tan^4 x \, dx &=\displaystyle \int \tan^2 x \tan^2 x \, dx&\mbox{}\\
&=\displaystyle \int (\sec^2 x-1) \tan^2 x \, dx&\mbox{}\\
&=\displaystyle \int \tan^2 x\sec^2 x-\tan^2 x \, dx&\mbox{}\\
&=\displaystyle \int \tan^2 x\sec^2 x\, dx-\int \tan^2 x \, dx&\mbox{}\\
&=\displaystyle \int u^2 \,du -\int \sec^2 x -1\, dx&\mbox{letting $u=\tan x$ so that $du=\sec^2 x \,dx$}\\
&=\displaystyle \frac{1}{3}u^3-(\tan x -x)+C &\mbox{}\\
&=\displaystyle \frac{1}{3}\tan^3 x-\tan x+x+C &\mbox{}\\
\end{array}
$$
Example: Another Boomerang Integral.
Find the indefinite integral. $\displaystyle \int \sec^3 x \, dx$
$$
\begin{array}{lll}
\displaystyle \int \sec^3 x \, dx&=\displaystyle \int \sec x \sec^2 x \, dx &\mbox{}\\
&=\displaystyle \int \sec x \sec^2 x \, dx &\mbox{}\\
&=\displaystyle \int u v' \, dx &\mbox{letting $u=\sec x$ and $v'=\sec^2 x$}\\
&=\displaystyle uv-\int u' v \, dx &\mbox{}\\
&=\displaystyle \sec x \tan x-\int \sec x \tan x \cdot \tan x \, dx &\mbox{$u'=\sec x \tan x$ and $v=\tan x$}\\
&=\displaystyle \sec x \tan x-\int \sec x \tan^2 x \, dx &\mbox{}\\
&=\displaystyle \sec x \tan x-\int \sec x (\sec^2 x-1) \, dx &\mbox{using the identity $\tan^2 x=\sec^2 x-1$}\\
&=\displaystyle \sec x \tan x-\int \sec^3 x-\sec x \, dx &\mbox{}\\
&=\displaystyle \sec x \tan x-\int \sec^3 x\,dx+\int \sec x \, dx &\mbox{}\\
&=\displaystyle \sec x \tan x-\int \sec^3 x\,dx+\ln|\sec x +\tan x|+C &\mbox{}\\
\end{array}
$$
Then,
$$
\begin{array}{llll}
&\displaystyle \int \sec^3 x \, dx&=\displaystyle \sec x \tan x-\int \sec^3 x\,dx+\ln|\sec x +\tan x|+C&\\
\implies & \displaystyle 2\int \sec^3 x \, dx&=\displaystyle \sec x \tan x+\ln|\sec x +\tan x|+C&\mbox{the boomerang!}\\
\implies & \displaystyle \int \sec^3 x \, dx&=\displaystyle \frac{1}{2}\sec x \tan x+\frac{1}{2}\ln|\sec x +\tan x|+C&\mbox{the $\frac{1}{2}$ is absorbed by $C$}\\
\end{array}
$$
Strategy for Integrating $\displaystyle \int \tan^m x \sec^n x \, dx$
1. If $n$ is even and $n \geq 2,$ rewrite $\sec^n x$ as $\sec^{n -2} x \sec^ 2 x$ and use $\sec^2 x = \tan^2 x + 1$ to rewrite $\sec^{n -2} x$ in terms of $\tan x.$ Let $u = \tan x$ and $du = \sec^2 x \, dx.$
2. If $m$ is odd and $n \geq 1,$ rewrite $\tan^m x \sec^n x$ as $\tan^{m - 1} x \sec^{n -1} x \sec x \tan x$ and use $\tan^2 x = \sec^2 x - 1$ to rewrite $\tan^{m - 1} x$ in terms of $\sec x.$ Let $u = \sec x$ and $du = \sec x \tan x \, dx.$ (Note: If $n$ is even and $m$ is odd, then either strategy 1 or strategy 2 may be used.)
3. If $m$ is odd where $m \geq 3$ and $n = 0,$ rewrite $\tan^m x = \tan^{m - 2} x \tan^2 x$ as $\tan^{m - 2} x (\sec^ 2 x - 1) = \tan^{m - 2} x \sec^2 x - \tan^{m - 2} x.$ It may be necessary to repeat this process on the $\tan^{m - 2} x$ term.
4. If $m$ is even and $n$ is odd, then use $\tan^2 x = \sec^2 x - 1$ to express $\tan^m x$ in terms of $\sec x.$ Use integration by parts to integrate odd powers of $\sec x.$
Example
Find the indefinite integral. $\displaystyle \int \tan^4 x \sec^4 x \, dx$
$$
\begin{array}{lll}
\displaystyle \int \tan^4 x \sec^4 x \, dx&=\displaystyle \int \tan^4 x \sec^2 x \sec^2 x \, dx&\mbox{}\\
&=\displaystyle \int \tan^4 x (\tan^2 x+1) \sec^2 x \, dx&\mbox{using the identity $\sec^2 x=\tan^2 x+1$}\\
&=\displaystyle \int u^4 (u^2+1) \,du&\mbox{letting $u=\tan x$ so that $du=\sec^2 x\,dx$}\\
&=\displaystyle \int u^6+u^4 \,du&\mbox{}\\
&=\displaystyle \frac{1}{7}u^7+\frac{1}{5}u^5 +C&\mbox{}\\
&=\displaystyle \frac{1}{7}\tan^7 x+\frac{1}{5}\tan^5 x+C&\mbox{}\\
\end{array}
$$
Integrals Involving Products Sine and Cosine: To integrate integrals of the form $$\int \sin ax \sin bx \, dx$$ $$\int \sin ax \cos bx \, dx,$$ $$\int \cos ax \cos bx \, dx,$$ use the identities $$\sin ax \sin bx = \frac{1}{2}[\cos (a-b)x-\cos (a+b)x]$$ $$\sin ax \cos bx = \frac{1}{2}[\sin (a-b)x+\sin (a+b)x]$$ $$\cos ax \cos bx = \frac{1}{2}[\cos (a-b)x+\cos (a+b)x]$$
Example
Find the indefinite integral. $\displaystyle \int \sin 3x \cos 5x \, dx$
$$
\begin{array}{lll}
\displaystyle \int \sin 3x \cos 5x \, dx &=\displaystyle \int \frac{1}{2}[\sin (3-5)x+\sin (3+5)x] \,dx &\mbox{using the above identities}\\
&=\displaystyle \int \frac{1}{2}[\sin(-2x)+\sin (8x)] \,dx &\mbox{}\\
&=\displaystyle \frac{1}{2}\int [-\sin(2x)+\sin (8x)] \,dx &\mbox{using odd property of sine}\\
&=\displaystyle -\frac{1}{2}\int \sin(2x)\,dx +\frac{1}{2}\int \sin (8x) \,dx &\mbox{}\\
&=\displaystyle -\frac{1}{2}\left(-\frac{1}{2}\cos(2x)\right) +\frac{1}{2}\left(-\frac{1}{8}\cos(8x)\right)+C &\mbox{}\\
&=\displaystyle \frac{1}{4}\cos(2x)-\frac{1}{16}\cos(8x)+C &\mbox{}\\
\end{array}
$$