Professional Documents
Culture Documents
Submitted By: -
Where, U is an n × n real upper triangular matrix with positive diagonal elements. For
example, a 3 × 3 matrix U for a given 3 × 3 matrix A can be written as;
𝑎11 𝑎12 𝑎13
𝑎
[𝐴] = [ 21 𝑎22 𝑎23 ]
𝑎31 𝑎32 𝑎33
𝑢11 𝑢12 𝑢13
[𝑈] = [ 0 𝑢22 𝑢23 ]
0 0 𝑢33
This factorization is mainly used as a first step for the numerical solution of linear
equations of the form;
[A] [X] = [B] (1)
Where, A is a symmetric positive definite matrix. Such systems arise often in physics
applications, where A is positive definite due to the nature of the modeled physical phenomenon.
The matrix U is found using following formulas;
𝑖−1
2
𝑢𝑖𝑖 = √𝑎𝑖𝑖 − ∑ 𝑢𝑘𝑖
𝑘=1
𝑎𝑖𝑗 − ∑𝑖−1
𝑘=1 𝑢𝑘𝑖 𝑢𝑘𝑗
𝑢𝑖𝑗 =
𝑢𝑖𝑖
Which can be solved for Y and later equation (3) can be solved for X.
2. ALGORITHM
Input:
A symmetric positive definite matrix A whose elements are denoted by aij for 1 ≤ (i,j) ≤ n,
where n is the length of the matrix A.
Output:
The upper triangular matrix U whose elements are denoted by uij for 1 ≤ (i,j) ≤ n, where n
is the length of the matrix A.
Steps:
𝑖−1
2
𝑢𝑖𝑖 = √𝑎𝑖𝑖 − ∑ 𝑢𝑘𝑖
𝑘=1
𝑎𝑖𝑗 − ∑𝑖−1
𝑘=1 𝑢𝑘𝑖 𝑢𝑘𝑗
𝑢𝑖𝑗 =
𝑢𝑖𝑖
Stop.
3. CODE
% CHOLESKY DECOMPOSITION TO SOLVE A SYSTEM OF LINEAR EQUATIONS
clear
clc
flag=1;
while flag==1
Matrix=input('Enter a positive definite symmetric matrix of order n x n
like [6 15 55; 15 55 225; 55 225 979]: \n');
A=Matrix
[m,n] = size( A );
U = zeros( n, n );
K=eig(A)
for i=1:n
for j=1:n
if A(i,j)==A(j,i) && K(i,1)>=0
flag=2;
else
flag=1;
disp('Please use a symmetric positive definite matrix
only')
break
end
end
if flag == 1
break
end
end
end
for i=1:n
U(i, i) = sqrt(A(i, i) - U(:, i)'*U(:, i));
for j=(i + 1):n
U(i, j) = (A(i, j) - U(:,i)'*U(: ,j))/U(i, i);
end
end
display(U)
U_Transpose=U'
rhs=input('Enter the rhs of the equation [1 2 3]: \n');
B=rhs
Y=rhs/U';
X=Y/U
4. EXAMPLE PROBLEM
5. ERROR PROBLEM (WHEN MATRIX IN NOT SYMMETRIC)