Skip to main content

Linear Algebra with SageMath: Learn math with open-source software

Section 5.1 Operations with Vectors

The key detail about a vector is that it provides both a magnitude and a direction in a given space. A vector in \(R^n\) is an ordered collection of \(n\) numbers, represented as \((v_1, v_2, ..., v_n)\text{,}\) where each \(v_i\) is a number in \(R\text{.}\)
The space \(R^n\) refers to an \(n\)-dimensional space where each vector corresponds to a point or a direction. In the two-dimensional space \(R^2\text{,}\) for example, vectors are represented a pair \((x, y)\text{,}\) and in three-dimensional space \(R^3\text{,}\) vectors are represented by triples \((x, y, z)\text{.}\)
In this section, we will see introduce how to perform the arithmetic operations on vectors in Sage.

Subsection 5.1.1 Vector Arithmetic

Vectors can be added and subtracted using the + and - operators. The result of adding or subtracting two vectors is a new vector with the same number of components.
A vector can be multiplied by a scalar using the * operator. The result is a new vector with each component multiplied by the scalar.