Solution (source code)

= Solution

The <product-to-sum formula> immediately gives the <Fourier series>:
$$
\boxed{f(x)=\frac12\cos(2x)+\frac12\cos(8x)}.
$$
In the convention $f(x)=a_0/2+\sum_{n\geq1}(a_n\cos nx+b_n\sin nx)$, the only nonzero <Fourier coefficients> are $a_2=a_8=1/2$. This is a finite <trigonometric polynomial>, and the identity holds at both endpoints as well.