function table=problem3(nn)

%Programming Problem 4 
% Input nn=10:10:100 list of dimensions
% Outpuf table with errors

table = [];

for n=nn
    
a=matrixhw1(n);
      
  x = (1:n)';
  b = a*x;
  x1= mychol_solver(a,b);
  
%error 
e=norm(x-x1)/norm(x);
table=[table; n e];
end


function a=matrixhw1(n)
a=[];
for i=1:n
    for j=1:n
        a(i,j)=1/(i+j)^2;
    end
    a(i,i)=1;
end


function x = forbacksubs(A,x,f)

% FORWARD (f=0). Forward elimination.
% For lower triangular L, x = forbacksubs(L,b,0) solves L*x = b.
% BACKSUBS (f=1).  Back substitution.
% For upper triangular U, x = forbacksubs(U,b,1) solves U*x = b.


[n,n] = size(A);
if f==0
    x(1) = x(1)/A(1,1);
    for k = 2:n
        j = 1:k-1;
        x(k) = (x(k) - A(k,j)*x(j))/A(k,k);
    end
    
else
    
    x(n) = x(n)/A(n,n);
    
    for k = n-1:-1:1
        j = k+1:n;
        x(k) = (x(k) - A(k,j)*x(j))/A(k,k);
    end
end