Find $f$ such that $\int_{-\pi}^{\pi}|f(x)-\sin(2x)|^2 \, dx$ is minimal

113 Views Asked by At

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.

5

There are 5 best solutions below

5
On BEST ANSWER

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.

0
On

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.

0
On

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.

1
On

Let $f(x)=a+b\sin(x)+c\cos(x)$, you only need to determine the undefined coefficients $a$, $b$, and $c$.

5
On

Write $f(x)=a+b\cos x+c\sin x.$ Then

$$\begin{array}{rcl}\int_{-\pi}^{\pi}(f(x)-\sin(2x))^2dx & = & \int_{-\pi}^{\pi}(a+b\cos x+c\sin x-\sin(2x))^2dx \\ & = & \int_{-\pi}^{\pi}(a^2+b^2\cos^2 x+c^2\sin^2 x+\sin^2(2x))dx \\ & & +\int_{-\pi}^{\pi} (2ab\cos x+2ac\sin x)dx.\end{array}$$

Thus, you have to get where the function

$$F(a,b,c)=\int_{-\pi}^{\pi}(a^2+b^2\cos^2 x+c^2\sin^2 x+2ab\cos x+2ac\sin x+\sin^2(2x))dx$$ has a minimum. It must be

$$\frac{\partial F}{\partial a}=\frac{\partial F}{\partial b}=\frac{\partial F}{\partial c}=0.$$ For example,

$$\frac{\partial F}{\partial a}=4a\pi+2\int_{-\pi}^{\pi}(b\cos x+c\sin x)dx.$$