Linear Algebra – Finding Suitable Polynomial Function for Given Data Points

interpolationlinear algebrapolynomialssolution-verification

I'm working through examples on different kinds of interpolation methods, and I came across this video, with the following question:

Find a polynomial equation that best fits the following data points:
$$(-1,1),(0,1),(1,3),(2,1)$$

To solve this I constructed the following matrix equation:
$$V \cdot c = f, \text{V is the Vandermonde matrix}$$
$$\begin{pmatrix}1&-1&1&-1\\ \:1&0&0&0\\ \:1&1&1&1\\ \:1&2&4&8\end{pmatrix}\begin{pmatrix}c_0\\ \:c_1\\ \:c_2\\ \:c_3\end{pmatrix}=\begin{pmatrix}1\\ \:1\\ \:3\\ \:1\end{pmatrix}$$

Using Reduced Row Echelon Form (done on a piece of paper and confirmed by symbolab), I get the following matrix equation:

$$\DeclareMathOperator{rref}{rref}
\left[\begin{array}{rrrr|r}
1 & 0 & 0 & 0 & 1 \\
0 & 1 & 0 & 0 & 1 \\
0 & 0 & 1 & 0 & 1 \\
0 & 0 & 0 & 1 & -1 \\
\end{array}\right]$$

This means that $c_0=c_1=c_2=1, c_3=-1$ and my polynomial function is $f_1(x)=1+x+x^2-x^3$. However, the answer in the video is slightly different: $f_2(x) = 1+2x+x^2-x^3$. To check which one is correct, I simply checked with gave me the correct results for $x_i, i=0,1,2,3$. Unfortunately, my equation is off by a little: $f_1(-1)=2$ and $f_2(-1)=1$.

I'm not sure why my function is wrong, especially since I checked on Symbolab to reconfirm my solutions for $\vec c$. I suspect it may be a slight error in my RREF but I'm not 100% sure.

Best Answer

Let $f(x)=ax^3+bx^2+cx+d% let this ploynomial pass throught (-1,1),(0,1),(1,3),(2,1)$ Then we get four equations $$-a+b+c-d=1~~~~(1),~~ d=1~~~(2),~~ a+b+c+d=3~~~~(3),~~ 8a+4b+2x+d=1~~~~~(4)$$ These simple simultaneous equations can be solved to get $a=-1,b=1, c=2, d=1$ Fiinally we have $$f(x)=-x^3+x^2+2x+1$$

Related Question