Find the trigonometric polynomial p(t) = a_1\cos t + a_2\cos 2t + ... + a_n\cos nt so that the integral \int_0^{2\pi}\|t-p(t) \|^2dt is minimized, by defining a suitable inner product in the space of integrable functions on [0, 2\pi], and interpret the integral as the distance \| f - p\|, where f(t) = t.

I have no idea how to solve this, but the answer is a_n = \frac{1}{\pi}\int_0^{2\pi}t\cos(nt)dt = 0 for all n = 1,2,...,n