The dot product, also known as the scalar product, is a fundamental operation in linear algebra that takes two vectors and returns a single scalar value.
There are two primary ways to define the dot product:
- Algebraically, using the coordinates of the vectors
- Geometrically, using their magnitudes and the angle between them
While presented differently, these two definitions are equivalent in standard Euclidean space (like the familiar 2D plane or 3D space).
Coordinate Definition
Per the coordinate or algebraic definition, the dot product is the sum of the products of the corresponding entries of two vectors of numbers.
For example, given vectors \(\vec{a}\) and \(\vec{b}\): \[ \vec{a} = (a_1, a_2, ..., a_n) \qquad \vec{b} = (b_1, b_2, ... b_n) \] The dot product is defined as: \[ \vec{a} \cdot \vec{b} = \sum_{i=1}^n a_i b_i = a_1b_1 + a_2b_2 + \; ... \; + a_nb_n \] Where \(n\) denotes the dimension of the vector space.
For example, given two vectors \(\vec{v}\) and \(\vec{w}\) in \(\mathbb{R}^3\): \[ \vec{v} = (3, 1, 2) \qquad \vec{w} = (-1, 4, 3) \] Their dot product is: \[ \vec{v} \cdot \vec{w} = (3)(-1) + (1)(4) + (2)(3) = -3 + 4 + 6 = 7 \] Note that the result of this operation is scalar, not a vector, hence, the dot product is sometimes called the scalar product.
Properties
The dot product is commutative: \[ \vec{a} \cdot \vec{b} = \vec{b} \cdot \vec{a} \] It is distributive: \[ \vec{a} \cdot (\vec{b} + \vec{c}) = (\vec{a} \cdot \vec{b}) + (\vec{a} \cdot \vec{c}) \] It is associative with respect to scalar multiplication: \[ (c\vec{a}) \cdot \vec{b} = c(\vec{a} \cdot \vec{b}) = \vec{a} \cdot (c\vec{b}) \] The dot product of a vector with itself is its Euclidean length squared: \[ \vec{a} \cdot \vec{a} = \Vert \vec{a} \Vert ^2 \] The dot product involving a zero vector (a vector where all its components are zero) is 0: \[ \vec{0} \cdot \vec{a} = 0 \]
Euclidean Length
The formula for the Euclidean length (norm/magnitude) of a vector is: \[ \Vert \vec{a} \Vert = \sqrt{\vec{a} \cdot \vec{a}} \] This is equivalent to the following formula for a vector \(\vec{v}\) in \(\mathbb{R}^n\): \[ \Vert \vec{v} \Vert = \sqrt{(\vec{v}_1)^2 + (\vec{v}_2)^2 + \; ... \; + (\vec{v}_n)^2} \]
Geometric Definition
Per the geometric definition, the dot product of two Euclidean vectors \(\vec{a}\) and \(\vec{b}\) is defined by: \[ \vec{a} \cdot \vec{b} = \Vert \vec{a} \Vert \; \Vert \vec{b} \Vert \; \cos\theta \] Where \(\lVert \vec{a} \lVert\) and \(\lVert \vec{b} \lVert\) are the magnitude (Euclidean length) of \(\vec{a}\) and \(\vec{b}\), respectively, and \(\theta\) is the angle between \(\vec{a}\) and \(\vec{b}\)
Scalar Projection & Similarity
Given two vectors \(\vec{a}\) and \(\vec{b}\), imagine projecting \(\vec{a}\) onto the line that passes through the origin and the tip of \(\vec{b}\). The length of this projection is given by: \[ \Vert \vec{a} \Vert \; \cos \theta \] where \(\theta\) is the angle between the two vectors. This is called the scalar projection.
Multiplying the length of this scalar projection by the length of \(\vec{b}\) gives the dot product: \[ \Vert \vec{a} \Vert \; \Vert \vec{b} \Vert \;\cos \theta \] If the projection of \(\vec{a}\) is pointing in the opposite direction from \(\vec{b}\) the dot product will be negative.
Stated explicitly:
- When two vectors generally point in the same direction, their dot product is positive.
- When two vectors are perpendicular (orthogonal), their dot product is 0.
- When two vectors generally point in opposite directions, their dot product is negative.
Orthogonal Vectors
Two non-zero vectors \(\vec{a}\) and \(\vec{b}\) are orthogonal if and only if \(\vec{a} \cdot \vec{b} = 0\).
For example, vectors \(\vec{v}\) and \(\vec{w}\) are orthogonal: \[ \vec{v} = (-1, 5) \qquad \vec{w} = (5, 1) \] \[ \vec{v} \cdot \vec{w} = (-1)(5) + (5)(1) = -5 + 5 = 0 \]
Find the Angle Between Two Vectors
The following assumes that both \(\vec{a}\) and \(\vec{b}\) are not zero vectors since you can not divide by zero magnitude: \[ \vec{a} \cdot \vec{b} = \Vert \vec{a} \Vert \; \Vert \vec{b} \Vert \; \cos \theta \] \[ \cos \theta = \frac{\vec{a} \cdot \vec{b}}{\Vert \vec{a} \Vert \; \Vert \vec{b} \Vert} \] \[ \theta = \arccos(\cos \theta) \]