Minimizing integral using least-squares approximation

1.4k Views Asked by At

Find the polynomial $p(x)$ of degree at most $2$ that minimizes the integral $$\int_{-\pi/2}^{\pi/2} |\sin x - p(x)|^2 \cos x \:dx $$

Attempted solution

Let us define an inner product as $\langle f,g \rangle = \int_{- \pi/2}^{\pi/2}f(x)\overline{g(x)} \: dx$. It is easy to show that $\{1, x, x^2-\pi^2/12 \}$ forms an orthogonal basis for the product space which is composed of $\mathbb{P_2}$ with the above inner product. So I suppose we are looking to minimize $$\int_{-\pi/2}^{\pi/2} (\sin x - (a+bx+c(x^2-\pi^2/12)))^2 \cos x \: dx$$ which doesn't look too much fun. I think there is an easier approach by using the least-squares approximation, which I am not sure how to apply here. Does anyone see a somewhat simple solution?

2

There are 2 best solutions below

0
On BEST ANSWER

$$f(a,b,c)=\int_{-\pi/2}^{\pi/2}\left[\sin(x)-ax^2-bx-c\right]^2\cos(x)\,dx $$ is a regular function. By equating to zero $\frac{\partial f}{\partial b}$ you get $b=\frac{\pi}{2(\pi^2-8)}$, then by defining $g(a,c)=f\left(a,\frac{\pi}{2(\pi^2-8)},c\right)$ and equating to zero $\frac{\partial g}{\partial a}$ and $\frac{\partial g}{\partial c}$ you get $a=c=0$, so the optimal approximation is given by $p(x)=\frac{\pi x}{2(\pi^2-8)}$. In such a case

$$ \int_{-\pi/2}^{\pi/2}\left[\sin(x)-p(x)\right]^2\cos(x)\,dx = \frac{13}{24}-\frac{1}{\pi^2-8}=0.00679415598\ldots$$

The solution is greatly simplified by noticing in advance that $p(x)$ has to be an odd function, by symmetry.

2
On

The expression $\langle f,g\rangle = \int_{-\pi/2}^{\pi/2}f\overline{g}\cos x dx$ does define a complex inner product on $C[-\pi,\pi]$. The problem can then be restated as finding scalars $\alpha,\beta,\gamma$ such that $\|\sin x-\alpha -\beta x-\gamma x^2\|$ is minimized, which is achieved iff $(\sin x -\alpha-\beta x-\gamma x^2)\perp 1,x,x^2$. That gives a system of $3$ equations in the $3$ unknowns determined by $$ \int_{-\pi/2}^{\pi/2}(\sin x-\alpha-\beta x-\gamma x^2)\cos x dx =0 \\ \int_{-\pi/2}^{\pi/2}(\sin x-\alpha-\beta x-\gamma x^2)x\cos xdx = 0 \\ \int_{-\pi/2}^{\pi/2}(\sin x-\alpha-\beta x-\gamma x^2)x^2\cos xdx = 0. $$