We seek to compute $\int_0^{2\pi}g(x)^2dx$ with the following given: $$f(x) = \frac{\pi-x}{2}, x \in \left[0,2\pi\right] $$ $$g(x) = f(x+1)-f(x-1)$$ $$f(x) = \sum_{1}^\infty \frac{\sin(nx)}{n}$$ $$g(x) = 2\sum_1^\infty \frac{\sin(n)\cos(nx)}{n}$$
with the last expressions being the fourier series of $f(x)$ & $g(x)$ (computed previously).
We are advised to use "the definition of g$(x)$". Using $g(x) = \frac{\pi-x-1}{2}-\frac{\pi-x+1}{2}$ gives $g(x) = 1$ for all x which is incorrect. Using $g(x) = \left[\sin(nx+n) - \sin(nx-n)\right]\frac{1}{n}$ leads to a horrible expression that at least wolfram alpha calculates to be wrong. Using the fourier series of $g(x)$ is also incorrect.
How many other ways are there to think about this?
How do we interpret this notation?
$$\sum_{n\geq 1}\frac{\sin(nx)}{n}$$ is the Fourier series of the sawtooth wave, i.e. the piecewise-linear $2\pi$-periodic function whose limit for $x\to 0^+$ equals $\frac{\pi}{2}$ and whose limit for $x\to 2\pi^-$ equals $-\frac{\pi}{2}$. It follows that: $$ 2\sum_{n\geq 1}\frac{\sin(n)\cos(nx)}{n} $$ is a $2\pi$-periodic function that equals $\pi-1$ for $x\in(0,1)$ or $x\in(2\pi-1,2\pi)$ and $-1$ for $x\in(1,2\pi-1)$. By Parseval's theorem we have:
$$ 2\int_{0}^{1}(\pi-1)^2\,dx + \int_{1}^{2\pi-1}1\,dx = 4\pi \sum_{n\geq 1}\frac{\sin^2(n)}{n^2}$$ hence: $$ \sum_{n\geq 1}\frac{\sin^2(n)}{n^2}=\frac{\pi-1}{2}.$$