Module-2 Complete Note
Module-2 Complete Note
SHORT NOTE
ON
INTRODUCTION TO NUMERICAL LINEAR
ALGEBRA (INLA)
Department of Mathematics
School of CS & AI
SR University, Warangal-506371
Telangana
Topics Covered
➢ Cholesky factorization
➢ QR factorization
➢ Basics of Matrix
Note:
1. ‖−𝑥‖ = ‖𝑥‖
2 . ‖𝑥‖ − ‖𝑦‖ ≤ ‖𝑥 − 𝑦‖ f o r a l l 𝑥, 𝑦 ∈ ℝ𝑛
In general, if p is a real number greater than or equal to 1, then the p-norm or Holder
norm is defined by
1
‖𝑥‖𝑝 = (|𝑥1 |𝑝 + |𝑥2 |𝑝 + ⋯ + |𝑥𝑛 |𝑝 )𝑝
Example 2.1.1. Let 𝒙 = (𝟏, 𝟏, −𝟐) be a vector. Find the 1-norm, Euclidean norm and infinity
norm.
Solution: The sum norm or 1-norm is given by
‖𝑥‖1 = |1| + |1| + |−2| = 1 + 1 + 2 = 4
The Euclidean norm or two norm is given by
‖𝑥‖2 = √12 + 12 + (−2)2 = √6
The Infinity norm or maximum norm is given by
‖𝑥‖∞ = Max |𝑥𝑖 | = Max{|1|, |1|, |−2|} = Max{1,1, 2} = 2.
𝑖
satisfies all the properties of a matrix norm. This norm is called the matrix norm subordinate
to the vector norm or just subordinate matrix norm.
A very useful and frequently used property of a subordinate matrix norm (we shall sometimes call it the
p-norm of a matrix A) is ‖𝐴𝑥‖𝑝 ≤ ‖𝐴‖𝑝 ‖𝑥‖𝑝 .
Solution:
Spectral Norm of a matrix
Another useful p-norm is the spectral norm, denoted by ‖𝐴‖2 a n d i s d ef i ne d b y
‖𝐴𝑥‖2
‖𝐴‖2 = Max .
𝑥≠0 ‖𝑥‖2
𝟐 𝟓
Example 2.1.4. Let 𝑨 = ( ) be a matrix. Find the spectral norm of A.
𝟏 𝟑
S o l u t i o n : The eigenvalues of 𝐴𝑇 𝐴 are 𝜆1 = 0.0257 and 𝜆2 = 38.9743. (Verify yourself!!!)
Then the spectral norm of A is given by
‖𝐴‖2 = √maximum eigenvalue of 𝐴𝑇 𝐴
𝑜𝑟, ‖𝐴‖2 = √38.9743
‖𝐴‖2 = 6.2429
The Frobenius Norm
An important matrix norm compatible with the vector norm ‖𝑥‖2 is the Frobenius norm:
1
𝑛 𝑚 2
2
‖𝐴‖𝐹 = [∑ ∑|𝑎𝑖𝑗 | ]
𝑗 𝑖
A matrix norm ‖. ‖𝑀 and vector norm ‖. ‖𝑣 are compatible if ‖𝐴𝑥‖𝑣 ≤ ‖𝐴‖𝑀 ‖𝑥‖𝑣 .
𝟐 𝟓
Example 2.1.5. Let 𝑨 = ( ). Then find the Frobenius Norm of the matrix.
𝟏 𝟑
Solution: The Frobenius Norm of the matrix A is given by
1
𝑛 𝑚 2
2
‖𝐴‖𝐹 = [∑ ∑|𝑎𝑖𝑗 | ] = √30.
𝑗 𝑖
𝑈11 = 1
𝑈12 = 2
𝑈13 = 4
𝐿31 𝑈13 + 𝐿32 𝑈23 + 𝑈33 = 13, or, 2 × 4 + 1 × 2 + 𝑈33 = 13, or, 𝑈33 = 3.
2 2 3
𝐴 (1)
= [0 1 0] ; ℎ𝑒𝑟𝑒 𝑚 = −2, 𝑚 = − 1 𝑎𝑟𝑒 𝑡ℎ𝑒 𝑚𝑢𝑡𝑖𝑝𝑙𝑖𝑒𝑟𝑠.
5 21 31 2
0 1 2
Step 2 (eliminate the entries of the second column of 𝑨(𝟏) below the diagonal)
Multiply the second column of 𝑨(𝟏) by −1 and add to the third row.
2 2 3
𝐴 (2)
= [0 1 0] ; ℎ𝑒𝑟𝑒 𝑚 = −1.
5 32
0 0 2
2 2 3
So, 𝑈 = 𝐴 (2)
= [0 1 0],
5
0 0
2
1 0 0 1 0 0
𝐿= 𝐿−1
1 = [−𝑚21 1 0] = [2 1 0].
1
−𝑚31 −𝑚32 1 2
1 1
Example 4
𝒙𝟏 𝟏 𝟐 𝟒 𝒙𝟏 𝟑
Find the solution of 𝑿 = [𝒙𝟐 ] of the system [𝟑 𝟖 𝟏𝟒 ] [ 𝒙 𝟐 ] = [𝟏𝟑]
𝒙𝟑 𝟐 𝟔 𝟏𝟑 𝒙𝟑 𝟒
Solution
The first step is to calculate the LU decomposition of the coefficient matrix. Here, the factorization has
already been done (see Example 2.2.1).
We found that
1 0 0 1 2 4
𝐿 = [3 1 0], 𝑈 = [0 2 2].
2 1 1 0 0 3
𝑦1
The next step is to solve 𝐿𝑌 = 𝐵 for the vector 𝑌 = [𝑦2 ]. That is, we consider
𝑦3
1 0 0 𝑦1 3
𝐿𝑌 = [3 1 0] [𝑦2 ] = [13] = 𝐵
2 1 1 𝑦3 4
which can be solved by forward substitution.
From the top equation we see that 𝑦1 = 3.
The middle equation states that 3𝑦1 + 𝑦2 = 13 and hence 𝑦2 = 4.
Finally, the last one that 2𝑦1 + 𝑦2 + 𝑦3 = 4 from which we see that 𝑦3 = −6.
Now that we have found 𝑌 we finish the procedure by solving 𝑈𝑋 = 𝑌 for 𝑋. That is, we solve
1 2 4 𝑥1 3
𝑈𝑋 = [0 2 2] [𝑥2 ] = [ 4 ] = 𝑌
0 0 3 𝑥3 −6
by using back substitution.
Starting with the bottom equation we see that 3𝑥3 = −6 so clearly 𝑥3 = −2.
The middle equation implies that 2𝑥2 + 2𝑥3 = 4 and it follows that 𝑥2 = 4.
The top equation states that 𝑥1 + 2𝑥2 + 4𝑥3 = 3 and consequently 𝑥1 = 3.
Therefore, the solution to then given system of simultaneous equations is
3
𝑋=[ 4 ]
−2
2.2.4. Existence (Do matrices always have an LU Factorization?)
No. Sometimes it is impossible to write a matrix in the form “lower triangular” × “upper triangular”.
Why not?
An invertible matrix A has an 𝐿𝑈 decomposition provided that all its leading submatrices have non-zero
determinants. The kth leading submatrix of A is denoted 𝐴𝑘 and is the k × k matrix found by looking only
at the top k rows and leftmost k columns. For example, if
1 2 4
𝐴 = [3 8 14]
2 6 13
then the leading submatrices are
1 2 4
1 2
𝐴1 = [1], 𝐴2 = [ ], 𝐴3 = [3 8 14]
3 8
2 6 13
The fact that this matrix A has an LU decomposition can be guaranteed in advance because none of these
determinants is zero:
𝟏 𝟐 𝟑
Example 5. Show that Show that [𝟐 𝟒 𝟓] does not have an LU decomposition
𝟏 𝟑 𝟒
Solution
The second leading submatrix has determinant equal to
𝟏 𝟐 𝟒
Example 6. Find the LU Factorization of the matrix 𝑨 = (𝟒 𝟓 𝟔) using Gauss elimination
𝟕 𝟖 𝟗
with partial pivoting method.
Solution
Disadvantages of LU Factorization:
1. Pivoting Issues: Without proper pivoting strategies, LU factorization may encounter problems
with matrices that have small pivots or are close to singular. Pivoting is often required to improve
stability.
2. Storage Requirements: The LU factorization process requires additional storage space for the
factors L and U, which can be a concern for large matrices.
3. Computationally Expensive: LU factorization can be computationally expensive for large
matrices.
Exercises 2.2
2.3. Cholesky Factorization
2.3.1. Definition (positive definite matrix)
A symmetric matrix A is positive definite if for every nonzero vector x, 𝒙𝑻 𝑨𝒙 > 𝟎. Let 𝒙 =
𝑥1
𝑥2
(𝒙𝟏 , 𝒙𝟐 , . . . , 𝒙𝒏 ) = [ … ]. Then 𝒙𝑻 𝑨𝒙 = ∑𝒏𝒊,𝒋=𝟏 𝒂𝒊𝒋 𝒙𝒊 𝒙𝒋 is called the quadratic farm associated with 𝐴.
𝑥𝑛
A positive semidefinite matrix is similarly definite. A symmetric matrix 𝐴 is positive semidefinite
if 𝒙𝑻 𝑨𝒙 ≥ 0 for all vectors 𝑥.
A commonly used notation for a symmetric positive definite (positive semidefinite matrix) is 𝐴 >
0 (≥ 0).
2. A symmetric matrix A is positive definite if and only if all its leading principal minors are positive. i.e.,
the determinant of 𝐴𝑘 (the upper left 𝑘 × 𝑘 submatrix) should be positive.
4. If 𝐴 = (𝑎𝑖𝑗 ) is symmetric positive definite, then the largest element (in magnitude) of the whole matrix
must lie on the diagonal.
5. The sum of two symmetric positive definite matrices is symmetric positive definite.
𝟗 𝟔
Example 1: Let 𝑨 = [ ] be a 𝟐 × 𝟐 matrix.
𝟔 𝒂
A is symmetric
|A1|=9>0
9 6
|A2|= | | = 9𝑎 − 36
6 𝑎
If 𝑎 > 4, then 𝐴 is positive definite.
If 𝑎 = 4, then 𝐴 is positive semi definite.
If 𝑎 < 4, then 𝐴 is not positive definite.
2 −𝟏 𝟎
Example 2: Is the matrix 𝑨 = [−𝟏 2 −1] positive definite?
𝟎 −1 𝟐
Solution
We will check whether all of its leading principal minors |𝐴𝑘 | are positive or not.
Now, |𝐴1 | = 2 > 0
𝟐 −𝟏
|𝐴2 | = | |=4−1=3>0
−𝟏 𝟐
𝟐 −𝟏 0
|𝐴3 | = |−𝟏 𝟐 −𝟏| = 2(4 − 1) + 1(−2 − 0) + 0(1 − 0) = 6 − 2 = 4 > 0
𝟎 −𝟏 𝟐
Therefore, all of its leading principal minors |𝐴𝑘 | are positive. So, the given matrix is positive definite.
2 2 2
𝑎22 = ℎ21 + ℎ22 ⇒ ℎ22 = √𝑎22 − ℎ21
2 2 2 2 2
𝑎33 = ℎ31 + ℎ32 + ℎ33 ⇒ ℎ33 = √𝑎33 − ℎ31 − ℎ32
In general, compute recursively the first through nth columns of H by comparing the entries of the respective
column of both sides of 𝐴 = 𝐻𝐻 𝑇 .
Remarks.
1. The matrix H above is computed column by column.
2. The positive definiteness of A will make the quantities under the square root signs positive.
𝟏 𝟏 𝟏
Example 2: Find the Cholesky factorization of the matrix 𝑨 = [𝟏 𝟓 𝟓]
𝟏 𝟓 𝟏𝟒
Solution
𝟏 𝟏 𝟏 𝑎11 𝑎12 𝑎13
𝑎
We have 𝑨 = [𝟏 𝟓 𝟓 ] = [ 21 𝑎22 𝑎23 ] (𝑠𝑎𝑦)
𝟏 𝟓 𝟏𝟒 𝑎31 𝑎32 𝑎33
ℎ11 0 0
Then the Cholesky factorization of A is given by 𝐴 = 𝐻𝐻 𝑇 , where 𝐻 = [ℎ21 ℎ22 0 ]
ℎ31 ℎ32 ℎ33
Now we will find the Cholesky Factor H in the following the steps:
Step-1 (Computation of the 1st column of H)
ℎ11 = √𝑎11 = √1 = 1
𝑎21 1
ℎ21 = = =1
ℎ11 1
𝑎31 1
ℎ31 = = =1
ℎ11 1
2
ℎ22 = √𝑎22 − ℎ21 = √5 − 12 = 2
𝑎32 − ℎ21 ℎ31 5 − 1.1
ℎ32 = = =2
ℎ22 2
2 2
ℎ33 = √𝑎33 − ℎ31 − ℎ32 = √14 − 12 − 22 = ℎ33 = √9 = 3
1 0 0
Thus 𝐻 = [1 2 0]
1 2 3
1 1 1
Hence the Cholesky Factorization of the matrix 𝐴 = [1 5 5 ] is given by
1 5 14
1 1 1 1 0 0 1 1 1
𝐴 = [1 5 5 ] = 𝐻𝐻 𝑇 = [1 2 0] [0 2 2]
1 5 14 1 2 3 0 0 3
Exercise 2.3
1. Find the Cholesky Factorization of the following symmetric positive definite matrices:
𝟐𝟓 𝟏𝟓 −𝟓
(a) [ 𝟏𝟓 𝟏𝟖 𝟎 ]
−𝟓 𝟎 𝟏𝟏
𝟗 −𝟔 𝟔
(b) [−𝟔 𝟓 −𝟏]
𝟔 −𝟏 𝟏𝟓
2. Solve the following systems of linear equations using Cholesky Factorization:
(a) 𝟐𝟓𝒙 + 𝟏𝟓𝒚 − 𝟓𝒛 = 𝟓
𝟏𝟓𝒙 + 𝟏𝟖𝒚 + 𝟎𝒛 = 𝟑
−𝟓𝒙 + 𝟎𝒚 + 𝟏𝟏𝒛 = 𝟏𝟐
(b) 𝟗𝒙 − 𝟔𝒚 + 𝟔𝒛 = 𝟐𝟏
−𝟔𝒙 + 𝟓𝒚 − 𝒛 = 𝟏
𝟔𝒙 − 𝒚 + 𝟏𝟓𝒛 = 𝟎
2.4. QR Factorization
2.4.1. Definition (Orthogonal matrix)
Recall that a square matrix 𝑄 is said to be an orthogonal matrix if 𝑄𝑄 𝑇 = 𝑄 𝑇 𝑄 = 𝐼,
The process of obtaining the QR factorization involves the Gram-Schmidt orthogonalization or other
methods like Householder reflections or Givens rotations. In this course we will focus only on QR
factorization using Gram-Schmidt orthogonalization.
𝑣
Step-1: Set 𝑣1 = 𝑎1. Then compute 𝑞1 = ‖𝑣1‖.
1
Step-2: For 𝑖 = 2, 3, … , 𝑛:
Compute 𝑣𝑖 = 𝑎𝑖 − ∑𝑖−1
𝑗=1(𝑞𝑗 . 𝑎𝑖 ). 𝑞𝑗
𝑣
Then find 𝑞𝑖 = ‖𝑣𝑖 ‖.
𝑖
Therefore, from the above steps, it can easily be seen that the vectors 𝑎𝑖 can be expressed as a
linear combination of 𝑞𝑖 as follows:
𝟏 𝟐 𝟎
Example 1. Compute the QR factorization for the matrix 𝑨 = [𝟎 𝟏 𝟏].
𝟏 𝟎 𝟏
Solution
1
Step-1: 𝑣1 = 𝑎1 = [0] and ‖𝑣1 ‖ = √12 + 02 + 12 = √2.
1
𝟏
𝑣1 1 1 √𝟐
𝑞1 = = [ 0] = 𝟎
‖𝑣1 ‖ √2 𝟏
1
[√𝟐]
Step-2: 𝑣2 = 𝑎2 − (𝑞1 . 𝑎2 ) 𝑞1
2 1 1
√2
= [1] − 2 [0] = [ 1 ]
√
0 1 −1
√2
This calculation required that (𝑞1 . 𝑎2 ) = = 1.
√2
𝟏
1 √𝟑
𝑣 1 𝟏
and 𝑞2 = ‖𝑣2 ‖ = [ 1 ]=
2 √3 √𝟑
−1 −𝟏
[√𝟑 ]
1 0
1 1 1
First, we compute (𝑞1 . 𝑎3 ) = [0] . [1] = (1.0 + 0.1 + 1.1) =
√2 √2 √2
1 1
1 1 0 1
(𝑞2 . 𝑎3 ) = [ 1 ] [1] =
. (1.0 + 1.1 − 1.1) = 0
√3 −1 1 √3
1
0 1 1 0 1 − −1
1 1 1 1 2 1
Therefore, 𝑣3 = [1] − 2 [ 0 ] − 0. [ 1 ] = [1 ] − [0 ] = [ 1 ] = [ 2]
√ √2 √3 2 1 2
1 1 −1 1 1 1
2
1 √6
Also, ‖𝑣3 ‖ = 2 √(−1)2 + 22 + 12 = 2
.
−𝟏
−1 −1 √𝟔
𝑣3 2 1 1 𝟐
and 𝑞3 = = [ 2 ] = 6[ 2 ] =
‖𝑣3 ‖ √6 2 √ √𝟔
1 1 𝟏
[√𝟔 ]
𝟏 𝟏 −𝟏
√𝟐 √𝟑 √𝟔
𝟏 𝟐
𝑄 = [𝑞1 |𝑞2 |𝑞3 ] = 𝟎
√𝟑 √𝟔
𝟏 −𝟏 𝟏
[√𝟐 √𝟑 √𝟔 ]
𝟏
‖𝑣1 ‖ (𝑞1 . 𝑎2 ) (𝑞1 . 𝑎3 ) √𝟐 √𝟐 √𝟐
and 𝑅 = [ 0 ‖𝑣2 ‖ (𝑞2 . 𝑎3 )] = 𝟎 √𝟑 𝟎
0 0 ‖𝑣3 ‖ √𝟔
[𝟎 𝟎 𝟐]
𝟏 𝟏 −𝟏
𝟏
√𝟐 √𝟑 √𝟔 √𝟐 √𝟐
𝟏 𝟐 √𝟐 𝟏 𝟐 𝟎
𝑖. 𝑒. , 𝟎 𝟎 √𝟑 𝟎 = [𝟎 𝟏 𝟏]
√𝟑 √𝟔 𝟏 𝟎 𝟏
𝟏 −𝟏 𝟏 √𝟔
[ 𝟎 𝟎
[√𝟐 𝟐]
√𝟑 √𝟔 ]
Exercise 2.4
1. Find the QR Factorization of the following matrices:
𝟏 −𝟏
(a) [ ]
−𝟏 𝟎
𝟐 𝟏
(b) [ ]
𝟏 𝟏
𝟏 𝟏 𝟎
−𝟏 𝟎 𝟏
(c) [ ]
𝟎 𝟏 𝟏
𝟏 −𝟏 𝟎
𝟏 𝟏 𝟎
−𝟏 𝟎 𝟏
(d) [ ]
𝟎 𝟏 𝟏
𝟎 𝟎 𝟏
𝟏 𝟏 𝟏
𝟏 𝟏 𝟎
(e) [ ]
𝟏 𝟎 𝟎
𝟎 𝟎 𝟎
2.5. Singular Value Decomposition (SVD)
In this section, we will discuss an extension of the diagonalization theory for symmetric matrices to gen-
eral matrices. The results that we will develop in this section have applications for compression, storage,
and transmission of digitized information and form the basis for many of the best computational algorithms
that are currently available for solving linear systems.
Singular Values:
If
√ is any√matrix order √
A m × n and λ1 , λ2 , . . . λn are eigenvalues of AT A then the numbers σ1 =
λ1 , σ2 = λ2 , . . . , σn = λn are called singular values of A.
First, compute
1 0 1 1 0
1 1 0
AT A = 1 0 = 1 1 0 = B (say)
0 0 1
0 1 0 0 1
The characteristic equation of B is |B − λI| = 0
1−λ 1 0
1 1−λ 0 =0
0 0 1−λ
λ3 − 3λ2 + 2λ = 0
λ(λ − 1)(λ − 2) = 0 ⇒ λ = 0, 1, 2
Hence 0, 1, 2 are the eigenvalues of the matrix B
1−λ 1 0 x 0
consider the system 1 1−λ 0 y = 0
0 0 1−λ z 0
Eigenvector corresponding to λ = 2:
1
−1 1 0 x 0
put λ = 2 in the system(1) we get 1 −1 0 y = 0
0 0 −1 z 0
R2 → R2 + R1
−1 1 0 x 0
0 0 0 y = 0
0 0 −1 z 0
−z = 0 ⇒ z = 0
−x + y = 0 ⇒ x = y
choose y = k then x = k
x k 1
∴ y = k = k 1 , where k ̸= 0 is a scalar
z 0 0
1
Hence 1 is an eigenvector of B corresponding to the eigenvalue λ = 2
0
Eigenvector corresponding to λ = 1
0 1 0 x 0
put λ = 1 in the system (1) we get 1 0 0 y = 0
0 0 0 z 0
R1 ↔ R2
1 0 0 x 0
0 1 0 y = 0
0 0 0 z 0
y = 0, x = 0
Choose z = k
x 0 0
∴ y = 0 = k 0 , where k ̸= 0 is a scalar
z k 1
0
Hence 0 is an eigenvector of B corresponding to the eigenvalue λ = 1
1
1 1 0 x 0
Eigenvector corresponding to λ = 0 put λ = 0 in the system (1) we get 1 1 0
y = 0
0 0 1 z 0
R2 → R2 − R1 ↔ R3
1 1 0 x 0 1 1 0 x O
0 0 0 y = 0 0 0 1 y = O
0 0 1 z 0 0 0 0 z O
z=O
x + y = 0 =⇒ x = −y
Choose y = k then x = −k
x −k −1
∴ y = k = k 1 , where k ̸= 0 is a scalar
z 0 0
−1
Hence 1 is an eigenvector of B corresponding to the eigenvalue λ = 0
0
The eigenvectors corresponding to λ = 2, 1, 0, respectively, are
1 0 −1
X1 = 1 , X2 = 0 and X3 = 1
0 1 0
Since X1T X2 = X2T X3 = X3T X1 = 0
Therefore, the eigenvectors X1 , X2 , X3 are orthogonal.
The normalized eigenvectors are
√ √
1/√2 0 −1/√ 2
v1 = 1/ 2 , v2 = 0 and v3 = 1/ 2
0 1 0
√ √ √
and the singular values of B are σ1 = 2, σ2 = 1 and σ3 = 0
√ √
1/√2 0 −1/√ 2 √
2 0 0
Thus V = v1 v2 v3 = 1/ 2 0 1/ 2 and Σ =
0 1 0
0 1 0
To find U , we compute
√
1/ 2
1 1 0 √
1 1 1
u1 = Av1 = √ 1/ 2 =
σ1 2 0 0 1 0
0
0
1 1 1 1 0 0
and u2 = Av2 = 0 =
σ2 1 0 0 1 1
1
Therefore,
1 0
U= u1 u2 =
0 1
We can easily verify that, U ΣV T = A
√ √
√
1/ 2 1/ 2 0
1 0 2 0 0
U ΣV T = 0√ 0√ 1
0 1 0 1 0
−1/ 2 1/ 2 0
1 0 1 1 0 1 1 0
= = =A
0 1 0 0 1 0 0 1
Exercise 2.5