How was this least squares polynomial obtained (solution provided)

72 Views Asked by At

Obtain a least squares polynomial of degree 2.

$$ \begin{array}{c|lcr} x & \text{0} & \text{0.25} & \text{0.5}& \text{0.75}&\text{1} \\ \hline y & 2.9646 & 3.1826 & 3.4773 & 4.1608 & 4.7182 \\ \end{array} $$

$n=2,m=5$

$5a_0+2.5a_1+1.875a_2=18.6878$
$2.5a_0+1.875a_1+1.5625a_2=10.4062$
$1.875a_0+1.5625a_1+1.3828a_2=8.1147$

so $P_2(x)=2.9514+1.0968x+0.6340x^2$

I know how to get from the matrix to the polynomial equation, I am just not sure how to construct the system of equations. The notes are very hard to read and understand, it would be nice to get it in an easy to understand form, and then go back and consolidate what I have learned.

1

There are 1 best solutions below

2
On

This is the matrix product $X^t\times X$ with $X_{ik} = x_i^{k-1}$ and $i=1\dots5, k=1\dots 3$, cf. the Wiki article Polynomial_regression. With your values you have $$X=\begin{bmatrix}1 & 0 &0\\ 1 & 0.25 & 0.0625\\ 1 & 0.5 & 0.25\\ 1 & 0.75 & 0.5625\\ 1 & 1 & 1 \end{bmatrix}$$ Note that I cannot reproduce your RHS. I get $X^t \times y= (18.5035, 10.3731, 8.1268875),\,$ this near your RHS but obviously different.