clear all; close all;
%-------------- demo_leb_constant_cheb.m -------------------------
% This script plots the Lebesgue constant of F-H's interpolant at 
% Chebychev-Gauss-Lobatto 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;
F3=inline('(1-cos(pi*t))/2','t');%distribution function of Chebychev-Gauss-Lobatto nodes

N=(1:100)';
lambda_n_vect=zeros(100,1);
for n=d+2:101
abscissa=(0:1/(n-1):1)';%equidistant points in [0,1]
x=F3(abscissa);%Chebychev-Gauss-Lobatto 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 Chebychev-Gauss-Lobatto nodes');