How can I prove $\lim_{n \to \infty} \int_{0}^{\pi/2} f(x) \sin ((2n+1) x) dx =0 $? For continuous $f$, $f \in L^2$, prove that $$\lim_{n \to \infty} \int_{0}^{\pi/2} f(x) \sin ((2n+1) x) dx =0 $$
 A: *

*Show it when $f$ is a polynomial. 

*Argue by density, using Stone-Weierstrass theorem. 

A: This is a special case of the Riemann–Lebesgue lemma. I think the easiest proof is by first showing it when $f$ is the characteristic function of an interval (a trivial explicit computation), then generalizing that to simple functions (by linear combinations), then generalizing further, in the case of Riemann integrable functions relying directly on the definition of the integral.
A: Since $f \in L^2$, given $\epsilon>0$ there is a step function 
$$
g:[0, \pi/2] \to \mathbb{R},\ g=\sum_{i=1}^kc_i\chi_{[x_{i-},x_i]}
$$ 
such that
$$
\int_0^{\pi/2}|f-g| \le \epsilon/2.
$$
We have
\begin{eqnarray}
a_n&=&\left|\int_0^{\pi/2}f(x)\sin((2n+1)x)dx\right|\cr
 &\le& \left|\int_0^{\pi/2}(f(x)-g(x))\sin((2n+1)x)dx\right|+\left|\int_0^{\pi/2}g(x)\sin((2n+1)x)dx\right|\cr
&\le& \int_0^{\pi/2}|f(x)-g(x)|dx+\left|\int_0^{\pi/2}g(x)\sin((2n+1)x)dx\right|\cr
&\le&\epsilon/2+|b_n|,
\end{eqnarray}
where
\begin{eqnarray}
b_n&=&\int_0^{\pi/2}g(x)\sin((2n+1)x)dx=\sum_{i=1}^kc_i\int_{x_{i-1}}^{x_i}\sin((2n+1)x)dx\cr
&=&-\sum_{i=1}^k\frac{c_i}{2n+1}\cos((2n+1)x)\big|_{x_{i-1}}^{x_i}.
\end{eqnarray}
Since
$$
|b_n| \le \sum_{i=1}^k\frac{2|c_i|}{2n+1} \le \frac{2k}{2n+1}\max_{1 \le i \le k}|c_i|,
$$
we have $b_n \to 0$ as $n \to \infty$. Therefore, there is an $n_0$ such that $|b_n| \le \epsilon/2$ for $n \ge n_0$. Thus $a_n \le \epsilon$ for every $n \ge n_0$, i.e. $a_n \to 0$ as $n \to \infty$.
A: This follows immediately from the Riemann-Lebesgue lemma. (Today must be Riemann-Lebesgue day, I just saw another one like that.) Let $g(x) = f(x)$ for $0 \leq x \leq \frac{\pi}{2}$ and let $g(x) = 0$ otherwise. Then you need to show that
$$\lim_{n \to \infty} \int_0^{2\pi}g(x)\sin((2n + 1) x) \,dx = 0$$
This is a direct consequence of the Riemann-Lebesgue lemma, as this holds whenever $g(x)$ is in $L^1$. $g(x)$ is in $L^1$ in the case at hand since the function is bounded. 
