In this explainer, we will learn how to find the rank and nullity of a matrix.

The βrankβ of a matrix is one of the most fundamental and useful properties of a matrix that can be calculated. In many senses, the rank of a matrix can be viewed as a measure of how much indispensable information is encoded by the matrix. As an example, we consider the following simple system of linear equations:

Notice how the second equation is essentially identical to the first equation, other than for a multiplication by 3. Moreover, we can multiply the second equation by a constant factor of without changing any of the properties:

If we were looking to solve this system of linear equations, then the second equation does not give us any extra information if we already know the first equation. In this sense, only the first equation is indispensable and the second equation is totally redundant and does not need to be written down.

When working with a system of linear equations, it is entirely possible that there is one or more redundant equations. Take, for example, the linear system of equations

Just like the previous example, the second equation is a copy of the first equation but, in this case, after a multiplication by . Therefore, the second equation offers no extra information and is redundant. Even worse, the third equation can be obtained from adding together the second and third equations. Therefore, the third equation is also redundant and only the first equation is indispensable.

One good way of thinking about the βrankβ of a matrix is that it measures the number of indispensable equations in the corresponding system of linear equations. There are other, more abstract ways of understanding the rank of a matrix without needing to refer to a system of linear equations, although these will be covered in another explainer. Before showing how to calculate the rank of a matrix, we first need to define several key concepts.

### Definition: Echelon Form

A matrix is said to be in βechelon formβ or βrow echelon formβ if the following two criteria are met:

- All zero rows are below all nonzero rows.
- The pivot of a nonzero row appears to the right of the pivot in all the rows above it.

The echelon form of a matrix is a vital idea that was first introduced when mathematicians were looking to find general methods for solving systems of linear equations. This definition is used to subsequently define the βreduced echelon formβ of a matrix, which we will not describe in this explainer but is of vital importance nonetheless.

Consider the matrix

We will take the first criterion of echelon form. The third row of this matrix is a zero row, which is not below the nonzero fourth row. Therefore, this matrix cannot meet the first criterion and so it is not in echelon form. However, if we had been given the matrix then the zero row would have been below all other zero rows and hence would have satisfied the first criterion.

Now we consider the second criterion. The βpivotβ of a row is the first nonzero entry of that row, which is also sometimes referred to as the βleading coefficientβ of that row. We highlight the pivots in the matrix immediately above:

The second criterion of echelon specifies that all pivots must appear to the right of any pivots in the row above. This is clearly not the case in our matrix, given that the pivot in the second row appears to the left of the pivot in the row above. If we had instead been given the matrix then every pivot is to the right of the pivots in the rows above. This new matrix satisfies both criteria of the echelon form.

### Definition: Rank of a Matrix

When in echelon form, the βrankβ of a matrix is the number of nonzero rows. Normally, this is denoted as .

There are a couple of points which follow from this definition that are worth discussing. First, the rank of a matrix counts the number of nonzero rows in that matrix. Quite naturally, that means that the rank of a matrix must be less than or equal to the number of rows in that matrix.

The second point arising from the above definition of the rank of a matrix is that, clearly, not every matrix is in echelon form, which means that our definition of the rank would not apply. In this case, we would ask ourselves the following question: How do we calculate the rank of a matrix if it is not already in echelon form? To answer this question, we will need one further definition and one further theorem.

### Definition: Elementary Row Operations

For any matrix of order , the three βelementary row operationsβ are as follows:

- switching of row with row , denoted ;
- multiplication of a single row by a nonzero constant , denoted ;
- a constant multiple of a row added to , denoted .

These three row operations are the key ingredients for taking a matrix and manipulating it into either echelon form or reduced echelon form, using a general and powerful technique known as GaussβJordan elimination. This is the approach that we will take when trying to understand the rank of a matrix, although we will not detail the full GaussβJordan method. We are nearly ready to begin calculating the rank for general matrices, but first we need one final theorem.

### Theorem: The Rank of a Matrix and Elementary Row Operations

The rank of a matrix is unaffected by the elementary row operations.

We will not provide a proof in this explainer, but we will instead assume that this is true and begin applying the result to aid our calculations of the matrix rank. In each of the following examples, our aim will be to take the given matrix and use elementary row operations to force this matrix into echelon form. With the knowledge that the elementary row operations do not change the rank of a matrix, we can then simply count the number of nonzero rows.

### Example 1: Rank of a 2 Γ 2 Matrix

Find the rank of the matrix

### Answer

We label the matrix as

This second row of is a copy of the first row after a multiplication by 2. We, therefore, perform the row operation , which gives the matrix

The second row is a zero row and appears below all nonzero rows, meeting the first criteria of echelon form. The pivot of each row is the first nonzero entry, as highlighted:

The second criterion of echelon form is that all pivots appear to the right of all pivots in the rows above. Since the highlighted entry is the only pivot in this matrix, this criterion is satisfied.

This matrix is in echelon form and has 1 nonzero row, which means that the rank of this matrix is 1. Since we only performed elementary row operations to move from to the matrix above, we know that shares this rank, and hence .

A decent guideline for how to approach the calculation of an echelon form is to continuously highlight all pivots in the matrix of interest. This draws the eye and can provide a steer as to which elementary row operations should be performed. We will demonstrate the utility of this approach in the following examples. Unlike the reduced echelon form of a matrix, which is unique, there are infinitely many possible echelon forms. Our echelon form of is likely to be entirely different to an echelon form produced using an alternative approach.

### Example 2: Finding the Rank of a Matrix

Find the rank of the matrix

### Answer

We label the matrix as

This matrix is certainly not in echelon form! First, we highlight all the pivots of the matrix:

The pivots in the second and third rows are not to the right of the pivots in the first row, so this matrix is definitely not in echelon form, meaning that we must perform elementary row operations to achieve this. We begin by trying to secure as many zeros as possible in the first column. There is already a pivot in the top left, so we will do our best to leave this entry alone, producing zeros in the remaining entries of the first column. This can be achieved by the elementary row operations and , with the result being as follows:

The pivot in the top left entry is now the only nonzero entry in the first column. The remaining pivots have been highlighted, with the pivots in the second, third, and fourth rows being to the right of the pivot in the first row. Unfortunately, the pivots in the third and fourth rows are not to the right of all pivots in the row above, which means that we must continue performing elementary row operations.

Now we see that the fourth row is just a copy of the third row after a multiplication by 2. The elementary row operation gives the matrix

We have a zero row at the bottom of this matrix and we will endeavor to leave this row unchanged. However, the pivot in the third row is not to the right of all pivots in the rows above, so we have not quite yet obtained an echelon form. We must find a way of removing the pivot in the third row in order to meet the second criterion of echelon form. This can be achieved by the row operation , which gives a much more agreeable structure of pivots:

Now every pivot is to the right of all the pivots in the rows above it, and the only zero row is at the bottom of the matrix. Therefore, this matrix is in echelon form. Given that there are three nonzero rows, the rank of this matrix is 3. We have only used elementary row operations to change the matrix into the matrix directly above. The rank of the original matrix is equal to the rank of the matrix above, meaning that .

### Example 3: Finding the Rank of a Matrix

Find the rank of the matrix

### Answer

We begin by defining the following matrix and highlighting the pivots:

The pivots in the second and third rows are not to the right of the pivot in the first row. Therefore, we need to remove these nonzero entries in the first column. The obvious choice of elementary row operations is and , giving the matrix where we have highlighted the pivots. The pivots in the third and fourth rows are not to the right of all pivots in the rows above, so this matrix is not in echelon form. There are many possible approaches for remedying this situation, and we choose the method that is arguably the most direct, which is by immediately removing the pivots in the third and fourth rows with the elementary row operations and . This gives the matrix

There is only one remaining obstruction to the matrix above being in echelon form, and that is the pivot in the fourth column, which is not to the right of all pivots in the columns above. We perform the row operation to get

The only zero row is at the bottom of the matrix and the pivots are all to the right of every pivot in the rows above. Therefore, this matrix is now in echelon form. Due to the presence of three nonzero rows, the rank of this matrix is 3. Given that we used only row elementary operations to transform from the original matrix to the matrix immediately above, we conclude that .

In the final example, we will give a matrix which has a larger number of rows and columns that we will then manipulate into an echelon form. With computations such as these, it is very easy to make an arithmetic error due to the large number of calculations that are involved. The example below is convenient in that the necessary elementary row operations are all easy to determine and do not introduce any fractions into the calculations. However, this will certainly not always be the case, and we should be wary that any error in calculation is likely to proliferate through the remaining calculations, causing the final outcome to be radically different from the correct solution.

### Example 4: Rank of a Matrix

Find the rank of the matrix

### Answer

We define the following matrix and highlight the pivot entries:

The pivots are all in the second column, which means that this matrix is not in echelon form, which requires all pivots to be to the right of every pivot in the rows above. We will eliminate the pivots in the second, third, and fourth rows using the elementary row operations , , and . The subsequent matrix is where the pivots have been highlighted. Before thinking any further about the pivots, we note that the fourth row is identical to the third row. We can quickly turn the fourth row into a zero row using the elementary row operation . This gives the matrix

The third row is a copy of the second row, except for a scaling by a factor of 2. The row operation then produces the matrix

There are now two zero rows which are at the bottom of the matrix, and the pivot in the second row is to the right of the pivot in the first row. This means that the matrix is in echelon form and, given that it has two nonzero rows, its rank is 2. Since we used only elementary row operations to transform the matrix into the matrix immediately above, the two matrices will have the same rank, and hence .

Unless a given matrix is already in echelon form, the rank of the matrix is usually not obvious upon first inspection. This means that normally we would have to perform (at least part of) the famed GaussβJordan elimination, as we did above. Mastering the technique of GaussβJordan elimination is arguably the single most important prerequisite for being able to compute the rank of a matrix. A related topic to the rank of a matrix is the βnullityβ or βnull spaceβ of a matrix, which is a quantity that counts the number of zero rows of a matrix in echelon form (rather than the number of nonzero rows, which is counted by the rank). These two concepts are used ubiquitously when studying linear algebra from a more abstract perspective, meaning that an understanding of their properties is essential.

### Key Points

- The pivots of matrix are the first nonzero entries of each row. These are sometimes referred to as the βleading coefficients.β
- Highlighting the pivots is normally very useful when attempting to perform GaussβJordan elimination or when performing elementary row operations in a general sense.
- A matrix is in echelon form if all zero rows are below all nonzero rows and if all pivots are to the right of any pivot in a row above.
- If a matrix is in echelon form, then the rank is the number of nonzero rows.
- The rank of a matrix is unchanged by elementary row operations.