0

Find all polynomial $f(x)$ of degree $\leq 3$ for which $$\int^{\pi}_{-\pi}\bigg(\cos(x)-f(x)\bigg)^2dx$$ has minimum value.

What i try: Let $f(x)=px^3+qx^2+rx+s$. Then

$$\int^{\pi}_{-\pi}\left(f(x)^2-2f(x)\cos(x)+\cos^2(x)\right)dx.$$

Here, I did not understand how I can solve the $(f(x))^2$ and $2xf(x)\cos x$ parts in some way.

Because when I put in the value of $f(x)$, this is very complex.

amWhy
  • 209,954
jacky
  • 5,194
  • 1
    Do you know the notion of inner product space and Gram-Schmidt? – Raoul Apr 29 '20 at 14:54
  • 1
    Integrals like $\int_\pi^\pi x^n \cos x dx $ can be a tedious for larger and larger $n$. However I think you can find tables where many of them are computed. I suspect that, given the structure of the integral (where $\cos x$ is an even function), you can assume that the polynomial is even, i.e. $ f(x)=q x^2 +s$ – DiegoG7 Apr 29 '20 at 15:04

1 Answers1

1

Let $f(x) = a x^3+bx^2 + c x+d$. The exact result is $$ \int _{-\pi}^{\pi}\bigg(\cos(x)-f(x)\bigg)^2\,dx = \frac{2 \pi ^7 a^2}{7}+\frac{2}{5} \pi ^5 \left(2 a c+b^2\right)+\frac{2}{3} \pi ^3 \left(2 b d+c^2\right)+\pi \left(8 b+2 d^2+1\right) $$We want to minimize this in terms of $a,b,c,d$. By symmetry, we can make the ansatz $a=c=0$: this is plausible because cosine is even, so an even polynomial should be the best fit over a symmetric interval. This yields $$ \int _{-\pi}^{\pi}\bigg(\cos(x)-(bx^2+d)\bigg)^2\,dx = \frac{2 \pi ^5 b^2}{5}+\frac{4}{3} \pi ^3 b d+8 \pi b+2 \pi d^2+\pi $$Taking the gradient and solving for $b,d$, we have $$ \nabla_{b,d} = \left(\frac{4 \pi ^5 b}{5}+\frac{4 \pi ^3 d}{3}+8 \pi ,\frac{4 \pi ^3 b}{3}+4 \pi d\right) $$ $$\nabla_{b,d}=(0,0)\Rightarrow (b,d) = \left(-\frac{45}{2 \pi ^4},\frac{15}{2 \pi ^2}\right) \approx \left(-0.230985, 0.759909\right) $$These values give the minimum value of the integral as $\pi -\frac{90}{\pi ^3}\approx 0.238955$. A similar analysis can be carried out if we don't initially assume $a=c=0$, but we get the same result.

Integrand
  • 8,457