Definition CSM. Column Space of a Matrix.
Suppose that is an matrix with columns Then the column space of written is the subset of containing all linear combinations of the columns of
.column_space()
. Here is a check.xxxxxxxxxx
D = matrix(QQ, [[ 2, -1, -4],
[ 5, 2, -1],
[-3, 1, 5]])
cs = D.column_space(); cs
xxxxxxxxxx
cs_span = (QQ^3).span(D.columns())
cs == cs_span
xxxxxxxxxx
coeff = matrix(QQ, [[ 2, 1, 7, -7],
[-3, 4, -5, -6],
[ 1, 1, 4, -5]])
constD = vector(QQ, [8, -12, 4])
constE = vector(QQ, [2, 3, 2])
cs = coeff.column_space()
coeff.solve_right(constD)
xxxxxxxxxx
constD in cs
xxxxxxxxxx
coeff.solve_right(constE)
xxxxxxxxxx
constE in cs
Definition NSM | |
Synopsis | Null space is solution set of homogeneous system |
Example | General solution sets described by Theorem PSPHS |
Theorem SLSLC | |
Synopsis | Solutions for linear combinations with unknown scalars |
Example | Deciding membership in spans |
Theorem SLEMM | |
Synopsis | System of equations represented by matrix-vector product |
Example | Solution to |
Theorem CSCS | |
Synopsis | Column space vectors create consistent systems |
Example | Deciding membership in column spaces |
xxxxxxxxxx
A = matrix(QQ, [[-1, -1, 0, 1, 0, 1, -2, -3, 0],
[-1, 0, 0, 5, -2, 6, -6, 3, 5],
[ 0, 0, 1, -6, -1, 0, -5, 0, 5],
[ 2, 2, 1, -8, -2, 0, -4, 8, 8],
[ 2, 2, 0, -2, -1, 0, 1, 8, 3],
[ 2, 1, 0, -6, -1, -1, -1, 6, 4]])
A.rref()
xxxxxxxxxx
B = A.matrix_from_columns(A.pivots())
A.column_space() == B.column_space()
xxxxxxxxxx
B.rref()
xxxxxxxxxx
cs = (QQ^6).span_of_basis(B.columns())
cs
xxxxxxxxxx
cs.basis()
xxxxxxxxxx
cs.echelonized_basis()
xxxxxxxxxx
cs == A.column_space()
xxxxxxxxxx
cs2 = (QQ^6).span_of_basis([A.column(i) for i in A.pivots()])
cs2 == A.column_space()
A
has four pivot columns, numbered 0,1,2,4
. The matrix B
is just a convenience to hold the pivot columns of A
. However, the column spaces of A
and B
should be equal, as Sage verifies. Also B
will row-reduce to the same 0-1 pivot columns of the reduced row-echelon form of the full matrix A
. So it is no accident that the reduced row-echelon form of B
is a full identity matrix, followed by sufficiently many zero rows to give the matrix the correct size..span_of_basis()
is new to us. It creates a span of a set of vectors, as before, but we now are responsible for supplying a linearly independent set of vectors. Which we have done. We know this because Theorem BCS guarantees the set we provided is linearly independent (and spans the column space), while Sage would have given us an error if we had provided a linearly dependent set. In return, Sage will carry this linearly independent spanning set along with the vector space, something Sage calls a “user basis.”cs
has two linearly independent spanning sets now. Our set of “original columns” is obtained via the standard vector space method .basis()
and we can obtain a linearly independent spanning set that looks more familiar with the vector space method .echelonized_basis()
. For a vector space created with a simple .span()
construction these two commands would yield identical results — it is only when we supply a linearly independent spanning set with the .span_of_basis()
method that a “user basis” becomes relevant.cs
is indeed the column space of A
(we knew it would be) and then we provide a one-line, totally general construction of the column space using original columns.xxxxxxxxxx
F = random_matrix(QQ, 5, 3)
F.matrix_from_columns(F.pivots()).rref() # random
xxxxxxxxxx
F = random_matrix(QQ, 3, 5)
F.matrix_from_columns(F.pivots()).rref() # random
xxxxxxxxxx
A = matrix(QQ, [[1, -1, 2],
[2, 1, 1],
[1, 1, 0]])
B = matrix(QQ, [[-7, -6, -12],
[ 5, 5, 7],
[ 1, 0, 4]])
A.is_singular()
xxxxxxxxxx
A.column_space() == QQ^3
xxxxxxxxxx
B.is_singular()
xxxxxxxxxx
B.column_space() == QQ^3
True
for any square matrix. Run the following repeatedly and it should always return True
. We have kept the size of the matrix relatively small to be sure that some of the random matrices produced are singular.xxxxxxxxxx
A = random_matrix(QQ, 4, 4)
A.is_singular() == (not A.column_space() == QQ^4)
.row_space()
. Indeed, given Sage’s penchant for treating vectors as rows, much of Sage’s infrastructure for vector spaces ultimately relies on Theorem REMRS. More on that in Sage SUTH0. For now, we reprise Example IAS as an illustration.xxxxxxxxxx
v1 = vector(QQ, [1, 2, 1, 6, 6])
v2 = vector(QQ, [3, -1, 2, -1, 6])
v3 = vector(QQ, [1, -1, 0, -1, -2])
v4 = vector(QQ, [-3, 2, -3, 6, -10])
X = (QQ^5).span([v1, v2, v3, v4])
A = matrix([v1, v2, v3, v4])
rsA = A.row_space()
X == rsA
xxxxxxxxxx
B = A.rref()
rsB = B.row_space()
X == rsB
xxxxxxxxxx
X
xxxxxxxxxx
X.basis()
xxxxxxxxxx
B
X
. The matrix A
has these four vectors as rows and B
is the reduced row-echelon form of A
. Then the row spaces of A
and B
are equal to the vector space X
(and each other). The way Sage describes this vector space is with a matrix whose rows are the nonzero rows of the reduced row-echelon form of the matrix A
. This is Theorem BRS in action where we go with Sage’s penchant for rows and ignore the text’s penchant for columns.xxxxxxxxxx
A = matrix(QQ,[[1, 1, 0, -1, 1, 1, 0],
[4, 5, 1, -6, 1, 6, 1],
[5, 5, 1, -5, 4, 5, 2],
[3, -1, 0, 5, 11, -5, 4]])
A.row_space() == A.transpose().column_space()
xxxxxxxxxx
B = matrix(QQ,[[ 7, 9, 2, -11, 1, 11, 2],
[-4, -3, 1, 2, -7, -2, 1],
[16, 8, 2, 0, 30, 0, 12],
[ 2, 10, 2, -18, -16, 18, -4]])
B.column_space() == B.transpose().row_space()
xxxxxxxxxx
A.rref() == B.rref()
xxxxxxxxxx
A.row_space() == B.row_space()
A
to illustrate Definition RSM, and the matrix B
to illustrate Theorem CSRST. A
and B
were designed to have the same reduced row-echelon form, and hence be row-equivalent, so this is not a consequence of any theorem or previous computation. However, then Theorem REMRS guarantees that the row spaces of A
and B
are equal.