Everything in this course comes together here. A system of linear equations can be written as one matrix equation A X = B AX = B A X = B , and then solved in three ways: by the inverse matrix, by Cramer's rule using determinants, or by row operations (the Gauss-Jordan method). The determinant of A A A also tells you in advance whether the system has exactly one solution. This lesson works through each method on the same systems so that you can compare them.
Writing a system as a matrix equation#
Take the system
2 x + 3 y = 8 , x − y = − 1 2x + 3y = 8, \qquad x - y = -1 2 x + 3 y = 8 , x − y = − 1
Collect the coefficients, the unknowns and the constants into matrices:
A = [ 2 3 1 − 1 ] , X = [ x y ] , B = [ 8 − 1 ] A = \begin{bmatrix} 2 & 3 \\ 1 & -1 \end{bmatrix}, \qquad X = \begin{bmatrix} x \\ y \end{bmatrix}, \qquad B = \begin{bmatrix} 8 \\ -1 \end{bmatrix} A = [ 2 1 3 − 1 ] , X = [ x y ] , B = [ 8 − 1 ]
Multiplying out, A X = [ 2 x + 3 y x − y ] AX = \begin{bmatrix} 2x + 3y \\ x - y \end{bmatrix} A X = [ 2 x + 3 y x − y ] , so the system is exactly the single equation A X = B AX = B A X = B . Here A A A is called the coefficient matrix .
Method 1: the inverse matrix#
If ∣ A ∣ ≠ 0 |A| \neq 0 ∣ A ∣ = 0 , multiply both sides of A X = B AX = B A X = B on the left by A − 1 A^{-1} A − 1 :
A − 1 A X = A − 1 B ⟹ I X = A − 1 B ⟹ X = A − 1 B A^{-1}AX = A^{-1}B \implies IX = A^{-1}B \implies X = A^{-1}B A − 1 A X = A − 1 B ⟹ I X = A − 1 B ⟹ X = A − 1 B
The system then has exactly one solution. (The multiplication must be on the left of both sides, because matrix multiplication is not commutative.)
Example 1#
Solve 2 x + 3 y = 8 2x + 3y = 8 2 x + 3 y = 8 , x − y = − 1 x - y = -1 x − y = − 1 by the inverse matrix.
∣ A ∣ = − 2 − 3 = − 5 ≠ 0 |A| = -2 - 3 = -5 \neq 0 ∣ A ∣ = − 2 − 3 = − 5 = 0 , so
A − 1 = 1 − 5 [ − 1 − 3 − 1 2 ] = 1 5 [ 1 3 1 − 2 ] \displaystyle A^{-1} = \frac{1}{-5}\begin{bmatrix} -1 & -3 \\ -1 & 2 \end{bmatrix} = \frac{1}{5}\begin{bmatrix} 1 & 3 \\ 1 & -2 \end{bmatrix} A − 1 = − 5 1 [ − 1 − 1 − 3 2 ] = 5 1 [ 1 1 3 − 2 ]
X = A − 1 B = 1 5 [ 1 3 1 − 2 ] [ 8 − 1 ] = 1 5 [ 8 − 3 8 + 2 ] = 1 5 [ 5 10 ] = [ 1 2 ] \displaystyle X = A^{-1}B = \frac{1}{5}\begin{bmatrix} 1 & 3 \\ 1 & -2 \end{bmatrix}\begin{bmatrix} 8 \\ -1 \end{bmatrix} = \frac{1}{5}\begin{bmatrix} 8 - 3 \\ 8 + 2 \end{bmatrix} = \frac{1}{5}\begin{bmatrix} 5 \\ 10 \end{bmatrix} = \begin{bmatrix} 1 \\ 2 \end{bmatrix} X = A − 1 B = 5 1 [ 1 1 3 − 2 ] [ 8 − 1 ] = 5 1 [ 8 − 3 8 + 2 ] = 5 1 [ 5 10 ] = [ 1 2 ]
So x = 1 x = 1 x = 1 , y = 2 y = 2 y = 2 . Check: 2 + 6 = 8 2 + 6 = 8 2 + 6 = 8 and 1 − 2 = − 1 1 - 2 = -1 1 − 2 = − 1 .
Example 2#
Solve by the inverse matrix:
x + 2 y + z = 8 , 2 x − y + z = 3 , x + y − z = 0 x + 2y + z = 8, \qquad 2x - y + z = 3, \qquad x + y - z = 0 x + 2 y + z = 8 , 2 x − y + z = 3 , x + y − z = 0
Here A = [ 1 2 1 2 − 1 1 1 1 − 1 ] A = \begin{bmatrix} 1 & 2 & 1 \\ 2 & -1 & 1 \\ 1 & 1 & -1 \end{bmatrix} A = 1 2 1 2 − 1 1 1 1 − 1 and B = [ 8 3 0 ] B = \begin{bmatrix} 8 \\ 3 \\ 0 \end{bmatrix} B = 8 3 0 .
∣ A ∣ = 1 ( 1 − 1 ) − 2 ( − 2 − 1 ) + 1 ( 2 + 1 ) = 0 + 6 + 3 = 9 |A| = 1(1 - 1) - 2(-2 - 1) + 1(2 + 1) = 0 + 6 + 3 = 9 ∣ A ∣ = 1 ( 1 − 1 ) − 2 ( − 2 − 1 ) + 1 ( 2 + 1 ) = 0 + 6 + 3 = 9
Working out the nine cofactors and transposing gives
adj A = [ 0 3 3 3 − 2 1 3 1 − 5 ] \text{adj}\,A = \begin{bmatrix} 0 & 3 & 3 \\ 3 & -2 & 1 \\ 3 & 1 & -5 \end{bmatrix} adj A = 0 3 3 3 − 2 1 3 1 − 5
X = 1 9 [ 0 3 3 3 − 2 1 3 1 − 5 ] [ 8 3 0 ] = 1 9 [ 0 + 9 + 0 24 − 6 + 0 24 + 3 + 0 ] = 1 9 [ 9 18 27 ] = [ 1 2 3 ] \displaystyle X = \frac{1}{9}\begin{bmatrix} 0 & 3 & 3 \\ 3 & -2 & 1 \\ 3 & 1 & -5 \end{bmatrix}\begin{bmatrix} 8 \\ 3 \\ 0 \end{bmatrix} = \frac{1}{9}\begin{bmatrix} 0 + 9 + 0 \\ 24 - 6 + 0 \\ 24 + 3 + 0 \end{bmatrix} = \frac{1}{9}\begin{bmatrix} 9 \\ 18 \\ 27 \end{bmatrix} = \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix} X = 9 1 0 3 3 3 − 2 1 3 1 − 5 8 3 0 = 9 1 0 + 9 + 0 24 − 6 + 0 24 + 3 + 0 = 9 1 9 18 27 = 1 2 3
So x = 1 x = 1 x = 1 , y = 2 y = 2 y = 2 , z = 3 z = 3 z = 3 . Check in the first equation: 1 + 4 + 3 = 8 1 + 4 + 3 = 8 1 + 4 + 3 = 8 .
Method 2: Cramer's rule#
Let Δ = ∣ A ∣ \Delta = |A| Δ = ∣ A ∣ , and let Δ 1 \Delta_1 Δ 1 , Δ 2 \Delta_2 Δ 2 , Δ 3 \Delta_3 Δ 3 be the determinants obtained by replacing the first, second and third columns of A A A by the column of constants B B B . If Δ ≠ 0 \Delta \neq 0 Δ = 0 ,
x = Δ 1 Δ , y = Δ 2 Δ , z = Δ 3 Δ \displaystyle x = \frac{\Delta_1}{\Delta}, \qquad y = \frac{\Delta_2}{\Delta}, \qquad z = \frac{\Delta_3}{\Delta} x = Δ Δ 1 , y = Δ Δ 2 , z = Δ Δ 3
For two unknowns, use Δ 1 \Delta_1 Δ 1 and Δ 2 \Delta_2 Δ 2 only.
Example 3#
Solve 2 x + 3 y = 8 2x + 3y = 8 2 x + 3 y = 8 , x − y = − 1 x - y = -1 x − y = − 1 by Cramer's rule.
Δ = ∣ 2 3 1 − 1 ∣ = − 5 , Δ 1 = ∣ 8 3 − 1 − 1 ∣ = − 8 + 3 = − 5 , Δ 2 = ∣ 2 8 1 − 1 ∣ = − 2 − 8 = − 10 \Delta = \begin{vmatrix} 2 & 3 \\ 1 & -1 \end{vmatrix} = -5, \quad \Delta_1 = \begin{vmatrix} 8 & 3 \\ -1 & -1 \end{vmatrix} = -8 + 3 = -5, \quad \Delta_2 = \begin{vmatrix} 2 & 8 \\ 1 & -1 \end{vmatrix} = -2 - 8 = -10 Δ = 2 1 3 − 1 = − 5 , Δ 1 = 8 − 1 3 − 1 = − 8 + 3 = − 5 , Δ 2 = 2 1 8 − 1 = − 2 − 8 = − 10
So x = − 5 − 5 = 1 \displaystyle x = \frac{-5}{-5} = 1 x = − 5 − 5 = 1 and y = − 10 − 5 = 2 \displaystyle y = \frac{-10}{-5} = 2 y = − 5 − 10 = 2 , as before.
Example 4#
Solve the system of Example 2 by Cramer's rule.
Δ = 9 \Delta = 9 Δ = 9 from Example 2. Replacing each column in turn by [ 8 3 0 ] \begin{bmatrix} 8 \\ 3 \\ 0 \end{bmatrix} 8 3 0 :
Δ 1 = ∣ 8 2 1 3 − 1 1 0 1 − 1 ∣ = 8 ( 1 − 1 ) − 2 ( − 3 − 0 ) + 1 ( 3 − 0 ) = 0 + 6 + 3 = 9 \Delta_1 = \begin{vmatrix} 8 & 2 & 1 \\ 3 & -1 & 1 \\ 0 & 1 & -1 \end{vmatrix} = 8(1 - 1) - 2(-3 - 0) + 1(3 - 0) = 0 + 6 + 3 = 9 Δ 1 = 8 3 0 2 − 1 1 1 1 − 1 = 8 ( 1 − 1 ) − 2 ( − 3 − 0 ) + 1 ( 3 − 0 ) = 0 + 6 + 3 = 9
Δ 2 = ∣ 1 8 1 2 3 1 1 0 − 1 ∣ = 1 ( − 3 − 0 ) − 8 ( − 2 − 1 ) + 1 ( 0 − 3 ) = − 3 + 24 − 3 = 18 \Delta_2 = \begin{vmatrix} 1 & 8 & 1 \\ 2 & 3 & 1 \\ 1 & 0 & -1 \end{vmatrix} = 1(-3 - 0) - 8(-2 - 1) + 1(0 - 3) = -3 + 24 - 3 = 18 Δ 2 = 1 2 1 8 3 0 1 1 − 1 = 1 ( − 3 − 0 ) − 8 ( − 2 − 1 ) + 1 ( 0 − 3 ) = − 3 + 24 − 3 = 18
Δ 3 = ∣ 1 2 8 2 − 1 3 1 1 0 ∣ = 1 ( 0 − 3 ) − 2 ( 0 − 3 ) + 8 ( 2 + 1 ) = − 3 + 6 + 24 = 27 \Delta_3 = \begin{vmatrix} 1 & 2 & 8 \\ 2 & -1 & 3 \\ 1 & 1 & 0 \end{vmatrix} = 1(0 - 3) - 2(0 - 3) + 8(2 + 1) = -3 + 6 + 24 = 27 Δ 3 = 1 2 1 2 − 1 1 8 3 0 = 1 ( 0 − 3 ) − 2 ( 0 − 3 ) + 8 ( 2 + 1 ) = − 3 + 6 + 24 = 27
So x = 9 9 = 1 \displaystyle x = \frac{9}{9} = 1 x = 9 9 = 1 , y = 18 9 = 2 \displaystyle y = \frac{18}{9} = 2 y = 9 18 = 2 , z = 27 9 = 3 \displaystyle z = \frac{27}{9} = 3 z = 9 27 = 3 .
Method 3: Gauss-Jordan (row operations)#
Write the augmented matrix [ A ∣ B ] [A \mid B] [ A ∣ B ] : the coefficient matrix with the constants as an extra column. Then use row operations, which do not change the solutions:
interchange two rows;
multiply a row by a non-zero number;
add a multiple of one row to another.
Aim to turn the left part into I I I ; the last column then shows the solution.
Example 5#
Solve the system of Example 2 by the Gauss-Jordan method.
[ 1 2 1 8 2 − 1 1 3 1 1 − 1 0 ] \left[\begin{array}{ccc|c} 1 & 2 & 1 & 8 \\ 2 & -1 & 1 & 3 \\ 1 & 1 & -1 & 0 \end{array}\right] 1 2 1 2 − 1 1 1 1 − 1 8 3 0
R 2 → R 2 − 2 R 1 R_2 \to R_2 - 2R_1 R 2 → R 2 − 2 R 1 and R 3 → R 3 − R 1 R_3 \to R_3 - R_1 R 3 → R 3 − R 1 :
[ 1 2 1 8 0 − 5 − 1 − 13 0 − 1 − 2 − 8 ] \left[\begin{array}{ccc|c} 1 & 2 & 1 & 8 \\ 0 & -5 & -1 & -13 \\ 0 & -1 & -2 & -8 \end{array}\right] 1 0 0 2 − 5 − 1 1 − 1 − 2 8 − 13 − 8
Interchange R 2 R_2 R 2 and R 3 R_3 R 3 , then multiply the new R 2 R_2 R 2 by − 1 -1 − 1 :
[ 1 2 1 8 0 1 2 8 0 − 5 − 1 − 13 ] \left[\begin{array}{ccc|c} 1 & 2 & 1 & 8 \\ 0 & 1 & 2 & 8 \\ 0 & -5 & -1 & -13 \end{array}\right] 1 0 0 2 1 − 5 1 2 − 1 8 8 − 13
R 1 → R 1 − 2 R 2 R_1 \to R_1 - 2R_2 R 1 → R 1 − 2 R 2 and R 3 → R 3 + 5 R 2 R_3 \to R_3 + 5R_2 R 3 → R 3 + 5 R 2 :
[ 1 0 − 3 − 8 0 1 2 8 0 0 9 27 ] \left[\begin{array}{ccc|c} 1 & 0 & -3 & -8 \\ 0 & 1 & 2 & 8 \\ 0 & 0 & 9 & 27 \end{array}\right] 1 0 0 0 1 0 − 3 2 9 − 8 8 27
R 3 → 1 9 R 3 \displaystyle R_3 \to \frac{1}{9}R_3 R 3 → 9 1 R 3 , then R 1 → R 1 + 3 R 3 R_1 \to R_1 + 3R_3 R 1 → R 1 + 3 R 3 and R 2 → R 2 − 2 R 3 R_2 \to R_2 - 2R_3 R 2 → R 2 − 2 R 3 :
[ 1 0 0 1 0 1 0 2 0 0 1 3 ] \left[\begin{array}{ccc|c} 1 & 0 & 0 & 1 \\ 0 & 1 & 0 & 2 \\ 0 & 0 & 1 & 3 \end{array}\right] 1 0 0 0 1 0 0 0 1 1 2 3
So x = 1 x = 1 x = 1 , y = 2 y = 2 y = 2 , z = 3 z = 3 z = 3 .
When is there exactly one solution?#
If ∣ A ∣ ≠ 0 |A| \neq 0 ∣ A ∣ = 0 , the system has exactly one solution, and all three methods find it.
If ∣ A ∣ = 0 |A| = 0 ∣ A ∣ = 0 , the inverse and Cramer's rule cannot be used. The system then has either no solution or infinitely many solutions. For example, x + 2 y = 3 x + 2y = 3 x + 2 y = 3 and 2 x + 4 y = 7 2x + 4y = 7 2 x + 4 y = 7 have ∣ A ∣ = 4 − 4 = 0 |A| = 4 - 4 = 0 ∣ A ∣ = 4 − 4 = 0 ; doubling the first gives 2 x + 4 y = 6 2x + 4y = 6 2 x + 4 y = 6 , which contradicts the second, so there is no solution. But x + 2 y = 3 x + 2y = 3 x + 2 y = 3 and 2 x + 4 y = 6 2x + 4y = 6 2 x + 4 y = 6 are the same equation, with infinitely many solutions.
Example 6#
Sita buys 2 2 2 pens and 3 3 3 notebooks for ₹110, and Ravi buys 3 3 3 pens and 1 1 1 notebook for ₹60. Find the price of a pen and of a notebook.
Let a pen cost ₹p p p and a notebook ₹n n n : 2 p + 3 n = 110 2p + 3n = 110 2 p + 3 n = 110 and 3 p + n = 60 3p + n = 60 3 p + n = 60 .
Δ = ∣ 2 3 3 1 ∣ = 2 − 9 = − 7 , Δ 1 = ∣ 110 3 60 1 ∣ = 110 − 180 = − 70 , Δ 2 = ∣ 2 110 3 60 ∣ = 120 − 330 = − 210 \Delta = \begin{vmatrix} 2 & 3 \\ 3 & 1 \end{vmatrix} = 2 - 9 = -7, \quad \Delta_1 = \begin{vmatrix} 110 & 3 \\ 60 & 1 \end{vmatrix} = 110 - 180 = -70, \quad \Delta_2 = \begin{vmatrix} 2 & 110 \\ 3 & 60 \end{vmatrix} = 120 - 330 = -210 Δ = 2 3 3 1 = 2 − 9 = − 7 , Δ 1 = 110 60 3 1 = 110 − 180 = − 70 , Δ 2 = 2 3 110 60 = 120 − 330 = − 210
So p = − 70 − 7 = 10 \displaystyle p = \frac{-70}{-7} = 10 p = − 7 − 70 = 10 and n = − 210 − 7 = 30 \displaystyle n = \frac{-210}{-7} = 30 n = − 7 − 210 = 30 : a pen costs ₹10 and a notebook ₹30.
Practice#
Solve 3 x − 2 y = 4 3x - 2y = 4 3 x − 2 y = 4 , x + 4 y = 6 x + 4y = 6 x + 4 y = 6 by the inverse matrix.
Solve 5 x + 2 y = 1 5x + 2y = 1 5 x + 2 y = 1 , 3 x + y = 1 3x + y = 1 3 x + y = 1 by Cramer's rule.
Solve x + y + z = 9 x + y + z = 9 x + y + z = 9 , 2 x − y + z = 5 2x - y + z = 5 2 x − y + z = 5 , x + 2 y − z = 4 x + 2y - z = 4 x + 2 y − z = 4 by Cramer's rule.
Solve 2 x + y − z = 3 2x + y - z = 3 2 x + y − z = 3 , x − y + z = 6 x - y + z = 6 x − y + z = 6 , x + 2 y + 3 z = 7 x + 2y + 3z = 7 x + 2 y + 3 z = 7 by any method.
Does the system x + 2 y = 3 x + 2y = 3 x + 2 y = 3 , 2 x + 4 y = 5 2x + 4y = 5 2 x + 4 y = 5 have a unique solution? Explain.
Two kg of apples and one kg of oranges cost ₹130; one kg of apples and three kg of oranges cost ₹140. Find the price per kg of each.
The ages of Ravi, Sita and Gopi add up to 66 66 66 . Ravi is 4 4 4 years older than Sita, and Sita is 7 7 7 years older than Gopi. Find their ages using matrices.
Solve the system of question 3 by the Gauss-Jordan method.
Answers#
Show answers
∣ A ∣ = 12 + 2 = 14 |A| = 12 + 2 = 14 ∣ A ∣ = 12 + 2 = 14 , A − 1 = 1 14 [ 4 2 − 1 3 ] \displaystyle A^{-1} = \frac{1}{14}\begin{bmatrix} 4 & 2 \\ -1 & 3 \end{bmatrix} A − 1 = 14 1 [ 4 − 1 2 3 ] , and X = 1 14 [ 16 + 12 − 4 + 18 ] = [ 2 1 ] \displaystyle X = \frac{1}{14}\begin{bmatrix} 16 + 12 \\ -4 + 18 \end{bmatrix} = \begin{bmatrix} 2 \\ 1 \end{bmatrix} X = 14 1 [ 16 + 12 − 4 + 18 ] = [ 2 1 ] . So x = 2 x = 2 x = 2 , y = 1 y = 1 y = 1 .
Δ = 5 − 6 = − 1 \Delta = 5 - 6 = -1 Δ = 5 − 6 = − 1 , Δ 1 = 1 − 2 = − 1 \Delta_1 = 1 - 2 = -1 Δ 1 = 1 − 2 = − 1 , Δ 2 = 5 − 3 = 2 \Delta_2 = 5 - 3 = 2 Δ 2 = 5 − 3 = 2 . So x = 1 x = 1 x = 1 , y = − 2 y = -2 y = − 2 .
Δ = 1 ( 1 − 2 ) − 1 ( − 2 − 1 ) + 1 ( 4 + 1 ) = 7 \Delta = 1(1 - 2) - 1(-2 - 1) + 1(4 + 1) = 7 Δ = 1 ( 1 − 2 ) − 1 ( − 2 − 1 ) + 1 ( 4 + 1 ) = 7 . Δ 1 = 14 \Delta_1 = 14 Δ 1 = 14 , Δ 2 = 21 \Delta_2 = 21 Δ 2 = 21 , Δ 3 = 28 \Delta_3 = 28 Δ 3 = 28 . So x = 2 x = 2 x = 2 , y = 3 y = 3 y = 3 , z = 4 z = 4 z = 4 .
∣ A ∣ = − 15 |A| = -15 ∣ A ∣ = − 15 ; the solution is x = 3 x = 3 x = 3 , y = − 1 y = -1 y = − 1 , z = 2 z = 2 z = 2 . (Check: 6 − 1 − 2 = 3 6 - 1 - 2 = 3 6 − 1 − 2 = 3 , 3 + 1 + 2 = 6 3 + 1 + 2 = 6 3 + 1 + 2 = 6 , 3 − 2 + 6 = 7 3 - 2 + 6 = 7 3 − 2 + 6 = 7 .)
No. ∣ A ∣ = 4 − 4 = 0 |A| = 4 - 4 = 0 ∣ A ∣ = 4 − 4 = 0 , and doubling the first equation gives 2 x + 4 y = 6 2x + 4y = 6 2 x + 4 y = 6 , which contradicts 2 x + 4 y = 5 2x + 4y = 5 2 x + 4 y = 5 . There is no solution.
2 a + r = 130 2a + r = 130 2 a + r = 130 and a + 3 r = 140 a + 3r = 140 a + 3 r = 140 , with Δ = 6 − 1 = 5 \Delta = 6 - 1 = 5 Δ = 6 − 1 = 5 , Δ 1 = 390 − 140 = 250 \Delta_1 = 390 - 140 = 250 Δ 1 = 390 − 140 = 250 , Δ 2 = 280 − 130 = 150 \Delta_2 = 280 - 130 = 150 Δ 2 = 280 − 130 = 150 . Apples ₹50 per kg, oranges ₹30 per kg.
With ages r r r , s s s , g g g : r + s + g = 66 r + s + g = 66 r + s + g = 66 , r − s = 4 r - s = 4 r − s = 4 , s − g = 7 s - g = 7 s − g = 7 . Solving gives g = 16 g = 16 g = 16 , s = 23 s = 23 s = 23 , r = 27 r = 27 r = 27 .
After R 2 → R 2 − 2 R 1 R_2 \to R_2 - 2R_1 R 2 → R 2 − 2 R 1 and R 3 → R 3 − R 1 R_3 \to R_3 - R_1 R 3 → R 3 − R 1 the rows are ( 1 , 1 , 1 ∣ 9 ) (1, 1, 1 \mid 9) ( 1 , 1 , 1 ∣ 9 ) , ( 0 , − 3 , − 1 ∣ − 13 ) (0, -3, -1 \mid -13) ( 0 , − 3 , − 1 ∣ − 13 ) , ( 0 , 1 , − 2 ∣ − 5 ) (0, 1, -2 \mid -5) ( 0 , 1 , − 2 ∣ − 5 ) . Continuing to reduce the left part to I I I gives the last column ( 2 , 3 , 4 ) (2, 3, 4) ( 2 , 3 , 4 ) , so x = 2 x = 2 x = 2 , y = 3 y = 3 y = 3 , z = 4 z = 4 z = 4 .