Mathematical methods for economic theory

Martin J. Osborne

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,
where a, b, c, d, u, and v are numbers with either a ≠ 0 or c ≠ 0 (or both) and either b ≠ 0 or d ≠ 0 (or both).

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

x2 = (v − cx1)/d.
Substituting this expression for x2 into the first equation yields
ax1 + b(v − cx1)/d = u,
which we can write as
(ad − bc)x1 = du − bv.
There are two cases:
ad − bc ≠ 0
We have
x1 = 
du − bv
ad − bc
.
To find x2 we use the fact that x2 = (v − cx1)/d to get
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 (x1x2) 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,
    (x1x2)  =  left parenthesis
    du − bv
    ad − bc
    av − cu
    ad − bc
    right parenthesis .
  • If ad = bc and du = bv then the set of solutions of the equations is the set of pairs
    left parenthesis x1
    v − cx1
    d
    right parenthesis
    for any number x1.
  • 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

left parenthesis a b right parenthesis
c d
left parenthesis x1 right parenthesis
x2
 = 
left parenthesis u right parenthesis
v
.     (*)

A general n-equation system in n variables may be written as
Ax = b,
where A is an n × n matrix and x and b are n × 1 column vectors.

If A is nonsingular, then multiplying each side by the inverse A−1 of A yields

x = A−1b,
the unique solution in this case. Thus solving the system of equations in this case amounts to finding the inverse of the matrix A.

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 (Ab) 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.
The following result gives the conditions under which the system of equations Ax = b has one, many, or no solutions.
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 = b
has 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 (Ab) 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.
Write it in matrix form. If ad ≠ bc then the inverse of the matrix on the left exists and is
1
ad − bc
left parenthesis d b right parenthesis
c a
so we have
left parenthesis x1 right parenthesis
x2
 = 
1
ad − bc
left parenthesis d b right parenthesis
c a
left parenthesis u right parenthesis
v
.
Thus
x1 = 
ud − bv
ad − bc
and
x2 = 
va − cu
ad − bc
as we found before.
Example 1.3.2
Consider the system of equations
2 x1 +  x2 +  2 x3  =  1
x1 − x2 + x3  =  0
2 x2 − x3  =  3.
When written in matrix form Ax = b, the matrix A is
left parenthesis 2 1 2 right parenthesis
1 −1 1
0 2 −1
.
The determinant of this matrix is 3 ≠ 0, so the matrix is nonsingular. Using the general formula for the inverse of a matrix, the inverse of the matrix is
left parenthesis −1/3 5/3 1 right parenthesis
1/3 −2/3 0
2/3 −4/3 −1
.
Multiplying this matrix by the transpose of (1, 0, 3) yields (x1x2x3) = (8/3, 1/3, −7/3), which is thus the unique solution of the system of equations. (By substituting this list of values into the original equations you can verify that it is indeed a solution.)
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.
When written in matrix form, the matrix on the left is
left parenthesis 4 2 1 right parenthesis
2 −2 2
0 4 −2
.
The determinant of this matrix is 0; its rank is 2. The augmented matrix is
left parenthesis 4 2 1 1 right parenthesis
2 −2 2 0
0 4 −2 3
.
This matrix has rank 3 (the determinant of the 3 × 3 matrix consisting of the last three rows and columns is 14 ≠ 0), so by the earlier result, the system of equations has no solution. (Another way to see that the system has no solution is to multiply the second equation by 2 and the third equation by 1.5 and add them together. The resulting equation is inconsistent with the first equation.)
Example 1.3.4
Consider the system of equations
3 x1 +  4 x2  =  7
6 x1 + 8 x2  =  14.
When written in matrix form, the matrix on the left is
left parenthesis 3 4 right parenthesis
6 8
.
The determinant of this matrix is 0; its rank is 1. The augmented matrix is
left parenthesis 3 4 7 right parenthesis
6 8 14
.
This matrix has rank 1 (the determinant of every 2 × 2 submatrix is 0), so by the earlier result, the system of equations has infinitely many solutions.

The second equation is twice the first one, so any (x1x2) that satisfies the first equation satisfies the second one. Hence (x1x2) 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 = b
where x is an n × 1 column vector. If A is nonsingular then the (unique) value of x that satisfies the system is given by
xi = |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 = ∑n
j=1
vijbj,
where vij is the (i,j)th component of A−1.

Now, by a previous result, the (i,j)th component of A−1 is (−1)i+j|Aji|/|A|. Thus

xi = ∑n
j=1
(−1)i+j|Aji|bj/|A|.
Finally, 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
|A*(b,i)| = ∑n
j=1
(−1)i+jbj|Aji|,
establishing 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.)
Example 1.3.5
Applying Cramer's rule to the system
ax1 + bx2  = u
cx1 + dx2  = v,
if ad ≠ bc we get
x1 = 
left parenthesis u b right parenthesis
v d
ad − bc
and
x2 = 
left parenthesis a u right parenthesis
c v
ad − bc
.
Calculating the determinants in the numerators, we have
x1 = 
ud − bv
ad − bc
and
x2 = 
va − cu
ad − bc
.
Cramer's rule is particularly useful if you want to calculate the value of only some of the variables in a solution of a system of equations, as the following example demonstrates.
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
is, by Cramer's rule, the determinant of
left parenthesis 2 1 2 right parenthesis
1 0 1
0 3 −1
divided by the determinant of
left parenthesis 2 1 2 right parenthesis
1 −1 1
0 2 −1
.
The first determinant is 1 and the second is 3, so the value of x2 in the solution of the system is 1/3.