Matrix solution of system of linear equations
There are two main methods of solving systems of linear equations using matrices: the inverse matrix method and Cramer's rule.
Solving system of linear equations by the inverse matrix method
A system of two equations with two unknowns
Consider the system of linear equations:
{ a 1 x + b 1 y = c 1 a 2 x + b 2 y = c 2 \begin{cases}
a_1x + b_1y = c_1 \\
a_2x + b_2y = c_2
\end{cases} { a 1 x + b 1 y = c 1 a 2 x + b 2 y = c 2
In matrix form, this becomes:
[ a 1 b 1 a 2 b 2 ] [ x y ] = [ c 1 c 2 ] \begin{bmatrix} a_1 & b_1 \\ a_2 & b_2 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} c_1 \\ c_2 \end{bmatrix} [ a 1 a 2 b 1 b 2 ] [ x y ] = [ c 1 c 2 ]
Let A = [ a 1 b 1 a 2 b 2 ] A = \begin{bmatrix} a_1 & b_1 \\ a_2 & b_2 \end{bmatrix} A = [ a 1 a 2 b 1 b 2 ] . The system can be written as:
A [ x y ] = [ c 1 c 2 ] A \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} c_1 \\ c_2 \end{bmatrix} A [ x y ] = [ c 1 c 2 ]
Pre-multiplying by A − 1 A^{-1} A − 1 :
A − 1 A [ x y ] = A − 1 [ c 1 c 2 ] A^{-1}A \begin{bmatrix} x \\ y \end{bmatrix} = A^{-1} \begin{bmatrix} c_1 \\ c_2 \end{bmatrix} A − 1 A [ x y ] = A − 1 [ c 1 c 2 ]
Since A − 1 A = I A^{-1}A = I A − 1 A = I (the identity matrix):
[ x y ] = A − 1 [ c 1 c 2 ] \begin{bmatrix} x \\ y \end{bmatrix} = A^{-1} \begin{bmatrix} c_1 \\ c_2 \end{bmatrix} [ x y ] = A − 1 [ c 1 c 2 ]
Example 10.17: A woman owns 21 domestic animals (goats and chickens) with a total of 76 legs. How many of each animal does she own?
Solution:
Let x x x be the number of goats and y y y be the number of chickens. Then:
{ x + y = 21 4 x + 2 y = 76 \begin{cases}
x + y = 21 \\
4x + 2y = 76
\end{cases} { x + y = 21 4 x + 2 y = 76
In matrix form:
[ 1 1 4 2 ] [ x y ] = [ 21 76 ] \begin{bmatrix} 1 & 1 \\ 4 & 2 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 21 \\ 76 \end{bmatrix} [ 1 4 1 2 ] [ x y ] = [ 21 76 ]
Let A = [ 1 1 4 2 ] A = \begin{bmatrix} 1 & 1 \\ 4 & 2 \end{bmatrix} A = [ 1 4 1 2 ] . det ( A ) = ( 1 ⋅ 2 ) − ( 1 ⋅ 4 ) = − 2 \det(A) = (1 \cdot 2) - (1 \cdot 4) = -2 det ( A ) = ( 1 ⋅ 2 ) − ( 1 ⋅ 4 ) = − 2 .
A − 1 = 1 − 2 [ 2 − 1 − 4 1 ] = [ − 1 1 2 2 − 1 2 ] A^{-1} = \frac{1}{-2} \begin{bmatrix} 2 & -1 \\ -4 & 1 \end{bmatrix} = \begin{bmatrix} -1 & \frac{1}{2} \\ 2 & -\frac{1}{2} \end{bmatrix} A − 1 = − 2 1 [ 2 − 4 − 1 1 ] = [ − 1 2 2 1 − 2 1 ]
[ x y ] = [ − 1 1 2 2 − 1 2 ] [ 21 76 ] = [ ( − 1 ) ( 21 ) + ( 1 2 ) ( 76 ) ( 2 ) ( 21 ) + ( − 1 2 ) ( 76 ) ] = [ 17 4 ] \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} -1 & \frac{1}{2} \\ 2 & -\frac{1}{2} \end{bmatrix} \begin{bmatrix} 21 \\ 76 \end{bmatrix} = \begin{bmatrix} (-1)(21) + (\frac{1}{2})(76) \\ (2)(21) + (-\frac{1}{2})(76) \end{bmatrix} = \begin{bmatrix} 17 \\ 4 \end{bmatrix} [ x y ] = [ − 1 2 2 1 − 2 1 ] [ 21 76 ] = [ ( − 1 ) ( 21 ) + ( 2 1 ) ( 76 ) ( 2 ) ( 21 ) + ( − 2 1 ) ( 76 ) ] = [ 17 4 ]
Therefore, x = 17 x = 17 x = 17 (goats) and y = 4 y = 4 y = 4 (chickens).
A system of three equations with three unknowns
Consider the system:
{ a 11 x + b 11 y + c 11 z = d 1 a 22 x + b 22 y + c 22 z = d 2 a 33 x + b 33 y + c 33 z = d 3 \begin{cases}
a_{11}x + b_{11}y + c_{11}z = d_1 \\
a_{22}x + b_{22}y + c_{22}z = d_2 \\
a_{33}x + b_{33}y + c_{33}z = d_3
\end{cases} ⎩ ⎨ ⎧ a 11 x + b 11 y + c 11 z = d 1 a 22 x + b 22 y + c 22 z = d 2 a 33 x + b 33 y + c 33 z = d 3
In matrix form:
[ a 11 b 11 c 11 a 22 b 22 c 22 a 33 b 33 c 33 ] [ x y z ] = [ d 1 d 2 d 3 ] \begin{bmatrix} a_{11} & b_{11} & c_{11} \\ a_{22} & b_{22} & c_{22} \\ a_{33} & b_{33} & c_{33} \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} d_1 \\ d_2 \\ d_3 \end{bmatrix} a 11 a 22 a 33 b 11 b 22 b 33 c 11 c 22 c 33 x y z = d 1 d 2 d 3
Let A A A be the coefficient matrix. Then:
[ x y z ] = A − 1 [ d 1 d 2 d 3 ] \begin{bmatrix} x \\ y \\ z \end{bmatrix} = A^{-1} \begin{bmatrix} d_1 \\ d_2 \\ d_3 \end{bmatrix} x y z = A − 1 d 1 d 2 d 3
The process involves finding the inverse of the 3x3 matrix A A A (which involves finding minors, cofactors, the adjoint, and the determinant), and then multiplying it by the constant matrix.
Solving a system of linear equations using Cramer's rule
A system of two equations and two unknowns
Consider the system:
{ a 1 x + b 1 y = c 1 a 2 x + b 2 y = c 2 \begin{cases}
a_1x + b_1y = c_1 \\
a_2x + b_2y = c_2
\end{cases} { a 1 x + b 1 y = c 1 a 2 x + b 2 y = c 2
Cramer's rule states:
x = ∣ c 1 b 1 c 2 b 2 ∣ ∣ a 1 b 1 a 2 b 2 ∣ = c 1 b 2 − c 2 b 1 a 1 b 2 − a 2 b 1 , y = ∣ a 1 c 1 a 2 c 2 ∣ ∣ a 1 b 1 a 2 b 2 ∣ = a 1 c 2 − a 2 c 1 a 1 b 2 − a 2 b 1 x = \frac{\begin{vmatrix} c_1 & b_1 \\ c_2 & b_2 \end{vmatrix}}{\begin{vmatrix} a_1 & b_1 \\ a_2 & b_2 \end{vmatrix}} = \frac{c_1b_2 - c_2b_1}{a_1b_2 - a_2b_1}, \quad y = \frac{\begin{vmatrix} a_1 & c_1 \\ a_2 & c_2 \end{vmatrix}}{\begin{vmatrix} a_1 & b_1 \\ a_2 & b_2 \end{vmatrix}} = \frac{a_1c_2 - a_2c_1}{a_1b_2 - a_2b_1} x = a 1 a 2 b 1 b 2 c 1 c 2 b 1 b 2 = a 1 b 2 − a 2 b 1 c 1 b 2 − c 2 b 1 , y = a 1 a 2 b 1 b 2 a 1 a 2 c 1 c 2 = a 1 b 2 − a 2 b 1 a 1 c 2 − a 2 c 1
Example 10.20: Solve:
{ 2 x + 3 y = 9 4 x − 2 y = 10 \begin{cases}
2x + 3y = 9 \\
4x - 2y = 10
\end{cases} { 2 x + 3 y = 9 4 x − 2 y = 10
Solution:
x = ∣ 9 3 10 − 2 ∣ ∣ 2 3 4 − 2 ∣ = − 18 − 30 − 4 − 12 = − 48 − 16 = 3 x = \frac{\begin{vmatrix} 9 & 3 \\ 10 & -2 \end{vmatrix}}{\begin{vmatrix} 2 & 3 \\ 4 & -2 \end{vmatrix}} = \frac{-18 - 30}{-4 - 12} = \frac{-48}{-16} = 3 x = 2 4 3 − 2 9 10 3 − 2 = − 4 − 12 − 18 − 30 = − 16 − 48 = 3
y = ∣ 2 9 4 10 ∣ ∣ 2 3 4 − 2 ∣ = 20 − 36 − 16 = − 16 − 16 = 1 y = \frac{\begin{vmatrix} 2 & 9 \\ 4 & 10 \end{vmatrix}}{\begin{vmatrix} 2 & 3 \\ 4 & -2 \end{vmatrix}} = \frac{20 - 36}{-16} = \frac{-16}{-16} = 1 y = 2 4 3 − 2 2 4 9 10 = − 16 20 − 36 = − 16 − 16 = 1
A system of three equations with three unknowns
For the system (10.17), Cramer's rule is:
x = ∣ A 1 ∣ ∣ A ∣ , y = ∣ A 2 ∣ ∣ A ∣ , z = ∣ A 3 ∣ ∣ A ∣ x = \frac{|A_1|}{|A|}, \quad y = \frac{|A_2|}{|A|}, \quad z = \frac{|A_3|}{|A|} x = ∣ A ∣ ∣ A 1 ∣ , y = ∣ A ∣ ∣ A 2 ∣ , z = ∣ A ∣ ∣ A 3 ∣
Where ∣ A ∣ |A| ∣ A ∣ is the determinant of the coefficient matrix, and ∣ A 1 ∣ |A_1| ∣ A 1 ∣ , ∣ A 2 ∣ |A_2| ∣ A 2 ∣ , and ∣ A 3 ∣ |A_3| ∣ A 3 ∣ are the determinants of matrices formed by replacing the first, second, and third columns of A A A , respectively, with the constants d 1 d_1 d 1 , d 2 d_2 d 2 , and d 3 d_3 d 3 .
Example 10.21: Solve the following system of equations using Cramer's rule:
{ x + 2 y + 3 z = 7 2 x + y − z = 7 3 x + y + 2 z = 0 \begin{cases}
x + 2y + 3z = 7 \\
2x + y - z = 7 \\
3x + y + 2z = 0
\end{cases} ⎩ ⎨ ⎧ x + 2 y + 3 z = 7 2 x + y − z = 7 3 x + y + 2 z = 0
Solution:
In matrix form:
[ 1 2 3 2 1 − 1 3 1 2 ] [ x y z ] = [ 7 7 0 ] \begin{bmatrix} 1 & 2 & 3 \\ 2 & 1 & -1 \\ 3 & 1 & 2 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 7 \\ 7 \\ 0 \end{bmatrix} 1 2 3 2 1 1 3 − 1 2 x y z = 7 7 0
Let A = [ 1 2 3 2 1 − 1 3 1 2 ] A = \begin{bmatrix} 1 & 2 & 3 \\ 2 & 1 & -1 \\ 3 & 1 & 2 \end{bmatrix} A = 1 2 3 2 1 1 3 − 1 2 . Calculate the determinant of A A A :
∣ A ∣ = 1 ∣ 1 − 1 1 2 ∣ − 2 ∣ 2 − 1 3 2 ∣ + 3 ∣ 2 1 3 1 ∣ = 1 ( 2 + 1 ) − 2 ( 4 + 3 ) + 3 ( 2 − 3 ) = 3 − 14 − 3 = − 14 |A| = 1\begin{vmatrix} 1 & -1 \\ 1 & 2 \end{vmatrix} - 2\begin{vmatrix} 2 & -1 \\ 3 & 2 \end{vmatrix} + 3\begin{vmatrix} 2 & 1 \\ 3 & 1 \end{vmatrix} = 1(2+1) - 2(4+3) + 3(2-3) = 3 - 14 - 3 = -14 ∣ A ∣ = 1 1 1 − 1 2 − 2 2 3 − 1 2 + 3 2 3 1 1 = 1 ( 2 + 1 ) − 2 ( 4 + 3 ) + 3 ( 2 − 3 ) = 3 − 14 − 3 = − 14
Now, create the matrices A 1 A_1 A 1 , A 2 A_2 A 2 , and A 3 A_3 A 3 by replacing the columns of A A A with the constant vector:
A 1 = [ 7 2 3 7 1 − 1 0 1 2 ] , A 2 = [ 1 7 3 2 7 − 1 3 0 2 ] , A 3 = [ 1 2 7 2 1 7 3 1 0 ] A_1 = \begin{bmatrix} 7 & 2 & 3 \\ 7 & 1 & -1 \\ 0 & 1 & 2 \end{bmatrix}, \quad
A_2 = \begin{bmatrix} 1 & 7 & 3 \\ 2 & 7 & -1 \\ 3 & 0 & 2 \end{bmatrix}, \quad
A_3 = \begin{bmatrix} 1 & 2 & 7 \\ 2 & 1 & 7 \\ 3 & 1 & 0 \end{bmatrix} A 1 = 7 7 0 2 1 1 3 − 1 2 , A 2 = 1 2 3 7 7 0 3 − 1 2 , A 3 = 1 2 3 2 1 1 7 7 0
Calculate their determinants:
∣ A 1 ∣ = 7 ∣ 1 − 1 1 2 ∣ − 2 ∣ 7 − 1 0 2 ∣ + 3 ∣ 7 1 0 1 ∣ = 7 ( 3 ) − 2 ( 14 ) + 3 ( 7 ) = 21 − 28 + 21 = 14 |A_1| = 7\begin{vmatrix} 1 & -1 \\ 1 & 2 \end{vmatrix} - 2\begin{vmatrix} 7 & -1 \\ 0 & 2 \end{vmatrix} + 3\begin{vmatrix} 7 & 1 \\ 0 & 1 \end{vmatrix} = 7(3) - 2(14) + 3(7) = 21 - 28 + 21 = 14 ∣ A 1 ∣ = 7 1 1 − 1 2 − 2 7 0 − 1 2 + 3 7 0 1 1 = 7 ( 3 ) − 2 ( 14 ) + 3 ( 7 ) = 21 − 28 + 21 = 14
∣ A 2 ∣ = 1 ∣ 7 − 1 0 2 ∣ − 7 ∣ 2 − 1 3 2 ∣ + 3 ∣ 2 7 3 0 ∣ = 1 ( 14 ) − 7 ( 7 ) + 3 ( − 21 ) = 14 − 49 − 63 = − 98 |A_2| = 1\begin{vmatrix} 7 & -1 \\ 0 & 2 \end{vmatrix} - 7\begin{vmatrix} 2 & -1 \\ 3 & 2 \end{vmatrix} + 3\begin{vmatrix} 2 & 7 \\ 3 & 0 \end{vmatrix} = 1(14) - 7(7) + 3(-21) = 14 - 49 - 63 = -98 ∣ A 2 ∣ = 1 7 0 − 1 2 − 7 2 3 − 1 2 + 3 2 3 7 0 = 1 ( 14 ) − 7 ( 7 ) + 3 ( − 21 ) = 14 − 49 − 63 = − 98
∣ A 3 ∣ = 1 ∣ 1 7 1 0 ∣ − 2 ∣ 2 7 3 0 ∣ + 7 ∣ 2 1 3 1 ∣ = 1 ( − 7 ) − 2 ( − 21 ) + 7 ( − 1 ) = − 7 + 42 − 7 = 28 |A_3| = 1\begin{vmatrix} 1 & 7 \\ 1 & 0 \end{vmatrix} - 2\begin{vmatrix} 2 & 7 \\ 3 & 0 \end{vmatrix} + 7\begin{vmatrix} 2 & 1 \\ 3 & 1 \end{vmatrix} = 1(-7) - 2(-21) + 7(-1) = -7 + 42 - 7 = 28 ∣ A 3 ∣ = 1 1 1 7 0 − 2 2 3 7 0 + 7 2 3 1 1 = 1 ( − 7 ) − 2 ( − 21 ) + 7 ( − 1 ) = − 7 + 42 − 7 = 28
Now, apply Cramer's rule:
x = ∣ A 1 ∣ ∣ A ∣ = 14 − 14 = − 1 x = \frac{|A_1|}{|A|} = \frac{14}{-14} = -1 x = ∣ A ∣ ∣ A 1 ∣ = − 14 14 = − 1
y = ∣ A 2 ∣ ∣ A ∣ = − 98 − 14 = 7 y = \frac{|A_2|}{|A|} = \frac{-98}{-14} = 7 y = ∣ A ∣ ∣ A 2 ∣ = − 14 − 98 = 7
z = ∣ A 3 ∣ ∣ A ∣ = 28 − 14 = − 2 z = \frac{|A_3|}{|A|} = \frac{28}{-14} = -2 z = ∣ A ∣ ∣ A 3 ∣ = − 14 28 = − 2
Therefore, the solution is x = − 1 x = -1 x = − 1 , y = 7 y = 7 y = 7 , and z = − 2 z = -2 z = − 2 .