09. Dot product, 1

09. Dot product, 1

Dot product

Given two vectors v = ( v 1 v n ) and w = ( w 1 w n ) in 𝐑 n , what is the angle between them?

To define angles in 𝐑 n , note that the two vectors v and w are contained in a unique 2-plane, and we mean the usual angle between v and w inside that plane.

To measure the angle between vectors in 3D, look inside the unique plane containing them and use the usual definition of angle

To compute that angle, we introduce the dot product v w .

Definition:

The dot product v w is the number v 1 w 1 + + v n w n .

Theorem:

If θ is the angle between v and w then v w = | v | | w | cos θ . Recall that | v | means the length of v .

We will prove this in due course, but first we'll explore it a little.

Let v = ( 1 0 ) and w = ( 0 1 ) . We have v w = 1 × 0 + 0 × 1 = 0 .

The vectors v=(1,0) and w=(0,1) (at right angles)

This makes sense: the angle between v and w is π / 2 radians, and cos ( π / 2 ) = 0 . In this case, we say the vectors are orthogonal to one another (equivalent to "perpendicular" or "at right angles").

Let v = ( 1 1 ) and w = ( 1 0 ) . We can see the angle between them should be 45 degrees ( π / 4 radians).

The vectors v=(1,1) and w=(1,0) (at 45 degrees)

Let's confirm this: we have v w = 1 × 1 + 0 × 1 = 1 . We also have | v | = 1 + 1 = 2 by Pythagoras and | w | = 1 , so 1 = v w = | v | | w | cos θ = 2 cos θ , so cos θ should be 1 / 2 . Indeed, cos ( π / 4 ) = 1 / 2 .

Even if you didn't know the angle, you could figure it out as arccos ( 1 / 2 ) . You might object that arccos is multivalued, for example cos ( π / 4 ) = cos ( 3 π / 4 ) . This just corresponds to the fact that there are different ways of picking "the" angle between v and w (e.g. clockwise or anticlockwise).

Two lines which meet at 45 degrees could also be thought of as meeting at 135 degrees