function matrix0

% solve matrix equation (check on timing and errors)

n=2;
for in=1:10
    n=2*n;
    
    % enter matrix A
    A=zeros(n,n);
    for i=1:n
        A(i,i)=2;
        if i>1
            A(i,i-1)=-1;
        end
        if i<n
            A(i,i+1)=-1;
        end
    end
    %A(n,2)=5;
    
    % pick exact solution
    xe=ones(n,1);
    b=A*xe;
    
    % solve equation
    tic;
    xc=A\b;
    tt=toc;
    
    % compute error
    dim(in)=n;
    error(in)=norm(xe-xc,inf);
    fprintf('\n n = %d   Error = %5.1e  Time = %5.1e',n,error(in),tt)
    pause
end
fprintf('\n\n')















