Labrpt2 Math505 New Format
Labrpt2 Math505 New Format
Introduction - Newton’s divided difference method can be used to write the polynomial
function for use in interpolation without solving system of linear equations. A table can be
filled out so that the constants in the polynomial function is determined directly from the
table. There is also a method from Matlab that can be used to interpolate. This method
gives directly the polynomial function that can be used for interpolation, although this is
written differently from that of Newton’s divided difference.
Procedure - Solve the given problem below using Newton’s divided difference method
and Matlab.
From the data below, determine, by interpolation using a cubic polynomial, the value of y
if x = 7
Divided difference
x y 1st 2nd 3rd
4 20 = b0 b1 b2 b3
5 24
9 28
12 37
x=[4,5,9,12];
y=[20,24,28,37];
a=polyfit(x,y,3)
a =
polyval(a,7)
ans =
27.0714
Discussion –
Conclusion -
x1=[4 5 9 12];
y=[20 24 28 37];
syms x
pol=polyfit(x1,y,3) %returns the coefficients of the polynomial
polynomial=pol(1)*x^3+pol(2)*x^2+pol(3)*x+pol(4) %polynomial in x
y7=polyval(pol,7) % value of polynomial at x=7
Output
pol =
polynomial =
y7 =
References: use the references from the course specs in the moodle