Basis For Null Space Calculator
The null space of a matrix is the set of all vectors that the matrix sends to zero, and a basis for it is the compact list of vectors that generates the whole set. Every linear algebra course asks you to find one, and the hand computation, row reduction, pivot hunting, and back-substitution, is where most of the marks are lost to arithmetic slips rather than conceptual errors.
The Basis for Null Space Calculator below does the full job: enter any matrix up to 4×4, and it row-reduces it, identifies the free variables, and hands you the basis vectors, the nullity, and the rank. It uses exact rational arithmetic where the numbers are clean, so you get (1, −2, 1) instead of (0.9999999, −2.0000001, 1).
Quick Answer
Key takeaways
- The null space is the solution set of Ax = 0. Its basis has one vector per free variable.
- Free variables are the columns without pivots after row reduction. Each becomes 1 in its own basis vector, 0 in the others.
- Rank + nullity = number of columns (the rank-nullity theorem). The calculator checks this on every run.
- The identity matrix has a trivial null space: only the zero vector, nullity 0.
What a basis for the null space actually is
The null space of a matrix A, written Null(A), is the set of all vectors x with Ax = 0. That set is a subspace, and like every subspace it can be described by a basis: a minimal set of linearly independent vectors whose span is the whole space. So finding a basis for the null space means answering “how many independent directions does the solution set of Ax = 0 have, and which ones?”
The procedure is mechanical, which is exactly why it is worth automating: row-reduce A to reduced row echelon form, identify the pivot columns, and treat every non-pivot column as a free variable. For each free variable, set it to 1 (and the other free variables to 0), then read the pivot variables off the reduced equations. Each choice produces one basis vector, and the number of basis vectors is the nullity of A.
The algorithm, step by step
The calculator follows the standard textbook method, which every linear algebra text from De Anza’s course notes to Margalit and Rabinoff’s Interactive Linear Algebra teaches the same way:
Row-reduce to RREF. Use Gaussian elimination with partial pivoting (swapping in the largest available entry) to reach reduced row echelon form. Pivoting keeps the arithmetic stable and the output clean.
Mark pivot and free columns. Every column containing a leading 1 is a pivot column; every other column is free. The count of free columns is the nullity, and it equals the number of free variables.
Build one basis vector per free variable. Set the free variable to 1 (others to 0) and solve for the pivot variables from the reduced rows. The resulting vector is one basis vector.
Verify with rank-nullity. Rank (pivot columns) plus nullity (free columns) must equal the total number of columns. The calculator displays this check on every result.
Worked example, checked against this exact tool
Enter the pre-filled defaults (the 2×3 matrix [[1, 2, 3], [4, 5, 6]]) and click Calculate. Here is what happens, verified against the underlying code:
| Step | Detail |
|---|---|
| RREF | [[1, 0, −1], [0, 1, 2]] |
| Pivot columns | 1 and 2 (rank 2) |
| Free variable | x3 (nullity 1) |
| Basis vector | (1, −2, 1) |
| Rank-nullity check | 2 + 1 = 3 columns |
Sanity check by hand: A × (1, −2, 1) = (1 − 4 + 3, 4 − 10 + 6) = (0, 0). The vector is genuinely in the null space, and since there is exactly one free variable, it alone spans the whole null space.
What competing null-space tools get wrong
We tested the popular null-space calculators before building this page. The gaps are real.
Fractional garbage. Several tools print (0.99999999, −2.00000001, 1.00000002) because they divide by pivots with no cleanup. This one rounds and snaps near-zero values to 0, so textbook answers come out as textbook answers.
No rank-nullity check. Competing tools show the basis but never confirm it. The rank + nullity = columns row on every result is a free correctness check that catches wrong pivot detection instantly.
Hidden pivot logic. Most tools never show which columns are pivots, so when the answer looks odd you cannot tell why. The rank and nullity rows make the free-variable structure explicit.
Trivial cases crash or confuse. Several calculators error out or show empty results for the identity matrix or a zero row. This one reports the trivial null space plainly.
Frequently asked questions
The null space of an m×n matrix A is the set of all vectors x in Rⁿ with Ax = 0, the solution set of the homogeneous system. It is always a subspace of Rⁿ, and it always contains the zero vector.
Row-reduce A to reduced row echelon form. The columns without pivots are the free variables. For each free variable, set it to 1 (and the other free variables to 0), solve for the pivot variables from the reduced equations, and collect the resulting vector. The set of these vectors is the basis.
Nullity is the dimension of the null space: the number of vectors in any basis for it, equivalently the number of free variables (columns without pivots). The rank-nullity theorem says rank + nullity = number of columns.
The trivial null space contains only the zero vector, so its nullity is 0. This happens exactly when every column has a pivot, for example the identity matrix, or any square matrix with full rank. It means Ax = 0 has only the solution x = 0.
Yes, one vector per free variable. The 2×3 matrix [[1, 2, 3], [2, 4, 6]] has two free variables, so its basis is {(−2, 1, 0), (−3, 0, 1)} and its nullity is 2. Wider matrices (more columns than rows) always have at least one free variable.
No. The nullity is fixed, but the specific basis vectors are not: any set of nullity-many linearly independent vectors spanning the null space is a valid basis. The calculator returns one standard choice (free variables set to 1 in turn), which is the form textbooks expect.
Add This Calculator to Your Website
References
- De Anza College, “4.7: Row, Column, and Null Spaces” (Mathematics LibreTexts) – null space as a span of basis vectors, nullity as the dimension of the null space, with a worked parametric example. LibreTexts: Row, Column, and Null Spaces. Accessed October 19, 2026.
- Margalit and Rabinoff, “2.8: The Rank Theorem” (Interactive Linear Algebra, Mathematics LibreTexts) – rank-nullity theorem: rank(A) + dim Nul(A) = number of columns, with definitions of rank and nullity. LibreTexts: The Rank Theorem. Accessed October 19, 2026.
- Mission College, “5.5: The Rank Theorem” (Mathematics LibreTexts) – rank as the number of pivot columns, nullity as the number of free variables (columns without pivots). LibreTexts: The Rank Theorem (Mission College). Accessed October 19, 2026.
