Matrix Rank Calculator

Compute the rank of any matrix using Gaussian elimination. Visualize the row echelon form, determine full-rank status, and explore key linear algebra properties.

Enter any real numbers
⭐ Full Rank 3×3
? Rank 2 (singular)
? Rank 1
? 3×4 Rectangular
? 4×4 Identity
Privacy first: All matrix computations are performed locally in your browser. No data is sent to any server.

Understanding Matrix Rank: A Comprehensive Guide

In linear algebra, the rank of a matrix is one of the most fundamental invariants. It reveals the number of linearly independent rows or columns, which in turn determines the dimension of the column space and row space. The rank of a matrix A (denoted rank(A) or ρ(A)) is defined as the maximum number of linearly independent column vectors in the matrix, equivalently the dimension of the column space. By the rank–nullity theorem, the rank plus the nullity (dimension of the kernel) equals the number of columns.

For an m × n matrix A:

rank(A) = dim(Col(A)) = dim(Row(A)) ≤ min(m, n)

rank(A) + nullity(A) = n   (Rank–Nullity Theorem)

Why Matrix Rank Matters

  • Linear Systems: A system Ax = b is consistent if and only if rank([A | b]) = rank(A). The rank determines the number of free variables in the solution.
  • Data Science & Machine Learning: Matrix rank reveals the intrinsic dimensionality of data. Low-rank approximations (e.g., SVD, PCA) are used for dimensionality reduction, noise filtering, and recommender systems.
  • Control Theory: In state-space models, the rank of controllability and observability matrices determines whether a system is controllable or observable.
  • Computer Graphics: Transformation matrices with full rank preserve volume and orientation; singular matrices collapse space.
  • Economics & Statistics: Rank is used in econometrics to check for multicollinearity in regression models and to analyze input–output tables.

How the Calculator Works

Our calculator uses Gaussian elimination (row reduction) to transform the input matrix into row echelon form (REF). The algorithm scans each column from left to right, selects a pivot (the first non‑zero entry in the current row), and eliminates all entries below it. After completing the elimination, the number of non‑zero rows is the rank. For square matrices, the determinant is computed as the product of the pivots (with sign tracking) — a non‑zero determinant confirms full rank.

The calculator also reports the nullity via the rank–nullity theorem: nullity = number of columns − rank. This gives the dimension of the solution space to Ax = 0. All computations are performed with double‑precision floating‑point arithmetic, and numerical near‑zero values are treated as zero using a tolerance of 10−10.

Step‑by‑Step Algorithm

  1. Copy the input matrix to a working array.
  2. For each column from left to right, find a pivot row (non‑zero entry) at or below the current row.
  3. If no pivot is found, move to the next column.
  4. Otherwise, swap the pivot row with the current row, then normalize the pivot row.
  5. Eliminate all entries below the pivot in the same column using row operations.
  6. After processing all columns, count the number of non‑zero rows — this is the rank.
  7. For square matrices, the determinant is the product of the pivots (with sign flips from row swaps).
  8. Nullity = number of columns − rank.

Properties of Matrix Rank

  • rank(A) = rank(AT): The rank of a matrix equals the rank of its transpose.
  • rank(AB) ≤ min(rank(A), rank(B)): The rank of a product is never larger than the rank of either factor.
  • rank(A + B) ≤ rank(A) + rank(B): Subadditivity of rank.
  • Full rank: An m × n matrix has full rank if rank = min(m, n). For a square matrix, full rank means it is invertible (non‑singular).
  • Rank is invariant under invertible row or column operations: Elementary row/column operations do not change the rank.
Case Study: Dimensionality Reduction in Machine Learning

Consider a dataset with 500 samples and 100 features. The feature matrix X has dimensions 500 × 100. Computing the rank of X reveals the effective number of independent features. If rank(X) is significantly less than 100, the data lies on a lower‑dimensional subspace. This insight drives dimensionality reduction techniques like Principal Component Analysis (PCA), where the top k singular vectors (corresponding to the largest singular values) are used to project the data onto a k‑dimensional space while preserving most of the variance. In practice, a rank calculation helps choose the number of principal components to retain.

Example: A 100×100 matrix with rank 20 implies that only 20 linearly independent directions exist. The nullity is 80, meaning there are 80 dimensions of redundancy or noise. By truncating to rank 20, we can compress the data by 80% with minimal information loss.

Common Misconceptions

  • “Rank equals the number of non‑zero entries.” — False. Rank is the number of non‑zero rows after row reduction, not the number of non‑zero entries in the original matrix.
  • “A square matrix always has full rank.” — False. Only invertible (non‑singular) matrices have full rank. Many square matrices are singular (rank < n).
  • “Rank is the same as determinant.” — For square matrices, a non‑zero determinant implies full rank, but rank is defined for all matrices (including non‑square), while determinant is only defined for square matrices.
  • “Row and column ranks can differ.” — False. For any matrix, the row rank equals the column rank — this is a foundational theorem in linear algebra.

Applications Across Disciplines

  • Network Analysis: The rank of an adjacency matrix relates to the connectivity and number of independent paths in a graph.
  • Image Processing: Grayscale images can be represented as matrices; low‑rank approximations are used for compression and denoising.
  • Quantum Mechanics: Density matrices have rank equal to the number of pure states in a mixed state decomposition.
  • Operations Research: In linear programming, the rank of the constraint matrix determines the number of basic feasible solutions.
  • Cryptography: Rank is used in coding theory to design error‑correcting codes and in the analysis of linear cryptosystems.

Rooted in rigorous mathematics – This tool implements Gaussian elimination as taught in standard linear algebra courses (Strang, G. Introduction to Linear Algebra; Lay, D.C. Linear Algebra and Its Applications). The algorithm follows the numerical stability practices outlined in Trefethen & Bau, Numerical Linear Algebra. All results are verified against multiple reference implementations. Reviewed by the GetZenQuery tech team, last updated July 2026.

Frequently Asked Questions

The rank of a matrix is the maximum number of linearly independent rows (or columns). Think of it as the “information content” of the matrix — how many truly independent directions it contains. For example, a matrix with rank 1 means all rows are multiples of each other; it contains only one independent pattern.

Yes. An m × n matrix has full rank if rank = min(m, n). For example, a 3×2 matrix has full rank if its rank is 2 (the smaller dimension). In this case, the columns are linearly independent. Full rank does not require the matrix to be square.

The rank–nullity theorem states that for an m × n matrix, rank + nullity = n. Nullity is the dimension of the null space (the set of vectors x such that Ax = 0). A high nullity means many solutions to the homogeneous system, indicating redundancy in the columns.

For a square matrix, a determinant of zero indicates that the matrix is singular (non‑invertible), meaning its rank is less than the matrix size. This implies the rows (or columns) are linearly dependent, and the linear system Ax = b either has no solution or infinitely many solutions.

For diagonalizable matrices, yes — the rank equals the number of non‑zero eigenvalues (counted with algebraic multiplicity). However, for general matrices, the rank is not directly equal to the number of non‑zero eigenvalues (e.g., nilpotent matrices have all eigenvalues zero but may have positive rank). The rank is better understood through row/column independence.

References: MathWorld – Matrix Rank; Strang, G. Introduction to Linear Algebra, 5th ed. (2016); Lay, D.C. Linear Algebra and Its Applications, 5th ed. (2015); Wikipedia – Rank (linear algebra).