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 x_{1} and x_{2}:
ax_{1} + bx_{2}  = u 
cx_{1} + dx_{2}  = v, 
One straightforward way to solve for x_{1} and x_{2} 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
x_{1} = du − bv ad − bc . x_{2} = av − cu ad − bc .  ad − bc = 0
 Given that
(ad − bc)x_{1} = du − bv,if du ≠ bv then the equations have no solution, and if du = bv the set of solutions is the set of pairs (x_{1}, x_{2}) satisfying cx_{1} + dx_{2} = v (that is, the set of pairs (x_{1}, (v − cx_{1})/d) for any number x_{1}).
In summary, the solutions of the system of equations have three possible forms.
 If ad ≠ bc then the equations have a unique solution,
(x_{1}, x_{2}) = 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
x_{1}, v − cx_{1} 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^{−1}b. 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
ax_{1} + bx_{2} = u cx_{1} + dx_{2} = v. 1 ad − bc d −b −c a x_{1} x_{2} = 1 ad − bc d −b −c a u v . x_{1} = ud − bv ad − bc x_{2} = va − cu ad − bc
 Example 1.3.2

Consider the system of equations
2 x_{1} + x_{2} + 2 x_{3} = 1 x_{1} − x_{2} + x_{3} = 0 2 x_{2} − x_{3} = 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 x_{1} + 2 x_{2} + x_{3} = 1 2 x_{1} − 2 x_{2} + 2 x_{3} = 0 4 x_{2} − 2 x_{3} = 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 x_{1} + 4 x_{2} = 7 6 x_{1} + 8 x_{2} = 14. 3 4 6 8 . 3 4 7 6 8 14 . The second equation is twice the first one, so any (x_{1}, x_{2}) that satisfies the first equation satisfies the second one. Hence (x_{1}, x_{2}) is a solution of the system of equations if and only if 3x_{1} + 4x_{2} = 7, or, if you like, x_{2} = (7 − 3x_{1})/4.
Cramer's rule
A useful implication of the fact that the solution of the system Ax = b is given by x = A^{−1}b 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 byx_{i} = 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^{−1}b, so that
x_{i} = ∑nwhere v_{ij} is the (i,j)th component of A^{−1}.
j=1v_{ij}b_{j},Now, by a previous result, the (i,j)th component of A^{−1} is (−1)^{i+j}A_{ji}/A. Thus
x_{i} = ∑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}A_{ji}b_{j}/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+j}b_{j}A_{ji},
 Example 1.3.5

Applying Cramer's rule to the system
ax_{1} + bx_{2} = u cx_{1} + dx_{2} = v, x_{1} = u b v d ad − bc x_{2} = a u c v ad − bc . x_{1} = ud − bv ad − bc x_{2} = va − cu ad − bc .
 Example 1.3.6

The value of x_{2} in a solution of the system of equations
2 x_{1} + x_{2} + 2 x_{3} = 1 x_{1} − x_{2} + x_{3} = 0 2 x_{2} − x_{3} = 3 2 1 2 1 0 1 0 3 −1 2 1 2 1 −1 1 0 2 −1 .