clear all; close all;
%--------------- demo_leb_constant_extended_cheb.m ---------------
% This script plots the Lebesgue constant of F-H's interpolant at
% extended Chebychev nodes.
% 
% Functions called: weights, leb_constant
% 
%-----------------------------------------------------------------
% Authors: 
%      Stefano De Marchi and Cinzia Bandiziol
%      Department of Pure and Applied Math.
%      University of Padova
%           
% Version: May 2015		
%------------------------------------------------------------------			

d=3;
g=inline('1/2*(1-cos((2*k+1)*pi/(2*n+2))./cos(pi/(2*n+2)))','n','k');
N=(1:100)';
lambda_n_vect=zeros(100,1);
for n=d+2:101
k_vect=(0:n-1)';
n_vect=n*ones(n,1);
x=g(n,k_vect);% extended Chebychev nodes   
w=weights(d,x);
[lambda_n, points]=leb_constant(min(x),max(x),n,x,w);
lambda_n_vect(n-1)=lambda_n;
end
c=find(lambda_n_vect~=0);
plot(N(c),lambda_n_vect(c),'ob');
title('Lebesgue constant at extended Chebychev nodes');