# Matrix Rank Calculator

Created by Maciej Kowalski, PhD candidate
Reviewed by Anna Szczepanek, PhD and Jack Bowater
Last updated: Nov 07, 2022

Welcome to the matrix rank calculator, where you'll have the opportunity to learn how to find the rank of a matrix and what that number means. In short, it is one of the basic values that we assign to any matrix, but, as opposed to the determinant, the array doesn't have to be square. The idea of matrix rank in linear algebra is connected with linear independence of vectors. In particular, a full rank matrix is an array whose rows are all linearly independent, and such objects are of particular interest to mathematicians.

## What is a matrix?

You know how, when you get bored, you stare at the paint patterns on the ceiling and your mind begins to wonder and, before you know it, you've come up with a whole new system of categorizing the style of paint chips? Mathematicians are no different. Maths all started when one of them was sent (by their spouse, no doubt) to fetch some turkey for dinner and a couple of apples for the kids. One turkey, two apples. Easy enough, those are simple numbers. They come quite naturally, so we call them just that - natural numbers.

But groceries cost money, so buying all of that made a small dent in the household budget: $-\text{\textdollar}10$. This new negative number lumped in with the natural numbers to make up the so-called integers. But that's not all! The kids are fussy enough, so the apples had to be cut into halves and then into quarters. Those new values were called fractions and we grouped with what we had so far to form the rational numbers.

And then there came that Pythagoras guy from across the yard with his theorem which introduced some ugly new numbers that he called square roots. What is more, he declared that $\pi$, used in circle calculations, is also one and called the whole lot the real numbers. But that must have been the end of it, right? Surely there can't be anything more, can there?

Well, oddly enough, mathematics didn't end there. While Isaac Newton was bored enough to invent calculus, some other mathematicians figured out even more numbers and called them complex numbers. Although both are quite interesting and extremely useful, that's not why we're here.

A matrix is an array of elements (usually numbers) that has a set number of rows and columns. An example of a matrix would be

$\scriptsize A=\begin{pmatrix} 3&-1\\ 0&2\\ 1&-1 \end{pmatrix}$

Moreover, we say that a matrix has cells, or boxes, into which we write the elements of our array. For example, matrix $A$ above has the value $2$ in the cell that is in the second row and the second column. The starting point here is 1-cell matrices, which are, for all intents and purposes, the same thing as real numbers.

As you can see, matrices came to be when a scientist decided that he needed to write a few numbers concisely and operate with the whole lot as a single object. As such, they are extremely useful when dealing with:

• Systems of equations, as you can discover at Omni's Cramer's rule calculator;
• Vectors and vector spaces;
• 3-dimensional geometry (e.g., the dot product and the cross product);
• Eigenvalues and eigenvectors; and
• Graph theory and discrete mathematics.

When we operate with regular numbers, we usually want to add them, take their fractions, and so on. More or less, the same is possible with matrices, but it tends to get messy. Adding and subtracting arrays is simple enough, we taught you to do it in the blink of an eye at our matrix addition calculator, but when we move on to multiplication, it gets tricky, trust us. Not to mention division, which here is not an operation in itself, but rather a multiplication by the inverse, which sometimes doesn't even exist. And let's not forget about the cofactor matrix and adjoint matrix...

Fortunately, all of the above is a matter for a different time and a different calculator. We're here to see how to find the rank of a matrix, and that's what we'll focus on now.

## Definition: the rank of a matrix

Rank in linear algebra is a number that we assign to any matrix. It is the maximal number of linearly independent rows of the matrix. Equivalently, though it's not at all obvious at first glance, it is also the maximal number of linearly independent columns. But what does all this fancy language really mean?

The definition comes from looking at a matrix row by row (or column by column). As such, we can think of our array with $n$ rows as $n$ separate lines of numbers. Such objects, i.e., matrices with one row, are called vectors, and they are elements of so-called vector spaces. For example, the numerical axis, the Cartesian plane, and 3-dimensional space are all examples of vector spaces.

We say that vectors $\vec{v}_1$, $vec{v}_2$, $\vec{v}_3$, ..., $\vec{v}_n$ are linearly independent if the equation

$\scriptsize a_1\times\vec{v}_1+a_2\times\vec{v}_2+a_3\times\vec{v}_3+...+a_n\times\vec{v}_n = 0$

where $a_1$, $a_2$, $a_3$, ..., $a_n$ are some real numbers, is true if and only if $a_1=a_2+a_3=...=a_n=0$. Equivalently, at least one of the vectors is the sum of the other ones (with some multiplicities).

🔎 For an in-depth analysis of linear dependence and independence, we invite you to visit the linear independence calculator!

Just to paint a picture, when we are on the real plane (vectors are just pairs of real numbers), then two linearly independent vectors will span the whole plane (we say that we have a full rank matrix in this case). This means that any point, i.e., any pair of real numbers, can be represented as a linear sum of the two vectors (sum of the two with some multiplicities). However, if they are linearly dependent, then this will not be possible, and the pair will only span a line instead. Since, in this case, we only have two objects, it will mean that one is a multiple of the other.

Rank in linear algebra is a tool that keeps track of linear independence, what vector space we're in, and the vector space's dimension. So, now that we know what to use it for, let's see how to find the rank of a matrix.

## How to find the rank of a matrix?

There are several ways to figure out the rank of a given matrix. Arguably, the simplest one is Gaussian elimination, or its slightly modified version, Gauss-Jordan elimination. They rely on so-called elementary row operations to modify the matrix into its (reduced) row echelon form — the form you can discover at Omni's (reduced) row echelon form calculator). From there, we can easily read out the rank of the matrix.

The operations are:

• Exchanging two rows of the matrix;
• Multiplying a row by a non-zero constant; and
• Adding to a row a non-zero multiple of a different row.

The key property here is that, although the above operations change our matrix, they don't change its rank. In other words, learning how to find the rank of a matrix boils down to learning the Gauss (or Gauss-Jordan) algorithm.

$\scriptsize\begin{pmatrix} a_1&a_2\\ b_1&b_2\\ c_1&c_2\\ \end{pmatrix}$

Then, provided that $a_1$ is not zero, the first step of the Gaussian elimination will transform the matrix into something in the form

$\scriptsize\begin{pmatrix} a_1&a_2\\ 0&s_2\\ 0&t_2 \end{pmatrix}$

with some real numbers $s_2$ and $t_2$. Then, as long as $s_2$ is not zero, the second step will give the matrix

$\scriptsize\begin{pmatrix} a_1&a_2\\ 0&s_2\\ 0&0 \end{pmatrix}$

Now we need to observe that the bottom row represents the zero vector (it has $0$'s in every cell), which is linearly dependent with any vector. Therefore, the rank of our matrix will simply be the number of non-zero rows of the array we obtained, which in this case is $2$.

In particular, observe that, whatever we'd done, we couldn't have obtained the third row non-zero since every consecutive number in that row was eliminated by one of the rows above. This means that a $3 \times 2$ can never be a full rank matrix, and further translates to the following general rule: if $A$ is a matrix of size $n \times m$, then

$\scriptsize\mathrm{rank}(A)\leq \mathrm{min}(n,m)$

Phew, that was quite some time pondering over theory. How about we move onto a numerical example and see the matrix rank calculator in action?

## Example: using the matrix rank calculator

Suppose that you're on a date in a fancy restaurant, and your partner challenges you into a matrix rank calculating competition. Apparently, it's a new viral TikTok challenge, so what can you do?

You ask a gentleman struggling with a steak on the table next to you for an example of a matrix. Obviously, he happily obliges.

$\scriptsize A=\begin{pmatrix} 0&2&-1\\ 1&0&1\\ 2&-1&3\\ 1&1&4 \end{pmatrix}$

Luckily enough, you know the Omni Calculator website inside out and visit the matrix rank calculator straight away. To make it work in your favor, we first need to tell the calculator what we're dealing with. It's a matrix of size $4 \times 3$, so we input $4$ under the number of rows, and $3$ under the number of columns. This will show us a symbolic example of a matrix similar to ours. We just need to give it the correct numbers.

According to the picture, the first row has elements $a_1$, $a_2$, and $a_3$, so we look back at our array and put its first row under these symbols:

$\scriptsize\begin{split} a_1&=0\\ a_2&=2\\ a_3&=-1 \end{split}$

Similarly, we input the other three rows:

$\scriptsize\begin{split} b_1&=1\\ b_2&=0\\ b_3&=1 \end{split}$

Then:

$\scriptsize\begin{split} c_1&=2\\ c_2&=-1\\ c_3&=3 \end{split}$

And finally:

$\scriptsize\begin{split} d_1&=1\\ d_2&=1\\ d_3&=4 \end{split}$

Once we input the last number, the matrix rank calculator will spit out the rank of our matrix. Unfortunately, just as it was about to do so, your date makes you put the phone down and points out that it'll be more fun to see how much time it takes to do it without any fancy tools. Oh well, it looks like we'll have to calculate it by hand, after all.

First of all, we see that the first element of the first row is $0$. We don't like zeros - we can't use them in Gauss-Jordan elimination to get rid of the other numbers in that column. So why don't we exchange the first row with the second?

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

Now that's more like it! With this, we can take care of the $2$ and the $1$ in the bottom two rows. To do this, we add a suitable multiple of the first one to these rows, so that we'll obtain zeros in the whole of the first column, apart from the first row. Since we have $1$ to work with and $2 + (-2)\times1 = 0$ and $1 + (-1)\times1 = 0$, we add a $(-2)$ multiple of the first row to the third one, and a $(-1)$ multiple to the fourth. Observe that we don't have to do anything with the second row since we already have $0$ there.

$\scriptsize \begin{split} &\begin{pmatrix} 1&0&1\\ 0&2&-1\\ 2 + (-2)\times1&-1 + (-2)\times0&3 + (-2)*1\\ 1 + (-1)\times1&1 + (-1)\times0&4 + (-1)*1 \end{pmatrix}=\\ &\begin{pmatrix} 1&0&1\\ 0&2&-1\\ 0&-1&1\\ 0&1&3 \end{pmatrix} \end{split}$

Alright, we've lost quite some time trying to use the matrix rank calculator before, so we need to speed up a little.

We move on to the second column. We'd like to use the $2$ in the second row to eliminate the $-1$ and the $1$ from the two bottom rows. Just as before, we add a suitable multiple of the second row: this time, it'll be $0.5$ for the third row, and $-0.5$ for the last.

$\scriptsize \begin{split} &\begin{pmatrix} 1&0&1\\ 0&2&-1\\ 0&-1 + 0.5\times2&1 + 0.5\times(-1)\\ 0&1 + (-0.5)\times2&3 + (0.5)\times(-1) \end{pmatrix}=\\ &\begin{pmatrix} 1&0&1\\ 0&2&-1\\ 0&0&0.5\\ 0&0&2.5 \end{pmatrix} \end{split}$

You see your partner nervously scribbling on her piece of paper, and the gentleman on the table next to you is cheering you on. Time for the last step.

Now we'd like to get rid of the $2.5$ in the fourth row using the $0.5$ from the third one. We add a multiple of $(-5)$ to obtain:

$\scriptsize \begin{split} &\begin{pmatrix} 1&0&1\\ 0&2&-1\\ 0&0&0.5\\ 0&0&2.5 + (-5)\times0.5 \end{pmatrix}=\\ &\begin{pmatrix} 1&0&1\\ 0&2&-1\\ 0&0&0.5\\ 0&0&0 \end{pmatrix} \end{split}$

The matrix has three non-zero rows, which means that $\mathrm{rank}(A) = 3$. You look triumphantly at your date and declare yourself the winner. The gentleman next to you is clapping, and you decide to celebrate it with a slice of chocolate cake. That much fun deserves a nice dessert and a good tip, don't you think?

Maciej Kowalski, PhD candidate
Number of rows
3
Number of columns
2
A=
 ⌈ a1 a2 ⌉ | b1 b2 ｜ ⌊ c1 c2 ⌋
First row
a₁
a₂
Second row
b₁
b₂
Third row
c₁
c₂
Result
 ⌈ ⌉ rank | ｜ = 0 ⌊ ⌋
People also viewed…

### BMR - Harris-Benedict equation

Harris-Benedict calculator uses one of the three most popular BMR formulas. Knowing your BMR (basal metabolic weight) may help you make important decisions about your diet and lifestyle.

### Cofunction

The cofunction calculator is here to find the cofunction of the trigonometric function you choose for a given angle between 0 and 90 degrees.

### Heptagon

Find the area, perimeter, or length of sides for a heptagon using our heptagon calculator.

### Ideal egg boiling

Quantum physicist's take on boiling the perfect egg. Includes times for quarter and half-boiled eggs.