clear all; close all; % Get data: x=0:10; y = sqrt(x); p = newton(x,y); % Evaluate y = sqrt(x) between 0 and 10 using the Lagrange polynomial with % step size 0.2 x1=0:0.2:10; N2=length(x1); for i=1:N2, yp(i) = eval_newton(x,p,x1(i)); true(i) = sqrt(x1(i)); end plot(x1,true,x1,yp,'o') title('Exact and interpolated results') figure(2); plot(x1,yp-true); title('Error plot') hold; y2=0*y; plot(x,y2,':')