Even though these are quite concepts that can be defined for a general vector space, let's define these first in $\R^{2}$.

## Length

The length of a vector $\vec v = \left[\begin{array}{c}x\\y\\z\end{array}\right]$ is given by $||\vec v|| = \sqrt{x^2 + y^2 + z^2}$

To define distance between points, it is useful to keep in mind this picture that relates points to vectors: ## Distance

The distance between two points $P_1 = (x_1, y_1, z_1)$ and $P_2 = (x_2, y_2, z_2)$ is given by

$\|\vec p_2 - \vec p_1\| = \sqrt{(x_2-x_1)^2 +(y_2-y_1)^2 + (z_2-z_1)^2}$

## Dot Product

The dot product of two vectors $\left[\begin{array}{c}x_1\\y_1\\z_1\end{array}\right]$ and $\vec v_2 = \left[\begin{array}{c}x_2\\y_2\\z_2\end{array}\right]$ is defined as

$\vec v_1 \cdot \vec v_2 = x_1 x_2 + y_1 y_2 + z_1 z_2$

A couple things to note:

• Dot product is related to length
$\vec v \cdot \vec v = x^2 + y^2 + z^2 = \|\vec v\|^2$
• Dot product is related to angle
$\vec v_1 \cdot \vec v_2 = \|\vec v_1\|\|\vec v_2\| \cos{\theta}$ where $\theta$ is the angle between $\vec v_1$ and $\vec v_2$

The proof of this last equation involves a trigonometric identity (the Law of Cosines) that I can never really remember. However, to get some idea why there is a relationship between dot product and angles, let's try to determine a test to see whether two vectors $\vec v_1$ and $\vec v_2$ are perpendicular. If they are perpendicular, then by Pythagoras, $\|\vec v_1\|^2 + \|\vec v_2\|^2 = \|\vec v_2 - \vec v_1\|^2$. Applying the length formula, this becomes

$(x_1^2 + y_1^2+ z_1^2) + (x_2^2 + y_2^2 + z_2^2) = (x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2$ Expanding out and canceling, we get that the test for perpendicularity is given by

$x_1 x_2 + y_1 y_2 + z_1 z_2 = 0 \Longrightarrow \vec v_1 \cdot \vec v_2 = 0$ This is consistent with the equation above since $\cos 90^{\circ} = 0$.