Question: What is wrong with algorithm?

Hello! I have written a algorithm. Can you help me find errors? thank you very much. sorry, my English is not very good!

LL:=proc(A::Matrix)
uses LA= LinearAlgebra;
local i, j, k, n:= LA:-RowDimension(A),
L:= Matrix(LA:-Dimensions(A));
L[1,1]:=sqrt(A[1,1]);
for j from 2 to n do
L[j,1]:=(A[j,1])/(L[1,1]);
end do;
for i from 2 to n-1 do
L[i,i]:=(A[i,i]-add(L[i,k]^(2),k=1..i-1))^(1/(2));
for j from i+1 to n do
L[j,i]:=(1/L[i,i])*(A[j,i]-add(L[j,k]*L[i,k],k=1..i-1));
end do;
end do;
L[n,n]:=(A[n,n]-add((L[n,k])^(2),k=1..n-1)^(1/(2));
L;

Please Wait...