# 6.04: Direction Cosines

- Page ID
- 9971

## Unit Vectors

Corresponding to every vector \(x\) is a unit vector \(u_x\) pointing in the same direction as \(x\). The term unit vector means that the norm of the vector is 1:

\[||u_x||=1\]

The question is, given \(x\), how can we find \(u_x\)? The first part of the answer is that \(u_x\) will have to be a positive scalar multiple of \(x\) in order to point in the same direction as \(x\), as shown in this Figure. Thus

\[u_x=αx\]

But what is \(α\)? We need to choose \(α\) so that the norm of \(u_x\) will be 1:

\[||ux||=1\]

\[|αx||=1\]

\[|α|||x||=1\]

\[α=\frac {1} {||x||}\]

We have dropped the absolute value bars on \(α\) because \(||x||\) is positive. The \(α\) that does the job is 1 over the norm of \(x\). Now we can write formulas for \(u_x\) in terms of \(x\) and \(x\) in terms of \(u_x\):

\[u_x=\frac 1 {||x||}x\]

\[x=||x||u_x\]

So the vector \(x\) is its direction vector \(u_x\), scaled by its Euclidean norm.

## Unit Coordinate Vectors

There is a special set of unit vectors called the unit coordinate vectors. The *unit coordinate vector* \(e_i\) is a unit vector in \(∇^n\) that points in the positive direction of the \(i^{\mathrm{th}}\) coordinate axis. The Figure shows the three unit coordinate vectors in \(∇^3\).

For three-dimensional space, \(R^3\), the unit coordinate vectors are

\[e_1=\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix},e_2=\begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix}, e_3=\begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix}\]

More generally, in n-dimensional space, there are \(n\) unit coordinate vectors given by

You should satisfy yourself that this definition results in vectors with a norm of l.

Exercise \(\PageIndex{1}\)

Find the norm of the vector au where \(u\) is a unit vector.

Exercise \(\PageIndex{2}\)

Find the unit vector \(u_x\) in the direction of

- \(x=\begin{bmatrix} 3 \\ 4 \end{bmatrix}\)
- \(x=\begin{bmatrix} 3 \\ 6 \\ −2 \end{bmatrix}\)
- \(x=\begin{bmatrix} 1 \\ −1 \\ 1 \\ −1 \end{bmatrix}\)

## Direction Cosines

We often say that vectors “have magnitude and direction.” This is more or less obvious from "Linear Algebra: Vectors", where the three-dimensional vector \(x\) has length \(\sqrt{x^2_1+x^2_2+x^2_3}\) and points in a direction defined by the components \(x_1\), \(x_2\), and \(x_3\). It is perfectly obvious from Equation \(\PageIndex{8}\) where \(x\) is written as \(x=||x||\,u_x\). But perhaps there is another representation for a vector that places the notion of magnitude and direction in even clearer evidence.

The Figure below shows an arbitrary vector \(x∈R^3\) and the three-dimensional unit coordinate vectors \(e_1,e_2,e_3\). The inner product between the vector \(x\) and the unit vector \(e_k\) just reads out the \(k^\mathrm{th}\) component of \(x\):

\[(x,e_k)=(e_k,x)=x_k\]

Since this is true even in \(R^n\), any vector \(x∈R^n\) has the following representation in terms of unit vectors:

\[x=(x,e_1)e_1+(x,e_2)e_2+⋯+(x,e_n)e_n\]

Let us now generalize our notion of an angle \(θ\) between two vectors to \(R^n\) as follows:

\[\cosθ=\frac {(x,y)} {||x||||y||}\]

The celebrated Cauchy-Schwarz inequality establishes that \(−1−≤ \cos θ≤1\). With this definition of angle, we may define the angle \(θ_k\) that a vector makes with the unit vector \(e_k\) to be

\[\cosθ_k=\frac {(x,e_k)} {||x||||ek||}\]

But the norm of \(e_k\) is 1, so

\[\cosθ_k=\frac {(x,ek)} {||x||}=\frac {x_k} {||x||}\]

When this result is substituted into the representation of x in Equation \(\PageIndex{11}\), we obtain the formula

\[x=||x||\cosθ_1e_1+||x||\cosθ_2e_2+⋯+||x||\cosθ_ne_n=||x||(\cosθ_1e_1+\cosθ_2e_2+⋯+\cosθ_ne_n)\]

This formula really shows that the vector \(x\) has “magnitude” \(||x||\) and direction \((θ_1,θ_2,...,θ_n)\) and that the magnitude and direction are sufficient to determine \(x\). We call (\(\cosθ_1, \cos θ_2,..., \cos θ_n\)) the direction cosines for the vector \(x\). In the three-dimensional case, they are illustrated in the Figure above.

Exercise \(\PageIndex{3}\)

Show that Equation \(\PageIndex{12}\) agrees with the usual definition of an angle in two dimensions.

Exercise \(\PageIndex{4}\)

Find the cosine of the angle between \(x\) and \(y\) where

- \(x=\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix}\;y=\begin{bmatrix} 2 \\ 2 \\ 2 \end{bmatrix}\)
- \(x=\begin{bmatrix} 1 \\ −1 \\ 1 \\ −1 \end{bmatrix}\;y=\begin{bmatrix} −1 \\ 0 \\ 1 \\ 0 \end{bmatrix}\)
- \(x=\begin{bmatrix} 2 \\ 1 \\ −2 \end{bmatrix}\;y=\begin{bmatrix} 4 \\ 2 \\ −4 \end{bmatrix}\)

If we compare Equation \(\PageIndex{8}\) and Equation \(\PageIndex{15}\) we see that the direction vector \(u_x\) is composed of direction cosines: