Linear Equations
Linear Equations
Introduction
where 𝑎𝑖𝑗 are the known coefficients, 𝑏𝑖 are the known values and 𝑥𝑖 are
the unknown to be determined such that 𝑖 and 𝑗 = 1,2, … , 𝑛. The system can be
written in a matrix form as
Writing
This is the matrix form of the simultaneous equations. Here the unknown is
the vector 𝑿, since 𝑨 and 𝑩 are already known. 𝑨 is called the matrix of
coefficients (𝑎𝑖𝑗 ).
1
Cramer’s Rule
det( Ak )
xk = , k = 1, 2,.....,n
det( A)
and det(𝐴𝑘 ) is the determinant which is formed from the determinant det(𝐴)
by replacing the elements of the 𝑘𝑡ℎ column in it by the known values (𝑏𝑖 )
Note that:
2
Example 1
Use Cramer’s rule to solve the system of equations:
2 x − y + 3 z = 10,
x + 2 y − z = −5,
3 x + 4 y + 2 z = −4.
Solution
2 −1 3 10 − 1 3
det( A) = 1 2 − 1 = 15 , det( A1 ) = − 5 2 − 1 = 30
3 4 2 −4 4 2
2 10 3 2 − 1 10
det( A2 ) = 1 − 5 − 1 = −45 det( A3 ) = 1 2 − 5 = 15
3 −4 2 3 4 −4
Example 2
Use Cramer’s rule to solve the system of equations, if it is valid:
2 x1 − x2 + 3 x3 − 10 x4 = 0
x1 + 2 x2 − x3 + 5 x4 = 0
3 x1 + 4 x2 + 2 x3 + 4 x4 = 0
4 x1 + 3 x2 + x3 = 0
Solution
2 − 1 3 − 10
1 2 −1 5
Since det( A) = = 0 , so the system can't be solved using
3 4 2 4
4 3 1 0
3
Matrix Inverse Method
we can multiply both sides by 𝐴−1 from left, provided this exists, to give
𝐴−1 𝐴 𝑋 = 𝐴−1 𝐵
So, 𝑿 = 𝑨−𝟏 𝑩
The system has a unique solution if and only if the det(𝐴) ≠ 0. If so, the
homogeneous system (𝐵 = 0) possess only a trivial solution (𝑋 = 0).
Example 3
Solve the following system of equations by using matrix inverse method
𝑥1 + 2𝑥2 = 5 and 3𝑥1 + 7𝑥2 = 17
Solution
1 2 𝑥1 5
[ ] [𝑥 ]=[ ]
3 7 2 17
1 2 5
where 𝐴 = [ ] and 𝐵 = [ ].
3 7 17
1 7 −2 7 −2
𝐴−1 = [ ]=[ ]
1 −3 1 −3 1
𝑥1 7 −2 5 1
∴[𝑥 ]=[ ][ ] = [ ].
2 −3 1 17 2
4
Example 4
Solve the following system of equations by using matrix inverse method
2 x1 + 6 x2 + 8 x3 = 22
2 x1 + 5 x2 + 3 x3 = 8
3 x1 + 4 x2 − 4 x3 = −10
Solution
2 6 8 𝑥1 22
𝑥
[2 5 3 ] [ 2]=[ 8 ]
3 4 −4 𝑥3 −10
2 6 8 22
where 𝐴 = [ 2 5 3 ] and 𝐵 = [ 8 ].
3 4 −4 −10
1 −32 56 −22
−1
𝐴 = [ 17 −32 10 ]
−18
−7 10 −2
𝑥1 22
1 −32 56 −22 1 −36 2
∴ [ 𝑥2 ] = [ 17 −32 10 ] [ 8 ] = [ 18 ] = [ −1 ].
𝑥3 −18 −18
−7 10 −2 −10 −54 3
Note that:
The system in example (2) can't be solved using the matrix inverse method
because det(𝐴) = 0 and therefore 𝐴−1 does not exist.
Moreover, Cramer's rule and matrix inverse method are valid only if:
1) The system must have the same number of equations as unknowns, that
is, the coefficient matrix of the system 𝑨 must be square.
2) The determinant of the coefficient matrix must be non-zero (det(𝐴) ≠ 0).
The reason, of course, is that the inverse of a matrix exists.
5
Gauss Elimination Method
𝒌 𝑹𝒊
𝒌 𝑹𝒊 + 𝑹𝒋
𝑹𝒊 ↔ 𝑹𝒋
In practice, when carrying out elementary row operations on the matrix form,
it is useful to define the so-called augmented matrix, which consists of 𝐴 with
the right-hand side 𝐵 attached together.
Example 5
Solve the system of equations using Gauss elemination method
𝑥1 + 3 𝑥2 = 11
2 𝑥1 + 9 𝑥2 = 31
Solution
1 3 𝑥1 11
The matrix form: [ ] [𝑥 ]=[ ]
2 9 2 31
6
1 3 11 −2 𝑅1 + 𝑅2 1 3 11
Augmented matrix: [𝑨|𝑩]≡[ | ] ⇒ [ | ]
2 9 31 0 3 9
resulting in
𝑥1 + 3 𝑥2 = 11
3 𝑥2 = 9
the second equation gives 𝑥2 = 3 and perform back substitution in the first
equation to get 𝑥1 = 2.
1) All nonzero rows (rows with at least one nonzero element) are above any
rows of all zeroes, if any, belong at the bottom of the matrix.
2) The leading coefficient (the first nonzero number from the left, also called
the pivot) of a nonzero row is always strictly to the right of the leading
coefficient of the row above it.
3) Every leading coefficient is 1 and is the only nonzero entry in its column.
7
These are examples of matrices in reduced row echelon form (rref),
1 4 0 −1 −21
1 0 0 3 1 0 2 −1
0 0 1 −6 −11
[ 0 1 0 | 4 ] , [ 0 1 −4 | 5 ] and [ | ]
0 0 0 0 0
0 0 1 2 0 0 0 0
0 0 0 0 0
which show that the left of the matrix is not always an identity matrix.
Example 6
Solve the system of equations using Gauss-Jordan elimination method
𝑥1 + 3 𝑥2 = 11
2 𝑥1 + 9 𝑥2 = 31
Solution
1
𝑅
1 3 11 −2 𝑅1 + 𝑅2 1 3 11 3 2 1 3 11 −3 𝑅2+ 𝑅1 1 0 2
[ | ] ⇒ [ | ] ⇒ [ | ] ⇒ [ | ]
2 9 31 0 3 9 0 1 3 0 1 3
resulting in 𝑥1 = 2 and 𝑥2 = 3.
Note that:
In the previous example, after carrying out the elementary row operations, the
matrix 𝐴 is converted to 𝐼 and 𝐵 converted to the solution 𝑋.
Row Operations
i.e. [𝐴|𝐵] ⇒ [𝑰|𝑋]
Special case:
Row Operations
[𝑨|𝑰] ⇒ [ 𝑰 | 𝑨−𝟏 ]
8
Example 7
2 5
Use Gauss-Jordan elimination method to find 𝐴−1 for 𝐴 = [ ].
1 3
Solution
2 5 1 0 𝑅1↔ 𝑅2 1 3 0 1 −2𝑅1+ 𝑅2 1 3 0 1
[ | ] ⇒ [ | ] ⇒ [ | ]
1 3 0 1 2 5 1 0 0 −1 1 −2
− 𝑅2 1 3 0 1 −3𝑅2+ 𝑅1 1 0 3 −5
⇒ [ | ] ⇒ [ | ]
0 1 −1 2 0 1 −1 2
3 −5
∴ 𝐴−1 = [ ].
−1 2
Example 8
a) Find the inverse of 𝐴 (Using Gauss-Jordan elimination method)
0 1 1
𝐴=[ 1 0 −2]
−1 1 4
𝑅1 + 𝑅3 1 0 −2 0 1 0 −𝑅2+ 𝑅3 1 0 −2 0 1 0
⇒ [0 1 1 | 1 0 0] ⇒ [0 1 1 | 1 0 0]
0 1 2 0 1 1 0 0 1 −1 1 1
9
−𝑅3 + 𝑅2 1 0 0 −2 3 2
⇒ [0 1 0 | 2 −1 −1 ]
2𝑅3 + 𝑅1
0 0 1 −1 1 1
−2 3 2
−1
∴ 𝐴 = [ 2 −1 −1].
−1 1 1
b)
𝑦+𝑧 =0
𝑥 − 2𝑧 =1
𝑦 + 4𝑧 =2+𝑥
0 1 1 𝑥 0
[ 1 𝑦
0 −2 ] [ ] = [ 1 ]
−1 1 4 𝑧 2
𝐴 𝑋 = 𝐵 ⇒ 𝑋 = 𝐴−1 𝐵
𝑥 −2 3 2 0 7
𝑦
∴ [ ] = [ 2 −1 −1] [ 1 ] = [−3].
𝑧 −1 1 1 2 3
Example 9
Solve the following system of linear equations using Gauss-Jordan method
𝑥1 − 3𝑥2 + 4𝑥3 = 12
2𝑥1 − 5𝑥2 + 3𝑥3 = 13
𝑥1 − 4𝑥2 + 9𝑥3 = 23
Solution
1 −3 4 12 1 −3 4 12 1 0 −11 −21
[ 2 −5 3 | 13 ] ⇒ [0 1 −5 | −11 ] ⇒ [ 0 1 −5 | −11 ]
1 −4 9 23 0 −1 5 11 0 0 0 0
This last matrix is in reduced row echelon form so we can stop. It corresponds
to the augmented matrix of the following system.
10
𝑥1 − 11𝑥3 = −21
𝑥2 − 5𝑥3 = −11
𝑥1 = −21 + 11 𝑥3
𝑥2 = −11 + 5 𝑥3
Since there is no specific value for 𝑥3 , it can be chosen arbitrarily. This means
that there are infinitely many solutions for this system. We can represent all
the solutions by using a parameter 𝑡 as follows.
Note that: In example (9), the value of det(𝐴) = 0. This explains the zero row
appeared in rref(A).
Example 10
Solve the following system of equations
𝑥+2𝑦+3𝑧 =0
4𝑥 + 5 𝑦 + 6 𝑧 =6
Solution
1 2 3 0 1 2 3 0 1 2 3 0
[ | ] ⇒ [ | ] ⇒ [ | ]
4 5 6 6 0 −3 −6 6 0 1 2 −2
1 0 −1 4
∴ rref(𝐴|𝐵) = [ | ]
0 1 2 −2
The system reduced to
𝑥− 𝑧 =4
𝑦+2𝑧 = −2
11
Let 𝑧 = 𝑡, then 𝑥 = 4 + 𝑡 and 𝑦 = −2 − 2𝑡. The solution can be written as
𝑥 4 1
[ 𝑦 ] = [−2] + 𝑡 [−2].
𝑧 0 1
Example 11
Solve the following system of equations
𝑥1 + 2 𝑥2 + 3 𝑥3 = 4
2 𝑥1 + 3 𝑥2 + 7 𝑥3 = 6
𝑥1 + 𝑥2 + 4 𝑥3 = 9
Solution
1 2 3 4 1 2 3 4 1 2 3 4
[ 2 3 7 |6 ] ⇒ [ 0 −1 1 | −2 ] ⇒ [0 1 −1 | 2 ]
1 1 4 9 0 −1 1 5 0 −1 1 5
1 0 5 0
∴ rref(𝐴|𝐵) = [ 0 1 −1 | 2 ]
0 0 0 7
Third equation does not make sense. We recognize that the system is
inconsistent when we get to an equation that says 0 = something nonzero. So,
the system has no solution.
12
Example 12
Find the value(s) of the constant 𝑘 such that the following system
𝑥1 + 2𝑥2 + 3𝑥3 = 4
𝑥1 + 𝑘 𝑥2 + 4𝑥3 = 6
𝑥1 + 2𝑥2 + (𝑘 + 2) 𝑥3 = 6
Solution
1 2 3 4 1 2 3 4
[ 1 𝑘 4 |6] −𝑅1 + 𝑅2 and – 𝑅1 + 𝑅3 [0 𝑘−2 1 |2]
1 2 𝑘+2 6 0 0 𝑘−1 2
Note that:
• A unique solution to 𝐴𝑋 = 𝐵 if and only if rref(A) has a leading 1 in every
column.
• No solution if and only if rref(𝐴|𝐵) has a leading 1 in the last column.
• In all other cases we have infinitely many solutions.
13
Example 13
Solve the following homogeneous system of equations
1 1 3 𝑥1 0
[ −1 1 −1 ] [ 𝑥2 ] = [ 0 ]
3 −1 5 𝑥3 0
Solution
1 1 3 0 1 1 3 0 1 1 3 0
[ −1 1 −1 | 0 ] ⇒ [0 2 2 | 0] ⇒ [0 1 1 | 0]
3 −1 5 0 0 −4 −4 0 0 −4 −4 0
1 0 2 0
∴ rref(𝐴|𝐵) = [ 0 1 1 | 0 ]
0 0 0 0
i.e.
𝑥1 + 2 𝑥3 = 0
𝑥2 + 𝑥3 = 0
𝑥1 −2𝑡 −2
𝑥
∴ [ 2 ] = [ −𝑡 ] = 𝑡 [ −1 ]. (Non-trivial solution)
𝑥3 𝑡 1
14