Skip to article frontmatterSkip to article content

1.8 General Linear Systems

There is not always one solution

Dept. of Electrical and Systems Engineering
University of Pennsylvania

Binder

Lecture notes

1Reading

Material related to this page, as well as additional exercises, can be found in ALA Ch. 1.8.

2Learning Objectives

By the end of this page, you should know:

  • how to put a matrix in to row echelon form
  • compute the rank of a matrix
  • how to solve general linear systems using row echelon form

3Row Echelon Form

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 mm equations and nn unknowns, including non-square (mnm \neq 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.

An example of a matrix in row echelon form is

[2015600117000-3100000],\begin{bmatrix} \textbf{2} & 0 & 1 & -5 & 6 \\ 0 & 0 & \textbf{1} & 1 & 7 \\ 0 & 0 & 0 & \textbf{-3} & 1\\ 0 & 0 & 0 & 0 & 0 \end{bmatrix},

where r=3,m=4r=3, m=4 and the pivots 3, -1, and 2 are in bold\textbf{bold}.

If AA is an m×nm \times n matrix, then we can find an m×mm \times m permutation matrix PP and an m×mm \times m lower triangular matrix LL such that

PA=LU, PA = LU,

where UU is an m×nm \times 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

[13210a26143b13331c39872d],\left[ \begin{array}{ccccc|c} 1 & 3 & 2 & -1 & 0 & a \\ 2 & 6 & 1 & 4 & 3 & b \\ -1 & -3 & -3 & 3 & 1 & c \\ 3 & 9 & 8 & -7 & 2 & d\end{array}\right],

where b=[abcd]\textbf{b} = \begin{bmatrix} a \\ b \\ c \\ d\end{bmatrix} 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)(1,1) entry is a pivot. We use elementary row operations to make the entries below the pivot to be zero.

[13210a00363b2a00121c+a00242d3a],\left[ \begin{array}{ccccc|c} 1 & 3 & 2 & -1 & 0 & a \\ 0 & 0 & -3 & 6 & 3 & b-2a \\ 0 & 0 & -1 & 2 & 1 & c+a \\ 0 & 0 & 2 & 4 & 2 & d-3a\end{array}\right],

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)(2, 3) entry is nonzero, and becomes our second pivot (associated with the second row), which we use to zero out entries below it:

[13210a00363b2a00000cb3+53a00004d+23b133a].\left[ \begin{array}{ccccc|c} 1 & 3 & 2 & -1 & 0 & a \\ 0 & 0 & -3 & 6 & 3 & b-2a \\ 0 & 0 & 0 & 0 & 0 & c-\frac{b}{3}+\frac{5}{3}a \\ 0 & 0 & 0 & 0 & 4 & d + \frac{2}{3}b-\frac{13}{3}a\end{array}\right].

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

[13210a00363b2a00004d+23b133a00000cb3+53a].\left[ \begin{array}{ccccc|c} 1 & 3 & 2 & -1 & 0 & a \\ 0 & 0 & -3 & 6 & 3 & b-2a \\ 0 & 0 & 0 & 0 & 4 & d + \frac{2}{3}b-\frac{13}{3}a \\ 0 & 0 & 0 & 0 & 0 & c-\frac{b}{3}+\frac{5}{3}a \end{array}\right].

The three pivots are 1, -3, and 4 at (1,1)(1,1), (2,3)(2, 3), and (3,4)(3, 4).

4Rank of a Matrix

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 AA.

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.

Python Break!

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

5Solving Linear Systems in Row Echelon Form

Suppose we have reduced the system to row echelon form [Uc][U | \textbf{c}], corresponding to the linear system Ux=cU\vv x = \vv c. We will now discuss how to solve such a system, and the types of solution sets that are possible.

5.1No Solution

First, we check for inconsistent equations. For example, if the ithi^{th} row of UU is all zeros, but the corresponding entry ci0c_i \neq 0, then this would represent 0=ci00 = c_i \neq 0. This case corresponds to when Ax=bA \textbf{x} = \textbf{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 cb3+53a0c-\frac{b}{3}+\frac{5}{3}a \neq 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.

5.2Compatible 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=cU \textbf{x} = \textbf{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=1a = 0, b = 3, c=1, d=1:

[132100003633000043000000].\left[ \begin{array}{ccccc|c} 1 & 3 & 2 & -1 & 0 & 0 \\ 0 & 0 & -3 & 6 & 3 & 3 \\ 0 & 0 & 0 & 0 & 4 & 3 \\ 0 & 0 & 0 & 0 & 0 & 0 \end{array}\right].

Let us denote the variables as (x,y,z,u,v)(x, y, z, u, v). Following (13), (x,z,v)\color{red}{(x, z, v)} are basic variables, while (y,u)\color{green}{(y, u)} are free variables. We first need to solve the reduced system

x+3y+2zu=0,3z+6u+3v=3,4v=30=0,\begin{align*} \color{red}{x}+\color{green}{3y}+\color{red}{2z}-\color{green}{u} &= 0, \\ -\color{red}{3z} + \color{green}{6u} + \color{red}{3v} &= 3, \\ \color{red}{4v} &= 3 \\ 0 &= 0, \end{align*}

for the basic variables (x,z,v)\color{red}{(x, z, v)} in terms of the free variables (y,u)\color{green}{(y, u)}. Back Substitution combined with a bit of algebra gives us the following general solution

v=34, z=1+2u+v=14+2u, x=3y2z+u=123y3u.v=\frac{3}{4}, \ z = -1 + 2u + v = -\frac{1}{4} + 2u, \ x = -3y - 2z + u = \frac{1}{2}-3y-3u.

As the name suggests, we are free to chose any values for the free variables (y,u)\color{green}{(y, u)}: any resulting solution will satisfy (15). One possible solution for (4) is obtained by setting y=y=0y=y=0 so that x=12,y=0,z=14,u=0,v=34x = \frac{1}{2},\, y=0,\, z=-\frac{1}{4},\, u =0,\, v = \frac{3}{4}.

5.3General Properties

  1. In general, for an m×nm \times n system (mm equations and nn unknowns) of rank rr, there are rr basic variables and mrm - r free variables.
  2. There are mrm - 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 cic_i are zero.

Our discussion is summarized in the following theorem.

6A Geometric perspective

Suppose we have mm equations in three unknowns of the form

ai1x1+ai2x2+ai3x3=bi,a_{i1}x_1 + a_{i2}x_2 + a_{i3}x_3 = b_i,

where i=1,2,,mi = 1,2,\ldots,m. The solution set to each equation (23) defines a plane PiP_i in three dimensional space. Therefore, when solving Ax=bA \textbf{x} = \textbf{b}, we are looking for a point (x1,x2,x3)(x_1, x_2, x_3) that lies in all of the planes PiP_i defined by the mm equations of the form (23).

Geometrically, we are looking for a point x\textbf{x} that lies in the intersection P1P2PmP_1 \cap P_2 \cap \ldots \cap P_m. The picture below illustrates the three possible solution sets for m=3m=3 equations with three unknowns.

Geometry of solution set

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=bA\vv x = \vv 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.

Binder