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.

Hint: You can somehow write
$$\sin(2x) = a + b \sin(x) + c \cos(x) + g(x)$$
where $g(x)$ is orthogonal to $1, \sin x,$ and $\cos x$. This means you can write your integral as 
$$\int_{-\pi}^\pi \left(\left[f(x) - (a + b \sin(x) + c \cos(x))\right]^2 + g(x)^2 \right) dx.$$
You need to find how to write $\sin(2x)$ as above, how to get to the second integral, and how that integral is useful. 
