Optimal way to do linear approximation of function on an interval.

45 Views Asked by At

Assume that I want to find the line which in squared integral sense ends up being closest to another function on an interval:

$$\min_{k,m}\left\{\int_{a}^{b} |f(x)-(kx+m)|^2dx\right\}$$

Expanding the square: $$f(x)^2 - 2 f(x)(kx+m) + (kx+m)^2$$

Let's assume we know $$\int_a^b f(x) dx = [F(x)]_a^b\\\int_a^b f(x)^2 dx = [F_2(x)]_a^b$$

How can we derive optimal $k$ and $m$? Is this sufficient information or do we need to know something more?

1

There are 1 best solutions below

3
On

As Damien writes, we will need the expression $$\int_a^b xf(x) dx$$

We can try integration by parts:

$$\int_a^b u(x)v'(x)dx = [u(x)v(x)]_a^b - \int_a^b u'(x)v(x)dx$$ If we set $u(x)=x,v'(x)=f(x)$

$$\int_a^b xf(x)dx = [xF(x)]_a^b - \int_a^b F(x)dx$$

Here we will also need $\int_a^b F(x)dx$.

And since we don't know $F(a),F(b)$ separately we won't be able to calculate $bF(b)-aF(a)$ either.


Another thing we can do is to approximate $f$ by straight line between $f(a)$ and $f(b)$ on $[a,b]$ for only the purpose of approximating the above integral.

$$f_{appr}(x) = f(a) + \frac{(x-a)(f(b)-f(a))}{b-a}$$

Now $\int xf_{appr}(x)dx $ can be easily calculated as a polynomial.

How good this approximation will be, I don't know. Experiments will probably need to be conducted.