Vector Operations
Vectors define several operations:
- Addition
-
Two vectors can be added, denoted by \(\mathbf{z} = \mathbf{x} + \mathbf{y}\). Both vectors must be the same length, and vector addition adds the corresponding elements of each vector to produce a new vector (\(z_i = x_i + y_i\)).
Vectors can also be added to a scalar, as in \(\mathbf{z} = \mathbf{x} + y\), in which case \(y\) is added to each element of \(\mathbf{x}\).
- Scalar multiplication
-
A vector \(\mathbf{x}\) can be multipled by a scalar \(\alpha \in \Reals\), denoted \(\mathbf{y} = \alpha\mathbf{x}\). This is defined by multipling each element of the vector by the scalar, so \(y_i = \alpha x_i\).
Addition and scalar multiplication combine to support subraction (\(\mathbf{x} - \mathbf{y}\)).
- Inner product
-
The inner product or dot product of two vectors, denoted \(\mathbf{x} \cdot \mathbf{y}\), is the sum of the products of the corresponding pairs of elements:
\[\mathbf{x} \cdot \mathbf{y} = \sum_i x_i y_i\]
Note that “multiplication” is not a supported operation for vectors. Array-oriented programming environments such as NumPy, R, and Matlab implement array multiplication arr1 * arr2 that multiplies the elements pairwise to produce a new vector of the same length, analogous to vector addition. This pairwise multiplication is a very useful operation in many contexts, but it is not a defined operator in linear algebra.