% % Matlab script file to illustrate some features of polynomial % interpolation: Lebesgue constants, Chebyshev abscissae vs % equi-distant nodes, etc. % % C.G. (11-96) % m = 800 ; t = [ 0 : m ]' * 2 / m - 1 ; % number/vector of sample points % % Loop over n = 5, 10, 15, 20. % for in = 1 : 4 n = 5 * in ; % % put the different node sets in the columns of the array tau. % tau = zeros( n + 1, 3 ) ; % initialize an array of the proper dimensions tau(:,1) = [ 0 : n ]' * 2 / n - 1 ; % equally spaced nodes on [-1,1] tau(:,2) = - cos( ( 2*[0:n]' + 1 ) * pi / ( 2*n + 2 ) ) ; % Chebyshev nodes tau(:,3) = - cos( [ 0 : n ]' * pi / n ) ; % modified Chebyshev nodes % % evaluate the Lebesgue constant for these three node sets on [-1,1]. % imask = ones( n+1, 1 ) ; ident = eye( n+1 ) ; % init mask and unit vectors for k = 1 : 3 sum = zeros( m+1, 1 ) ; % initialize sum (at each t point) to zero for i = 0 : n p = poly( tau(logical(imask-ident(:,i+1)),k) ) ; % coeff's of i'th % Lagrange poly sum = sum + abs( polyval( p, t ) / polyval( p, tau(i+1,k) ) ) ; end table(in,k+1) = max( sum ) ; end table(in,1) = n ; end table