Skip to content

Sixian Li

Dot products and projections

Linear Algebra

Last year, I watched 3Blue1Brown’s video of dot products, but I only had a vague idea about their connection to projections. However, dot products showed up again and again in my math courses, so I decided to rewatch it. To my relief, it makes much more sense after MATH223, and the connection is indeed “truly awesome” as 3B1B said in the video. Now, I’m going to reconstruct the whole idea to deepen my understanding. I created images with the help of Mathcha, an online math editor.

Multiplying a 1×21\times 2 matrix [uxuy]\begin{bmatrix} u_{x} & u_{y} \end{bmatrix} with a 2D(2×12\times 1) vector [x y]\begin{bmatrix} x\ y \end{bmatrix} gives us a 1×11\times 1 scalar value s = uxx +uyy.s\ =\ u_{x} x\ +u_{y} y.We interpret this as “transforming any 2D vector to a point on the 1D number line”. Although this numerical value is just from the familiar matrix-vector multiplication, its geometric meaning is exciting. Questions What does multiplying by [uxuy]\begin{bmatrix} u_{x} & u_{y} \end{bmatrix} mean geometrically? How is this related to taking the dot product with the vector [ux uy]\begin{bmatrix} u_{x}\ u_{y} \end{bmatrix}? Imgur

Let i, j\vec{i} ,\ \vec{j} be unit vectors in R2\mathbb{R}^{2}, and let u =[ux uy]\vec{u} \ =\begin{bmatrix} u_{x}\ u_{y} \end{bmatrix} be a unit vector on line LL.


But  proji u | \ proj_{\vec{i}} \ \vec{u} \ | is just the x-coordinate of u, ux\vec{u} ,\ u_{x}. Now, if we want to know the orthogonal projection of any vector in R2\mathbb{R}^{2} onto line LL, we only need to find where i , j\vec{i} \ ,\ \vec{j} land. Note: The projection outputs a scalar, the orange dot on the number line, not a 2D vector lying on the line. What we get is the component of a vector in the direction u\vec{u}. Define the transformation T: R2RT:\ \mathbb{R}^{2}\rightarrow \mathbb{R} as T([xy])=[uxuy][xy]\begin{aligned}T(\begin{bmatrix}x \\ y\end{bmatrix}) =\begin{bmatrix}u_{x} & u_{y}\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}\end{aligned}

which is the orthogonal projection onto line LL. First, is it linear? Let v, w R2,c R.\vec{v} ,\ \vec{w} \ \in \mathbb{R}^{2} , c\ \in \mathbb{R} . T(0) = [uxuy][00] = 0T(cv+w)= [uxuy][cvx+wxcvy+wy]= ux(cvx+wx) + uy(cvy+wy)= cvxux + cvyuy+ uxwx +uywycT(v)+T(w)=c [uxuy][vxvy] + [uxuy][wxwy]= c(uxvx+uyvy) + (uxwx+uywy)\begin{aligned} T(\vec{0}) \ & =\ \begin{bmatrix} u_{x} & u_{y} \end{bmatrix}\begin{bmatrix} 0\\ 0 \end{bmatrix} \ =\ 0\\ & \\ T( c\vec{v} +\vec{w}) & =\ \begin{bmatrix} u_{x} & u_{y} \end{bmatrix}\begin{bmatrix} cv_{x} +w_{x}\\ cv_{y} +w_{y} \end{bmatrix}\\ & =\ u_{x}( cv_{x} +w_{x}) \ +\ u_{y}( cv_{y} +w_{y})\\ & =\ cv_{x} u_{x} \ +\ cv_{y} u_{y} +\ u_{x} w_{x} \ +u_{y} w_{y}\\ & \\ cT(\vec{v}) +T(\vec{w}) & =c\ \begin{bmatrix} u_{x} & u_{y} \end{bmatrix}\begin{bmatrix} v_{x}\\ v_{y} \end{bmatrix} \ +\ \begin{bmatrix} u_{x} & u_{y} \end{bmatrix}\begin{bmatrix} w_{x}\\ w_{y} \end{bmatrix}\\ & =\ c( u_{x} v_{x} +u_{y} v_{y}) \ +\ ( u_{x} w_{x} +u_{y} w_{y)} \end{aligned}

It is easy to see that (1) = (2), so it is linear. For any vector [xy]R2,\begin{bmatrix} x\\y \end{bmatrix} \in \mathbb{R}^{2} , T([xy])=T(xi +yj)= xT(i)+yT(j)= xux + yuy\begin{aligned}T\left(\begin{bmatrix}x\\y\end{bmatrix}\right) &=T\left( x\vec{i} \ +y\vec{j}\right) &=\ xT\left(\vec{i}\right) +yT\left(\vec{j}\right) &=\ xu_{x} \ +\ yu_{y}\end{aligned} which is the same as taking the dot product [x y][ux uy]\begin{bmatrix} x\ y \end{bmatrix} \cdot \begin{bmatrix} u_{x}\ u_{y} \end{bmatrix}. What if u\vec{u} is not the unit vector? Then the unit vector will be u1 u \vec{u}\frac{1}{||\ \vec{u} \ ||}. So our matrix encoding the projection is now [ux u uy u ]\begin{bmatrix} \frac{u_{x}}{||\ \vec{u} \ ||} & \frac{u_{y}}{||\ \vec{u} \ ||} \end{bmatrix}. T([xy]) =xux u  + yuy u  u  T([xy]) =xux + yuy\begin{aligned}T\left(\begin{bmatrix}x\\y\end{bmatrix}\right) \ & =\frac{xu_{x}}{||\ \vec{u} \ ||} \ +\ \frac{yu_{y}}{||\ \vec{u} \ ||}\\ ||\ \vec{u} \ ||\ T\left(\begin{bmatrix}x\\y\end{bmatrix}\right) \ & =xu_{x} \ +\ yu_{y}\end{aligned}\\ The left hand is multiplying the projection of [x y]\begin{bmatrix} x\ y \end{bmatrix} onto LL by the length of u\vec{u}, and the right hand side is [x y][ux uy]\begin{bmatrix} x\ y \end{bmatrix} \cdot \begin{bmatrix} u_{x}\ u_{y} \end{bmatrix}

It is time to answer our questions:

  • Geometrically, multiplying by [uxuy]\begin{bmatrix} u_{x} & u_{y} \end{bmatrix} is the same as finding the component of any vector in direction u =[ux uy]\vec{u} \ =\begin{bmatrix} u_{x}\ u_{y} \end{bmatrix} and scaling by u| \vec{u} |. The lengthy version: projecting one vector onto the other one and multiplying by the length of the one being projected onto.
  • Applying this transformation gives us the same result as taking the dot product with u\vec{u}. This association is what he mentioned in the video as “duality”, a fascinating concept in math, so it’s definitely worth watching. Thanks again for the inspiration.