It is possible to construct vector spaces several ways in Sage. For now, we will show you two basic ways. Remember that while our theory is all developed over the complex numbers, $\complexes$, it is better to initially illustrate these ideas in Sage using the rationals, QQ.
To create a vector space, we use the VectorSpace() constructor, which requires the name of the number system for the entries and the number of entries in each vector. We can display some information about the vector space, and with tab-completion you can see what functions are available. We will not do too much with these methods immediately, but instead learn about them as we progress through the theory.
Notice that the word “dimension” is used to refer to the number of entries in a vector contained in the vector space, whereas we have used the word “degree” before. Try pressing the Tab key while in the next cell to see the range of methods you can use on a vector space.
We can easily create “random” elements of any vector space, much as we did earlier for the kernel of a matrix. Try executing the next compute cell several times.
Vector spaces are a fundamental objects in Sage and in mathematics, and Sage has a nice compact way to create them, mimicking the notation we use when working on paper.
Sage can determine if two vector spaces are the same. Notice that we use two equals sign to test equality, since we use a single equals sign to make assignments.