09. Dot product, 1

09. Dot product, 1

Dot product

Given two vectors v equals v_1 up to v_n and w equals w_1 up to w_n in R n, what is the angle between them?

To define angles in R 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 dot w.

Definition:

The dot product v dot w is the number v_1 w_1 plus dot dot dot plus v_n w_n.

Theorem:

If theta is the angle between v and w then v dot w equals norm v times norm w times cos theta Recall that norm v means the length of v.

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

Let v be 1, 0 and w be 0, 1. We have v dot w equals 1 times 0 plus 0 times 1, which equals 0.

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

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

Let v be 1, 1 and w be 1, 0. We can see the angle between them should be 45 degrees (pi over 4 radians).

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

Let's confirm this: we have v dot w equals 1 times 1 plus 0 times 1, which equals 1. We also have norm v equals square root 2 by Pythagoras and norm w equals 1, so 1 equals v dot w equals norm v norm w cos theta, which eqals root 2 cos theta so cos theta should be one over root 2. Indeed, cos pi over 4 equals one over root 2.

Even if you didn't know the angle, you could figure it out as arccos of one over root 2. You might object that arccos is multivalued, for example cos of pi over 4 equals cos of 3 pi over 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