Length

As mentioned, vectors have both a direction and a magnitude. The total magnitude of a vector can be calculated as a scalar quite easily.

In the two-dimensional case, the length of a vector $\underline{v}$ is as simple as using the Pythagoras’ theorem as such: $\sqrt{{\underline{v}_1}^2 + {\underline{v}_2}^2}$
In the general case:

\[ |\underline{v}| \equiv \sqrt{\sum_{i=1}^{N} {v_i}^2 } \]

Sometimes, $|\underline{v}|^2$ is used to avoid the square root.
Note that for any vector $\underline{v}$ then $|\underline{v}| \geq 0$

Unit Vector

A unit bector is a vector that has a length 1.
This is denoted as: $\hat{\underline{u}}$

\[ |\underline{\hat{v}}| = 1 \]

In two dimensions, unit vectors can be thought of as arrows that point to the edge of a circle wih a radius equal to 1.

Given any vector $\underline{u}$ (with the excepton of the zero vector):

\[ |\underline{\hat{v}}| = \frac{1}{|\underline{u}|} \underline{u} \]

Dot Product

One of the most important vector operations, the dot product is essentially the multiplication of two vectors.
It holds some interesting properties.

It is defined as so: Given any vector $\underline{u}$ (with the excepton of the zero vector):

\[ \underline{u}^T \cdot \underline{v} \equiv \sum_{i=1}^N u_i v_i \]

Often, this notation is simplified as $\underline{u} \cdot \underline{v}$.

  • $|\underline{u}|^2 = $\underline{u}^T \cdot \underline{u}$
  • $\underline{u}^T \cdot \underline{v} = \underline{v}^T \cdot \underline{u}$
  • $\underline{0}^T \cdot \underline{u} = 0$
  • $a(\underline{u}^T \cdot \underline{v}) = (a\underline{u}_T) \cdot \underline{v}$
  • $(\underline{u} + \underline{v})^T \cdot \underline{w} = \underline{u}^T \cdot \underline{w} + \underline{v}^T \cdot \underline{w}$

Angles

The dot product is quite special as it is related to the angle $\theta$ between the vectors as such:

\[ \underline{u}^T \cdot \underline{v} = |\underline{u}||\underline{v}|\cos(\theta) \]

Remember that $cos(90) = 0$ and $cos(0) = 1$.
This means that when $\theta = 90$ then $\underline{u}^T \cdot \underline{v} = 0$!
Vectors with a dot product of zero are called orthogonal.

If you picture a right-angled triangle, with sides as vectors, $\underline{h}$, $\underline{o}$, $\underline{a}$…

  • $\underline{h} = \underline{a} + \underline{o}$
  • $|\underline{a}| = |\underline{h}|\cos(\theta)$
  • $\underline{a}$ is orthogonal to $\underline{o} \Rightarrow \underline{o}^T \cdot \underline{a} = 0$
  • Any vector can be written as the sum of orthogonal vectors

Projection

The dot product allows us to project vectors on to other vectors.

The projection of $\underline{u}$ onto $\underline{v}$ gives us:

\[ \underline{x} = \frac{ \underline{u} \cdot \underline{v} }{ |\underline{v}|^2 } \underline{v} \]

We use $|\underline{v}|^2$ in the denominator as if you recall, if $\underline{u}$ and $\underline{v}$ are the same then $\underline{u} \cdot \underline{v}$ will give $|u|^2$.
So if we consider that to be the maximum generated by a dot product, it must be divided by that to get the scaling factor to use for our destination vector $\underline{v}$

Projection onto unit vector

If you have a unit vector, projection becomes as simple as merely:

\[ \underline{x} = (\underline{u} \cdot \underline{\hat{v}})\underline{v} \]

This is because with a unit vector, $|\underline{v}|^2 = 1$.

Dimensionality

This ALL generalises to higher dimensions.