Approximating $\sin x$ with given polynomials .

155 Views Asked by At

I am required to approximate function $ sin (\pi x) \text{ on} -1 \leq x \leq 1 $ with the function $$ f_{N}(x) = \displaystyle\sum_{k=0}^{N‎} a_{k}x^{2k+1}$$ where coefficients $\ a_{k},\ k=0,1,..N$ are chosen to minimize integral $$F(a_{0},a_{1},...a_{N}) = \displaystyle \int_{-1}^{1} [f_{N}(x) - sin(\pi x)]^2 dx $$ I need to show the coefficients $ a_{k},\ k= 0,1,..N,\ $ are given by the solution of linear equations $$ \displaystyle\sum_{k=0}^{N} \frac{a_k}{2(k+j)+3 } = I_j , \text{where } I_j = \displaystyle\int_{0}^{1} x^{2j+1} sin(\pi x)\ dx , $$ for $j=0,1,..N$,

I am out of ideas how can summation with 'a' coefficient in LHS I can produce 'sin' on RHS

2

There are 2 best solutions below

0
On BEST ANSWER

This reduces to a standard least squares fit problem.

Let $b_k(x) = x^{2k+1}$, $k=0,..,N$, and $f(x) =\sin(\pi x)$. The problem is to solve $\min_{a \in \mathbb{R}^{n+1}} \| \sum_k a_k b_k -f \|^2 = \min_{a \in \mathbb{R}^{n+1}} \| Ba -f \|^2$, where $B: \mathbb{R}^{n+1} \to L^2[-1,1]$ is given by $(B a)(x) = \sum_k a_k b_k(x)$.

Since \begin{eqnarray} \| Ba -f \|^2 &=& \langle Ba -f , Ba -f \rangle \\ &=& \langle Ba, B a \rangle -2\langle Ba ,f \rangle + \|f\|^2 \\ &=& \langle a, B^*B a \rangle -2\langle Ba ,f \rangle + \|f\|^2 \\ &=& \langle a, B^*B a \rangle -2\langle a ,B^*f \rangle + \|f\|^2 \\ \end{eqnarray} we see that this is a convex quadratic problem in $\mathbb{R}^{n+1}$, and the first order conditions give $B^*Ba = B^* f$.

To compute $B^*$, use the definition \begin{eqnarray} \langle B^*g,a \rangle &=& \langle g,Ba \rangle \\ &=& \int g(x) (Ba)(x)dx \\ &=& \sum_k a_k \int g(x) x^{2k+1} dx \\ &=& \sum_k a_k c_k \\ &=& \langle c,a \rangle \end{eqnarray} so $[B^* g]_k = c_k = \int g(x) x^{2k+1} dx$.

Note that $[B^*Ba]_j = \int (Ba)(x) x^{2j+1}dx = \sum_k a_k \int x^{2(k+j)+2} dx$ and $[B^*f]_j = \int \sin(\pi x) x^{2j+1} dx$.

Now evaluate the $[B^*Ba]_j$ and use oddness to get the $I_j$ formula.

Note:

The whole dual thing can be avoided by noting that \begin{eqnarray} \|B a -f \|^2 &=& \int (\sum_k a_k x^{2k+1} - f(x))^2 dx \\ &=& \sum_j \sum_k a_ja_k \int x^{2(k+j)+2}dx - 2 \sum_j a_j \int x^{2j+1} f(x)dx + \int f(x)^2 dx \\ &=& \langle a, Ga \rangle - 2 \langle a , c \rangle + \|f\|^2 \end{eqnarray} where $[G]_{jk} = \int x^{2(k+j)+2}dx$ and $c$ is as above. At a solution the first order conditions will give $Ga=c$ which is equivalent to the desired result.

0
On

The non-negative function $F(a_0,a_1,\ldots,a_N)=\int_{-1}^1(\sum_{k=0}^Na_kx^{2k+1}-\sin\pi x)^2\,dx$ is quadratic in each of its variables, and therefore is minimized when each of its derivatives is $0$. The derivative with respect to $a_j$ is

$$\begin{align} \int_{-1}^12x^{2j+1}\left(\sum_{k=0}^Na_kx^{2k+1}-\sin\pi x\right)\,dx &=2\sum_{k=0}^Na_k\int_{-1}^1x^{2(k+j)+2}\,dx-2\int_{-1}^1x^{2j+1}\sin\pi x\,dx\\ &=4\sum_{k=0}^N{a_k\over2(k+j)+3}-2\int_{-1}^1x^{2j+1}\sin\pi x\,dx \end{align}$$

Setting this equal to $0$ implies

$$\sum_{k=0}^N{a_k\over2(k+j)+3}={1\over2}\int_{-1}^1x^{2j+1}\sin\pi x\,dx=\int_0^1x^{2j+1}\sin\pi x\,dx$$

where the final step uses the fact that $x^{2j+1}\sin\pi x$ is an even function.