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.
The reason for writing $|f(x)-\sin(2x)|^2$ rather than $(f(x)-\sin(2x))^2$ is that one can allow the coefficients in the linear combination to be complex numbers, not just real numbers, so the square need not be non-negative unless you take the absolute value first.
Now let's see how to use the "tip" you're given: $$ \int_{-\pi}^\pi \sin (x)\sin(2x)\,dx=\int_{-\pi}^\pi \cos (x)\sin (2x) \, dx = \int_{-\pi}^\pi \sin (2x) \, dx=0 \tag{tip} $$
We have \begin{align} & \int_{-\pi}^\pi |f(x)-\sin(2x)|^2\,dx = \int_{-\pi}^\pi|(a + b\cos x+c\sin x)-\sin(2x)|^2\,dx \\[8pt] = {} & \int_{-\pi}^\pi {\huge(}|a+b\cos x+c\sin x|^2 \\[6pt] & {}\qquad\qquad{} + \underbrace{\Big((a+\bar a+(b+\bar b)\cos x+(c+\bar c)\sin x\Big)\sin(2x)}_{\text{The ``tip" says the integral of this part is $0$.}} + \sin^2(2x){\huge)}\,dx \\[8pt] = {} & \int_{-\pi}^\pi |a+b\cos x+c\sin x|^2 + \sin^2(2x)\,dx. \tag2 \end{align} What values of $a,b,c$ minimize this last expression $(2)$? Clearly making them all $0$ makes the integral of that first square $0$, but making any of them anything other than $0$ makes the integral of that part a positive number.