%  This function solves the first part of homework problem [H6.1]
%  --------------------------------------------------------------
%
echo on
diary nsds_hw6_1a.dry
%
%  We want to check the behavior of Newton-Gregory
%  polynomials for interpolation among arbitrary
%  data points.
%
%  Given the following data vectors:
%
xvec = [  0;  6; 12; 18; 24; 36; 48; 60; 66; 72];
yvec = [  6; 16; 28; 21; 18; 34; 18; 25; 15;  4];
%
%  In order to be able to apply Nordsieck interpolation,
%  we need equidistant data points.  We use spline
%  interpolation to get those.
%
xvec_new = [0:6:72]';
yvec_new = spline(xvec,yvec,xvec_new)
%
%  The cleaned-up data can be represented as:
%
xvec = xvec_new;
yvec = yvec_new;
[ xvec , yvec ]
%
%  Now, we shall apply in parallel Nordsieck interpolation
%  and spline interpolation to these data.
%
xvec_new = [0:72]';
yvec_new = nordsieck_intpol(xvec,yvec,xvec_new);
yvec_new2 = spline(xvec,yvec,xvec_new);
%
%  Plot the results
%
plot(xvec_new,yvec_new,xvec_new,yvec_new2)
grid on
title('ttt')
xlabel('xxx')
ylabel('yyy')
print -deps nsds_hw6_1a.eps
%
%  The Nordsieck approach worked, but the interpolation is
%  not as smooth as in the case of cubic splines.
%
diary off
echo off
%
return