Matrix Rank Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

What is matrix rank?

The rank of a matrix is the number of linearly independent rows or columns it contains. In linear algebra, matrices are used to represent systems of linear equations and linear transformations. The rank tells you how many independent directions of information the matrix carries.

If the rank of an m by n matrix is equal to the smaller of m and n, the matrix is said to have full rank. Otherwise, it is rank-deficient, meaning that at least one row or column can be written as a linear combination of the others.

Formal definition and formulas

There are several equivalent ways to define the rank of a matrix A:

All of these numbers are equal, and that common value is the rank of A. In symbols, you will often see the notation rank(A) or rk(A).

The connection to the null space is captured by the Rank–Nullity Theorem. For a matrix A with n columns, we have:

rank ( A ) + nullity ( A ) = n

Here, nullity(A) is the dimension of the null space of A, that is, the number of independent solutions to A x = 0.

How this matrix rank calculator works

This calculator accepts real-valued entries for a matrix up to size 3×3. You can use it for 2×2 or 3×3 matrices, and also for rectangular matrices such as 2×3 or 3×2, provided they fit within the 3×3 grid. Any empty fields you leave in the grid are treated as zeros.

The core of the computation is row reduction to row-echelon form. The algorithm:

  1. Reads your entries into a 3×3 matrix, inserting 0 for any blank cell.
  2. Starts with the first row and first column, searching for a pivot (a nonzero entry) in that column.
  3. If necessary, swaps rows to bring a nonzero entry into the pivot position.
  4. Uses elementary row operations (adding multiples of one row to another) to create zeros below the pivot.
  5. Moves to the next row and the next column to find the next pivot and repeats the process.
  6. Counts the number of pivot rows in the resulting row-echelon form. This count is the rank.

Elementary row operations preserve the row space and the solution set of the associated system of linear equations. That is why they do not change the rank of the matrix.

Supported matrix sizes and input behavior

The on-page grid always shows 3 rows and 3 columns, but you are not required to fill every box:

Interpreting blanks as zeros means that the calculator effectively works with a fixed 3×3 matrix whose unused entries are 0. For rank calculations this is equivalent to embedding your smaller matrix in a 3×3 matrix with extra zero rows or columns.

Row reduction method in more detail

Suppose you have a 3×3 matrix A with entries aij:

A = [ [a11, a12, a13], [a21, a22, a23], [a31, a32, a33] ].

The calculator applies row operations such as:

These are the same steps you would follow by hand when solving a system of linear equations using Gaussian elimination. When the matrix is in row-echelon form (all nonzero rows above any all-zero rows, and each leading entry to the right of the one above it), the number of nonzero rows equals the rank.

Numerical tolerance and zero rows

The implementation uses floating-point arithmetic. To decide whether an entry is effectively zero, the code compares its absolute value to a small tolerance. If all entries in a row are smaller than this tolerance in absolute value, that row is treated as a zero row and does not contribute to the rank.

This approach is standard in numerical linear algebra and helps avoid treating tiny rounding errors as genuine pivots. However, it also means that rows made up of very small numbers (for example, 1×10−12) can be treated as zero in borderline cases. See the limitations section below for more guidance.

Geometric interpretation of rank

You can think of the columns of a matrix as vectors starting at the origin. All linear combinations of these column vectors form the column space. The rank of the matrix is precisely the dimension of this column space.

For small matrices, the geometric picture is intuitive:

Rank is also tied to the null space. If a matrix has rank 2 and 3 columns, then its nullity is 1. That means there is exactly one independent direction in which nonzero inputs are mapped to the zero vector. In practical terms, there is one free variable when solving A x = 0.

Interpreting the calculator output

After you enter your matrix and run the calculation, the tool returns a single integer: the rank of the matrix. Here is how to interpret that number:

For a square coefficient matrix in a linear system A x = b:

Worked examples

Example 1: Full-rank 2×2 matrix

Consider the 2×2 matrix

A = [ [1, 2], [3, 4] ].

In the calculator, you can enter:

Row reduction steps:

  1. Start with rows [1, 2] and [3, 4].
  2. Use R2 ← R2 − 3R1 to eliminate the first entry of the second row, giving R2 = [0, −2].
  3. Now the rows are [1, 2] and [0, −2]. Both rows are nonzero.

There are two pivot rows, so the rank is 2. Since this equals the size of the matrix, A is invertible and its columns are linearly independent.

Example 2: Rank-deficient 3×3 matrix

Consider the 3×3 matrix

A = [ [1, 2, 3], [2, 4, 6], [1, 1, 1] ].

Notice that the second row is exactly 2 times the first row, so those two rows are not independent. In the calculator, enter:

Row reduction steps:

  1. Use R2 ← R2 − 2R1 to eliminate the first entry in row 2. This gives R2 = [0, 0, 0].
  2. Use R3 ← R3 − R1 to simplify row 3. This gives R3 = [0, −1, −2].
  3. Now the rows are [1, 2, 3], [0, 0, 0], [0, −1, −2].
  4. Swap rows 2 and 3 to bring the nonzero row up if you prefer the standard echelon form.

There are two nonzero rows in the echelon form, so the rank is 2. The matrix is not full rank. This tells you that:

Comparison with related matrix concepts

Rank is closely connected to other familiar matrix properties. The table below summarizes some key relationships for square matrices.

Concept What it measures Relation to rank
Determinant A scalar summarizing volume scaling and orientation. A square matrix has full rank if and only if its determinant is nonzero.
Invertibility Whether there exists a matrix A−1 such that A A−1 = I. A is invertible exactly when it has full rank (rank equals its size).
Null space All vectors x with A x = 0. The dimension of the null space is the number of columns minus the rank.
Linear independence Whether a set of vectors contains no nontrivial linear relations. The rank equals the maximal number of linearly independent rows or columns.
Solutions of A x = b Consistency and number of solutions. Rank helps determine whether the system has zero, one, or infinitely many solutions.

Limitations and assumptions of this calculator

This tool is designed as a quick, educational calculator for small matrices. Keep the following points in mind when interpreting the results:

As long as you are aware of these assumptions, the rank reported by the calculator is a reliable guide to linear independence and the structure of your system.

Enter matrix entries to compute the rank.

Embed this calculator

Copy and paste the HTML below to add the Matrix Rank Calculator – Rank of 2×2 and 3×3 Matrices to your website.