Professional Documents
Culture Documents
System of Linear Equations: Vietnamese-German University
System of Linear Equations: Vietnamese-German University
Tan Do
Vietnamese-German University
Lecture 5
In this lecture
Linear equation
a1 x1 + a2 x2 + . . . + an xn = b,
x1 − 2x2 + x3 = 0
A system of linear equations (or linear system for short) consists of several linear
equations together.
Example
3x1 − x2 = 7
x1 + 2x2 = 10
x1 − 2x2 + x3 = 0
10x1 + 23x2 − x3 = 12
is an underdetermined system.
A system of linear equations which has more equations than the number of variables is called an
overdetermined system.
Example
x1 + x2 = 3
x1 − 2x2 = 1
5x1 + 9x2 = −8
is an overdetermined system.
A system of linear equations with the number of equations equal to the number of variables is
called a square system.
Tan Do (VGU) Introduction to MATLAB Lecture 5 5 / 28
How to solve a linear system
Forward elimination
To solve a linear system, the idea is to remove as many variables in the equations as we
can.
x1 − 2x2 + x3 = 0 (1)
x1 − 2x2 + x3 = 0 (1)
Backward substitution
9 15
x2 − x3 = − (2b)
4 4
11
x3 = (3b)
5
Now that we already have the value of x3 , we will substitute this value back in (2b) to get the
value of x2 .
15 9 11 6
x2 = − + ∗ = .
4 4 5 5
x1 − 2x2 + x3 = 0
is
1
x1 =
5
6
x2 =
5
11
x3 =
5
Matrix form
x1 − 2x2 + x3 = 0 1 −2 1x1 0
x1 + 2x2 − 8x3 = −15 −→ 1
2 −8 x2 = −15
−4x1 + 5x2 + 9x3 = 25 −4 5 9 x3 25
and so on.
Augmented matrix
We can use matrix form of a linear system to solve for its solution.
Suppose we want to solve the system
x1 − 2x2 + x3 = 0
−4 5 9 x3 25
where
1 −2 1 x1 0
A= 1 2 −8 , x = x2 and b = −15 .
−4 5 9 x3 25
In solving for the solution of the system, what really matters are the coecients of the variables,
not the variables themselves. So it is redundant to write x1 , x2 and x3 all the time.
−4 5 9 25
Remember that the rst column in this matrix stands for the coecients associated with x1 ,
column 2 with x2 and column 3 with x3 .
Next we carry out the forward elimination and backward substitution as before.
1 −2 1 0 1 −2 1 0 1 −2 1 0
R2 =R2 −R1 R3 =R3 +4R1
1 2 −8 −15 −−−−−−−−−→ 0 4 −9 −15 −−−−−−−−−−→ 0 4 −9 −15
−4 5 9 25 −4 5 9 25 0 −3 13 25
Then we eliminate x2 in Row 3 of the augmented matrix and then normalize the coecient of
x3to obtain the value of x3 .
1 −2 1 0 1 −2 1 0
R3 =R3 +3R2 R3 =R3 ÷ 25
. . . −−−−−−−−−→ 0 −9 −15 −−−−−− −−4
→ −9 −15
1 0 1
4 4 4 4
25 55 11
0 0 4 4
0 0 1 5
1
1 0 0 5
R1 =R1 +2R2 6
−−−−−−−−−−→ 0 1 0 5
0 0 1 11
5
6
x2 =
5
11
x3 =
5
Tan Do (VGU) Introduction to MATLAB Lecture 5 13 / 28
Matrix method
The steps that we carried out before to obtain the solution of the system are called row
operations.
To get an overview of what we did, we give a summary of the steps carried out before.
In order to make the process of getting solution faster, we combine several row operations in one
step here.
1 −2 1 0 R2 =R2 −R1 1 −2 1 0 1 −2 1 0
1
R3 =R3 +4R1 R2 = 4 R2 −9 −15
1 2 −8 −15 −−−−−−−−−−→ 0 4 −9 −15 −−−−−−−→ 0 1
4 4
−4 5 9 25 0 −3 13 25 0 −3 13 25
−7 − 15 −7 − 15
R3 =R3 +3R2 1 0 1 0
R1 =R1 +2R2 2 2 R3 =R3 ÷ 25 2 2
−9 −15 4 −9 −15
−−−−−−−−−−→ 0 1 −−−−−−−−−→ 0 1
4 4 4 4
0 0 25 55 0 0 1 11
4 4 5
R2 =R2 + 9 R3
4 1
R1 =R1 + 7 R3
1 0 0 5
2 6
−
−−−−−−−−−−
→ 0 1 0
5
0 0 1 11
5
Signicance Using row operations, we obtain new systems of linear equations which are
equivalent to the original system.
Another example
x1 + 2x2 + 7x3 = 2
To solve the system, we rst form the augmented matrix and then perform row operations until
we obtain the solution.
2 4 −6 10 1 2 −3 5 R2 =R2 −R1 1 2 −3 5
1
R1 = 2 R1 R3 =R3 −7R1
1 2 7 2 −−−−−−−→ 1 2 7 2 −−−−−−−−−−→ 0 0 10 −3
7 14 9 26 7 14 9 26 0 0 30 −9
41
1 2 −3 5 R1 =R1 +3R2 1 2 0
R2 = 1 R2 R3 =R3 −30R2 10
10 3 3
−−−−−−−−→ 0 0 1 − 10 −−−−−−−−−−−→ 0 0 1 − 10
0 0 30 −9 0 0 0 0
In sum,
41
x1 = − 2t
10
x2 = t, t∈R
3
x3 = −
10
3x1 + x2 − 2x3 = 1
x1 + x2 + x3 = 0
2x1 − 3x3 = 2
We have
3 1 −2 1 1 1 1 0 R2 =R2 −3R1 1 1 1 0
h i R1 ↔R2 R3 =R3 −2R1
A b = 1 1 1 0 −−−−−−→ 3 1 −2 1 −−−−−−−−−−→ 0 −2 −5 1
2 0 −3 2 2 0 −3 2 0 −2 −5 2
−3 1
1 1 1 0 R1 =R1 −R2 1 0 −2
R2 =− 1 R2 R3 =R3 +2R2 2
2 5 1 − 5 1
−
−−−−−−−−
→ 0 1 −−−−−−−−−→ 0 1
2 2 2 2
0 −2 −5 2 0 0 0 3
3 −1
R3 = 1 R3
1 0 −2 2
3 5 1
−−−−−−−→ 0 1
2 2
0 0 0 1
Leading 1's
Recall the nal forms of the augmented matrices in the above examples.
1 41
− 32 − 12
1 0 0 5
1 2 0 10
1 0
6 3 5 1
0 1 0 and 0 0 1 − 10 and 0 1
5 2 2
11
0 0 1 5
0 0 0 0 0 0 0 1
The rst 1's that we see in each row of the matrices (looking from left to right) are called
leading 1's.
The variables corresponding to the leading 1's are called leading variables.
The remaining variables are called free variables.
Rank of a matrix
The rank of a matrix is the number of leading 1's appearing in the (reduced) row echelon form of that matrix. So
for Example 1,
1
1 −2 1 0 1 0 0 5
has rank 3 since its rref is
h i
A b = −8 −15 6
1 2 0 1 0
5
−4 5 9 25 0 0 1 11
5
Based on our experience so far, we deduce the following about the number of solutions of a
linear system.
Denition
A system which has a solution is said to be consistent.
A system which has no solution is said to be inconsistent.
The method to determine the consistency and the solution set of a linear system using rref of
the corresponding augmented matrix is called the Gaussian-Jordan elimination method.
Motivation
Ax = b, (2)
Question Can we obtain the solution of (2) using a similar method as (1)?
This means we are talking about matrix division.
Answer This is unfortunately not possible.
But if we look at things in a dierent way, something is still possible.
Tan Do (VGU) Introduction to MATLAB Lecture 5 25 / 28
Inverse of a matrix
We can rewrite x = b
a
as
x = a−1 ∗ b.
The condition here is that a 6= 0.
It turns out that it is possible to dene the inverse of a matrix provided some conditions
are met.
x = A−1 ∗ b
Inverse of a matrix
" #
R1 =R1 −2R2 1 0 3
− 11 2
−−−−−−−−−−→ 11
0 1 7 1
− 11
11
Application
x + 2y = 1
7x + 3y = −2
" #
1 2
We know from before that is invertible. So
7 3
" # " #−1 " # " #" # " #
3 2 7
x 1 2 1 − 11 11
1 − 11
= = 7 1
= 9
.
y 7 3 −2 11
− 11 −2 11