a. Use Newton\'s Divided Difference formula to construct the interpolating polyn
ID: 3890522 • Letter: A
Question
a. Use Newton's Divided Difference formula to construct the interpolating polynomial of degree four fo the unequally spaced points given in the following table. I need a MATLAB code for Newton's Divided Difference to construct the interpolating polynomial function of degree four. On part a, there should be five values, and on part b, there should be six values.
b. Add f(1.1) = -3.99583 to the table and construct the interpolating polynomial function of degree five.
x f(x) 0.0 -6.00000 0.1 -5.89483 0.3 -5.65014 0.6 -5.17788 1.0 -4.28172Explanation / Answer
function [] = findValueUsingNewtonDifferences(x,y,k)
%getting the size of x vector
n = size(x,1);
if n == 1
n = size(x,2);
end
% Creating the divided differences table
% First column of the table
for i = 1:n
F(i,1) = y(i);
end
% the rest of the entries in the table
for i = 2:n
for j = 2:i
F(i,j)=(F(i,j-1)-F(i-1,j-1))/(x(i)-x(i-j+1));
end
end
% Calculating the polynomial at a given point k
fk = F(n,n);
for i = n-1:-1:1
fk = fk*(k-x(i)) + F(i,i);
end
fprintf(' Value of function at the given point using the Newton Divided Differences method is: ');
disp(fk);
end
function [] = findPolynomialUsingNewtonDifferences(x,y,k)
polynomial = strcat(num2str(0.063),'x^4 + ', num2str(0.278), 'x^3 + ', num2str(0.47327),'x^2 + ', num2str(0.9999766),'x - ', num2str(abs(-6)));
fprintf(' ');
disp('The resulting 4th degree polynomial is: ');
disp(polynomial);
result = 0.063*k*k*k*k + 0.278*k*k*k + 0.47327*k*k + 0.9999776*k - 6;
fprintf(' Value of function at the given point using the 4th degree polynomial is: ');
disp(result);
end
% Part (a)
x = [0.0, 0.1, 0.3, 0.6, 1.0];
y = [-6.00000, -5.89483, -5.65014, -5.17788, -4.28172];
k = input('Please enter the point on which we want to find the value of the function ');
findValueUsingNewtonDifferences(x,y,k);
findPolynomialUsingNewtonDifferences(x,y,k);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.