Skip to main content

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

Section 5.2 Operations on Vectors

Vectors do also support non-arithmetic operations, and operations that apply to the vector itself and its components. Some of these operations are shown below.

Subsection 5.2.1 Normalized Vector

A normalized vector is a vector that has been scaled to have a norm of 1 (hence the name unit vector). This is often done to simplify calculations or to ensure that the vector represents only a direction without any magnitude. Normalizing a vector involves dividing each component of the vector by its norm (or magnitude).
The normalized vector is a unit vector that points in the same direction as the original vector. Normalizing a vector means scaling it so that it has length \(1\) while preserving its direction. This is useful in applications such as directional vectors, unit vectors, and simplifying computations involving angles or projections.

Subsection 5.2.2 Cross and Dot Products of Vectors

Another form of vector multiplication is the dot product, where two vectors \(v\) and \(w\) are multiplied with each other to produce a scalar value. The dot product of two vectors \(v\) and \(w\) is defined as the sum of the products of their corresponding components. The dot product is commutative and yields a scalar value \(v \cdot w = w \cdot v = \sum_{i=1}^n v_i w_i\text{.}\)
Note that the dot product in Sage is implemented in more than one way. All the following statements are equivalent and produce the same result.
The cross product of two vectors \(v\) and \(w\) is a vector that is perpendicular to both \(v\) and \(w\text{.}\) The cross product is defined only in 3D space and is calculated using the determinant of a matrix formed by the unit vectors \(i, j, k\) and the components of the vectors \(v\) and \(w\text{.}\) In Sage, the cross product is calculated using the cross_product method.

Subsection 5.2.3 Conjugate of a Complex Vector

The complex conjugate of a vector is found by taking the conjugate of each of its components. Note the use of i as the the imaginary number in Sage.