Clenshaw algorithm for least squares approximation

102 Views Asked by At

I am taking a numerical linear algebra class where we are currently learning about least squares and orthogonal polynomials and how to make use of these tools in order to approximate certain functions.

Right now, i am stuck in a homework problem that goes like this:

Approximate $$f(x)=\frac{1}{1+25 x^{2}}$$ through a function of the form $$g_{m}(x)=\sum_{k=0}^{m} c_{k} P_{k}(x)$$ with the goal of finding the minimum value of $$\int_{-1}^{1}\left[f(x)-g_{m}(x)\right]^{2} d x$$

where $\left\{P_{k}\right\}_{k=0}^{\infty}$ stands for the family of the Legendre polynomials.

Where am i stuck? I dont know what the coefficients $c_{k}$ should be and how they could be obtained. After obtaining or generating them i should be done.

What have i done so far? I have already implemented the Clenshaw algorithm in order to calculate $g_{m}\left(x_{j}\right)$. The teacher explicitly asked us to use it.

Thanks in advance!

1

There are 1 best solutions below

2
On BEST ANSWER

Hmmm. I'd call that homework "interesting". Finding optimal $c_k$ is not the problem, but I suspect finding a closed expression was not required (that would be quite a challenge, though I wouldn't exclude the possibility, with very special functions, though). So I guess you have to devise an algorithm (and your "implement" and "generate" point in the same direction). Your "I dont know what the coefficients $c_k$ should be" is quite poor: partial derivative with respect to $c_k$ equal zero means (through orthogonality) $$c_k=\frac{\int^1_{-1}\,f(x)\,P_k(x)\,dx}{\int^1_{-1}\,P^2_k(x)\,dx}=\frac{2k+1}2\,\int^1_{-1}\,f(x)\,P_k(x)\,dx.$$ It's obvious this is $0$ for odd $k$ due to symmetry. For even $k$, $P_k(x)$ is a polynomial in $x^2$, so we have $$\frac{P_k(x)}{1+25\,x^2}=Q(x)+\frac{C}{1+25\,x^2}$$ with a polynomial $Q$ and a constant $C$, and the integral is quite obvious. For small $m$, you could do it manually, though I'd advise against it (it's tedious and error-prone). If you want to program that, I'd advise against using explicit formulas expressing $P_k(x)$ as a sum of monomials $x^l$: the coefficients increase exponentially (like $O(5^k)$), so you'll have to expect cancelling of significant digits.

For finding $c_k$, Clenshaw is useless, you'd need it only for calculating functional values of this approximation, for instance to plot it, just to show that Runge's phenomenon https://en.wikipedia.org/wiki/Runge%27s_phenomenon doesn't occur, here.