$4^\text{th}$ order polynomial approximation for: $f(x) = e^{-\cos(2\pi x)}$

79 Views Asked by At

I know how to find a polynomial approximation for a function $f(x)$ around a fixed number let's say $x=0$.

However I do not have an idea about how to solve the following:

Find a $4^\text{th}$ order polynomial approximation for: $f(x) = e^{-\cos(2\pi x)}$, where $x \in [0,1]$ such that $\int_{0}^{\\1} |f(x) - p(x)|^2$ is minimized.

Could you please help me?

4

There are 4 best solutions below

0
On BEST ANSWER

Using Michael's notation, you want to minimise

$$I(A,B,C,D,E) = \int_0^1(f(x)-p(x))^2dx = \int_0^1(f(x)-A-Bx-Cx^2-Dx^3-Ex^4)^2dx$$

So set

$$\frac{\partial I}{\partial A} = \frac{\partial I}{\partial B} = \frac{\partial I}{\partial C} = \frac{\partial I}{\partial D} = \frac{\partial I}{\partial E} = 0$$

For example,

$$\frac{\partial I}{\partial C} = \int_0^1\frac{\partial}{\partial C}\{(f(x)-A-Bx-Cx^2-Dx^3-Ex^4)^2\}dx = -2\int_0^1x^2(f(x)-p(x))dx$$

Setting this to zero gives $\int_0^1x^2f(x) = \int_0^1x^2p(x)dx$.

In this way, you get the five equations

$$\int_0^1f(x) = \int_0^1p(x)dx$$
$$\int_0^1xf(x) = \int_0^1xp(x)dx$$
$$\int_0^1x^2f(x) = \int_0^1x^2p(x)dx$$
$$\int_0^1x^3f(x) = \int_0^1x^3p(x)dx$$
$$\int_0^1x^4f(x) = \int_0^1x^4p(x)dx$$

The left-hand sides are constants that you can evaluate, and the right-hand sides are linear functions of $A,B,C,D,$ and $E$. So you get five linear equations in five unknowns, which you can solve by the usual means.

2
On

$$\int_0^1(f(x)-A-Bx-Cx^2-Dx^3-Ex^4)^2dx$$ If you expand this, you get a quadratic in $A,B,C,D,E$.

0
On

The preferred answer in this situation computes the projection using an orthogonal basis, where we measure orthogonality using the $L^2$ inner product, i.e. $\langle f,g \rangle = \int_0^1 f(x) g(x) dx$. Here the system of orthogonal polynomials is a small variant on the Legendre polynomials; namely, you want $p_n(x)=L_n(2x-1)$, where $L_n$ are the Legendre polynomials. Then the projection of $f$ is

$$g(x) = \sum_{n=0}^4 c_n p_n(x)$$

where

$$c_n = \frac{\int_0^1 f(x) p_n(x) dx}{\int_0^1 p_n(x)^2 dx}.$$

Note that no system of linear equations is required.

The denominators are easy to compute (change variables back to $[-1,1]$, then use https://en.wikipedia.org/wiki/Legendre_polynomials#Orthogonality). The numerators are nontrivial integrals, which probably have no closed form solution, so that numerical methods will be required.

0
On

In the same spirit as in previous answers, let us consider the more general problem in which you want to approximate a function $f(x)$ by a polynomial of degree $n$ $(p(x)=\sum_{i=0}^n c_ix^i)$ over a range $a\leq x \leq b$, you need to solve $n$ equations of the form $$\int_a^b x^k f(x)\,dx=\int_a^b x^k p(x)\,dx=\sum_{i=0}^n \int_a^bc_ix^{i+k}\,dx=\sum_{i=0}^n\frac{b^{i+k+1}-a^{i+k+1}}{i+k+1}c_i$$ which is a linear system in $c_i$ (index $k$ runs from $0$ to $n$). This does not make any problem except that the most lhs may not have exact values because the antiderivative of $x^k f(x)$ cannot be explicitly written; this is the case in your problem since if $k=0$ we get $I_0(1)$ but, for any $k>0$, I do not think that there is any closed form expression.

In such a case, you then need to evaluate numerically the different integrals. For your problem, setting $$A_k=\int_0^1 x^k\, e^{-\cos(2\pi x)}\,dx$$ we can get (I give you more values than required if you want to try higher orders for the polynomial) $$\left( \begin{array}{cc} k & A_k \\ 0 & 1.26606587775201 \\ 1 & 0.633032938876004 \\ 2 & 0.367964621370908 \\ 3 & 0.235430462618360 \\ 4 & 0.162251055432262 \\ 5 & 0.118749024029389 \\ 6 & 0.0912794861934411 \\ 7 & 0.0730200008162695 \\ 8 & 0.0603319560387539 \\ 9 & 0.0511686546243073 \\ 10 & 0.0443250409943864 \end{array} \right)$$

Since $a=0,b=1$, you then just need to solve $$A_k=\sum_{i=0}^n\frac{c_i}{i+k+1}$$