1.3 Solving systems of linear equations: matrix inversion and Cramer's rule
Two equations in two variables
Consider a system of two equations in two variables x1 and x2:
ax1 + bx2 | = u |
cx1 + dx2 | = v, |
One straightforward way to solve for x1 and x2 is to isolate one of the variables in one of the equations and substitute the result into the other equation. Suppose that d ≠ 0. Then from the second equation we have
- ad − bc ≠ 0
- We have
x1 = du − bv ad − bc . x2 = av − cu ad − bc . - ad − bc = 0
- Given that
(ad − bc)x1 = du − bv,if du ≠ bv then the equations have no solution, and if du = bv the set of solutions is the set of pairs (x1, x2) satisfying cx1 + dx2 = v (that is, the set of pairs (x1, (v − cx1)/d) for any number x1).
In summary, the solutions of the system of equations have three possible forms.
- If ad ≠ bc then the equations have a unique solution,
(x1, x2) = du − bv ad − bc , av − cu ad − bc . - If ad = bc and du = bv then the set of solutions of the equations is the set of pairs
x1, v − cx1 d - If ad = bc and du ≠ bv then the equations have no solution.
This method of isolating a variable in one equation and substituting it into another equation is cumbersome when the system consists of more than two equations and two variables. I now describe a more elegant method.
n equations in n variables
We can write the system of two equations in two variables in the previous section in matrix form, as
|
|
= |
|
. (*) |
If A is nonsingular, then multiplying each side by the inverse A−1 of A yields
If the determinant of A is zero, then whether the system of equations has many solutions or none depends on the ranks of A and the augmented matrix defined as follows.
- Definition
- Let A be an n × n matrix and b an n × 1 column vector. The augmented matrix of (A, b) is the matrix with n rows and n + 1 columns in which A constitutes the first n rows and columns and b is the last column.
- Proposition 1.3.1
-
Let A be an n × n matrix and let b be an n × 1 column vector. If A is nonsingular then the system of equations
Ax = bhas a unique solution, x = A−1b. If the determinant of A is zero, then the system has infinitely many solutions if the rank of the augmented matrix of (A, b) is equal to the rank of A, and otherwise has no solution.
- Source
- For a proof, see Hadley (1961), pp. 168–169.
If n = 2 or n = 3, the inverse of A is relatively easy to compute, so that if a system of equations has a solution, this solution may easily be found, as the following examples demonstrate.
- Example 1.3.1
-
Consider the system of equations
ax1 + bx2 = u cx1 + dx2 = v. 1 ad − bc d −b −c a x1 x2 = 1 ad − bc d −b −c a u v . x1 = ud − bv ad − bc x2 = va − cu ad − bc
- Example 1.3.2
-
Consider the system of equations
2 x1 + x2 + 2 x3 = 1 x1 − x2 + x3 = 0 2 x2 − x3 = 3. 2 1 2 1 −1 1 0 2 −1 . −1/3 5/3 1 1/3 −2/3 0 2/3 −4/3 −1 .
- Example 1.3.3
-
Consider the system of equations
4 x1 + 2 x2 + x3 = 1 2 x1 − 2 x2 + 2 x3 = 0 4 x2 − 2 x3 = 3. 4 2 1 2 −2 2 0 4 −2 . 4 2 1 1 2 −2 2 0 0 4 −2 3 .
- Example 1.3.4
-
Consider the system of equations
3 x1 + 4 x2 = 7 6 x1 + 8 x2 = 14. 3 4 6 8 . 3 4 7 6 8 14 . The second equation is twice the first one, so any (x1, x2) that satisfies the first equation satisfies the second one. Hence (x1, x2) is a solution of the system of equations if and only if 3x1 + 4x2 = 7, or, if you like, x2 = (7 − 3x1)/4.
Cramer's rule
A useful implication of the fact that the solution of the system Ax = b is given by x = A−1b if A is nonsingular is the following result (due to Gabriel Cramer, 1704–1752), which gives an explicit expression for the value of each variable separately.- Proposition 1.3.2 (Cramer's rule)
-
Let A be an n × n matrix, let b be an n × 1 column vector, and consider the system of equations
Ax = bwhere x is an n × 1 column vector. If A is nonsingular then the (unique) value of x that satisfies the system is given byxi = |A*(b,i)|/|A| for i = 1, ..., n,where A*(b,i) is the matrix obtained from A by replacing the ith column with b.
- Proof
-
We have x = A−1b, so that
xi = ∑nwhere vij is the (i,j)th component of A−1.
j=1vijbj,Now, by a previous result, the (i,j)th component of A−1 is (−1)i+j|Aji|/|A|. Thus
xi = ∑nFinally, calculate the determinant of A*(b,i) in the statement of the result by expanding along its ith column. This column is b, so according to the second part of a previous result we have
j=1(−1)i+j|Aji|bj/|A|.|A*(b,i)| = ∑nestablishing the result. (Note that because i is the index of the column along which we are expanding, the roles of i and j here are reversed relative to their roles in the statement of the result we are using.)
j=1(−1)i+jbj|Aji|,
- Example 1.3.5
-
Applying Cramer's rule to the system
ax1 + bx2 = u cx1 + dx2 = v, x1 = u b v d ad − bc x2 = a u c v ad − bc . x1 = ud − bv ad − bc x2 = va − cu ad − bc .
- Example 1.3.6
-
The value of x2 in a solution of the system of equations
2 x1 + x2 + 2 x3 = 1 x1 − x2 + x3 = 0 2 x2 − x3 = 3 2 1 2 1 0 1 0 3 −1 2 1 2 1 −1 1 0 2 −1 .