Integrating $\int \sin^n{x} \ dx$
I am working on trying to solve this problem:
Prove: $\int \sin^n{x} \ dx = -\frac{1}{n} \cos{x} \cdot \sin^{n - 1}{x} + \frac{n - 1}{n} \int \sin^{n - 2}{x} \ dx$
Here are the steps that I follow in the example that I am reading:
$u = \sin^{n - 1}{x}$
$du = (n - 1) \cdot \sin^{n - 2}{x} \cdot \cos{x} \ dx$
$v = -\cos{x}$
$dv = \sin{x} \ dx$
$\int \sin^n{x} \ dx = \sin^{n - 1}{x} \cdot \sin{x} \ dx$
$\int \sin^n{x} \ dx = \underbrace{\sin^{n - 1}{x}}_{u} \cdot \underbrace{-\cos{x}}_{v} - \int \underbrace{-\cos{x}}_{v} \cdot \underbrace{(n - 1) \cdot \sin^{n - 2}{x} \cdot \cos{x} \ dx}_{du}$
$\int \sin^n{x} \ dx = -\cos{x} \cdot \sin^{n - 1}{x} + (n - 1)\int \sin^{n - 2}{x} \cdot \cos^{2}{x} \ dx$
$\int \sin^n{x} \ dx = -\cos{x} \cdot \sin^{n - 1}{x} + (n - 1)\int \sin^{n - 2}{x} \cdot \left(1 - \sin^{2}{x}\right) \ dx$
Here is where I get lost. How did we go from $\int \sin^{n - 2}{x} \cdot \left(1 - \sin^{2}{x}\right) \ dx$ to $\int \sin^{n - 2}{x} \ dx - (n - 1) \int \sin^{n}{x} \ dx$? Even more specifically, where did $\sin^{n}{x}$ come from?
$\int \sin^n{x} \ dx = -\cos{x} \cdot \sin^{n - 1}{x} + (n - 1)\int \sin^{n - 2}{x} \ dx - (n - 1) \int \sin^{n}{x} \ dx$
I get this part.
$n\int \sin^n{x} \ dx = -\cos{x} \cdot \sin^{n - 1}{x} + (n - 1)\int \sin^{n - 2}{x} \ dx$
$\int \sin^n{x} \ dx = -\frac{1}{n} \cos{x} \cdot x \ \sin^{n - 1}{x} + \frac{n - 1}{n} \int \sin^{n - 2}{x} \ dx$
Could someone please explain what I am missing?
Thank you for your time.
First let us denote
$$I_n = \int \sin^n{x} \ dx $$
$$ \int u(x) v'(x) dx = u(x) v(x) - \int v(x) u' (x) dx $$
Here $u(x) = \sin^{n-1}{x} \hspace{3pt}$ and $\hspace{3pt} v'(x) = \sin x $
$ \Rightarrow v(x) = -\cos x$
Therefore $$ \begin{align*} I_n &= -\cos x \hspace{3pt} \sin^{n-1}x + \int \cos^2 x \hspace{4pt} (n-1) \sin^{n-2} x \hspace{4pt} dx \\ &= -\cos x \hspace{3pt} \sin^{n-1}x + (n-1) \int \sin^{n-2} x \hspace{4pt} dx - (n-1) \int \sin^{n} dx\\ &= -\cos x \hspace{3pt} \sin^{n-1}x + (n-1) \int \sin^{n-2} x \hspace{4pt} dx - (n-1) I_n \end{align*} $$
$$ \Rightarrow (1+n-1)I_n = -\cos x \hspace{3pt} \sin^{n-1}x + (n-1) \int \sin^{n-2} x dx $$
$$ \Rightarrow I_n = \frac{-\cos x \hspace{3pt} \sin^{n-1}x}{n} + \frac{(n-1)}{n} \int \sin^{n-2} x dx $$
Here is a direct expansion.
Since $e^{ix} =\cos(x)+i\sin(x)$, $\sin(x) =\frac12(e^{ix}-e^{-ix}) =\frac12e^{ix}(1-e^{-2ix}) $.
Therefore
$\begin{array}\\ \sin^n(x) &=\frac1{2^n}(e^{ix}-e^{-ix})^n\\ &=\frac1{2^n}\sum_{k=0}^n\binom{n}{k}e^{ikx}(-1)^{n-k}e^{-i(n-k)x}\\ &=\frac1{2^n}\sum_{k=0}^n\binom{n}{k}(-1)^{n-k}e^{i(2k-n)x}\\ &=\frac1{2^n}\sum_{k=0}^n\binom{n}{k}(-1)^{n-k}(\cos((2k-n)x)+i\sin((2k-n)x))\\ &=\frac1{2^n}\sum_{k=0}^n\binom{n}{k}(-1)^{n-k}\cos((2k-n)x) \qquad\text{since the sum is real}\\ \text{so}\\ I_n(x) &=\int \sin^n(x)dx\\ &=\int\frac1{2^n}\sum_{k=0}^n\binom{n}{k}(-1)^{n-k}\cos((2k-n)x)dx\\ &=\frac1{2^n}\sum_{k=0}^n\binom{n}{k}(-1)^{n-k}\int\cos((2k-n)x)dx\\ &=\frac1{2^n}\sum_{k=0}^n\binom{n}{k}(-1)^{n-k}\dfrac{\sin((2k-n)x)}{2k-n} \qquad\text{except at } 2k=n\\ I_{2n}(x) &=\int \sin^{2n}(x)dx\\ &=\int\frac1{2^{2n}}\sum_{k=0}^{2n}\binom{2n}{k}(-1)^{2n-k}\cos((2k-2n)x)dx\\ &=\frac1{2^{2n}}\sum_{k=0}^{2n}\binom{2n}{k}(-1)^{2n-k}\int\cos((2k-2n)x)dx\\ &=\frac1{2^{2n}}\sum_{k=0}^{2n}\binom{2n}{k}(-1)^{k}\int\cos((2k-2n)x)dx\\ &=\frac1{2^{2n}}\left(\sum_{k=0}^{n-1}\binom{2n}{k}(-1)^{k}\int\cos((2k-2n)x)dx+\binom{2n}{n}(-1)^{n}\int\cos(0)dx+\sum_{k=n+1}^{2n}\binom{2n}{k}(-1)^{k}\int\cos((2k-2n)x)dx\right)\\ &=\frac1{2^{2n}}\left(\sum_{k=0}^{n-1}\binom{2n}{k}(-1)^{k}\int\cos((2k-2n)x)dx+\binom{2n}{n}(-1)^{n}x+\sum_{k=0}^{n-1}\binom{2n}{2n-k}(-1)^{2n-k}\int\cos((2(2n-k)-2n)x)dx\right)\\ &=\frac1{2^{2n}}\left(\sum_{k=0}^{n-1}\binom{2n}{k}(-1)^{k}\int\cos((2k-2n)x)dx+\binom{2n}{n}(-1)^{n}x+\sum_{k=0}^{n-1}\binom{2n}{k}(-1)^{k}\int\cos((2n-2k)x)dx\right)\\ &=\frac1{2^{2n}}\left(2\sum_{k=0}^{n-1}\binom{2n}{k}(-1)^{k}\int\cos((2k-2n)x)dx+\binom{2n}{n}(-1)^{n}x\right)\\ &=\frac1{2^{2n}}\left(2\sum_{k=0}^{n-1}\binom{2n}{k}(-1)^{k}\dfrac{\sin((2k-2n)x)}{2k-2n}+\binom{2n}{n}(-1)^{n}x\right)\\ &=\frac1{2^{2n-1}}\sum_{k=0}^{n-1}\binom{2n}{k}(-1)^{k}\dfrac{\sin((2k-2n)x)}{2k-2n}+\binom{2n}{n}\dfrac{(-1)^{n}x}{2^{2n}}\\ I_{2n-1}(x) &=\int \sin^{2n-1}(x)dx\\ &=\int\frac1{2^{2n-1}}\sum_{k=0}^{2n-1}\binom{2n-1}{k}(-1)^{2n-1-k}\cos((2k-(2n-1))x)dx\\ &=\frac1{2^{2n-1}}\sum_{k=0}^{2n-1}\binom{2n-1}{k}(-1)^{2n-1-k}\int\cos((2k-2n+1)x)dx\\ &=\frac1{2^{2n-1}}\sum_{k=0}^{2n-1}\binom{2n-1}{k}(-1)^{k+1}\int\cos((2k-2n+1)x)dx\\ &=\frac1{2^{2n-1}}\left(\sum_{k=0}^{n-1}\binom{2n-1}{k}(-1)^{k+1}\int\cos((2k-2n+1)x)dx+\sum_{k=n}^{2n-1}\binom{2n-1}{k}(-1)^{k+1}\int\cos((2k-2n+1)x)dx\right)\\ &=\frac1{2^{2n-1}}\left(\sum_{k=0}^{n-1}\binom{2n-1}{k}(-1)^{k+1}\int\cos((2k-2n+1)x)dx+\sum_{k=0}^{n-1}\binom{2n-1}{2n-1-k}(-1)^{2n-1-k}\int\cos((2(2n-1-k)-2n+1)x)dx\right)\\ &=\frac1{2^{2n-1}}\left(\sum_{k=0}^{n-1}\binom{2n-1}{k}(-1)^{k}\int\cos((2k-2n+1)x)dx +\sum_{k=0}^{n-1}\binom{2n-1}{2n-1-k}(-1)^{2n-1-k}\int\cos(2n-1-2k)x)dx\right)\\ &=\frac1{2^{2n-1}}\left(\sum_{k=0}^{n-1}\binom{2n-1}{k}(-1)^{k}\int\cos((2k-2n+1)x)dx+\sum_{k=0}^{n-1}\binom{2n-1}{k}(-1)^{k+1}\int\cos(2k-2n+1)x)dx\right)\\ &=\frac1{2^{2n-1-2}}\sum_{k=0}^{n-1}\binom{2n-1}{k}(-1)^{k}\int\cos((2k-2n+1)x)dx\\ &=\frac1{2^{2n-2}}\sum_{k=0}^{n-1}\binom{2n-1}{k}(-1)^{k}\dfrac{\sin((2k-2n+1)x}{2k-2n+1}\\ \end{array} $