Introduction
In this article, we will study dot product of vectors and its relationship to the magnitude of the vectors and the angle between them. We will visualize these concepts with an interactive demo.
In this article, we will study dot product of vectors and its relationship to the magnitude of the vectors and the angle between them. We will visualize these concepts with an interactive demo.
To understand dot product of vectors, we recommend familiarity with the concepts in
Follow the above links to first get acquainted with the corresponding concepts.
The dot product of two vectors is the sum of the element-wise product of the two vectors. So,
$$ \va \cdot \vb = \sum_{i=1}^n a_i b_i $$
If \( \theta \) is the angle between two vectors \( \va \) and \( \vb \) in the Euclidean space, then \( \va \cdot \vb = ||\va||_2 ||\vb||_2 \cos\theta \).
Note that the unit vectors \( X \) and \( Y \) axes are \( \vx = [0,1] \) and \( \vy = [1,0] \), for the horizontal and vertical axis respectively. Observe that their dot product is zero. That is, \( \vx \cdot \vy = 0 \). No wonder, because the two axes are perpendicular to each other!
Consider the dot product of a vector with itself.
\begin{aligned} \vx \cdot \vx &= ||\vx||_2 ||\vx||_2 \cos 0 \\\\ &= ||\vx||_2 ||\vx||_2 \\\\ &= ||\vx||_{2}^2 \end{aligned}
This is because the angle between a vector and itself is \( 0 \) and \( \cos 0 = 1 \).
So, the dot product of a vector with itself is akin to finding the square of its magnitude. You will see this alternative way of arriving at vector magnitude in a number of places in machine learning literature.
Interact with the next demo to understand how the angle between two vectors relates to their dot products. The angle value varies between 0 and 180 degrees. The normalized product of two vectors is
Understand the effect of superimposing the two vectors, putting them at a right angle, or pointing them in opposite directions.
Now that you dot product and angle between vectors, it is time to build expertise in other topics in linear algebra.
Help us create more engaging and effective content and keep it free of paywalls and advertisements!
Stay up to date with new material for free.