Topic

The four fundamental subspaces

An m×n matrix A sends vectors with n entries to vectors with m entries. Four subspaces say everything about which vectors it can reach and which it loses:

  • the column space: every A·x, the right-hand sides b for which A·x = b can be solved;
  • the null space: every x with A·x = 0, the freedom left in any solution;
  • the row space: the combinations of rows, the part of x that A actually sees;
  • the left null space: every y with yᵀA = 0, one condition yᵀb = 0 each for b to be reachable.

The rank r ties them together: the column and row spaces have dimension r, the null space n − r, the left null space m − r. The row space is perpendicular to the null space, and the column space to the left null space. All four come out of row reduction, and exactly: a rational matrix has rational bases.

The library calls are rank(A), nullspace(A) and spaces(A). Try making the third row the sum of the first two, or adding a column.

In code

import { spaces, nullspace } from "@ratmath/linalg";

const A = [[1, 2, 3], [2, 4, 6], [1, 0, 1]];
const S = spaces(A);
S.rank;                                       // 2
S.nullity;                                    // 1
S.columnSpace.map((v) => v.toStrings());      // columns 1 and 2 of A
S.rowSpace.map((v) => v.toStrings());         // [[["1","0","1"]], [["0","1","1"]]]
nullspace(A).exact().map((v) => v.toStrings());   // [[["-1"], ["-1"], ["1"]]]
Try itEdit the code and run it with @ratmath/linalg and Core's Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs