# third-order Newton’s interpolating polynomial

3 views (last 30 days)
ِAbo Alqahtani on 3 Dec 2022
Answered: William Rose on 3 Dec 2022

William Rose on 3 Dec 2022
Here is the start of a solution. You will learn a lot more about Matlab by finishing it yourself.
Good luck!
% Create vectors with the known data
%I changed the order of x3,y3 and x4,y4 so the points are increasing
x=[1,4,5,6]; %known x values
y=[0,1.386294,1.609438, 1.791759]; %known y values
b1=y(1);
b2=(y(2)-y(1))/(x(2)-x(1));
b3=0; %edit this
b4=0; %edit this
b5=0; %edit this
xq=2; %query point
yq=b1+b2*(xq-x(1)); %edit this
fprintf('y(interp)=%.4f at x=%.4f.\n',yq,xq);
y(interp)=0.4621 at x=2.0000.
plot((1:.1:6),log(1:.1:6),'-b',x,y,'bx',xq,yq,'ro')
xlabel('x'), ylabel('y')
legend('y=ln(x)','known','interpolated','Location','SE')

### Categories

Find more on Surface and Mesh Plots in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by