function van

% solve matrix equation using Vandermonde matrix (check on timing and errors)

n=2;
for in=1:6
    n=2*n;
    
    % enter Vandermonde matrix A
    A=zeros(n,n);
    for i=1:n
        a=1/i;
        A(i,1)=1;
        for j=2:n
            A(i,j)=a^(j-1);
        end
    end
    
    % pick exact solution
    xe=ones(n,1);
    b=A*xe;
    
    % solve equation
    tic;
    xc=A\b;
    tt=toc;
    
    % compute error(s)
    error=norm(xe-xc,inf);
    fprintf('\n n = %d   Error = %5.1e  Time = %5.1e',n,error,tt)
    pause
end
fprintf('\n\n')






