Find $f$ such that $\int_{-\pi}^{\pi}|f(x)-\sin(2x)|^2 \, dx$ is minimal Fairly simple question that's been bothering me for a while. 
Supposedly it should be simple to solve from the properties of inner product but I can't seem to solve it.
Find $f(x) \in \operatorname{span}(1,\sin (x),\cos (x))$ such that $\int_{-\pi}^{\pi}|f(x)-\sin(2x)|^2dx$ is minimal.
Tip: $\int_{-\pi}^\pi \sin (x)\sin(2x)\,dx=\int_{-\pi}^\pi \cos (x)\sin (2x) \, dx = \int_{-\pi}^\pi \sin (2x) \, dx=0$
I'm at a complete blank and I'd like a tip in the right direction.

Let $f(x)=a+b\cos x+c\sin x$.
Expand $|f(x)-\sin2x|^2=(a+b\cos x+c\sin x-\sin2x)^2$
Integrate each bit.
