---
# System prepended metadata

title: Untitled

---

## Orthogonal Projections
### By Orion Sinacori

Orthogonal vectors in linear algebra are useful tools that allow us to find distances of different vectors or project a vector along a line in the direction of a different vector. To use this tool we will first need to understand what it means to be orthogonal. When working with vectors, two vectors are orthogonal if they are perpendicular to each other such as the identity matrix. We can also say that two vectors are orthogonal if their dot product is equal to 0. For example, we can say that the set $\{\begin{bmatrix}
-1\\ 5\\ -3\\
\end{bmatrix},
\begin{bmatrix} -1\\ 1\\ 2\\
\end{bmatrix}\}$ is orthogonal since $(-1 \times -1) + (5 \times 1) + (-3 \times 2) = 0$. 

Now that we know what it means to be orthogonal, we can learn about orthogonal projections. To find an orthogonal projection of a vector $\vec{y}$ along a line $L$ in the direction of $\vec{u}$ is $\widehat{\vec{y}} = \text{proj}_\vec{u}\vec{y} = \frac{\vec{y}\cdot \vec{u}}{\vec{u} \cdot \vec{u}} \vec{u}$. To put this into perspective, lets think of it geometrically. Imagine you are standing in the middle of a room and the bottom right corner of the room is the origin. From the origin to your head will be the vector $\vec{y}$ and the the line along the floor going to the left of the origin will be the vector $\vec{u}$. What the equation above does is take the vector to your head or $\vec{y}$ and projects it onto the floor or $\vec{u}$ as if there was a straight line running from your head to the line on the floor that is orthogonal to $\vec{u}$. From the origin to the point where that new line from your head meets the line on the floor is called $\widehat{\vec{y}}$. We can also say that the vector from your head following the line to the floor is called $\vec{z}$ which is orthogonal to $\vec{u}$ and the magnitude of this vector is the distance from $\vec{y}$ and $\widehat{\vec{y}}$.

Now we can work through an example. Find the distance from $\vec{y} = \begin{bmatrix} 6\\ -2\\
\end{bmatrix}$ to the line in the direction of $\vec{u} = \begin{bmatrix} 2\\ 1\\
\end{bmatrix}$.

First we need to find $\widehat{\vec{y}}$.

$\begin{align*}
\text{proj}_{\vec{u}}\vec{y} & = \frac{\vec{y}\cdot \vec{u}}{\vec{u} \cdot \vec{u}} \vec{u}\\
& = \frac{\begin{bmatrix} 
6\\ -2\\
\end{bmatrix} \cdot \begin{bmatrix}
2\\ 1\\
\end{bmatrix}}{\begin{bmatrix}
2\\ 1\\
\end{bmatrix} \cdot \begin{bmatrix}
2\\ 1\\
\end{bmatrix}} \begin{bmatrix}
2\\ 1\\
\end{bmatrix}\\
& = \frac{10}{5} \begin{bmatrix}
2\\ 1\\
\end{bmatrix}\\
& = 2\begin{bmatrix}
2\\ 1\\
\end{bmatrix}\\
& = \begin{bmatrix}
4\\ 2\\
\end{bmatrix}
\end{align*}$

Now that we have $\widehat{\vec{y}}$ we can calculate the distance from $\vec{y}$ to $\widehat{\vec{y}}$. To find $\vec{z}$ we can use the formula $\vec{y} = \widehat{\vec{y}} + \vec{z}$. If we subtract $\widehat{\vec{y}}$ from both sides we get $\vec{y} - \widehat{\vec{y}} = \vec{z}$. Notice:

$\begin{align*}
\vec{z} & = \begin{bmatrix} 
6\\ -2\\
\end{bmatrix} - \begin{bmatrix} 
4\\ 2\\
\end{bmatrix}\\ 
& = \begin{bmatrix} 
2\\ -4\\
\end{bmatrix}
\end{align*}$

Now we can find the magnitude of $\vec{z}$ to give us our distance. $\sqrt{(2\times2) + (-4 \times -4)} = \sqrt{20} = 2 \sqrt{5}$. Thus $2 \sqrt{5}$ is the distance between $\vec{y}$ and $\widehat{\vec{y}}$.

For further practice, find the distance from $\vec{y} = \begin{bmatrix} 
2\\ -4\\ 1\\
\end{bmatrix}$ to the line in the direction of $\vec{u} = \begin{bmatrix} 
2\\ 1\\ 1\\
\end{bmatrix}$.