Question 6.5: Newton's interpolating polynomial. The set of the following ......

Newton’s interpolating polynomial.

The set of the following five data points is given:

\begin{array}{cr}x & 1 & 2 & 4 & 5 & 7 \\y & 52 & 5 & -5 & -40 & 10\end{array}

(a) Determine the fourth-order polynomial in Newton’s form that passes through the points. Calculate the coefficients by using a divided difference table.

(b) Use the polynomial obtained in part (a) to determine the interpolated value for x=3.

(c) Write a MATLAB user-defined function that interpolates using Newton’s polynomial. The input to the function should be the coordinates of the given data points and the x coordinate of the point at which y is to be interpolated. The output from the function is the y value of the interpolated point.

Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

(a) Newton’s polynomial for the given points has the form:

f(x)=y=a_{1}+a_{2}(x-1)+a_{3}(x-1)(x-2)+a_{4}(x-1)(x-2)(x-4)+a_{5}(x-1)(x-2)(x-4)(x-5)

With the coefficients determined, the polynomial is:

f(x)=y=52-47(x-1)+14(x-1)(x-2)-6(x-1)(x-2)(x-4)+2(x-1)(x-2)(x-4)(x-5)

(b) The interpolated value for x=3 is obtained by substituting for x in the polynomial:

f(3)=y=52-47(3-1)+14(3-1)(3-2)-6(3-1)(3-2)(3-4)+2(3-1)(3-2)(3-4)(3-5)=6
t6.5
The 'Blue Check Mark' means that either the MATLAB code/script/answer provided in the answer section has been tested by our team of experts; or the answer in general has be fact checked.

Learn more on how do we answer questions.

Script File

(c) The MATLAB user-defined function for Newton's interpolation is named Yint=NewtonsINT (x, y, X int ) . x and y are vectors with the coordinates of the given data points, and Xint is the coordinate of the point at which y is to be interpolated.

  • The program starts by calculating the first divided differences, which are then used for calculating the higher divided differences. The values are assigned to a table named divDIF.
  • The coefficients of the polynomial (first row of the table) are then assigned to a vector named a.
  • The known polynomial is used for interpolation.

Program 6-5: User-defined function. Interpolation using Newton's polynomial.

function Yint = NewtonsINT(x,y,Xint)
% NewtonsINT fits a Newtons polynomial to a set of given points and
% uses the polynomial to determines the interpolated value of a point.
% Input variables:
% x A vector with the x coordinates of the given points.
% y A vector with the y coordinates of the given points.
% Xint The x coordinate of the point to be interpolated.
% Output variable:
% Yint The interpolated value of Xint.

n = length(x) ;

a (l)= y (l);
for i = l: n - 1
divDIF(i,l)=(y(i+l)-y(i))/(x(i+ 1)-x(i));
end
for j = 2 :n - 1 for i = l:n - j
divDIF(i,j)=(divDIF(i+l,j-l) -divDIF(i,j-1))/(x(j+i)-x(i));
end

end
for j = 2 :n
a(j) = divDIF(l,j - 1); end
Yint =a (1);
xn = 1;
for k = 2:n
xn = xn*(Xint - x (k - 1));

Yint = Yint + a (k) *xn;
end

The length of the vector \mathrm{x} gives the number of coefficients (and terms) of the polynomial

The first coefficient a_{1}.

Calculate the finite divided differences. They are assigned to the first of divDIF.

Calculate the second and higher divided differences (up to an order of (n-1) ). The values are assigned in columns to divDIF.

Assign the coefficients a_{2} through a_{n}. to vector a.

Calculate the interpolated value of Xint. The first term in the polynomial is a_{1}. The following terms are added by using a loop.

The NewtonsinT ( x, y, Xint) Function is then used in the Command Window for calculating the interpolated value of x=3.

>> x = [l 2 4 5 7];
>> y = [52 5 -5 -40 10) ;
>> Yinterpolated = NewtonsINT(x,y,3)
Yinterpolated =

6

Related Answered Questions