Section 5.2 Dot and Cross Products
Vectors do also support non-arithmetic operations, and operations that apply to the vector itself and its components.
The dot product of two vectors \(v=(v_1, v_2, ..., v_n)\) and \(w=(w_1, w_2, ..., w_n)\) is defined as the sum of the products of their corresponding components \(v \cdot w = w \cdot v = \sum_{i=1}^n v_i w_i\text{.}\)
Observe that the dot product of two vectors produces a scalar (a single number), not a vector. Also, note that the dot product in Sage is implemented in two ways:
we can also compute the dot product manually by its definition
The cross product of two vectors \(v=(v_1, v_2, v_3)\) and \(w=(w_1, w_2, w_3)\) is defined as the vector whose components are given by \(v \times w = (v_2 w_3 - v_3 w_2, v_3 w_1 - v_1 w_3, v_1 w_2 - v_2 w_1)\text{.}\) In Sage, the cross product is calculated using the
cross_product
method.