Unit 5 · Algebra · 8 teaching hours · 28 min read
Matrix Based System of Linear Equations
What the syllabus asks for 3
- Cramer's rule (up to three variables)
- Matrix method: row-equivalent (Gauss) method
- Matrix method: inverse matrix method
A system of linear equations is a set of straight-line (or plane) equations that must hold at the same time. Solving one by "substitute and eliminate" works for two unknowns and becomes a mess for three. Matrices turn the whole system into one equation, AX = B, and then offer three mechanical methods: Cramer's rule (determinants), the row-equivalent or Gauss method (row operations), and the inverse matrix method (X = A^{-1}B). This unit builds all three and finishes with the question the board asks most often: when does a system have exactly one solution, when infinitely many, and when none at all?
Write the equations with the unknowns in the same order, put the missing coefficients in as zeros, and read off three objects: the coefficient matrix A, the column of unknowns X and the column of constants B. Then AX = B. The determinant |A| decides which method will work: if |A| \ne 0 all three methods give the one answer; if |A| = 0 neither Cramer's rule nor the inverse exists, and only row operations can tell you what is going on.
For the system x + 2y + z = 8, \;2x + 3y - z = 5, \;3x - y + 2z = 7, the matrix form is shown below. Multiplying the first row of A into the column X reproduces x + 2y + z, which is why the single matrix equation says the same thing as all three original equations.
5.1 Cramer's rule (up to three variables)
Two variables
Eliminate y: multiply the first equation by b_2, the second by b_1, and subtract.
Eliminating x the same way gives (a_1b_2 - a_2b_1)\,y = a_1c_2 - a_2c_1. Each bracket is a 2\times 2 determinant: writing D for the determinant of the coefficients, D_x for D with the x-column replaced by the constants, and D_y likewise,
Three variables
The same statement holds with 3\times 3 determinants. For AX = B with D = |A| \ne 0,
where D_x, D_y, D_z are D with the first, second, third column replaced by the column of constants. Replace a column, never a row.
Problem. Solve by Cramer's rule: \;2x + 3y = 13, \;3x - y = 3.
Solution.
so a unique solution exists. Replacing the first column by (13, 3),
and replacing the second column,
Check in the first equation: 2(2) + 3(3) = 13. Correct.
Problem. Solve by Cramer's rule: \;x + y + z = 4, \;x - y + z = 6, \;2x + y - z = 0.
Solution. Expand every determinant along its first row.
Check in the third equation: 2(2) + (-1) - 3 = 0. Correct.
Problem. In a shop in Bhaktapur, 2\ \text{kg} of apples and 3\ \text{kg} of oranges cost Rs 640, while 3\ \text{kg} of apples and 2\ \text{kg} of oranges cost Rs 610. Find the price per kilogram of each fruit using Cramer's rule.
Solution. Let apples cost Rs x per kg and oranges Rs y per kg. Then
Apples cost Rs 110 per kg and oranges Rs 140 per kg. Check: 2(110) + 3(140) = 220 + 420 = 640. Correct.
If D = 0 you may not divide, and the rule says nothing at all. The system then has either no solution or infinitely many — §5.4 shows how to tell which. Writing "x = 0/0" earns no marks.
5.2 Matrix method: row-equivalent (Gauss) method
Elementary row operations
Two matrices are row-equivalent (written \sim) if one can be obtained from the other by a sequence of elementary row operations:
| Operation | Symbol | Effect on the system |
|---|---|---|
| Swap two rows | R_i \leftrightarrow R_j | write the equations in a different order |
| Multiply a row by c \ne 0 | R_i \rightarrow cR_i | multiply an equation through by c |
| Add a multiple of one row to another | R_i \rightarrow R_i + cR_j | add c\times(one equation) to another |
Each operation is reversible and none of them changes the solution set — they are exactly the moves you already make when eliminating by hand. So we apply them to the augmented matrix [A\,|\,B], the coefficient matrix with the constant column attached, and read the answer off at the end.
Gauss elimination drives the coefficient block to echelon form (all zeros below the leading diagonal), after which the unknowns come out one at a time by back substitution, starting with the last equation.
Problem. Solve by the row-equivalent (Gauss) method:
Solution. The augmented matrix has rows (1, 2, 1 \,|\, 8), (2, 3, -1 \,|\, 5), (3, -1, 2 \,|\, 7).
Clear the first column. R_2 \rightarrow R_2 - 2R_1 gives (0, -1, -3 \,|\, -11); R_3 \rightarrow R_3 - 3R_1 gives (0, -7, -1 \,|\, -17).
Clear the second column. R_3 \rightarrow R_3 - 7R_2 gives (0, 0, 20 \,|\, 60).
The system is now triangular:
Back substitute. z = 3. Then -y - 9 = -11, so y = 2. Then x + 4 + 3 = 8, so x = 1.
Solution: x = 1, y = 2, z = 3. Check in the third equation: 3(1) - 2 + 2(3) = 7. Correct.
Problem. Solve by Gauss elimination: \;y + z = 5, \;x + y - z = 0, \;2x - y + z = 3.
Solution. The first pivot position is 0, so start by swapping rows.
R_1 \leftrightarrow R_2: rows become (1, 1, -1 \,|\, 0), (0, 1, 1 \,|\, 5), (2, -1, 1 \,|\, 3).
R_3 \rightarrow R_3 - 2R_1: (0, -3, 3 \,|\, 3).
R_3 \rightarrow R_3 + 3R_2: (0, 0, 6 \,|\, 18).
So 6z = 18, giving z = 3; then y + 3 = 5, so y = 2; then x + 2 - 3 = 0, so x = 1.
Check: 2(1) - 2 + 3 = 3. Correct.
Swap it with a lower row that has a non-zero entry in that column and carry on. Only if the whole column below is zero is something special happening — then the determinant is zero and you are in §5.4.
Gauss-Jordan method
Gauss-Jordan keeps going after echelon form: make every pivot 1 and clear the entries above the pivots as well as below. The augmented matrix ends as [I \,|\, X] and the solution is simply read off — no back substitution at all.
Problem. Solve the system of Worked example 5.4 by the Gauss-Jordan method.
Solution. Start from the echelon form already obtained: (1, 2, 1 \,|\, 8), (0, -1, -3 \,|\, -11), (0, 0, 20 \,|\, 60).
Make the pivots 1. R_2 \rightarrow -R_2 gives (0, 1, 3 \,|\, 11); R_3 \rightarrow \frac{1}{20}R_3 gives (0, 0, 1 \,|\, 3).
Clear above the third pivot. R_1 \rightarrow R_1 - R_3 gives (1, 2, 0 \,|\, 5); R_2 \rightarrow R_2 - 3R_3 gives (0, 1, 0 \,|\, 2).
Clear above the second pivot. R_1 \rightarrow R_1 - 2R_2 gives (1, 0, 0 \,|\, 1).
The matrix is now [I \,|\, X] with last column (1, 2, 3), so x = 1, y = 2, z = 3 — the same answer, read straight off.
5.3 Matrix method: inverse matrix method
Start from the matrix equation and multiply on the left by A^{-1}, which exists exactly when |A| \ne 0:
Since A^{-1} = \dfrac{\mathrm{adj}\,A}{|A|}, the practical formula is
so the whole job is: find |A|, find the cofactors, transpose them to get \mathrm{adj}\,A, multiply by B, divide by |A|.
For a 2\times2 matrix the inverse is the familiar swap-and-negate rule.
Problem. Solve \;2x + 3y = 13, \;3x - y = 3 by the inverse matrix method.
Solution. Here A has rows (2, 3) and (3, -1), and B = (13, 3).
For a 2\times2 matrix, swap the diagonal entries and negate the other two: \mathrm{adj}\,A has rows (-1, -3) and (-3, 2), so
Then
So x = 2, y = 3, agreeing with Worked example 5.1.
Three unknowns
Problem. The sum of three numbers is 6. Twice the third number added to the first gives 7. Three times the first, added to the sum of the second and third, gives 12. Find the numbers by the inverse matrix method.
Solution. Let the numbers be x, y, z:
So A has rows (1,1,1), (1,0,2), (3,1,1) and B = (6, 7, 12).
Determinant. Expanding along the first row,
Cofactors. C_{11} = -2, C_{12} = 5, C_{13} = 1; C_{21} = 0, C_{22} = -2, C_{23} = 2; C_{31} = 2, C_{32} = -1, C_{33} = -1.
Adjoint. Transpose the cofactor matrix: \mathrm{adj}\,A has rows (-2, 0, 2), (5, -2, -1), (1, 2, -1).
Multiply and divide.
The numbers are 3, 1 and 2. Check: 3+1+2 = 6; 3 + 2(2) = 7; 9 + 1 + 2 = 12. Correct.
Problem. A hotel in Pokhara charges Rs x a night for a single room, Rs y for a double and Rs z for a deluxe room. One group paid Rs 9000 for 2 singles, 1 double and 1 deluxe; a second paid Rs 10\,000 for 1 single, 2 doubles and 1 deluxe; a third paid Rs 12\,000 for 1 single, 1 double and 2 deluxe. Find the three tariffs.
Solution. The system is
Adding all three equations gives a shortcut worth spotting: 4(x+y+z) = 31\,000, so x + y + z = 7750. Subtracting this from each equation in turn,
(The same answer comes from X = \frac14(\mathrm{adj}\,A)B with \mathrm{adj}\,A having rows (3,-1,-1), (-1,3,-1), (-1,-1,3).)
Single Rs 1250, double Rs 2250, deluxe Rs 4250. Check: 2(1250) + 2250 + 4250 = 9000. Correct.
X = A^{-1}B, never BA^{-1}: matrix multiplication is not commutative, and BA^{-1} is not even defined here (3\times1 times 3\times3). And always compute |A| before starting the cofactors — if |A| = 0 there is no inverse and the method cannot be used at all.
| Method | Needs | Best when |
|---|---|---|
| Cramer's rule | \|A\| \ne 0; four determinants | 2 or 3 unknowns, coefficients small |
| Inverse matrix | \|A\| \ne 0; adjoint | several systems share the same A |
| Gauss / Gauss-Jordan | nothing | always — and the only method when \|A\| = 0 |
5.4 Consistency: unique solution, infinitely many, or none
A system is consistent if it has at least one solution and inconsistent if it has none. Row reduce the augmented matrix and one of exactly three pictures appears in the last row.
- |A| \ne 0: exactly one solution, X = A^{-1}B. The system is consistent and determinate. Cramer and the inverse both work.
- |A| = 0 and every D_x, D_y, D_z = 0: the equations are dependent, so there are infinitely many solutions — write one unknown as a parameter t.
- |A| = 0 but at least one of D_x, D_y, D_z \ne 0: the equations contradict each other and there is no solution.
A homogeneous system (B = 0) is never inconsistent: x = y = z = 0 always works. It has a non-trivial solution exactly when |A| = 0.
Problem. Show that \;x + y + z = 6, \;2x + 3y + 4z = 20, \;x + 2y + 3z = 14 has infinitely many solutions, and find them.
Solution. |A| = 1(9-8) - 1(6-4) + 1(4-3) = 1 - 2 + 1 = 0, so there is no unique solution. Row reduce:
R_2 \rightarrow R_2 - 2R_1 gives (0, 1, 2 \,|\, 8); R_3 \rightarrow R_3 - R_1 gives (0, 1, 2 \,|\, 8) — the same row.
R_3 \rightarrow R_3 - R_2 gives (0, 0, 0 \,|\, 0), the statement 0 = 0, which is true but empty. Only two independent equations remain:
Put z = t (any real number). Then y = 8 - 2t and
So the solutions are (x, y, z) = (t-2,\ 8-2t,\ t) for every real t — a whole line of them. Check in the second equation: 2(t-2) + 3(8-2t) + 4t = 2t - 4 + 24 - 6t + 4t = 20 for every t. Correct.
Problem. Show that \;x + y + z = 6, \;2x + 3y + 4z = 20, \;x + 2y + 3z = 15 is inconsistent.
Solution. The coefficient matrix is the same as in the last example, so |A| = 0 again. Row reducing the augmented matrix:
R_2 \rightarrow R_2 - 2R_1 gives (0, 1, 2 \,|\, 8); R_3 \rightarrow R_3 - R_1 gives (0, 1, 2 \,|\, 9).
R_3 \rightarrow R_3 - R_2 gives (0, 0, 0 \,|\, 1), i.e. 0 = 1, which is false. The three planes have no common point: the system is inconsistent and has no solution.
(Changing a single constant from 14 to 15 turned infinitely many solutions into none — this is why the constants must be row-reduced along with the coefficients.)
Problem. For what values of \lambda and \mu does the system \;x + y + z = 6, \;x + 2y + 3z = 10, \;x + 2y + \lambda z = \mu have (i) a unique solution, (ii) no solution, (iii) infinitely many solutions?
Solution. Expanding along the first row,
(i) If \lambda \ne 3 then |A| \ne 0 and there is a unique solution for every \mu.
If \lambda = 3, row reduce: R_2 \rightarrow R_2 - R_1 gives (0, 1, 2 \,|\, 4) and R_3 \rightarrow R_3 - R_1 gives (0, 1, 2 \,|\, \mu - 6). Then R_3 \rightarrow R_3 - R_2 gives (0, 0, 0 \,|\, \mu - 10).
(ii) If \lambda = 3 and \mu \ne 10 the last row reads 0 = \mu - 10 \ne 0: no solution.
(iii) If \lambda = 3 and \mu = 10 the last row is 0 = 0: infinitely many solutions, namely z = t, y = 4 - 2t, x = 6 - y - z = 2 + t.
Check (iii) in the second equation: (2+t) + 2(4-2t) + 3t = 10 for all t. Correct.
Problem. Show that \;x + y + z = 0, \;2x - y + 3z = 0, \;4x + y + 5z = 0 has a non-trivial solution and find it.
Solution. The system is homogeneous, so x = y = z = 0 is always a solution. A non-trivial one exists only if
which it is. Row reduce: R_2 \rightarrow R_2 - 2R_1 gives (0, -3, 1 \,|\, 0) and R_3 \rightarrow R_3 - 4R_1 gives (0, -3, 1 \,|\, 0), the same row, so R_3 \rightarrow R_3 - R_2 gives all zeros. We are left with
Put z = 3t: then y = t and x = -y - z = -4t. The solutions are (-4t,\ t,\ 3t); taking t = 1 gives (-4, 1, 3).
Check in the third equation: 4(-4) + 1 + 5(3) = -16 + 16 = 0. Correct.
Chapter summary
- Every linear system is AX = B with A the coefficient matrix, X the column of unknowns and B the column of constants.
- Cramer: x = D_x/D, y = D_y/D, z = D_z/D, where D = |A| and each D_x replaces the matching column of D by B. Requires D \ne 0.
- Row-equivalent (Gauss): apply elementary row operations (R_i \leftrightarrow R_j, R_i \rightarrow cR_i, R_i \rightarrow R_i + cR_j) to [A\,|\,B] until the coefficient block is upper triangular, then back substitute. Row operations never change the solution set.
- Gauss-Jordan: carry on until [I\,|\,X]; the solution is the last column.
- Inverse method: X = A^{-1}B = \dfrac{1}{|A|}(\mathrm{adj}\,A)B, valid only when |A| \ne 0. Multiply on the left.
- Consistency: |A| \ne 0 → unique; |A| = 0 with a zero row in the reduced augmented matrix → infinitely many (use a parameter t); |A| = 0 with a row 0 = k \ne 0 → no solution.
- A homogeneous system has a non-trivial solution if and only if |A| = 0.
Practice questions
Group A — Multiple choice (1 mark each)
- The system AX = B has a unique solution if [1]a|A| = 0b|A| \ne 0cB = 0dA is symmetric
- In Cramer's rule, D_y is obtained from D by replacing [1]arow 2 by Bbcolumn 2 by Bcrow 1 by Bdcolumn 1 by B
- Which of these is not an elementary row operation? [1]aR_1 \leftrightarrow R_2bR_2 \rightarrow 3R_2cR_2 \rightarrow 0 \cdot R_2dR_2 \rightarrow R_2 - 4R_1
- If the last row of a row-reduced augmented matrix is (0\ 0\ 0 \,|\, 5), the system has [1]aa unique solutionbtwo solutionscinfinitely many solutionsdno solution
- For AX = B with |A| \ne 0, the solution is [1]aX = BA^{-1}bX = A^{-1}BcX = AB^{-1}dX = B^{-1}A
- A homogeneous system AX = O in three unknowns has a non-trivial solution if [1]a|A| \ne 0b|A| = 0c|A| = 1dnever
Answers to Group A
1. (b) — only then does A^{-1} exist, and then X = A^{-1}B is the one solution.
2. (b) — always a column, and the column belonging to that unknown.
3. (c) — multiplying a row by 0 destroys the equation; the multiplier must be non-zero.
4. (d) — that row says 0 = 5, which is impossible, so the system is inconsistent.
5. (b) — multiply AX = B on the left by A^{-1}.
6. (b) — if |A| \ne 0 the only solution is X = A^{-1}O = O, the trivial one.
Group B — Short answer (5 marks each)
- Solve by Cramer's rule: \;4x + 3y = 18, \;3x - 2y = 5. [5]
- Solve by Cramer's rule: \;x + y + z = 6, \;x + 2y + 3z = 14, \;x + 4y + 9z = 36. [5]
- Solve by the row-equivalent (Gauss) method: \;x + y + z = 2, \;2x - y + 3z = 0, \;3x + 2y - z = 9. [5]
- Solve by the inverse matrix method: \;2x + y = 8, \;x + 3y = 9. [5]
- Examine the consistency of \;x + 2y = 4, \;2x + 4y = 8, \;3x + 6y = 12 and solve it if it is consistent. [5]
- Find the value of k for which \;x + y + z = 1, \;x + 2y + 3z = 4, \;x + 4y + kz = 6 fails to have a unique solution, and say what happens for that value. [5]
Answers to Group B
1. D = (4)(-2) - (3)(3) = -8 - 9 = -17.
Check: 4(3) + 3(2) = 18. Correct.
2. Expanding along the first row each time,
Check in the third equation: 1 + 8 + 27 = 36. Correct.
3. Augmented rows (1,1,1\,|\,2), (2,-1,3\,|\,0), (3,2,-1\,|\,9).
R_2 \rightarrow R_2 - 2R_1: (0,-3,1\,|\,-4). R_3 \rightarrow R_3 - 3R_1: (0,-1,-4\,|\,3). R_3 \rightarrow 3R_3 - R_2: (0,0,-13\,|\,13).
So z = -1; then -3y + (-1) = -4 gives y = 1; then x + 1 - 1 = 2 gives x = 2.
Solution x = 2, y = 1, z = -1. Check: 3(2) + 2(1) - (-1) = 9. Correct.
4. A has rows (2,1), (1,3) and B = (8, 9). |A| = 6 - 1 = 5 \ne 0, and \mathrm{adj}\,A has rows (3, -1), (-1, 2), so
So x = 3, y = 2. Check: 2(3) + 2 = 8 and 3 + 3(2) = 9. Correct.
5. The second and third equations are just 2\times and 3\times the first, so row reduction (R_2 \rightarrow R_2 - 2R_1, R_3 \rightarrow R_3 - 3R_1) gives two rows of zeros. The system is consistent with only one independent equation, so it has infinitely many solutions: put y = t, then x = 4 - 2t, i.e. (4-2t,\ t) for every real t.
6. D = 1(2k - 12) - 1(k - 3) + 1(4 - 2) = k - 7, so the unique solution fails exactly when k = 7.
With k = 7: R_2 \rightarrow R_2 - R_1 gives (0,1,2\,|\,3) and R_3 \rightarrow R_3 - R_1 gives (0,3,6\,|\,5). Then R_3 \rightarrow R_3 - 3R_2 gives (0,0,0\,|\,-4), i.e. 0 = -4. So for k = 7 the system is inconsistent and has no solution. (Had the right-hand side of the third equation been 10 instead of 6, the last row would read 0 = 0 and there would be infinitely many solutions.)
Group C — Long answer (8 marks each)
- (a) Derive Cramer's rule for the system a_1x + b_1y = c_1, a_2x + b_2y = c_2. [4](b) Hence solve \;x + y + z = 4, \;2x + y - z = 3, \;x - y + 2z = 8 by Cramer's rule. [4]
- (a) Show that AX = B has the solution X = A^{-1}B when |A| \ne 0, and solve \;x + 2y - z = 2, \;2x - y + z = 3, \;x + y + z = 6 by the inverse matrix method. [5](b) Solve the same system by Gauss-Jordan and compare the labour. [3]
- (a) Explain, with the determinant in each case, when a system of three linear equations in three unknowns has a unique solution, infinitely many solutions, or no solution. [4](b) Discuss the system \;x + y + z = 6, \;x + 2y + 3z = 10, \;x + 2y + \lambda z = \mu for all values of \lambda and \mu. [4]
Answers to Group C
1. (a) Multiply the first equation by b_2 and the second by b_1 and subtract:
Similarly, multiplying by a_2 and a_1 and subtracting,
Writing D = a_1b_2 - a_2b_1, D_x = c_1b_2 - c_2b_1 and D_y = a_1c_2 - a_2c_1 as determinants, x = D_x/D and y = D_y/D provided D \ne 0.
(b) Expanding along the first row,
Check in the third equation: 3 - (-1) + 2(2) = 8. Correct.
2. (a) If |A| \ne 0 then A^{-1} exists; multiplying AX = B on the left by it gives (A^{-1}A)X = A^{-1}B, i.e. IX = X = A^{-1}B.
Here A has rows (1,2,-1), (2,-1,1), (1,1,1) and B = (2, 3, 6).
Cofactors: C_{11} = -2, C_{12} = -1, C_{13} = 3; C_{21} = -3, C_{22} = 2, C_{23} = 1; C_{31} = 1, C_{32} = -3, C_{33} = -5. Transposing, \mathrm{adj}\,A has rows (-2, -3, 1), (-1, 2, -3), (3, 1, -5). Then
So x = 1, y = 2, z = 3. Check: 1 + 4 - 3 = 2. Correct.
(b) Augmented rows (1,2,-1\,|\,2), (2,-1,1\,|\,3), (1,1,1\,|\,6).
R_2 \rightarrow R_2 - 2R_1: (0,-5,3\,|\,-1). R_3 \rightarrow R_3 - R_1: (0,-1,2\,|\,4). R_2 \leftrightarrow R_3, then R_2 \rightarrow -R_2: (0,1,-2\,|\,-4). R_3 \rightarrow R_3 + 5R_2: (0,0,-7\,|\,-21), so R_3 \rightarrow -\frac{1}{7}R_3 gives (0,0,1\,|\,3). R_2 \rightarrow R_2 + 2R_3: (0,1,0\,|\,2); R_1 \rightarrow R_1 + R_3: (1,2,0\,|\,5); R_1 \rightarrow R_1 - 2R_2: (1,0,0\,|\,1).
The matrix is [I\,|\,(1,2,3)], the same answer. Gauss-Jordan needed no cofactors and no division until the very end, so for a single system it is much less work than the inverse method; the inverse only pays off when several systems share the same A.
3. (a) Let D = |A|.
- D \ne 0: the inverse exists, X = A^{-1}B is the only solution — unique (the three planes meet in one point).
- D = 0 and the row-reduced augmented matrix has a row of zeros: the equations are dependent, giving infinitely many solutions (the planes meet in a line, or coincide). Equivalently D_x = D_y = D_z = 0.
- D = 0 but a row reduces to 0 = k with k \ne 0: the equations contradict each other, so there is no solution (at least one of D_x, D_y, D_z is non-zero).
(b) D = 1(2\lambda - 6) - 1(\lambda - 3) + 1(2-2) = \lambda - 3.
If \lambda \ne 3: D \ne 0, so there is a unique solution for every \mu.
If \lambda = 3: row reducing gives (0,1,2\,|\,4) from R_2 - R_1 and (0,1,2\,|\,\mu-6) from R_3 - R_1; subtracting leaves (0,0,0\,|\,\mu-10).
- \lambda = 3, \mu \ne 10: last row is 0 = \mu - 10 \ne 0 — no solution.
- \lambda = 3, \mu = 10: last row is 0 = 0 — infinitely many solutions, z = t, y = 4 - 2t, x = 2 + t for every real t.
Practise more: Mathematics question bank