% % 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) yvec_new = 6.0000 16.0000 28.0000 21.0000 18.0000 27.1158 34.0000 26.5108 18.0000 21.7161 25.0000 15.0000 4.0000 % % The cleaned-up data can be represented as: % xvec = xvec_new; yvec = yvec_new; [ xvec , yvec ] ans = 0 6.0000 6.0000 16.0000 12.0000 28.0000 18.0000 21.0000 24.0000 18.0000 30.0000 27.1158 36.0000 34.0000 42.0000 26.5108 48.0000 18.0000 54.0000 21.7161 60.0000 25.0000 66.0000 15.0000 72.0000 4.0000 % % 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