function err = ipolinferror(f,a,b,nvec,N)
% Computation of error of polynomial interpolant of a function (passed
% as function handle f) on interval [a,b] for different polynomial degrees
% (passed in row vector nvec) and equidistant interpolation nodes.
% The function returns a matrix of polynomials degrees next to the 
% approximate maximum norms of the interpolation errors.

if (nargin < 5), N = 100000; end
t = linspace(a,b,N); % sampling points

% Main loop over polynomial degrees
err = [];
for n=nvec
  x = linspace(a,b,n+1); % interpolation nodes
  y = f(x);              % sample f 
  pv = ipolevalbarycentric(x,y,t);
  err = [err; n max(abs(f(t)-pv))];
end

