NM Course
NM Course
2 Matrix Analysis 7
2.1 Vector spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.1 Matrix operations . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.2 Invertible matrix . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.3 The transpose of a matrix . . . . . . . . . . . . . . . . . . . . . 13
2.2.4 The trace of a square matrix . . . . . . . . . . . . . . . . . . . . 13
2.2.5 The determinant . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.6 Eigenvalues and Eigenvectors . . . . . . . . . . . . . . . . . . . 15
1
2 CONTENTS
Chapter 1
1.1 Motivations
s × 10e ,
with:
3
4CHAPTER 1. GENERAL INFORMATIONON NUMERICAL ANALYSIS AND SCIENTIFIC CALCULA
The significant corresponds to the significant number (and the sign), while the
exponent corresponds to the order of magnitude.
Example 1.1.
369 = 3 × 102 + 6 × 101 + 9 × 100 .
2. In basis 2
In base 2, the scientific notation of a real takes the following form:
s × 2e
with:
• e an integer, called exponent,
• s a real, such that 1 ≤ |s| < 2 or s = 0, called Significant.
Example 1.2.
10012 = 1 × 23 + 0 × 22 + 0 × 21 + 1 × 20 .
sign × mantissa × 2e ,
with
• the sign, positive or negative;
• mantissa (or significance), a positive real such that 1 ≤ mantisse < 2;
• exponent e, an integer.
Over the years, a variety of floating-point representations have been used in com-
puters. In 1985, the IEEE 754 Standard for Floating-Point Arithmetic was established,
and since the 1990s, the most commonly encountered representations are those defined
by the IEEE
IEEE 754 has 3 basic components (s, e, m) :
1.2. FLOATING-POINT ARITHMETIC AND ROUNDING ERRORS 5
Types w t Total
Single precision 8 bits 23 bits 32 bits
Double precision 11 bits 52 bits 64 bits
Example 1.3.
In computing, a roundoff error, also called rounding error is the difference between
the result produced by a given algorithm using exact arithmetic and the result produced
by the same algorithm using rounded arithmetic.
in short, there are two major facets of roundoff errors involved in numerical calcu-
lations:
1. Data measurement is not accurate (due to instruments);
2. The use of approximate values instead of exact values (e.g. 3.14 instead of π)
Definition 1.2. Suppose x∗ is an approximation to the number x. The absolute
error in this approximation noted E is given by
E = |x − x∗ |.
Example 1.4.
Value Representation Approximate value Absoluted Error
1 ¯
0,142857142857.. = 0,142857 0,142857 1
× 10−6
7 7
π 3,141592653589793.. 3,141592 0,653589793.. × 10−6
e 2,718281828459045.. 2,718281 0,828459045.. × 10−6
Example 1.5. If x = 100 and x∗ = 100.1 the absolute error is 0.1, whereas if x = 1
and x∗ = 1.1 the absolute error is still 0.1. Note that if x∗ is an approximation to x,
then x∗ is an equally good approximation to a with respect to the absolute error.
For some purposes the absolute error may be what we want, but in many cases it is
reasonable to say that the error is smaller in the first example above than in the second,
since the numbers involved are bigger. The relative error takes this into account
Definition 1.3. Suppose x∗ is an approximation to the number x. The relative
error in this approximation noted Er is given by
|x − x∗ | E
Er = = .
|x| |x|
6CHAPTER 1. GENERAL INFORMATIONON NUMERICAL ANALYSIS AND SCIENTIFIC CALCULA
We note that the relative error is obtained by scaling the absolute error with the
size of the number that is approximated. If we compute the relative errors in the
approximations above we find that it is 0.001 when x = 100 and x∗ = 100.1, while
when x = 1 and x∗ = 1.1 the relative error is 0.1. In contrast to the absolute error,
we see that the relative error tells us that the approximation in the first case is much
better than in the latter case.
Chapter 2
Matrix Analysis
Definition 2.1. A vector space E over a field K or K-vector space consists of a set of
E (elements of E are called vectors), a field K (elements of K are scalars) and the two
operations:
• Vector addition of E × E in E :
E×E →E
(u, v) → u + v
• Scalar Multiplication of K × E in E :
K×E →E
(λ, u) 7→ λ · u
7
8 CHAPTER 2. MATRIX ANALYSIS
2.2 Matrices
Definition 2.2. A real n × m matrix A is a rectangular array
More generally, we may take the entries aij from an abstract field K, but for now
we suppose K = R, the real numbers.
The diagonal entries are the aij with i = j, i.e. the aii .
The set of real n × m matrices is denoted
In the case that m = n we also write Mn (R), and we call a matrix in Mn (R) a
square matrix.
Example 2.2. For example, M3 (R) is the set of all real 3 × 3 matrices, and M5,7 (2Z)
is the set of all 5 × 7 matrices with even integer entries.
• Addition:
Definition 2.3. Two or more matrices of the same order can be added by adding
the corresponding elements of the matrices. If A and B are two matrices with the
same dimension n × m, then the addition of matrices A and B is C = A + B of
dimension n × m defined by
cij = aij + bij .
Example 2.6.
Å ã Å ã Å ã
0 −1 2 −3 0 0
A= B= and AB =
0 5 0 0 0 0
1 − 32
Å ã
Then B = . To prove that it is suitable, it is necessary also show BA = I
0 13
1 − 32
Å ã
−1
equality. The matrix A is therefore invertible and A = .
0 13
2.2. MATRICES 11
Matrix 2 × 2
Å ã
a b
To calculate the inverse of a 2 × 2 matrix , consider the matrix A = .
c d
Proposition 2.6. If ad − bc ̸= 0, then A is invertible and
Å ã
−1 1 d −b
A =
ad − bc −c a
We will demonstrate how to derive the inverse of a matrix using the Gauss-Jordan
(or reduced row) elimination method. Finding the inverse of a matrix implies several
prerequisites, including the matrix being invertible. To be invertible, a matrix must
be a square matrix and its determinant must be non-zero. A matrix with a zero
determinant is considered singular, which means it is not invertible.
Before we begin, it’s important to note that a matrix can represent a system of
linear equations solvable using row elementary operations. These operations preserve
the set of solutions represented by the matrix. There are three types of row elementary
operations:
1. Li ← λLi with λ ̸= 0: Multiplying each element of a row by a non-zero real.
2. Li ← Li + λLj with λ ∈ K(et j ̸= i): Replacing a row with the sum of itself and
a multiple of another row.
3. Li ← Lj : Swapping two rows of the matrix.
Ñ é
1 2 1
Example 2.9. Let’s calculate the inverse of A = 4 0 −1 .
−1 2 2
We start with: Ñ é
1 2 1 1 0 0
(A | I) = 4 0 −1 0 1 0
−1 2 2 0 0 1
12 CHAPTER 2. MATRIX ANALYSIS
To make 0s appear on the first column, on the second line, we will use the elementary
operation L2 ← L2 − 4L1 which leads to the augmented matrix:
Ñ é
1 2 1 1 0 0
0 −8 −5 −4 1 0 L2 ←L2 −4L1
−1 2 2 0 0 1
1 0 − 14 0 1
Ñ é
4
0
5 1 1
0 1 8 2
−8 0
0 0 12 −1 12 1
Then
1 0 − 41 0 1
Ñ é
4
0
0 1 58 1
2
− 1
8
0
0 0 1 −2 1 2 L3 ←2L3
1 0 0 − 12 21 1
Ñ é
2
0 1 0 4 − 4 − 54
7 3
.
0 0 1 −2 1 2
then á ë
a11 a21 . . . an1
a12 a22 . . . an2
AT = .. .. .. .
. . .
a1p a2p . . . anp
Example 2.10.
Ñ éT Ñ é
1 2 3 1 4 −7
4 5 −6 = 2 5 8
−7 8 9 3 −6 9
Ñ éT
0 3 Å ã
0 1 −1
1 −5 =
3 −5 2
−1 2
Ñ é
T 1
1 −2 5 = −2
5
2. (αA)T = αAT .
3. (AB)T = B T AT .
1. tr(A + B) = tr A + tr B.
4. tr(AB) = tr(BA).
Theorem 2.3. Let A = (ai,j )1≤i,j≤n be a square matrix of order n, (Ci,j )1≤i,j≤n its
cofactors.
Example 2.12. Let us compute (again) the determinant of the following matrix
Ñ é
1 −1 2
A= 6 3 1 .
4 5 3
2.2. MATRICES 15
3. det(AT ) = det(A).
4. det(αA)n = αn det(A).
5. detI n = 1.
6. If two columns are identical on A then detA = 0.
7. If a column of A is a linear combination of the other columns then detA = 0.
• The vector X is then called the eigenvector of A associated with the eigenvalue
λ.
Example 2.13. Let A ∈ M3 (R) be the matrix
Ñ é
1 3 3
A= −2 11 −2
8 −7 6
Ñ é
−1
• X1 = 0 is the eigenvector of A. Indeed,
1
Ñ éÑ é Ñ é Ñ é
1 3 3 −1 2 −1
AX1 = −2 11 −2 0 = 0 = −2 0 = −2X1 .
8 −7 6 1 −2 1
16 CHAPTER 2. MATRIX ANALYSIS
Let A be an n × n matrix.
1. First, find the eigenvalues λ of A by solving the equation χA (λ) = 0.
2. For each λ, find the basic eigenvectors X ̸= 0 by finding the basic solutions to
(A − λI)X = 0.
To verify your work, make sure that AX = λX for each λ and associated eigenvector
X.
Example 2.14. Ñ é
1 3 3
A= −2 11 −2
8 −7 6
Therefore
χA (X) = det (A − λI3 )
ÑÑ é Ñ éé
1 3 3 1 0 0
= det −2 11 −2 −λ 0 1 0
8 −7 6 0 0 1
1−λ 3 3
= −2 11 − λ −2
8 −7 6−λ
= ···
= −λ3 + 18λ2 − 51λ − 182
= −(λ + 2)(λ − 7)(λ − 13).
Then, the eigenvalues are: −2, 7 and 13.
2.2. MATRICES 17
In this chapter, we call for direct methods because in the absence of rounding
errors they would finally give the exact solution after a finite number of elementary
operations. This methods are used only if the number of equations is not too high
(n ≤ 100).
Definition 3.1. Direct techniques are methods that theoretically give the exact so-
lution to the system in a finite number of steps.
So, we will consider this methods for solving a linear system of n equations in n
variables. Such a system has the form:
a11 x1 + a12 x2 + · · · + a1n xn = b1
a21 x1 + a22 x2 + · · · + a2n xn = b2
.. (1)
.
a x + a x + ··· + a x = b
n1 1 n2 2 nn n n
where we are given the constants aij , for each i, j = 1, 2, ..., n, and bi , for each
i = 1, 2, ..., n.
The linear system (1) can be rewritten as the following matrix-vector form:
AX = B, (2)
Theorem 3.1. A given square system, say, Ax = B gives a very unique result for
every column matrix B. This is possible if and only if the determinant of A is not
equal to zero, i.e., detA ̸= 0.
19
20 CHAPTER 3. DIRECT METHODS FOR SOLVING LINEAR SYSTEM
To solve this kind of system, the first idea that comes to mind is the use of Cramer’s
formulas given by:
det Ai
xi = , for i = 1, . . . ,n.
det A
Or Ai is the square matrix formed by replacing the k − th column of A by the column
vector B.
As a result, for the resolution of the system (2) by these method, a total of
TCramer = (n + 1)2 n! − 1 elementary operations, for example for n = 5, we have
TCramer = 4319 and for n = 10, we have TCramer ∽ 4 × 108 .
In this case, it becomes very slow in execution time (of calculations) as soon as n
exceeds 4.
Example 3.1. Solve the given system of equations using Cramer’s Rule.
x + 2y + 3z = −5
3x + y − 3z = 4
−3x + 4y + 7z = −7
Solution: So, in order to solve the given equation, we will make four matrices.
These matrices will help in getting the values of x, y, and z .
Ñ é
1 2 3
A= 3 1 −3
−3 4 7
Then
Ñ é Ñ é Ñ é
−5 2 3 1 −5 3 1 2 −5
A1 4 1 −3 , A2 3 4 −3 , A3 3 1 4
−7 4 7 −3 −7 7 −3 4 −7
Then,
det A1 −40
x= = = −1,
det A 40
det A2 40
y= = = 1,
det A 40
det A3 −80
z= = = −2.
det A 40
Therefore,
(x,y,z) = (−1,1, − 2).
Another method consists in calculating the inverse matrix of A, that is to say:
A−1 AX = A−1 B then X = A−1 B.
To do this, we use a total of T Inverse = n! (n2 + n + 1) + 3n2 − n elementary op-
erations, for example for n = 5, we have TInverse = 3790 and for n = 10, we have
TInverse ∽ 4.108 .
This method is therefore no more advantageous than the first.
3.1. TRIANGULAR SYSTEMS OF EQUATIONS (BACK SUBSTITUTION) 21
1. If A is upper triangular, the system (2) can be written in the following form:
a11 x1 + a12 x2 + . . . + ain xi + . . . a1n xn = b1
a22 x2 + . . . + ai2 xi + . . . a2n xn = b2
... .. .. .. ..
. . . .
aii xi + ... ain xn = bi
.. .. ..
..
.
. . .
ann xn = bn
and since ni=1 aii = det(A) ̸= 0, the system is solved by first computing xn in
Q
the last equation and then xn−1 and so on, thus leading to
®
xn = Äbn /ann ä
xi = bi − nj=i+1 aij xj a1ii
P
2. If A is lower triangular, the system (2) can be written in the following form:
a11 x1 = b1
a21 x1 + a22 x2 = b2
.. ... .. ..
. . .
ai1 x1 + ai2 x2 + . . . + aii xi = bi
.. .. .. .. ..
..
.
. . . . .
an1 x1 + an2 x2 + . . . + ani xi + . . . ann xn = bn
6
= 2.
x4 =
3
Using x2 in the third equation, we obtain
6 − 5(2)
x3 = = −1.
6
Now x3 = −1 and x4 = 2 are used to find x2 in the second equation:
7 − 7(−1) + 4(2)
x2 = = −4.
2
Finally, x1 is obtained using the first equation:
1. Transforming the given system into a “triangular system” equivalent to the orig-
inal system, i.e,
transformation (n)
[A, B] −→ A ; B (n) , A(n) Upper triangular matrix,
(1) (1) (1) (1)
(n) (n) (n) (n)
a11 a12 . . . . . . .a1n b1 a11 a12 . . . . . . .a1n b1
(1) (1) (1) (1) (n) (n) (n)
a21 a22 . . . . . . .a2n b2 0 a22 . . . . . . .a2n b2
−→
......... .........
(1) (1) (1) (1) (n) (n)
an1 an1 . . . . . . ..ann bn 0 0 . . . . . . ann bn
2. Solve the resulting trigonometric system A(n) x = B (n) by the “back substitution”
method of which x is the exact solution of the system Ax = B.
(1)
If the pivot element a11 ̸= 0, we do the following operation
L(2)
1 = L1
(1)
(1)
ai1
L(2) (1)
i = Li − (1) L1
(1)
a11
(1)
(If a11 = 0 it changed the order of the equations, that is, replace the first equation
(1)
with another equation so that it becomes a11 ̸= 0).
We then obtain:
(2) (2) (2) (2)
a11 a12 . . . . . . .a1n b1
(2) (2) (2)
0 a22 . . . . . . .a2n b2
î ó
(2) (2)
A ;B =
0 .........
(2) (2) (2)
0 an1 . . . . . . ann bn
And so on:
L(k+1)
i
(k)
= Li , i = 1, . . . ,k (k)
At the k-th step aik
(k) ; akk ̸= 0
L(k+1)
i
(k)
= Li −
(k)
(k) Lk , i = k + 1, . . . ,n
akk
Then:
î ó 1 3 3 ;0
A(2) ; B (2) = 0 −3 −6 ; 0
0 −7 −3 ; 11
(2)
Since a22 ̸= 0 ,
(3) (2)
L1(3) = L1(2)
L2 = L2
(2)
a32
L(3) (2) (2) (2) (2)
L2 = L3 − 73 L1
3 = L3 −
(2)
a22
We obtain,
î ó 1 3 3 ;0
A(3) ; B (3) = 0 −3 −6 ; 0
0 0 11 ; 11
Therefore,
î ó 1 3 3 ;0
A(3) ; B (3) = 0 −3 −6 ; 0
0 0 11 ; 11
(k)
2. If αkk ̸= 0 the Gaussian method is applicable and therefore A is factored in the
form LU .
Solution:
Determine the matrix U = A(n) by the Gauss method according to Example 3.3, we
get: Ñ é
1 3 3
U = A(3) = 0 −3 −6
0 0 11
The matrix L is defined by
Ñ é
1 0 0 (k)
aik
L= α21 1 0 αik = (k)
α31 α32 1 akk
Then Ñ é
1 0 0
L= 2 1 0
3 73 1
the resolution of Ax = B in two simple steps
Ñ éÑ é Ñ é
1 0 0 y1 0 y1 = 0 y1 = 0
Ly = B ⇒ 2 1 0 y2 = 0 ⇒ 2y1 + y2 = 0 ⇒ y =0
2
3 73 1 y3 11 7
3y1 + 3 y2 + y3 = 11 y3 = 11
Ñ éÑ é Ñ é
1 3 3 x1 y1 x1 + 3x2 + 3x3 = 0 x1 = 3
Ux = y ⇒ 0 −3 −6 x2 = y2 ⇒ −3x2 − 6x3 = 0 ⇒ x = −2
2
0 0 11 x3 y3 11x3 = 11 x3 = 1
Chapter 4
27
28 CHAPTER 4. ITERATIVE METHODS FOR SOLVING LINEAR SYSTEMS
4.1 Generality
Definition 4.1. A square matrix A is said to be strictly diagonally dominant if
n
X
∀i ∈ [1, n], |aii | > |aj | .
j=1,j̸=i
Example 4.1. •
é
|a11 | > |a12 | + |a13 | |7| > |2| + |0|
Ñ
7 2 0
3 5 −1 |a22 | > |a21 | + |a23 | |5| > |3| + | − 1|
0 5 −6
|a33 | > |a31 | + |a32 | | − 6| > |0| + |5|
•
é
|a11 | < |a12 | + |a13 | |20| < |12| + |25|
Ñ
20 12 25
12 −18 2 |a22 | > |a21 | + |a23 | | − 18| > |12| + |2|
1 2 5
|a33 | > |a31 | + |a32 | |5| > |1| + |2|
Definition 4.2. A symmetric matrix A is a matrix that is symmetric along the diag-
onal, which means:
AT = A.
Example 4.2.
Ñ é Ñ é
20 12 5 20 12 5
A= 12 15 2 , AT = 12 15 2
5 2 25 5 2 25
Definition 4.3. Let A ∈ Mn (R). The leading Principal Minors of matrix A are the
determinants of the leading principal submatrices. For a 3×3 matrix, these submatrices
are obtained by progressively considering the top-left 1 × 1, 2 × 2, and 3 × 3 blocks of
the original matrix.
Example 4.3. Ñ é
2 0 1
A= 0 −1 1
1 0 −2
4.1. GENERALITY 29
∆1 = 2
2 0
∆2 = = (2) × (−1) − (0) × (0) = −2
0 −1
2 0 1
−1 1 0 −1
∆3 = 0 −1 1 =2 +1 =4+1=5
0 −2 1 0
1 0 −2
Theorem 4.1. Let A ∈ Mn (R). A is positive definite if and only if all leading principal
minors are strictly positive, i.e., ∆i > 0 for i = 1,...,n.
Example 4.4. Ñ é
20 12 5
A= 15 15 2
5 2 25
A is positive definite.
Matrix Norms:
Definition 4.4. The norm of a square matrix A is a non-negative real number denoted
∥A∥. There are several different ways of defining a matrix norm, but they all share the
following properties:
4. ∥A + B∥ ≤ ∥A∥ + ∥B∥.
5. ∥AB∥ ≤ ∥A∥∥B∥.
The 1−norm: It is the maximum absolute column sum. Put simply, we sum the
absolute values down each column and then take the biggest answer, i.e.,
n
X
∥A∥1 = max |aij | .
j=1...n
i=1
n
X
∥A∥1 = max |aij |
j=1...n
i=1
= max {|20| + |12| + |5|,|12| + |15| + |2|,|5| + |2| + |25|}
= max {37,29,32} = 37.
The infinity-norm: It is the maximum absolute row sum. Put simply, we sum
the absolute values along each row and then take the biggest answer, i.e.,
n
X
∥A∥∞ = max |aij | .
i=1...n
i=1
n
X
∥B∥∞ = max |aij |
i=1...n
j=1
A = M − N,
with M invertible, and “easy to invert,” which means that M is close to being a
diagonal or a triangular matrix.
Then, the system (4) is equivalent to
M x = N x + b.
that is,
x = M −1 N x + M −1 b.
4.2. DESCRIPTION OF THE METHODS OF JACOBI, GAUSS-SEIDEL, AND RELAXATION31
G = M −1 N and c = M −1 b.
G = M −1 N = M −1 (M − A) = I − M −1 A,
k+1 k
x = M −1 N x +M −1 b, k ≥ 0,
0
starting from any arbitrary vector x.
To describe the various choices of M and N , it is convenient to write A in terms
of three submatrices D, E, F ,as
A = D − E − F,
where
Example 4.7.
Ñ é Ñ é Ñ é
2 −1 0 1 0
0
A= −1 4 −1 b= 1 with x= 0
0 −1 2 1 0
We use the Jacobi’s method
Ü ê
n
k+1 1 X k
xi = bi − aij xj ; i = 1, . . . , n.
aii j=1
i̸=j
k 0 1 2 3 4
x1 0 0,5 0,625 0,75 0,78125
x2 0 0,25 0,5 0,5625 0,625
x3 0 0,5 0,625 0,75 0,78125
k+1 k
x = (D − E)−1 F x +(D − E)−1 b.
That is,
i−1 n
k+1 1 X k+1 1 X k bi
xi = − aij xj − aij xj + .
aii j=1 aii j=i+1 aii
k
This method consists in constructing the sequence (x)k∈N of Mn,1 (R). Assuming
(0
x∈ Mn,1 (R)
k+1 k+1 k
x i = − a1ii i−1
P 1
Pn bi
j=1 aij xj − aii j=i+1 aij xj + aii
Example 4.8.
Ñ é Ñ é Ñ é
2 −1 0 1 0
0
A= −1 4 −1 b= 1 avec x= 0
0 −1 2 1 0
Ñ é
0
0
From x= 0 we get:
0
k 0 1 2 3 4
x1 0 0,5 0,6875 0,796875 0,82421875
x2 0 0,375 0,59375 0,6484375 0,66210938
x3 0 0,6875 0,796875 0,82421875 0,83105469
Remark 4.1.
• One of the advantages of the method of Gauss-Seidel is that is requires only half
of the memory used by Jacobi’s method, since we only need
k+1
uk+1 k k
1 , . . . , ui−1 , ui+1 , . . . , un .
to compute uk+1
i .
This method its called the Successive Over-Relaxation method (or SOR).
In particular,
1. If 0 < ω < 1, the method is called Under-Relaxation.
where x is the solution to (4). In practice, the iterative process is stopped at the
minimum value of n such that
n
∥ x −x∥ < ε,
where ε is a fixed tolerance and ∥.∥ is any convenient vector norm.
However, since x must verify Ax = b, so ∥Ax − b∥ = 0, we can also consider the
stopping test as:
n
1. ∥A x −b∥ < ε.
n n−1
∥x− x ∥
2. k < ε.
∥x∥
n n−1
3. ∥ x − x ∥ < ε.
In practice, we add also a stop condition on the number of iterations for avoid too
many calculations.
Example 4.9. Study of the convergence of the Jacobi and Gauss-Seidel methods in the
case where the matrix of the linear system is:
1. Ñ é
−4 1 0
A1 = 1 −4 1 ;
0 1 −4
the two methods converge.
2. Ñ é
1 2 −2
A2 = 1 1 1 .
2 2 1
the Jacobi method converges and the Gauss-Seidel method diverges.