gizmobench

Subspace Basis Calculator

Type or paste a matrix of up to 10 rows and 10 columns, say whether your vectors are its columns or its rows, and press Find bases. The matrix is reduced to reduced row echelon form in exact fractions, and you get a basis for the span chosen from your own vectors, bases for the column space, row space and null space, the rank and nullity, and each dependent vector written as a combination of the basis. Every row operation can be listed with the matrix it produces, and every null space vector is multiplied back through the matrix to show the product is exactly zero. Turn on Gram-Schmidt to make the vectors orthogonal in order: a vector that depends on the earlier ones is reported and skipped rather than divided by zero, and unit vectors are given exactly, with a square root where the length needs one, and as decimals labelled approximate.

Your vectors

Example input

Vectors are the matrix

Matrix A, 3 by 3. Each column is one vector. Arrow keys move between cells.
v1v2v3
row 1
row 2
row 3
Paste rows instead

One row per line, or separate rows with a semicolon or with a slash that has spaces around it. Separate entries with spaces, commas or tabs. 1/2 written without spaces is a fraction.

Gram-Schmidt

One number per cell: a whole number, a decimal like 0.5, a fraction like 1/3 or exponent notation like 1.5e-2. A blank cell counts as 0. Up to 10 rows and 10 columns, with at most 12 digits above and below the line in each entry. Arrow keys move between cells; Enter finds the bases.

Result

RREF(A), with the pivots outlined

Reduced row echelon form of A
1 (pivot)0−1
01 (pivot)2
000
  • Pivot columns: 1, 2
  • Basis of the span, from your columns: v1, v2
  • Null space basis: (1, −2, 1)
  • Residual A·n = (0, 0, 0)

Rank 2 and nullity 1 for a 3 × 3 matrix: the 3 column vectors span a space of dimension 2.

Rank
2
Nullity
1
Pivot columns
1, 2
Residual check
Exact zero, 1 vector

Bases

  • Span of your vectorsdimension 2, chosen from your columns
    v1 = (1, 4, 7) v2 = (2, 5, 8)
  • Column spacethe pivot columns of A
    (1, 4, 7) (2, 5, 8)
  • Row spacethe non-zero rows of RREF(A)
    (1, 0, −1) (0, 1, 2)
  • Null spaceweights that combine your vectors to zero
    n1 = (1, −2, 1)

Dependent vectors

Each is a combination of the basis vectors chosen from your columns, read off its column of RREF(A) and then recomputed exactly.

  • v3 = −v1 + 2·v2 (checked exactly)

Checks

  • A × n1 = (0, 0, 0), exactly zero
  • rank + nullity = 2 + 1 = 3, the number of columns

Row reduction

5 row operations take A to its reduced row echelon form, in exact fractions.

Worked examples

  • rows 1 2 3; 4 5 6; 7 8 93 × 3 example
    rank 2, null-space basis (1, −2, 1)
  • columns (1, 2) and (2, 4)span example
    rank 1, basis (1, 2)
  • matrix [1 2]null space example
    null-space basis (−2, 1), rank + nullity = 2
  • (1, 2) then (2, 4)Gram-Schmidt dependent example
    v2 reported as dependent; no division by zero
  • rows (1, 1, 0), (1, 0, 1), (0, 1, 1)Gram-Schmidt example
    orthonormal basis (1, 1, 0)/√2, (1, −1, 2)/√6, (−1, 1, 1)/√3
How the bases are found. Row reduction marks the pivot columns. Those columns of A itself, not of the reduced form, are a basis for the column space, and the non-zero rows of the reduced form are a basis for the row space. Each column without a pivot is a free variable and gives one null space vector, with that variable set to 1 and the others read off the reduced form. Rank plus nullity always equals the number of columns, and every null space vector is multiplied back through A to confirm the product is exactly zero.

Common questions

How do you find a basis for the span of a set of vectors?
Put the vectors in as the columns of a matrix and row reduce it. The columns that end up holding a pivot mark a basis: take those vectors from your original list, not from the reduced form. With (1, 2) and (2, 4), the reduced form has one pivot, in column 1, so (1, 2) alone is a basis, the span has dimension 1, and the page shows v2 = 2·v1. If your vectors are written as rows, choose Rows: the independent rows are then picked the same way, by reducing the transpose, and the non-zero rows of the reduced form are given as a second basis of the same span.
How do I find the null space of a matrix?
Row reduce it. Each column without a pivot is a free variable. Set one free variable to 1 and the others to 0, read the pivot variables off the reduced form, and you have one basis vector for each free column. For the matrix [1 2], the equation is x1 + 2x2 = 0, x2 is free, and the basis vector is (−2, 1). The number of these vectors is the nullity, and rank plus nullity equals the number of columns: 1 + 1 = 2 here. Each null space vector is multiplied back through the matrix and the product is shown, so you can see it is exactly zero.
What is the difference between the column space and the row space?
The column space is every combination of the columns, and the row space is every combination of the rows. Both have the same dimension, the rank, but they are found differently. A basis for the column space is the pivot columns of the original matrix, because row operations change the columns. A basis for the row space is the non-zero rows of the reduced form, because row operations do not change which vectors the rows span. For [1 2 3; 4 5 6; 7 8 9] that gives (1, 4, 7) and (2, 5, 8) for the column space, and (1, 0, −1) and (0, 1, 2) for the row space.
What does Gram-Schmidt do here, and what happens if my vectors are dependent?
It takes your vectors in order and subtracts from each one its projections onto the orthogonal vectors before it, in exact fractions, so the vectors it keeps are pairwise orthogonal and span the same space. If what is left of a vector is exactly the zero vector, that vector already lies in the span of the earlier ones: it is reported as dependent and skipped, so nothing is ever divided by zero. With (1, 2) then (2, 4), the second is reported as dependent. Orthonormal also divides each kept vector by its length: (3, 4) becomes (3/5, 4/5) exactly, while (1, 1, 0) becomes (1, 1, 0)/√2, shown as well as 0.707106781187 in decimals labelled approximate.
Why are the answers fractions instead of decimals?
Whether a vector depends on the others is an exact question. A vector is dependent only when its remainder after elimination is exactly zero, and in decimal arithmetic a remainder that should be zero often comes out as a tiny number such as 0.0000000000000004, which a program then has to guess about. Here every entry is a fraction of two whole numbers and nothing is rounded, so a zero is exactly zero and a pivot is never an artefact of rounding. The only decimals the page computes are the approximate readings of orthonormal vectors, and they are labelled as approximate.
What can I type in a cell, and how large can the matrix be?
A whole number, a decimal like 0.5, a fraction like 1/3, exponent notation like 1.5e-2, or a number with a minus sign pasted from a PDF. A blank cell counts as 0, and 0.1 is read exactly as 1/10. The matrix can have up to 10 rows and 10 columns, and each entry can have up to 12 digits above and below the line, which keeps even a dense 10 × 10 of long fractions quick to reduce. To enter a whole matrix at once, open Paste rows instead, put one row per line and press Fill grid. The last matrix of your own that reduced successfully is kept in this browser, with your settings, and restored on your next visit; nothing is uploaded.

Exact within its bounds: row reduction, rank, nullity, every basis and every residual check use fractions of whole numbers with no rounding, for up to 10 rows and 10 columns with numerators and denominators of up to 12 digits. Orthonormal vectors are shown exactly, with a square root where the length is irrational, and as decimals rounded to 12 significant digits that are labelled approximate. It finds bases, not matrix products, inverses or eigenvalues.