Cholesky

Cholesky[A_]:=(
n=Length[A];
L=Table[0,{i,n},{j,n}];
For[k=1, k≤n, k++, (*Iterate over the columns*) 
(*Find the diagonal element*)
sum=0;
For[p=1,p≤k-1,p++,
sum+=L[[k,p]]^2;
];
L[[k,k]]=√(A[[k,k]]-sum);
For[j=k+1,j≤n,j++, (*Find all the elements below the main diagonal*)
sum=0;
For[i=1,i≤k-1,i++,
sum+=L[[k,i]]L[[j,i]]
];
L[[j,k]]=(1/(L[[k,k]]))(A[[k,j]]-sum)
]
];
L
)
LUSolve[L_,U_,b_]:=(
Module[{x,y}, (*Define x and y to be local variables*)
n=Length[b];
y=Table[0,{i,n}] ;
For[i=1,i≤n, i++,
sum=0;
For[j=1,j≤i-1,j++,
sum+=L[[i,j]]y[[j]]
];
y[[i]]=(1/(L[[i,i]]))(b[[i]]-sum)

];
x=Table[0,{i,n}] ;
For[i=n,i≥1, i--,
sum=0;
For[j=i+1,j≤n,j++,
sum+=U[[i,j]]x[[j]]
];
x[[i]]=(1/(U[[i,i]]))(y[[i]]-sum)

];
x
])