Evaluation of a general trigonometric integral How can I evaluate the integral
$$\int\sin^k(x)\ dx$$
in which I don't know if $k$ is an even or an odd number?
 A: We can also use integration by parts to reduce the integral to either $\int\sin(x)\,\mathrm{d}x$ or $\int1\,\mathrm{d}x$.
$$
\begin{align}
\int\sin^n(x)\,\mathrm{d}x
&=-\int\sin^{n-1}(x)\,\mathrm{d}\cos(x)\tag{1}\\
&=-\cos(x)\sin^{n-1}(x)+(n-1)\int\sin^{n-2}(x)\cos^2(x)\,\mathrm{d}x\tag{2}\\
&=-\frac1n\cos(x)\sin^{n-1}(x)+\frac{n-1}n\int\sin^{n-2}(x)\,\mathrm{d}x\tag{3}
\end{align}
$$
Explanation:
$(1)$: $\mathrm{d}\cos(x)=-\sin(x)\,\mathrm{d}x$
$(2)$: integrate by parts
$(3)$: add $(n-1)\int\sin^n(x)\,\mathrm{d}x$ to both sides and divide by $n$
Modulo a constant of integration, induction and $(3)$ yields
$$
\begin{align}
&\int\sin^n(x)\,\mathrm{d}x\\
&=\frac{(n-1)!!}{n!!}x[n\text{ is even}]-\cos(x)\sum_{k=0}^{\lfloor\frac{n-1}2\rfloor}\frac{(n-1)!!(n-2k)!!}{n!!(n-2k-1)!!}\frac{\sin^{n-2k-1}(x)}{n-2k}\\
&=\frac{(n-1)!!}{n!!}\left(x[n\text{ is even}]-\cos(x)\sum_{k=0}^{\lfloor\frac{n-1}2\rfloor}\frac{(n-2k-2)!!}{(n-2k-1)!!}\,\sin^{n-2k-1}(x)\right)
\tag{4}
\end{align}
$$
where $[\dots]$ are Iverson Brackets.
A: The usual form of the resulting integral depends, for one, on the parity of $k$ (i.e., whether it is even or odd).
If you really want a general formula, you could expand using the complex representation of $\sin$, namely,
$$\sin z = \frac{\exp(iz) - \exp(-iz)}{2i},$$
expand $\sin^k z$ using the binomial theorem, integral term-by-term (which is easy, since each term is an exponential function), then rewrite the resulting complex expression as a sum of sine and cosine functions.
The above technique may or may not be useful. In general, it is better to do the following: If $k$ is even, use the double angle identity to write the integral in terms of $\cos^{k / 2}$, and handle any terms $\cos^{\ell}$ with even $\ell$ that occur with the same method. If $k$ is odd, say, $k = 2 m + 1$, we can write $$\int \sin^k x \,dx = \int (1 - \cos^2 x)^m \sin x \,dx,$$ after which the substitution $u = \cos x$ transforms the integral into one with a polynomial integrand. Any terms $\cos^{\ell} x$ with odd $\ell$ that occur can be handled analogously.
A: Let $f(x) = \sin^k x$.
We have $\sin x = \frac{e^{ix} - e^{-ix}}{2i}$. So 
$$
\begin{align*}
f(x) &= \frac{1}{(2i)^k}(e^{ix} - e^{-ix})^k \\
&=\frac{1}{(2i)^k} \sum_{j = 0}^k \binom{k}{j} (e^{ix})^{k-j} (-e^{-ix})^j \\
&=\frac{1}{(2i)^k} \sum_{j = 0}^k (-1)^j \binom{k}{j} e^{(k-2j)ix} \\
&=\frac{1}{(2i)^k} \left(\sum_{0 \leq j < k/2} \left[(-1)^j\binom{k}{j}e^{(k-2j)ix} + (-1)^{k-j} \binom{k}{k-j}e^{(2j-k)ix} \right] + \varepsilon (-1)^{k/2}\binom{k}{k/2}\right), 
\end{align*}
$$
where the term with $\varepsilon$ appears only if $k$ is even, and then $\varepsilon = 1$. On the last line, we've grouped together symmetric terms of the sum. From here on, we distinguish between even $k$ and odd $k$.
If $k$ is even, say $k = 2m$, then
$$
\begin{align*}
f(x) &= \frac{(-1)^m}{2^{2m}} \left[ \sum_{j = 0}^{m-1} (-1)^{j}  \binom{2m}{j} \left(e^{2(m-j)ix} + e^{2(j-m)ix}\right) + (-1)^m\binom{2m}{m} \right]\\
&= \frac{1}{2^{2m}} \left[ \sum_{j=0}^{m-1} (-1)^{m-j} \binom{2m}{j} \cdot 2 \cos 2(m-j)x + \binom{2m}{m} \right] \\
&=\frac{1}{2^{2m-1}} \sum_{h = 1}^m (-1)^h \binom{2m}{m-h} \cos 2hx + \frac{1}{2^{2m}}\binom{2m}{m},
\end{align*}
$$
which is easy to integrate. (From $0$ to $\pi$, only the last term has a nonzero integral.) The last term is like half what the term for $h = 0$ would be. For example, for $k = 6$, we get
$$\sin^6 x =  \frac{20}{64} - \frac{15}{32} \cos 2x + \frac{6}{32} \cos 4x - \frac{1}{32} \cos 6x  $$
If $k$ is odd, say $k = 2m + 1$, then we have 
$$
\begin{align*}
f(x) &= \frac{(-1)^{m}}{2^{2m}} \sum_{j = 0}^m (-1)^j \binom{2m+1}{j} \frac{e^{[2(m-j) + 1]x} - e^{-[2(m-j) + 1]x}}{2i} \\
&=\frac{1}{2^{2m}} \sum_{j = 0}^m (-1)^{m-j} \binom{2m+1}{j} \sin [2(m-j) + 1]x \\
&=\frac{1}{2^{2m}} \sum_{h = 0}^m (-1)^{h} \binom{2m+1}{m-h} \sin (2h + 1)x,
\end{align*}
$$
which is again easy to integrate. From $0$ to $\pi$, this last formula won't immediately give you the simplest form of the integral, which is twice the Wallis integral. Also, there are some circumstances where it might be preferable to integrate directly from one of the complex forms of $f(x)$, using the fact that the integral of $e^{inx}$ is $\displaystyle \frac{e^{inx}}{in}$.
For $k = 7$, we get 
$$\sin^7 x = \frac{35}{64} \sin x - \frac{21}{64} \sin 3x + \frac{7}{64} \sin 5x - \frac{1}{64} \sin 7x.$$
