I revamp Steven Gubkin's answer at Math Educators SE, based on partial fractions.
Develop a general strategy for integrals of powers of trig functions: If a power is odd, you can use Pythagorean identity and a substitution. If both powers are even, use half angle reduction formulas. For instance, substitute $u = \cos(x)$ in
$\begin{align}
= & \int \color{red}{\sin^{2k+1}} && \color{DarkTurquoise}{\cos^m(x)} & \, dx \\
= & \int \color{red}{(1-\cos^2(x))^k} && \color{DarkTurquoise}{\cos^m(x)} & \color{red}{\sin(x)} \, dx\\
= & \int -(1-u^2)^k && \color{DarkTurquoise}{u^m} & \, du
\end{align}$
Start with some positive integer examples. Here, you just get a polynomial, so you can integrate by expanding and integrating termwise. Then observe the same strategy works for all integers, you just get rational functions of $u$ if an exponent is negative, which you might have to decompose with partial fractions.
An example of this general strategy is integrating secant !
$$
\begin{align}
\int \sec(x) dx &= \int \cos(x)^{-1} dx \qquad \textrm{ (This is an odd power of cosine.)}\\
&= \int \color{BlueViolet}{\cos(x)^{-2}} \qquad \qquad \color{Peru}{\cos(x) \, dx}\\
&=\int \color{DarkOrchid}{(1-\sin^2(x))^{-1}} \quad \, \color{Peru}{\cos(x) \, dx}\\
&=\int \frac{1}{1-u^2} du\\
&=\frac{1}{2}\int \frac{1}{1-u}+\frac{1}{1+u} du\\
&=\frac{1}{2}\left( \ln(1+u) - \ln(1-u)\right)+C\\
&=\frac{1}{2}\ln(\frac{1+\sin(x)}{1-\sin(x)})+C\\
&=\frac{1}{2}\ln(\frac{(1+\sin(x))^2}{\cos^2(x)})+C\\
&=\ln\left| \frac{1+\sin(x)}{\cos(x)} \right|+C\\
&=\ln\left| \sec(x) +\tan(x)\right|+C
\end{align}
$$
So, integrating secant fits into our more strategy for integrating any function of the form $\sin^n(x)\cos^m(x)$.