Definition B. Basis.
Suppose \(V\) is a vector space. Then a subset \(S\subseteq V\) is a basis of \(V\) if it is linearly independent and spans \(V\text{.}\)
.basis()
, and the result is a list of vectors. Another method for a vector space is .basis_matrix()
which outputs a matrix whose rows are the vectors of a basis. Sometimes one form is more convenient than the other, but notice that the description of a vector space chooses to print the basis matrix (since its display is just a bit easier to read). A vector space typically has many bases (infinitely many), so which one does Sage use? You will notice that the basis matrices displayed are in reduced row-echelon form — this is the defining property of the basis chosen by Sage.
basis='pivot'
keyword when we construct null spaces. This is because we initially prefer to see the basis described in Theorem BNS, rather than Sage’s default basis, the echelonized version. But the echelonized version is always present and available.
v1
and v2
are linearly independent and thus span a subspace with a basis of size 2. We first create this subspace and let Sage determine the basis, then we illustrate a new vector space method, .subspace_with_basis()
, that allows us to specify the basis. (This method is very similar to .span_of_basis()
, except it preserves a subspace relationship with the original vector space.) Notice how the description of the vector space makes it clear that W
has a user-specified basis. Notice too that the actual subspace created is the same in both cases.
.coordinate_vector(v)
computes a vector whose entries express v
as a linear combination of basis vectors. Verify for yourself in each case below that the components of the vector returned really give a linear combination of the basis vectors that equals v3
.
QQbar
, the field of algebraic numbers. We form the four vectors of the orthonormal basis, install them as the basis of a vector space and then ask for the coordinates. Sage treats the square roots in the scalars as “symbolic” expressions, so we need to explicitly coerce them into QQbar
before computing the scalar multiples.