% Example 4.1.4: Quadratic interpolation.
% Estimate 
%       exp(0.826) 
% using the function values 
%   exp(0.82)=2.270500, exp(0.83)=2.293319, exp(0.84)=2.316367
%
clear all
x_nodes = [0.82 0.83 0.84] ;
y_values = [2.270500 2.293319 2.316367];
x_eval = 0.826 ;
divdif_y = divdif(x_nodes,y_values);
format long
p_eval = interp(x_nodes,divdif_y,x_eval);
error = exp(x_eval)-p_eval;

fprintf('The error in the quadratic interpolation of \n in exp(%.3f)=%.10f is %.10f\n',x_eval,exp(x_eval),error)

t=0.8:0.01:0.842;
f=exp(t);
figure(1)
title('Example 4.1.4')
axis([0.817 0.85 2.2 2.4])
hold all
plot(x_nodes,y_values,'o')
plot(t,f,'-')
plot(x_eval,p_eval,'*')


