Rank math

The rank of a matrix is a number that represents the number of independent rows or columns of the matrix.

Definition

The rank of a matrix is the maximum number of linearly independent rows/columns in the matrix. A zero matrix has rank zero, every other matrix has rank at least one. A matrix of type m× n can have rank at most min(m, n). Thus, if the matrix has fewer rows than columns, the rank of the matrix will be at most equal to the number of rows. Similarly for columns.

The rank of a matrix is usually denoted by the English word "rank". We then write rank(A) = x.

How to calculate the rank

Now how to calculate the rank of a matrix. It's quite simple. You have to rearrange the matrix in a way that makes it clear which rows are linearly independent. This is most often done by adjusting the matrix to a stepped shape (all zeros below the diagonal) and then you can see where the matrix stands. Shupity presto for an example - we have this matrix:

$$\left(\begin{array}{ccc}1&2&1\\1&1&-1\\1&3&3\end{array}\right)$$

And we have to find out its rank. Now we have to realize one small thing. If we have two rows that are full of numbers different from zero, they can theoretically be linearly dependent. We would have to calculate that. But if one of those rows has a zero in some place, and the other row doesn't have a zero in the same place, we can say with confidence that they are not dependent. For we can find no number by which we can multiply that zero (hence the whole line) to get the same number there as is in the other line. Therefore, we will always try to modify the matrices into a stepwise form to get those zeros there.

We can write the previous paragraph as follows. If α1, α2≠0, then:

$$ \alpha_1\begin{pmatrix}1&2&3\end{pmatrix}+\alpha_2\begin{pmatrix}0&2&3\end{pmatrix}\ne\begin{pmatrix}0&a&b\end{pmatrix} $$

Therefore, we try to get the matrix into a similar shape so that we can easily see the dependencies. Look at the example:

$$ \begin{pmatrix} 4&-5&1\\ 0&7&2\\ 0&0&3 \end{pmatrix} $$

This is a matrix in stepwise form, no rows are linearly dependent. You can't use the first two rows to express the third, because if you have non-zero alpha coefficients, you will always have some non-zero number in the first few places.

The procedure is usually like this: first, get zeros in the first column (except for the first row). Then we modify the matrix further to get zeros in the second column, then the third, etc. etc. etc. until we end up with a staircase. Add up the non-zero rows and lo and behold, we have a rank matrix. We can use these modifications without changing the rank of the matrix:

  • Swap any two rows.
  • Multiply a row by any non-zero expression.
  • Add one row to the other.
  • All of the previous modifications can be applied to columns.

Example

In our previous matrix, we will make the adjustments as follows: Let's see what the relationship is between the elements a11 and a21. We can see that they are the same, so to get zero at a21, we need to add −1 times the first row. Add −1 times the first line to the second line (or subtract the first line from the second):

$$\left(\begin{array}{ccc}1&2&1\\0&-1&-2\\1&3&3\end{array}\right)$$

Now we have a zero where we wanted it to be. Now we still need to get a zero in the a31 position. There's a one again, so we just subtract the first row:

$$\left(\begin{array}{ccc}1&2&1\\0&-1&-2\\0&1&2\end{array}\right)$$

Now we've got zeros in the first column, so let's go to the second column with gusto. We can see that the numbers a22 and a32 are reversed, so we just need to add the rows:

$$\left(\begin{array}{ccc}1&2&1\\0&-1&-2\\0&0&0\end{array}\right)$$

And we've got one zero row. The editing is already done, we've got a stepped shape. Now we just add the non-zero rows and we have the rank. It's equal to the rank A = 2. This matrix had a rank of two.

The second example

Now let's try to calculate the rank of a slightly larger matrix:

$$\left(\begin{array}{cccc}7&2&5&1\\1&3&5&-7\\4&-5&1&0\\2&8&10&-9\end{array}\right)$$

The rank of a matrix is the maximum number of linearly independent rows, so we can afford to rearrange the rows in the matrix as we like. For example, here it would be useful to have the row with a one at the top of the matrix, so that we can calculate it better. So we can safely move the first row with the second row:

$$\left(\begin{array}{cccc}1&3&5&-7\\7&2&5&1\\4&-5&1&0\\2&8&10&-9\end{array}\right)$$

Now we proceed as in the previous example. We need to have all zeros in the first column (instead of the first row, of course), so we add −7 times the first row to the second row, −4 times the third row, and −2 times the last row. The first line remains unchanged:

$$\left(\begin{array}{cccc}1&3&5&-7\\0&-19&-30&50\\0&-17&-19&28\\0&2&0&5\end{array}\right)$$

Swap the rows again, this time we should get the last row instead of the second row, because of the two in the second position. Swap the second and fourth rows:

$$\left(\begin{array}{cccc}1&3&5&-7\\0&2&0&5\\0&-17&-19&28\\0&-19&-30&50\end{array}\right)$$

But we see that under the two we have the numbers −17 and −19. Neither of those numbers is divisible by two, which is kind of awkward, even embarrassing. So now we multiply the third and fourth lines by two:

$$\left(\begin{array}{cccc}1&3&5&-7\\0&2&0&5\\0&-34&-38&56\\0&-38&-60&100\end{array}\right)$$

Now we can proceed with the adjustments, trying to zero out the second column. To the third row we read 17 times the second row and to the fourth row 19 times:

$$\left(\begin{array}{cccc}1&3&5&-7\\0&2&0&5\\0&0&-38&141\\0&0&-60&195\end{array}\right)$$

Okay, now we've got some pretty - for further editing - awkward numbers, but we'll manage somehow. Divide the third line by −38:

$$ \begin{pmatrix} 1&3&5&-7\\ 0&2&0&5\\ 0&0&1&-141/38\\ 0&0&-60&195 \end{pmatrix} $$

Now multiply the third line by 60 and add to the fourth line:

$$ \begin{pmatrix} 1&3&5&-7\\ 0&2&0&5\\ 0&0&1&-141/38\\ 0&0&0&195-\frac{60\cdot141}{38} \end{pmatrix} \sim \begin{pmatrix} 1&3&5&-7\\ 0&2&0&5\\ 0&0&1&-141/38\\ 0&0&0&-\frac{525}{19} \end{pmatrix} $$

We come up with an ugly, but non-zero number. So the matrix has rank four, it contains no linearly dependent rows.

Example with parameter

What is the rank of the matrix A depending on the parameter q?

$$ A=\begin{pmatrix} 1&8&17\\ q&5&8\\ 4&1&3 \end{pmatrix} $$

This is a bit more complicated problem because we have the parameter q. We need to find out at what values of q the matrix has the maximum rank, if any, and at what values it has a lower rank. We'll follow the classical approach, except that sometimes we'll use the abstract q instead of the concrete values. In the first step, we'll move the q parameter to a nicer place, namely the bottom right. We'll swap the second row with the third, and then the first column with the last:

$$ \begin{pmatrix} 1&8&17\\ q&5&8\\ 4&1&3 \end{pmatrix} \sim \begin{pmatrix} 1&8&17\\ 4&1&3\\ q&5&8 \end{pmatrix} \sim \begin{pmatrix} 17&8&1\\ 3&1&4\\ 8&5&q \end{pmatrix} $$

Now we've got the parameter in a convenient place where it won't matter too much. In the first column, however, we have some rather awkward numbers, but we have a one in the very middle: we move it up to the left, i.e. we swap the first and second rows and the first and second columns:

$$ \begin{pmatrix} 17&8&1\\ 3&1&4\\ 8&5&q \end{pmatrix} \sim \begin{pmatrix} 3&1&4\\ 17&8&1\\ 8&5&q \end{pmatrix} \sim \begin{pmatrix} 1&3&4\\ 8&17&1\\ 5&8&q \end{pmatrix} $$

Now we have a nice matrix. Multiply the first row by −8 and add to the second row:

$$ \begin{pmatrix} 1&3&4\\ 8&17&1\\ 5&8&q \end{pmatrix} \sim \begin{pmatrix} 1&3&4\\ 0&-7&-31\\ 5&8&q \end{pmatrix} $$

Multiply the first row −5 and add to the third row:

$$ \begin{pmatrix} 1&3&4\\ 0&-7&-31\\ 5&8&q \end{pmatrix} \sim \begin{pmatrix} 1&3&4\\ 0&-7&-31\\ 0&-7&q-20 \end{pmatrix} $$

Okay, we have the first column as we need it. Now we add −1 times the second row to the third row:

$$ \begin{pmatrix} 1&3&4\\ 0&-7&-31\\ 0&-7&q-20 \end{pmatrix} \sim \begin{pmatrix} 1&3&4\\ 0&-7&-31\\ 0&0&q+11 \end{pmatrix} $$

And we are done with the matrix adjustments. We see that the first and second columns are definitely linearly independent. But the third row may be linearly dependent. A row will be linearly dependent if it is all zero, that is, if we choose the parameter q so that the expression q + 11 is zero. Obviously, if q = −11, then the row is null and so the row is linearly dependent.

So the final verdict: for q = −11 the matrix has rank two, otherwise it has rank three.