We can use the Sage tools we already have, along with
Theorem LIVRN, to determine if sets are linearly independent. There is just one hitch — Sage has a preference for placing vectors into matrices as
rows, rather than as columns. When printing vectors on the screen, writing them
across the screen makes good sense, and there are more mathematical reasons for this choice. But we have chosen to present introductory linear algebra with an emphasis on the
columns of matrices — again, for good mathematical reasons. Fortunately, Sage allows us to build matrices from columns as well as rows.
Let us redo
Example LDHS, the determination that a set of three vectors is linearly dependent. We will enter the vectors, construct a matrix with the vectors as
columns via the
column_matrix()
constructor, and analyze. Here we go.
Notice that we never explicitly row-reduce
A
, though this computation must happen behind the scenes when we compute the list of pivot columns. We do not really care
where the pivots are (the actual list), but rather we want to know
how many there are, thus we ask about the
length of the list with the function
len()
. Once we construct the matrix, the analysis is quick. With
\(n\neq r\text{,}\) Theorem LIVRN tells us the set is linearly dependent.
Reprising
Example LIS with Sage would be good practice at this point. Here is an empty compute cell to use.
While it is extremely important to understand the approach outlined above, Sage has a convenient tool for working with linear independence. .linear_dependence()
is a method for vector spaces, which we feed in a list of vectors. The output is again a list of vectors, each one containing the scalars that yield a nontrivial relation of linear dependence on the input vectors. We will give this method a workout in the next section, but for now we are interested in the case of a linearly independent set. In this instance, the method will return nothing (an empty list, really). Not even the all-zero vector is produced, since it is not interesting and definitely is not surprising.
Again, we will not say anymore about the output of this method until the next section, and do not let its use replace a good conceptual understanding of this section. We will redo
Example LDHS again, you try
Example LIS again. If you are playing along, be sure
v1, v2, v3
are defined from the code above.
The only comment to make here is that we need to create the vector space
QQ^5
since
.linear_dependence()
is a method of vector spaces.
Example LIS should proceed similarly, though being a linearly independent set, the comparison with the empty list should yield
True
.