# Section3.3Rank and the RREF¶ permalink

# SubsectionThe Assignment

- Read chapter 3 section 3 of
*Strang*. - Read the following and do the exercises below.

# SubsectionLearning Goals

Before class, a student should be able to:

- State a definition of the rank of a matrix.
- Compute the rank of a matrix.
- Describe the relation between the rank and the size of the column space.
- Construct the nullspace matrix associated to a matrix.

Some time after class, a student should be able to:

- Use the RREF and special solutions associated to a matrix to describe how free columns are linear combinations of earlier pivot columns.

# SubsectionDiscussion: The Rank of a Matrix

The new concept for this section is the *rank* of a matrix.
There are *three* definitions of rank given in the first two
pages of this section. It is important to know them and see that they
are equivalent.

Another important part of what happens here is the realization that
putting the matrix into reduced row echelon form, which uses *row*
operations, actually tells us something about the *columns* of the
matrix. This is kind of amazing.

Take a matrix \(A\) and put it into reduced row echelon form
\(R = \mathrm{rref}(A)\). Then \(A\) and \(R\) have the same shape.
In particular, they have the same number of columns. But in \(R\)
it is easy to see the location of the pivots. This divides up the
columns of \(R\) into those columns having a pivot, the *pivot columns*,
and those which do not, the *free columns*.
We will label a column of \(A\) as a pivot column or a free column in a way
that corresponds. Here is the startling fact:

How exactly can we see this? Strang uses the construction of a
*nullspace matrix*. The special solutions we learned about
in the last section can be bundled together as the columns of a matrix
\(N\), called the nullspace matrix. This matrix has two important
properties:

- \(AN = 0\); and
- Each column of \(N\) (i.e. each special solution) holds the coefficients needed to write down a interesting linear combination equation on the columns of \(A\).

Finally, please use some caution when reading through the area with blue boxes and equations (4) and (5) on page 147. Note that Strang introduces a big simplifying assumption that makes his work easier. The general principles will hold, but those nice, neat equations won't always look so good for an arbitrary matrix.

# SubsectionSageMath and the Rank

SageMath has a built-in command for the rank of a matrix. It is called
`.rank()`, of course.

SageMath knows how to do the underlying computations, too. Let's have Sage
compute the reduced row echelon form of `A`:

Nice! Note that this fits the “special case” form that Strang uses on page 147. Let's see what else it can do.

We can make SageMath give us just the matrix in that last response.

That is *almost* Strang's version of a nullspace matrix in this case.
Part of what we need to do is make the rows into columns. The transpose command is
the way to do that:

That is *NOT* exactly Strang's nullspace matrix. But it is very close.
In fact, it still has this crucial property:

What has happened here is that SageMath constructs a *different* version
of the nullspace matrix than Strang does. Strang's version is easier to
find by hand and tends to have \(1\)'s and \(0\)'s and the end.
The SageMath version comes from a routine that strongly prefers to
start with \(1\)'s and \(0\)'s.

The two version of nullspace matrix are related, of course. Let's see how:

*That* is Strang's nullspace matrix.

Where does this relationship come from? I have a hint: *Column Operations*.
How can we use the structure of matrix multiplication to see why left multiplication
by `E.inverse()` performs some column operations?

Here is another thing to think about: where does that `E` come from?
Compare `A` and `N`. Notice anything? Remember that Strang wants
the nullspace matrix to have \(1\)'s and \(0\)'s in the free columns.

# SubsectionExercises

##### Task79

Give an example of a \(5 \times 3\) matrix which has- rank equal to 3, and
- all non-zero entries,

##### Task80

Give an example of a \(3 \times 3\) matrix which has- rank equal to 2,
- a nullspace of \(\{0\}\), and
- all non-zero entries,