Description
Hi
How are you
I need you to do it by using matlab code
Thanks
Unformatted Attachment Preview
Purchase answer to see full attachment

Explanation & Answer

Hi, here is your assignment together with matlab files :).
1
Computational Methods in Engineering
Problem 1:
Matlab Code:
% Problem 1:
x=[0 1 2.5 3 4.5 5 6];
y=[2 5.4375 7.3516 7.5625 8.4453 9.1875 12];
newton_interpolation(x, y, 3.5)
function fp = newton_interpolation(x,y,p)
% x and y are two Row Matrices and p is point of interpolation
n = length(x);
a(1) = y(1);
for k = 1 : n - 1
d(k, 1) = (y(k+1) - y(k))/(x(k+1) - x(k));
end
for j = 2 : n - 1
for k = 1 : n - j
d(k, j) = (d(k+1, j - 1) - d(k, j - 1))/(x(k+j) - x(k));
end
end
d
for j = 2 : n
a(j) = d(1, j-1);
end
Df(1) = 1;
c(1) = a(1);
for j = 2 : n
Df(j)=(p - x(j-1)) .* Df(j-1);
c(j) = a(j) .* Df(j);
end
fp=sum(c);
end
Output:
d = 6×6
3.4375
-0.8646
1.2761
-0.4271
0.4218
0.0834
0.5885
0.4479
1.4844
0.8854
2...
