In this post we look at solving the integrals of the form
$$I(m,n) = \int \sin^mx \cdot \cos^nx \cdot dx \tag{1}$$
where $m,\ n$ are whole numbers (not necessarily positive).
This is usually done by applying some of the recurrence formulas listed below.
$$I(m,n) = \frac{1}{m+1} \sin^{m+1}x \cos^{n-1}x + \frac{n-1}{m+1} \cdot I(m+2, n-2), for\ \ m \ne -1 \tag{2}$$
$$I(m,n) = -\frac{1}{n+1} \sin^{m-1}x \cos^{n+1}x + \frac{m-1}{n+1} \cdot I(m-2, n+2), for\ \ n \ne -1 \tag{3}$$
$$I(m,n) = I(m-2,n) - I(m-2,n+2), for\ any \ m,n \tag{4}$$
$$I(m,n) = I(m,n-2) - I(m+2,n-2), for\ any \ m,n \tag{5}$$
Then from (2) and (5) we derive (2'), while from (3) and (4) we derive (3'). The formulas (2') and (3') are used to reduce the degree either of the sine or of the cosine. They turn out to be very useful when $m,n$ are positive.
$$I(m,n) = \frac{1}{m+n} \sin^{m+1}x\cos^{n-1}x + \frac{n-1}{m+n} \cdot I(m, n-2),\ for \ m \ne -1,\ m+n \ne 0 \tag{2'}$$
$$I(m,n) = -\frac{1}{m+n} \sin^{m-1}x\cos^{n+1}x + \frac{m-1}{m+n} \cdot I(m-2, n),\ for \ n \ne -1,\ m+n \ne 0 \tag{3'}$$
When both $m, n$ are non-negative usually it is useful to apply formula (6). Note though that (6) is valid for any values of $m,n$, and not just for non-negative values.
$$I(m,n) = I(m+2, n) + I(m, n+2) \tag{6}$$
The last two formulas (2'') and (3'') can be easily derived from (2') and (3'). They allow us to increase the degree of the sine or of the cosine. They are usually used when $m$ or $n$ is negative.
$$I(m,n) = -\frac{1}{n+1} \sin^{m+1}x\cos^{n+1}x + \frac{m+n+2}{n+1} \cdot I(m, n+2),\ for \ m \ne -1,\ n \ne -1 \tag{2''}$$
$$I(m,n) = \frac{1}{m+1} \sin^{m+1}x\cos^{n+1}x + \frac{m+n+2}{m+1} \cdot I(m+2, n),\ for \ m \ne -1,\ n \ne -1 \tag{3''}$$
It can be proved that using these formulas the calculation of the integral (1) always boils down to calculating one of the below given integrals. These integrals below are calculated directly (e.g. by integration by parts or by even simpler means).
$$\int \sin{x}\ dx = -\cos{x}$$
$$\int \cos{x}\ dx = \sin{x}$$
$$\int \frac{dx}{\sin{x}} = \ln |\tan ({\frac{x}{2})}|$$
$$\int \frac{dx}{\cos{x}} = \ln |\tan {(\frac{x}{2}+\frac{\pi}{4})}|$$
$$\int \sin{x}\ \cos{x}\ dx = -\frac{1}{4}\cos{2x}$$
$$\int \frac{dx}{\sin{x}\cos{x}} = \ln |\tan {(x)}|$$
$$\int \frac{\sin{x}}{\cos{x}}\ dx = - \ln |\cos{x}|$$
$$\int \frac{\cos{x}}{\sin{x}}\ dx = \ln |\sin{x}|$$
$$\int \sin^2{x}\ dx = \frac{1}{2}x - \frac{1}{4}\sin{2x}$$
$$\int \cos^2{x}\ dx = \frac{1}{2}x + \frac{1}{4}\sin{2x}$$
$$\int \frac{dx}{\sin^2{x}} = -\cot{x}$$
$$\int \frac{dx}{\cos^2{x}} = \tan{x}$$
It should be noted that when $m$ is odd we can introduce/enter one of the $\sin{x}$ multipliers under the differential sign (where it becomes $\cos{x}$). Then by letting $t=\cos{x}$ and by using that $\sin^2{x} = 1 - \cos^2{x}$, we get an integral from a rational function of $t$.
Analogically, when $n$ is odd we can introduce/enter one of the $\cos{x}$ multipliers under the differential sign (where it becomes $\sin{x}$). Then by letting $t=\sin{x}$ and by using that $\cos^2{x} = 1 - \sin^2{x}$, we get an integral from a rational function of $t$.