Specifically I would like to know how one can justify the following equality $$\begin{align} &2 \int_0^1 f(x) \sin(nx) \, dx \\ = &\int_0^\frac{\pi}{n}f(x)\sin(nx) \, dx - \int_1^{1+\frac{\pi}n} f(x)\sin(nx) \, dx + \int_0^1 \left(f(x)-f\left(x-\frac {\pi}n \right) \right) \sin(nx) \, dx \end{align} $$ knowing that (as $\sin(nx)$ has a period of $\frac{2\pi}n$) $$ \int_0^1 f(x) \sin(nx) \, dx = -\int_{\frac{\pi}n}^{1+\frac{\pi}n} f\left(x-\frac {\pi}n \right) \sin(nx) \, dx $$ for all continuous functions $f: \mathbb R \to \mathbb R$?
The equality in question is taken from page 1 of this PDF file and is used to prove that $$ \lim_{n \to \infty} \int_0^1 f(x) \sin(nx) \, dx = 0 $$ if $f : \mathbb R \to \mathbb R$ is continuous.
I am already aware of the Riemann Lebesgue Lemma, but I wanted to understand precisely the justification of the equality in question. The remainder of the proof follows easily for me.
The equality is incorrect.
Let $f(x) = x$. Then we get
$$\begin{align}2 \int_0^1 x \sin nx \, dx &= \frac{2 \sin n}{n^2}-\frac{\cos n}{n} \\ &\neq \frac{2 \sin n}{n^2} +\frac{2\pi}{n^2} - \frac{2 \cos n}{n} - \frac{2 \pi \cos n}{n^2}\\ &= \int_0^{\pi/n} x \sin nx \, dx - \int_{1}^{1 + \pi/n} x \sin nx \, dx + \int_0^1 [x - (x -\pi/n)] \sin nx \, dx\end{align}$$
The correct result is
$$\begin{align} 2 \int_0^1 f(x) \sin nx \, dx &= \int_0^\frac{\pi}{n}f\left(x-\frac {\pi}n \right)\sin(nx) \, dx - \int_1^{1+\frac{\pi}n} f\left(x-\frac {\pi}n \right)\sin(nx) \, dx \\ &+ \int_0^1 \left(f(x)-f\left(x-\frac {\pi}n \right) \right) \sin(nx) \, dx \end{align} $$
This follows easily by splitting the integral over $[\pi/n, 1+\pi/n]$ on the RHS of the first line of the solution in the attached PDF into integrals over $[\pi/n,1]$ and $[1,1 + \pi/n]$ and then adding and subtracting the integral over $[0,\pi/n]$.