Engineering/Mathematics/Vector Spaces
Rank and Nullity of a Matrix
Rank is the dimension of the column space and nullity is the dimension of the null space. One row reduction delivers both, and their sum is always the number of columns.
- Core level
- Stream: dimension
- Reading time 15 min
- Ref KVS-ENG-MATH-0070
- Taxonomy
- Engineering / Mathematics
- Prerequisite
- Dimension; column space; null space; RREF
- Rank
- Nullity
- Conservation law
- Cost
- One reduction, operations
Overview
Every matrix carries several subspaces with it, and the two most consequential are the column space — everything the matrix can produce as an output — and the null space — everything the matrix destroys. Each is a vector space in its own right and therefore has a dimension. Those two dimensions are important enough to be given names of their own: the dimension of the column space is the rank, and the dimension of the null space is the nullity.
Both numbers come from the same computation. Reduce the matrix to reduced row-echelon form and count: the number of non-zero rows, equivalently the number of pivot columns, is the rank; the number of columns without a pivot is the nullity. No separate calculation is needed, because the pivot structure simultaneously selects a basis for the column space from the original columns and generates one basis vector of the null space per free variable.
The two counts are not independent. Every column of the matrix is either a pivot column or it is not, so their sum is the total number of columns. That trivial-looking observation is the rank-nullity relationship, and it is one of the most useful accounting identities in applied mathematics: it says that the output richness of a linear map and the amount of input it discards are complementary, trading off against one another with a fixed total.
Engineering interpretations follow directly. Rank counts independent measurements, independent reactions, independent equilibrium equations or controllable directions; nullity counts self-stress states, redundant parameters, mechanisms and unobservable modes. A model whose rank falls short of the number of parameters it declares is unidentifiable by exactly the nullity, and that deficiency is visible in the pivot pattern long before an optimiser fails to converge.
Definition
Rank of a Matrix
ROMLet be an matrix. The rank of , written , is the dimension of its column space: . Since the column space is the span of the columns, the rank is the maximum number of linearly independent columns the matrix contains.
Rank is bounded above by both and . A matrix with is said to have full rank.
Nullity of a Matrix
NOMLet be an matrix. The nullity of , written , is the dimension of its null space: , where . It counts the independent directions in the input space that the matrix maps to zero.
Computing Rank and Nullity
CRNLet be an matrix and let be a row-equivalent matrix in reduced row-echelon form with non-zero rows. Then and . Both quantities are therefore read off a single reduction, with no additional arithmetic.
Rank Plus Nullity is Columns
RPNCFor any matrix , . The identity holds for every matrix without exception, including matrices of zero rank and matrices of full column rank, and it involves the column count only — the number of rows never appears.
Concepts
Why the pivot count is the rank
A basis of the column space is obtained by selecting from the original columns of exactly those indexed by the pivot columns of its reduced row-echelon form. The non-pivot columns are linear combinations of the pivot columns to their left, so they contribute nothing to the span, while the pivot columns are independent because no such combination can produce one of them.
Since the reduced form has one leading one per non-zero row, and one leading one per pivot column, the count of non-zero rows and the count of pivot columns coincide. Both equal the number of vectors in the extracted basis of the column space, and therefore both equal .
Why the free-variable count is the nullity
Solving from the reduced form expresses each dependent variable, one per pivot column, in terms of the free variables, one per non-pivot column. Setting one free variable to and the others to produces a null space vector; doing this for each free variable in turn produces a set of vectors.
That set spans the null space, because any solution is recovered by scaling and adding according to its free-variable values. It is independent because each vector has a in a position where every other vector in the set has a — the position of its own free variable. A spanning independent set is a basis, so the nullity is .
The conservation law and what it forbids
Adding the two counts gives immediately. The identity is an accounting statement about columns: each column either hosts a leading one or does not, and the two cases are exhaustive and mutually exclusive. There is no room for a column to be partially counted, which is why the relationship holds exactly for every matrix over every field.
Its practical force is as a prohibition. Rank cannot be increased without nullity falling by the same amount. Adding sensors, equations or measurements can raise the rank only up to ; beyond that point additional rows are necessarily redundant. An engineer who wants to remove a mechanism from a structure or an unidentifiable direction from a model must add columns' worth of constraint, not merely more of the same rows.
Rank as the count of what survives
Interpreted as a linear map, takes to . The rank measures how much of the input variety appears at the output: it is the dimension of the set of achievable outputs. The nullity measures how much variety is annihilated on the way. The conservation law states that every input direction is accounted for in exactly one of the two categories.
This is why rank alone answers so many engineering questions. Whether a system of equations is solvable for a particular right-hand side is a question about membership of the column space; whether the solution is unique is a question about the null space being trivial. Both are settled by the same reduction, and the rank-nullity identity guarantees the two answers are consistent.
Bounds and the meaning of full rank
Since the column space is a subspace of spanned by vectors, . A matrix attaining this bound has full rank. For , full rank means full column rank: the columns are independent, the nullity is zero, and the map is injective. For , full rank means full row rank: the columns span , every right-hand side is achievable, and the map is surjective.
A wide matrix with therefore has nullity at least , so it always has a non-trivial null space. This is the structural reason a homogeneous system with more unknowns than equations always admits non-trivial solutions, stated as a dimension count rather than as a pivot argument.
Sensitivity: rank is exact but fragile
Rank is an integer, and integers do not vary continuously with the data. An arbitrarily small perturbation of a rank-deficient matrix can raise its rank to the maximum, which is why almost every matrix constructed from measurements has full rank when tested with an exact-zero criterion. The mathematically correct answer is then useless.
The practical replacement is numerical rank: the number of singular values that exceed a stated tolerance. This quantity does vary sensibly with the data, degrades gracefully and exposes how close the decision was. Any rank reported for measured data without an accompanying tolerance and singular-value spectrum should be treated as unsubstantiated.
Procedure: obtain rank and nullity from a single reduction
Equations
Rank as a dimension
EQ-RNM-01The defining statement. Rank is not primarily a count of pivots; it is the dimension of a subspace, and the pivot count is how that dimension is computed.
Nullity as a dimension
EQ-RNM-02The dimension of the set of inputs annihilated by . Zero nullity means the only such input is the zero vector.
Computing both from reduced row-echelon form
EQ-RNM-03is the number of non-zero rows of any row-equivalent matrix in reduced row-echelon form. Uniqueness of that form is what makes well defined.
Rank plus nullity is columns
EQ-RNM-04Exact for every matrix. Note that the row count does not appear: the identity is an accounting over columns only.
Bounds on rank
EQ-RNM-05The second inequality guarantees a non-trivial null space whenever a matrix has more columns than rows, regardless of its entries.
Basis of the column space from pivot columns
EQ-RNM-06The basis consists of columns of the original matrix, selected by the pivot indices of the reduced form. The reduced columns themselves are not used.
Numerical rank via singular values
EQ-RNM-07The production definition for floating-point data. The tolerance must be reported alongside the rank, or the number is not reproducible.
Variable Definitions
| Symbol | Name | Meaning | Domain / type |
|---|---|---|---|
| Matrix | The matrix whose rank and nullity are sought | m x n complex matrix | |
| Row count | Number of rows; the size of the vectors in the column space | positive integer | |
| Column count | Number of columns; the total shared between rank and nullity | positive integer | |
| Rank | Number of non-zero rows of the reduced row-echelon form, equal to | 0 to min(m,n) | |
| Pivot column set | Indices of columns containing a leading one; selects a basis of the column space | subset of 1..n of size r | |
| Free column set | Complement of ; each element contributes one basis vector of the null space | subset of 1..n of size n-r | |
| Column space | Span of the columns of ; the set of achievable outputs | subspace of C^m | |
| Null space | Set of inputs mapped to the zero vector | subspace of C^n | |
| Singular value | Non-negative quantities whose count above a tolerance defines the numerical rank | non-negative real |
Worked Numerical Example
Problem statement
A sensor fusion rig produces five output channels from seven adjustable excitation parameters, described by a gain matrix. Determine how many independent output directions the rig can reach and how many parameter combinations produce no output at all.
State the gain matrix
Rows correspond to output channels and columns to excitation parameters. The matrix is wide, with and , so a non-trivial null space is guaranteed before any arithmetic: the nullity is at least .
Reduce to reduced row-echelon form
Eliminate left to right, clearing each pivot column above and below. Column 2 acquires no pivot because it is exactly times column 1, and column 5 and column 7 likewise fail to introduce new directions.
Record the pivot and free sets
Leading ones appear in columns 1, 3, 4 and 6, so and . There are four non-zero rows and one zero row, confirming that one of the five output channels is a linear combination of the others.
Report the rank and a column space basis
The rank is , so the rig can reach a four-dimensional set of output patterns within the five-dimensional output space. A basis of that set is formed from the original columns indexed by , not the reduced ones.
Express the dependent variables
Each non-zero row of the reduced form solves for one dependent variable in terms of the free variables , and . Because each leading one is alone in its column, no back-substitution is required.
Build the null space basis
Set each free variable to in turn with the others at . This produces three vectors, one per element of , and they are independent because each carries a in a position where the others are .
Verify the null space vectors directly
Multiply each candidate by the original matrix and confirm the result is the zero vector. For , row 1 gives ; row 2 gives ; row 3 gives ; row 4 gives ; row 5 gives . The remaining two vectors check the same way against every row.
Confirm the accounting identity
The nullity is the number of free variables, , and the rank is . Their sum is the column count. Note that it is the column count that appears, not the row count — the identity would fail if were substituted for .
The rig delivers four independent output directions out of a possible five, so one output channel is redundant and could be removed without loss of information. Three independent combinations of the seven excitation parameters produce no output whatever: these are wasted control authority, and any calibration routine that treats all seven parameters as independent will find a three-dimensional family of equally good solutions rather than a unique one. Reducing the excitation set to four well-chosen parameters would make the calibration well posed.
Applications & Industry Use
Static indeterminacy and mechanisms
For an equilibrium matrix relating member forces to nodal loads, the nullity counts independent self-stress states — the degree of static indeterminacy — while the rank deficiency in the transposed compatibility relation counts mechanisms. Both numbers come from one reduction, and together they classify a pin-jointed assembly as statically determinate, indeterminate, a mechanism, or both at once.
Controllability and observability deficiency
The Kalman rank conditions ask whether a controllability or observability matrix has full rank. When it does not, the nullity gives the exact dimension of the uncontrollable or unobservable subspace, and the corresponding null space basis identifies which state combinations are affected. That is considerably more actionable than the binary answer, since it tells the designer where to add an actuator or a sensor.
Independent reactions and atom balances
The rank of a stoichiometric matrix is the number of independent reactions in a network, and the nullity of the atomic composition matrix gives the dimension of the space of balanced reactions. A network written with more reactions than its rank contains redundancy, and any kinetic parameters attached to the redundant directions cannot be estimated from concentration data.
Datum defect in network adjustment
A levelling or triangulation network adjusted from relative observations alone has a design matrix with non-zero nullity, the datum defect: translations and rotations of the whole network leave every observation unchanged. The nullity is exactly the number of external constraints that must be imposed to fix the datum, and the null space basis describes precisely which motions are unconstrained.
Identifiability of model parameters
A design matrix whose rank is less than its column count leaves the least-squares problem with a solution set of dimension equal to the nullity, so individual coefficients are not estimable even though fitted values are. Detecting this from the pivot pattern before fitting is far cheaper than diagnosing it from an optimiser that fails to converge or from wildly inflated standard errors.
Degenerate configurations in pose estimation
Estimating a camera pose or a fundamental matrix reduces to finding the null space of a measurement matrix built from correspondences. The expected nullity is one; a nullity of two or more signals a degenerate configuration — coplanar points, pure rotation — in which the solution is not unique. Monitoring the nullity is the standard guard against silently returning an arbitrary member of a solution family.
Design Considerations
Rank and nullity describe the matrix, not the system
Both quantities are properties of alone. Whether a particular system is consistent depends on as well, and is settled by reducing the augmented matrix. Do not augment when computing rank and nullity, and do not infer consistency from the rank of the coefficient matrix alone.
The identity uses columns, never rows
involves the column count exclusively. For a wide matrix the row count is smaller and substituting it produces a nullity that is too small, sometimes negative. When a matrix is transposed the identity still holds but with the roles of and exchanged, which is a distinct statement about a distinct null space.
Report a tolerance with any numerical rank
In floating point, rank is a threshold decision on the singular values. Two engineers using different tolerances will report different ranks for the same data, and both will be defensible. Publish the tolerance and the singular value spectrum; a clear multi-decade gap justifies the cut, while a gradual decay means the rank is not well determined at the precision available.
Prefer a rank-revealing factorisation to elimination on measured data
Gaussian elimination decides rank by comparing pivots against a threshold, and its pivot choices are discrete, so the answer can flip on a rounding error. A singular value decomposition orders the information by magnitude and exposes the margin of the decision. It costs several times more and is worth it whenever the rank feeds a downstream decision.
Use the deficiency, not just the deficiency flag
Discovering that a matrix is rank-deficient is only the first step. The null space basis says which parameter combinations are unresolved, and that is what tells a designer where to place an extra sensor, which two feedstocks are interchangeable, or which regression terms to merge. Compute and inspect the basis rather than merely reporting the count.
Design for full rank rather than repairing rank deficiency
Regularisation, pseudo-inverses and minimum-norm solutions all return an answer from a rank-deficient system, but the answer is a choice among infinitely many, made by the algorithm rather than by the engineer. Where the measurement or excitation design is under the engineer's control, adding an independent row is a better remedy than selecting a member of the solution family after the fact.
Standards & Codes
Notation, interchange and numerical standards that govern how this material is written down, stored and computed in production systems.
| Reference | Title | Relevance to this topic |
|---|---|---|
ISO 80000-2 | Quantities and units — Part 2: Mathematics | Prescribes upright typesetting for operator names such as and , distinguishing them from italic scalar variables like and used on this page. |
IEEE 754-2019 | IEEE Standard for Floating-Point Arithmetic | Defines the arithmetic and the machine epsilon against which numerical rank tolerances are scaled, and the rounding behaviour that makes an exact-zero pivot test invalid for measured data. |
LAPACK / BLAS reference | Linear Algebra PACKage reference implementation | Supplies xGESVD and xGESDD for the singular values behind a defensible numerical rank, and xGEQP3 for pivoted QR as a cheaper rank-revealing alternative. |
ISO 17123 | Optics and optical instruments — Field procedures for testing geodetic and surveying instruments | Underpins the network adjustment practice in which datum defect appears as a non-zero nullity of the design matrix, requiring explicit external constraints. |
ISO/IEC 40314 | Mathematical Markup Language (MathML) Version 3.0 | Encodes the matrices, set expressions and operator names on this page as semantic markup so that rank and nullity notation remains searchable and accessible. |
Material Selection
For a mathematical topic, "material" is the numeric representation: the scalar field, storage format and precision the computation is built from.
| Representation | Select when | Trade-off |
|---|---|---|
| Exact rational arithmetic | Rank of a structural, stoichiometric or incidence matrix, where the answer is a combinatorial fact about a model rather than an estimate from data. | Yields a certain rank with no tolerance decision, but intermediate fractions grow quickly and the result gives no indication of how nearly the rank might have differed. |
| Arbitrary-precision integers with fraction-free elimination | Large integer matrices from network or reaction models where exactness is required and rational blow-up must be avoided. | Bounds intermediate operand growth at the cost of a more complex algorithm and an echelon rather than fully reduced result. |
| IEEE 754 binary64 with SVD-based rank | Rank of a measured or simulated matrix where the decision has engineering consequences. | The most defensible route because the singular value spectrum exposes the margin, but several times the cost of elimination and memory traffic. |
| IEEE 754 binary64 with pivoted QR | Large matrices where an SVD is prohibitive but a numerical rank is still needed. | Substantially cheaper and usually reliable, but can misreport the rank for adversarial matrices, so it is an estimate rather than a certificate. |
| IEEE 754 binary32 | Rank monitoring inside a real-time vision or control loop where throughput dominates and the rank is expected to be unambiguous. | Halves memory traffic but leaves about seven significant digits, so only rank decisions with several decades of margin in the singular values are safe. |
| Finite field arithmetic modulo a prime | Certifying the rank of an integer matrix quickly, or coding-theory applications where the field is genuinely finite. | Exact with fixed-size operands and no growth, but the rank modulo an unlucky prime can be lower than the rank over the rationals; use several primes. |
| Sparse storage with a fill-reducing ordering | Very large structural or network matrices in which most entries are zero. | Makes the problem tractable at all, but elimination causes fill-in and a sparse QR or an iterative subspace method is usually preferable to direct reduction. |
Manufacturing Notes
Implementation notes — how the result is actually produced by hand, by algorithm and by library, including cost and numerical behaviour.
Cost of the computation
Reduction of an matrix costs operations, about in the square case, and delivers rank and nullity together with bases for the column and null spaces. A singular value decomposition costs several times more but yields the full spectrum. There is no shortcut: any method that determines rank must in effect perform an elimination or an orthogonal reduction.
Hand procedure and its checkpoints
Reduce fully, then write down and explicitly before doing anything else. Confirm as an immediate arithmetic check. Extract the column space basis from the original matrix, not the reduced one — this is the single most common slip. Then generate one null space vector per element of and verify each against the original matrix by direct multiplication.
Library behaviour
numpy.linalg.matrix_rank uses an SVD with a default tolerance of ; pass tol explicitly whenever the answer matters. scipy.linalg.null_space returns an orthonormal basis of the null space whose column count is the nullity, computed with the same tolerance convention. SymPy's Matrix.rank, Matrix.columnspace and Matrix.nullspace work exactly over the rationals and are the right tools for a structural model. MATLAB's rank and null follow the SVD convention.
Verifying rank and nullity independently
Compute the rank by reduction and separately count the singular values above a tolerance; agreement is strong evidence both are correct. Verify the null space basis by multiplication against the original matrix, and verify the column space basis by expressing every non-pivot column as a combination of the pivot columns. Finally check the conservation identity, which catches any miscount immediately.
Monitoring rank in a running system
Recomputing a full decomposition on every update is wasteful when a matrix is being extended row by row, as in recursive estimation. Incremental QR updates maintain a factorisation at per new row and expose the diagonal magnitudes that indicate rank deficiency. Track the smallest such magnitude as a health metric rather than recomputing the rank from scratch.
Failure Modes & Common Mistakes
| Failure mode / mistake | Impact | Root cause | Prevention & detection |
|---|---|---|---|
| Using reduced columns as the column space basis | high | The pivot columns of the reduced form are taken as basis vectors instead of the corresponding columns of the original matrix. | Row operations change the column space; only the pivot indices transfer. Extract the basis vectors from itself using those indices. |
| Substituting the row count into the conservation identity | high | used for a non-square matrix, giving a wrong or negative nullity. | The identity counts columns. Write it as and confirm that is the number of unknowns, not the number of equations. |
| Exact-zero rank test on floating-point data | high | A pivot or singular value of magnitude counted as non-zero, so a rank-deficient matrix is reported as full rank. | Use an SVD with an explicit tolerance scaled to the largest singular value and the matrix size, and report both the rank and the tolerance. |
| Counting zero rows instead of non-pivot columns for the nullity | medium | Nullity taken as the number of zero rows, which coincides with only when . | Count the columns without a leading one. For a wide matrix the zero-row count is far smaller than the nullity. |
| Augmenting with the right-hand side before computing rank | medium | The augmented matrix is reduced and its pivot count reported as the rank of the coefficient matrix. | Compute rank and nullity from alone. Augment only when the question is consistency, and then interpret a pivot in the final column as inconsistency rather than as extra rank. |
| Reporting rank deficiency without the null space | medium | The deficiency count is delivered as a diagnostic, leaving the engineer without the information needed to act on it. | Always return the null space basis alongside the nullity; it names the unresolved parameter combinations directly. |
| Assuming full column rank because the matrix is tall | medium | is mistaken for a guarantee that the columns are independent. | Shape bounds the rank but does not determine it. Reduce and check; duplicated or collinear columns make a tall matrix rank-deficient just as easily. |
| Comparing ranks computed with different tolerances | low | Ranks from two tools with different default thresholds are treated as contradictory or as evidence of a data change. | Fix and record the tolerance across a pipeline, and compare singular value spectra rather than integer ranks when tracking a system over time. |
FAQs
Why does the rank-nullity identity involve the number of columns and not the number of rows?
Because both quantities are counts over the columns. Each column of the reduced row-echelon form either contains a leading one, contributing to the rank, or does not, contributing a free variable to the nullity. The two cases are exhaustive and exclusive, so the totals add to the column count. The row count places an upper bound on the rank but never appears in the identity.
Is rank the number of independent rows or the number of independent columns?
Both, and that they agree is a genuine theorem rather than a definition. The rank is defined here as the dimension of the column space, but the row space has the same dimension. Consequently a matrix and its transpose always have the same rank, even though their null spaces generally have different dimensions.
Can I compute rank and nullity without doing a full reduction?
Not exactly, but the reduction to echelon form suffices for the counts. Clearing above the pivots produces the fully reduced form and is required only if the bases are wanted in their canonical form. For floating-point data, an SVD or a pivoted QR is preferable to elimination even though it costs more, because it exposes how close the rank decision was.
What does nullity mean physically?
It counts the independent input combinations that produce no output. In a structure those are self-stress states; in a control system they are uncontrollable directions; in a regression model they are parameter combinations the data cannot resolve; in a survey network they are unconstrained motions of the whole network. In every case the nullity is the number of degrees of freedom left undetermined.
Why does a matrix with more columns than rows always have a non-trivial null space?
Because the rank cannot exceed the number of rows, so whenever . This is the dimension-counting form of the familiar statement that a homogeneous system with more unknowns than equations always has non-trivial solutions.
How should I report the rank of a matrix built from measurements?
As a number accompanied by the tolerance used and, ideally, the singular value spectrum. Rank is an integer that does not vary continuously with the data, so a rank quoted without a tolerance is not reproducible. A spectrum showing a gap of several orders of magnitude at the cut is what makes the reported value credible.
Does the rank change if I row-reduce the matrix?
No. Row operations preserve the row space exactly and preserve the dimension of the column space, so the rank is unchanged — that invariance is precisely what makes reduction a valid way to compute it. The column space itself does change, which is why the basis must be extracted from the original columns.
References
- Beezer, R. A. A First Course in Linear Algebra, Version 0.70. University of Puget Sound, 2006. Section D, subsection RNM. Licensed under the GNU Free Documentation License v1.2.
- ISO 80000-2:2019, Quantities and units — Part 2: Mathematics. International Organization for Standardization.
- IEEE 754-2019, IEEE Standard for Floating-Point Arithmetic. Institute of Electrical and Electronics Engineers.
- Golub, G. H. and Van Loan, C. F. Matrix Computations, 4th edition. Johns Hopkins University Press, 2013.
- Anderson, E. et al. LAPACK Users' Guide, 3rd edition. Society for Industrial and Applied Mathematics, 1999.
- Pellegrino, S. and Calladine, C. R. 'Matrix analysis of statically and kinematically indeterminate frameworks'. International Journal of Solids and Structures, 22(4), 1986.
AI Suggested Questions
- Build a 6x9 integer matrix with rank 4 and show its null space basis, then verify rank plus nullity equals 9.
- For a pin-jointed truss equilibrium matrix, explain how rank and nullity translate into degree of static indeterminacy and number of mechanisms.
- How do I choose a singular value tolerance for a design matrix whose entries have three significant digits of measurement accuracy?
- Show a matrix whose rank changes when a single entry is perturbed by 10^-12, and explain what that implies for exact-zero rank tests.
- Compare the cost and reliability of rank determination by Gaussian elimination, pivoted QR and SVD for a 5000x300 matrix.
- Given a rank-deficient regression design matrix, which coefficients are estimable and how do I identify them from the null space?
Related Calculators
Compute rank, nullity and the pivot column set from a matrix, with a selectable numerical tolerance and a check of the conservation identity.
Null Space Basis CalculatorGenerate a basis of with one vector per free variable and verify each by direct multiplication against the original matrix.
Column Space Basis CalculatorExtract a basis of from the original columns indexed by the pivot set, and express every remaining column in terms of it.
Numerical Rank EstimatorReport singular values, the tolerance applied and the resulting numerical rank, with a spectrum plot showing the margin of the decision.
