Definition SSCV. Span of a Set of Column Vectors.
Given a set of vectors their span, is the set of all possible linear combinations of Symbolically,
.span()
.xxxxxxxxxx
V = QQ^4
v1 = vector(QQ, [1,1,2,-1])
v2 = vector(QQ, [2,3,5,-4])
W = V.span([v1, v2])
W
xxxxxxxxxx
x = 2*v1 + (-3)*v2
x
xxxxxxxxxx
x in W
xxxxxxxxxx
y = vector(QQ, [3, -1, 2, 2])
y in W
xxxxxxxxxx
u = vector(QQ, [3, -1, 2, 5])
u in W
xxxxxxxxxx
W <= V
W
, is created in the first compute cell with the .span()
method, which accepts a list of vectors and needs to be employed as a method of a vector space. The information about W
printed when we just input the span itself may be somewhat confusing, and as before, we need to learn some more theory to totally understand it all. For now you can see the number system (Rational Field
) and the number of entries in each vector (degree 4
). The dimension
may be more complicated than you first suspect.x
will be in the span W
since we built it as a linear combination of v1
and v2
. The vectors y
and u
are a bit more mysterious, but Sage can answer the membership question easily for both.<=
is meant here to be the βsubset ofβ relation, i.e. a slight abuse of the mathematical symbol W
really is a subset of V
.for
command) and the .random_element()
vector space method we can create many, but not all, of the elements of a span. In the examples below, you can edit the total number of random vectors produced, and if you create too many you may make it difficult (or impossible) to wade through them all.Sequence()
command to get nicely-formatted line-by-line output of the list, and notice that we are only providing a portion of the output here. You will want to evalaute the computation of vecs
and then evaluate the subsequent cell for maximum effect.)xxxxxxxxxx
V = QQ^4
W = V.span([ vector(QQ, [0, 1, 0, 1]),
vector(QQ, [1, 0, 1, 0]) ])
vecs = [(i, W.random_element()) for i in range(100)]
xxxxxxxxxx
Sequence(vecs, cr=True) # random
xxxxxxxxxx
V = QQ^4
W = V.span([ vector(QQ, [0, 1, 1, 0]),
vector(QQ, [0, 0, 1, 1]) ])
vecs = [(i, W.random_element()) for i in range(100)]
xxxxxxxxxx
Sequence(vecs, cr=True) # random
xxxxxxxxxx
V = QQ^4
W = V.span([ vector(QQ, [2, 1, 2, 1]),
vector(QQ, [4, 2, 4, 2]) ])
vecs = [(i, W.random_element()) for i in range(100)]
xxxxxxxxxx
Sequence(vecs, cr=True) # random
xxxxxxxxxx
V = QQ^4
W = V.span([ vector(QQ, [1, 0, 0, 0]),
vector(QQ, [0, 1 ,0, 0]),
vector(QQ, [0, 0, 1, 0]),
vector(QQ, [0, 0, 0, 1]) ])
vecs = [(i, W.random_element()) for i in range(100)]
xxxxxxxxxx
Sequence(vecs, cr=True) # random
xxxxxxxxxx
V = QQ^4
W = V.span([ vector(QQ, [1, 2, 3, 4]),
vector(QQ, [0,-1, -1, 0]),
vector(QQ, [1, 1, 2, 4]) ])
vecs = [(i, W.random_element()) for i in range(100)]
xxxxxxxxxx
Sequence(vecs, cr=True) # random
.columns()
to get all of the columns into a list at once.xxxxxxxxxx
coeff = matrix(QQ, [[33, -16, 10, -2],
[99, -47, 27, -7],
[78, -36, 17, -6],
[-9, 2, 3, 4]])
column_list = coeff.columns()
column_list
xxxxxxxxxx
span = (QQ^4).span(column_list)
const = vector(QQ, [-27, -77, -52, 5])
const in span
coeff
is trivial, just the zero vector.xxxxxxxxxx
nsp = coeff.right_kernel(basis='pivot')
nsp.list()
.right_kernel()
method for matrices. We use the optional argument basis='pivot'
, so we get exactly the spanning set xxxxxxxxxx
A = matrix(QQ, [[ 1, 3, 3, -1, -5],
[ 2, 5, 7, 1, 1],
[ 1, 1, 5, 1, 5],
[-1, -4, -2, 0, 4]])
nsp = A.right_kernel(basis='pivot')
N = nsp.basis()
N
xxxxxxxxxx
z1 = N[0]
z2 = N[1]
z = 4*z1 +(-3)*z2
z
xxxxxxxxxx
z in nsp
xxxxxxxxxx
sum([z[i]*A.column(i) for i in range(A.ncols())])
nsp
, and then asked for its .basis()
. For now, a βbasisβ will give us a spanning set, and with more theory we will understand it better. This is a set of vectors that form a spanning set for the null space, and with the basis='pivot'
argument we have asked for the spanning set in the format described in Theorem SSNS. The spanning set N
is a list of vectors, which we have extracted and named as z1
and z2
. The linear combination of these two vectors, named z
, will also be in the null space since N
is a spanning set for nsp
. As verification, we have used the five entries of z
in a linear combination of the columns of A
, yielding the zero vector (with four entries) as we expect.z
is in nsp
:xxxxxxxxxx
z in nsp
dimension
should wait for a bit. But you will notice now that the Basis matrix
has been replaced by User basis matrix
. This is a consequence of our request for something other than the default basis (the 'pivot'
basis). As part of its standard information about a null space, or a span, Sage spits out the basis matrix. This is a matrix, whose rows are vectors in a spanning set. This matrix can be requested by itself, using the method .basis_matrix()
. It is important to notice that this is very different than the output of .basis()
which is a list of vectors. The two objects print very similarly, but even this is different β compare the organization of the brackets and parentheses. Finally the last command should print true for any span or null space Sage creates. If you rerun the commands below, be sure the null space nsp
is defined from the code just above.xxxxxxxxxx
nsp
xxxxxxxxxx
nsp.basis_matrix()
xxxxxxxxxx
nsp.basis()
xxxxxxxxxx
nsp.basis() == nsp.basis_matrix().rows()
.solve_right()
method of a coefficient matrix, once supplied with the vector of constants. The vectors .right_kernel(basis='pivot')
method applied to the coefficient matrix. Theorem PSPHS amplifies and generalizes this discussion, making it clear that the choice of the particular particular solution xxxxxxxxxx
coeff = matrix(QQ, [[ 1, 4, 0, -1, 0, 7, -9],
[ 2, 8, -1, 3, 9, -13, 7],
[ 0, 0, 2, -3, -4, 12, -8],
[-1, -4, 2, 4, 8, -31, 37]])
n = coeff.ncols()
const = vector(QQ, [3, 9, 1, 4])
c = coeff.solve_right(const)
c
xxxxxxxxxx
N = coeff.right_kernel(basis='pivot').basis()
z1 = N[0]
z2 = N[1]
z3 = N[2]
z4 = N[3]
soln = c + 2*z1 - 3*z2 - 5*z3 + 8*z4
soln
xxxxxxxxxx
check = sum([soln[i]*coeff.column(i) for i in range(n)])
check
xxxxxxxxxx
check == const
soln
and add a linear combination of the spanning set for the null space to create another solution (which you can check).