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?
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.