So far we have discussed techniques for solving “nice” linear systems defined by nonsingular coefficient matrices: these are “nice” since they always have a unique solution. Now, we move towards more general systems that have m equations and n unknowns, including non-square (m=n) and singular coefficient matrices.
The good news is that we already have the tools that we need to solve the general case, but we need to make some small tweaks to accomodate this more general setting. We first define a generalization of upper triangular matrices that take a “stair case form”, called the row echelon form of a matrix.
where U is an m×n matrix in row echelon form. This fact follows from an analogous development of the LU-factorization using Gaussian Elimination, with some slight modifications for dealing with columns that do not have a pivot. We illustrate the procedure with an example which makes clear when things deviate from our previous approach.
Consider the linear system with the augmented matrix
where b=⎣⎡abcd⎦⎤ is a generic right hand side vector that we use to get a better understanding of the solution properties of this linear system. The (1,1) entry is a pivot. We use elementary row operations to make the entries below the pivot to be zero.
In (5), the second column has no suitable nonzero entry to use as the second pivot, because the 3 in the (1,2) position is already in a row with a pivot, so we move to the 3rd column. The (2,3) entry is nonzero, and becomes our second pivot (associated with the second row), which we use to zero out entries below it:
No suitable pivots are available in column 4 (since rows 1 and 2 already have pivots associated with them), and so the final pivot is the 4 in the fifth column. We want to put our matrix into row echelon form, so we swap rows 3 and 4 to get
We can now define the rank of a matrix. For now, this will seem like a strange thing to give a name to, but we’ll see later in the class that in addition to the algebraic properties we outline next, it also says a lot about the geometry of subspaces defined by the columns of A.
Rank plays a central role in our study of linear algebra, but right now we will explore the connections between rank and the solution set of a linear system.
Properties 1-3 are straightforward consequences of the definition of rank. Property 4 is not as obvious, but we’ll come back to it later in the class once we’ve developed more tools.
SymPy is a Python library for performing symbolic mathematics. We use it below to compute (reduced) row echelon forms of a matrix and see that it allows us to identify the rank of a matrix. In practice, numerical algebra routines based on the singular value decomposition, which we will see in the last third of the class, are used to compute the rank of a matrix: this is implemented by the numpy function np.linalg.matrix_rank.
## Row echelon form
import sympy
import numpy as np
# find the reduced row echelon form
A = sympy.Matrix([[1, 3, 2, -1, 0], [2, 6 ,1, 4, 3], [-1, -3, -3, 3, 1], [3, 9, 8, 7, 2]])
A_re = A.rref()
# find the rank of matrix
print("Row echelon form of the matrix:\n", A_re)
# find the rank of matrix
print("\nRank of the matrix: ", A.rank())
# Rank of a matrix using numpy
A_n = np.array([[1, 3, 2, -1, 0], [2, 6 ,1, 4, 3], [-1, -3, -3, 3, 1], [3, 9, 8, 7, 2]])
print("\nRank of the matrix using numpy: ", np.linalg.matrix_rank(A_n))
Row echelon form of the matrix:
(Matrix([
[1, 3, 0, 0, 8/7],
[0, 0, 1, 0, -3/7],
[0, 0, 0, 1, 2/7],
[0, 0, 0, 0, 0]]), (0, 2, 3))
Rank of the matrix: 3
Rank of the matrix using numpy: 3
Suppose we have reduced the system to row echelon form [U∣c], corresponding to the linear system Ux=c. We will now discuss how to solve such a system, and the types of solution sets that are possible.
First, we check for inconsistent equations. For example, if the ith row of U is all zeros, but the corresponding entry ci=0, then this would represent 0=ci=0. This case corresponds to when Ax=b has no solution, also called incompatible. For example, in our previous example (7) the last row is all zeros, and therefore the system (4) has no solution if c−3b+35a=0. If there are no such inconsistencies, the linear system is compatible, and has one or more solutions. Let’s see how to solve such compatible linear systems.
To find the solutions to compatible linear systems, we first split the variables into two separate classes.
As before, we use back substitution to solve Ux=c, but our goal is now to express the basic variables as a function of the free variables. We use our previous example to illustrate this procedure. Let’s fix a right hand side by setting a=0,b=3,c=1,d=1:
Let us denote the variables as (x,y,z,u,v). Following (13), (x,z,v) are basic variables, while (y,u) are free variables. We first need to solve the reduced system
for the basic variables (x,z,v) in terms of the free variables (y,u). Back Substitution combined with a bit of algebra gives us the following general solution
As the name suggests, we are free to chose any values for the free variables (y,u): any resulting solution will satisfy (15). One possible solution for (4) is obtained by setting y=y=0 so that x=21,y=0,z=−41,u=0,v=43.
In general, for an m×n system (m equations and n unknowns) of rank r, there are r basic variables and m−r free variables.
There are m−r all zero rows in the row echelon form of the linear system. The system is compatible if and only if the corresponding right-hand vector entries ci are zero.
Our discussion is summarized in the following theorem.
where i=1,2,…,m. The solution set to each equation (23) defines a plane Pi in three dimensional space. Therefore, when solving Ax=b, we are looking for a point (x1,x2,x3) that lies in all of the planes Pi defined by the m equations of the form (23).
Geometrically, we are looking for a point x that lies in the intersection P1∩P2∩…∩Pm. The picture below illustrates the three possible solution sets for m=3 equations with three unknowns.
This ends our initial exploration of solutions to systems of linear equations. Our story so far has been almost entirely algebraic in nature. However, the power and beauty of linear algebra is that it allows us to turn algebraic questions such as “Does Ax=b have a solution?” into geometric ones like “Do the planes defined by equations (23) intersect?” In the next lectures, we will explore this geometric perspective, and see that it allows us to unlock some incredibly powerful tools.