# How approximate $p_n(x)$ to minimize the value of integral

I have a continues function $f:[a,b]\to \mathbb{R}$. And want to approximate this function by $p_n(x)$ , ($p_n(x)$ is a polynomial of maximum degree $n.$)

To do this, the value of below integral must be minimized.

Must the value of $\int\limits_0^1 |f(x)-p_n(x)|\, dx$ be minimize.

Whit the help of optimization , how this problem solved? how can determine the $p_n(x)$?

• The larger $n$ the better the approximation unless $f$ is itself a polynomial of lower order. Nov 19 '17 at 8:37
• As @user121049 says, as $n$ increases the approximation gets better. You shouldn’t be solving for “the best $n$.” Rather, you should come up with a methodology that uses $n$ as a parameter. Nov 19 '17 at 14:25
• Does it have to be the integral of the absolute value of the differences you are minimising? If you minimised the square instead then the problem is a lot easier. It becomes very similar to doing linear regression. Nov 19 '17 at 18:25
• @StellaBiderman Except on very short intervals near the point of expansion, Taylor approximation is very bad at achieving $L^p$ closeness. Even for analytic functions (for which it is guaranteed to eventually work) it is still generally slow.
– Ian
Nov 19 '17 at 20:25
• And for $L^2$ you can use Legendre polynomials. Nov 20 '17 at 3:23

If one considers the linear space $P_n$ of polynomials with degree $\leq n$, one can, via the Gram-Schmidt process, create an orthonormal basis of polynomials with respect to the inner product

$$\langle f,g \rangle = \int_0^1 f(t)g(t) dt.$$

Let these polynomials be $u_0,\cdots,u_n$. Then, one can project $f$ onto $P_n$ as

$$f_n(x) = \sum_{i=0}^n \langle f,u_i\rangle u_i(x).$$

This approximation $f_n(x)$ is the polynomial in $P_n$ that minimizes

$$\int_0^1 |f(x)-f_n(x)|^2 dx.$$

(As an aside, this is very similar to how a periodic function's Fourier series is constructed, using the already orthogonal basis $1,\cos(x),\sin(x),\cos(2x),\sin(2x),\cdots$ of the trigonometric polynomials.)

• Note that this is $L^2$ minimization, which is a relatively easy problem. $L^1$ minimization as in the OP is not as easy as that.
– Ian
Nov 19 '17 at 20:03
• @Ian The way I read the question, it asked about a close approximate of a function by polynomials, not specifically about the $L^1$ norm (maybe just putting that down as an idea, and it is a good one). The way I've always seen this approximation done is with the $L^2$ norm, as it is much nicer. If this is more of an open-ended question, I think $L^2$ norm is fine. If not, can OP please indicate this, and I can delete my answer? Nov 20 '17 at 3:38
• @Carl Schidkraut hello, thanks for your answer, in answer , where you use of optimization? Nov 20 '17 at 9:15
• @linkhochon I don't directly use optimization, but the approximation polynomial $f_n(x)$ is the one that minimizes $$\int_0^1 |f(x)-f_n(x)|^2 dx.$$ If you want, I can try to find you a source for this; I'm not sure how to prove it offhand. Nov 20 '17 at 14:56
• @CarlSchildkraut The solution to this would be Legendre polynomials with some coordinate transformation, since these polynomials are orthogonal over the integral interval $[-1,1]$ instead of $[0,1]$. Nov 20 '17 at 18:56