I am trying to use Newtons algorithm for polynomial interpolation. The original polynomial is $p(x) = 3x^2+4x+7$ and the Points from which I am trying to interpolate the polynomial are $p(1) = 14$, $p(6) = 139$ and $p(7) = 182$.
Now as far as I know the formula for the interpolated polynomial should be $r(x) = a_0+a_1(x-x_0)+a_2(x-x_0)(x-x_1)$.
To find $a_0$ I calculate $y_0 = 14 = a_0$. Then, $y_1 = 139 = a_0 + a_1 (x_1-x_0)=14+a_1(6-1)$ so by solving for $a_1$ the result is $a_1 = 25$. At last, $y_2 = 182 = a_0 + a_1(x_1-x_0)+a_2(x_2-x_0)(x_2-x_1)=14+25(6-1)+a_2(7-1)(7-6)$ and solving for $a_2$ results in $a_2=\frac{43}{6}$.
By inserting the found values into the formula I get $r(x)=14+25(x-1)+\frac{43}{6}(x-1)(x-6)=\frac{43}{6}x^2-\frac{151}{6}x+32$.
This polynomial doesn't go though the last point though: $r(7)=\frac{43}{6}\cdot49-\frac{151}{6}\cdot7+32=207 \ne 182=p(7)$.
Am I doing something wrong or does this usually happen with this algorithm?
At your calculation of $a_2$ you substituted the value of $x_1$ for $x$ instead of $x_2$, which should have caused the error.