The Dot Product through Linear Transformations
This post was inspired by 3blue1brown’s video on the dot product. Here I explain his derivation, adding interactive Desmos graph to further explore the ideas.
Motivation
The big question is, how do we know how much one vector lies in the direction of another? For example, consider the following example where three vectors are compared to $\vec{u}=(4,3)$. $\vec{v_1}$ is pointing in about the same direction, $\vec{v_2}$ is at $90^{\circ}$ to $\vec{u}$, and $\vec{v_3}$ is in a very different direction than $\vec{u}$. Click the buttons on the graph below to see.
Drawing the vectors out, it’s clear that some have different directions. But how can we put numbers to this? That’s the idea: quantify how much two vectors are pointing in the same direction.
Projecting onto a line
The idea with this approach is that we will measure how much one vector lies in the direction of another. This geometrically looks like projecting one vector onto another. First consider the vector $\vv$. Now draw a number line that points in the same direction as $\vv$. This happens to lie on its span. Now, consider the vector $\vu$. Looking at the plane, we can draw a perpendicular line that projects $\vu$ onto the span of $\vv$. Let the projection of $\vu$ onto $\vv$ be $\puv$.
Note that while the number line lies on the span of $\vv$, the projections onto the number line are still real numbers in $\mathbb{R}$.
The whole point is that when $\vu$ and $\vv$ point in the about the same direction, $\puv$ is big and positive. When they point in opposite directions, $\puv$ is big and negative. This matches the intuition from earlier.
Notice that this defines a transformation (a function) from $\vu$ to a number on the number line. This transformation is $\mathbb{R}^2 \to \mathbb{R}$. It is also linear. But how? A neat (albeit not rigorous) way to tell if a transformation is linear to ask whether any straight line of evenly spaced dots remains straight and evenly spaced.
Play around with the graph below to see why projections match the intuition and make sense to describe how much two vectors lie in the same direction.
The point of all this is that $\vu\rightarrow\puv$ is a linear transformation. Like any linear transformation, if we can figure out where $\ihat$ and $\jhat$ land on the number line, that matrix completely describes how to get $\puv$.
Unit Vectors
Now we will find where $\ihat$ lands, which is the projection of $\ihat$ onto $\vu$. To begin, consider the unit vector $\uhat$. $\vu$ is any vector on the unit circle.