Finding Bases for Null Spaces, Row spaces and Column Spaces

Recall:

The Null Space of A is the solution to Ax=0.

The Row Space of A is the span of its row vectors.


The Column Space of A is the span of its column vectors. This is the same as the range of A.

The dimension of the Row Space is equal to the dimension of the Column Space and is called the Rank of A.

The Dimension of the Null Space plus the Rank equals the number of variables which is the number of columns.

> with(LinearAlgebra):

We create a matrix A.

> A:=Matrix([[0,3,2,3,2,4,7,1,0],[1,0,1,1,0,2,1,1,0],[0,0,0,0,0,4,4,4,4],[0,0,0,3,2,9,9,1,0],[1,3,3,4,2,6,8,2,0]]);

A := Matrix([[0, 3, 2, 3, 2, 4, 7, 1, 0], [1, 0, 1, 1, 0, 2, 1, 1, 0], [0, 0, 0, 0, 0, 4, 4, 4, 4], [0, 0, 0, 3, 2, 9, 9, 1, 0], [1, 3, 3, 4, 2, 6, 8, 2, 0]])

To find bases for the Row and Column Spaces put A into Reduced Row Echelon Form

> ReducedRowEchelonForm(A);

Matrix([[1, 0, 1, 0, (-2)/3, 0, -1, 5/3, 1], [0, 1, 2/3, 0, 0, 0, 1, 5/3, 5/3], [0, 0, 0, 1, 2/3, 0, 0, (-8)/3, -3], [0, 0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0]])

We see the that rank (the number of pivots) is four (4). The nonzero rows of rref(A) are a basis for the Row Space of A. The columns of A that correspond to the pivot columns of rref(A) are a basis for the Column Space of A. These are [0,1,0,0,1]^T, [3,0,0,0,3]^T, [3,1,0,3,4]^T, [4,2,4,9,6]^T. (The ^T means take the transpose to get a column vector).  The pivot columns of rref(A) are not a basis for the Column Space of A.

Maple has commands to give bases for the Row and Columns Spaces directly.

> RowSpace(A);

[Vector[row]([1, 0, 1, 0, (-2)/3, 0, -1, 5/3, 1]), Vector[row]([0, 1, 2/3, 0, 0, 0, 1, 5/3, 5/3]), Vector[row]([0, 0, 0, 1, 2/3, 0, 0, (-8)/3, -3]), Vector[row]([0, 0, 0, 0, 0, 1, 1, 1, 1])]

> C:=ColumnSpace(A);

C := [Vector[column]([[1], [0], [0], [0], [1]]), Vector[column]([[0], [1], [0], [0], [1]]), Vector[column]([[0], [0], [1], [0], [0]]), Vector[column]([[0], [0], [0], [1], [0]])]

Notice that Maple's choice of a basis for the column space of A is different then the one we picked. We shall check that they do in fact span the same space. We create matrices B1 and B2. B1 has as columns the basis vectors we found and B2 has as columns the basis vectors Maple found.

> B1:=Transpose(Matrix([[0,1,0,0,1], [3,0,0,0,3], [3,1,0,3,4], [4,2,4,9,6]]));

B1 := Matrix([[0, 3, 3, 4], [1, 0, 1, 2], [0, 0, 0, 4], [0, 0, 3, 9], [1, 3, 4, 6]])

> B2:=Transpose(Matrix([[1,0,0,0,1],[0,1,0,0,1],[0,0,1,0,0],[0,0,0,1,0]]));

B2 := Matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], [1, 1, 0, 0]])

> X:=LinearSolve(B1,B2);

X := Matrix([[0, 1, 1/4, (-1)/3], [1/3, 0, 5/12, (-1)/3], [0, 0, (-3)/4, 1/3], [0, 0, 1/4, 0]])

Thus B1 time X equals B2. This means there are linear combinations of the columns of B1 that give the columns of B2. It follows that the reverse is true. Hence they span the same space. (The matrix X is called a transition matrix or a change of basis matrix.)

Next we find a basis for the Null Space of A. Since there are 9 variables and the rank of A is 4, the dimension of the Null Space should be 9-4=5.

First we solve the homogeneous equation Ax=0.

> LinearSolve(A,ZeroVector(5));

Vector[column]([[-_t0[4]+5/2*_t0[7]+7/2*_t0[8]+9/2*_t0[9]+3/2*_t0[2]], [_t0[2]], [-3/2*_t0[2]-3/2*_t0[7]-5/2*_t0[8]-5/2*_t0[9]], [_t0[4]], [-3/2*_t0[4]+4*_t0[8]+9/2*_t0[9]], [-_t0[7]-_t0[8]-_t0[9]], [...

Since there are 5 parameters the dimension of the Null Space is indeed 5. Maple's choice of the names of these parameters is truly odd. Also, if you execute the LinearSolve command repeatedly it may produce different choices for form of the output. We can tease out a basis using the output of LinearSolve, but it is easier to use the NullSpace command.

> NullSpace(A);

{Vector[column]([[(-5)/3], [(-5)/3], [0], [8/3], [0], [-1], [0], [1], [0]]), Vector[column]([[-1], [(-2)/3], [1], [0], [0], [0], [0], [0], [0]]), Vector[column]([[2/3], [0], [0], [(-2)/3], [1], [0], [...

If we wish to have an orthonormal basis we can use the GramSchmidt command.

> evalf(GramSchmidt(NullSpace(A),normalized));

{Vector[column]([[-.2601329908], [-.4335549846], [0.], [.7803989722], [0.], [-.2601329908], [0.], [0.], [.2601329908]]), Vector[column]([[-.3631879524], [-.3490096296], [.7455073533], [-.3317975173], ...