% Example 4.1.3: Quadratic interpolation.
% Construct P2(x) 
% using the data points 
%   (0,-1), (1,-1), (2,7)
% and graph.
clear all

x_nodes = [0 1 2] ;
y_values = [-1 -1 7];

divdif_y = divdif(x_nodes,y_values)


t=x_nodes(1)-0.5:0.01:x_nodes(end)+0.5;
p_eval = interp(x_nodes,divdif_y,t);

figure(1)
title('Example 4.1.3')
axis([t(1) t(end) min(p_eval)*1.5 max(p_eval)*1.5])
hold all
plot(x_nodes,y_values,'o')
plot(t,p_eval)
legend('data','\Pi_2 interpolating polynomial')

