%
% OPTCONDVS  Optimally conditioned
%   Vandermonde matrix with symmetric
%   nodes
%   n>2
%
n=5;
ns=floor((n+1)/2);
if ns==n/2  %n is even
  A=zeros(ns); Aeq=[]; 
  b=zeros(ns,1); beq=[];
  for k=1:ns-1
    A(k,k+1)=1; A(k,k)=-1;
  end  
  A(ns,ns)=-1;
else
  A=zeros(ns-1,ns); Aeq=zeros(1,ns); 
  b=zeros(ns-1,1); beq=[0];
  for k=1:ns-1
    A(k,k+1)=1; A(k,k)=-1;
  end
  Aeq(1,ns)=1;
end
%x0=[2 0]';
%x0=[1.5 .8]';
x0=[1.22 1 0]';
%x0=[1.18 1.05 .4]';
%x0=[1.145 1.033 .562 0]';
%x0=[1.05 .96 .77 .2]';
%x0=[1.14 1.05 .84 .1 0]';
%x0=[1.1276 1.0630 .8807 .5752 .1855]';
[xmin,fmin,fl]=fmincon(@(x) condVs(n,x),x0,A,b,Aeq,beq)
sum(xmin.^(n-1))
