function poliposcdata(n,N)
% MATLAB function for polynomial interpolation of oscillatory data
% Argument n specifies the polynomial degree
if (nargin < 2), N = 10000; end; 
t = linspace(0,n*pi/2,N); % For plotting

% Initialization of oscillatory data
x = linspace(0,n*pi/2,n+1); y = sin(x);  

% Two different ways to compute polynomial interpolant
v_monom = ipolevalmonom(x,y,t);
v_bary = ipolevalbarycentric(x,y,t);

% Graphical output
figure('name','Polynomial interpolation');
plot(x,y,'r+',t,v_monom,'b-',t,v_bary,'m-');
xmax = max(x); xmin = min(x);
axis([xmin*2/3+xmax/3,xmin/3+xmax*2/3,-2,2]);
set(gca,'fontsize',14);
xlabel('{\bf t}');
ylabel('{\bf p(t)/y_{i}}');
title(['Polynomial interpolation of oscillatory data, n= ', num2str(n)]);
legend('Monomial based','Barycentric formula','location','best');


