Back to the on-screen lesson ·

The dot product

One number built from matching components that computes $|\mathbf{u}||\mathbf{v}|\cos\theta$: the orthogonality test, scalar and vector projection, work, and the direction cosines.

Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.

1. What you will learn

By the end of this lesson you will be able to compute a dot product from components, use it to find the angle between two vectors, test two vectors for orthogonality, and split one vector into the part along another and the part across it. You will also be able to say why the projection's multiplier divides by the dot product of the target with itself rather than by its length.

2. What you already have

Components, length and scaling from the last lesson, and the cosine rule from trigonometry. The dot product is the bridge between them: it is defined by an arithmetic anybody can do in a second, and it computes an angle, which nothing about the arithmetic suggests it should.

3. The words this lesson will use

Two vectors are orthogonal — the word this course prefers to perpendicular, because the zero vector is orthogonal to everything and perpendicular to nothing — when their dot product is zero. The scalar projection of $\mathbf{u}$ onto $\mathbf{v}$ is how far $\mathbf{u}$ reaches in $\mathbf{v}$'s direction, a number. The vector projection is that reach written as a vector along $\mathbf{v}$. The direction cosines of a vector are the cosines of the three angles it makes with the axes.

4. One number that knows the angle

For $\mathbf{u} = \langle u_1, u_2, u_3 \rangle$ and $\mathbf{v} = \langle v_1, v_2, v_3 \rangle$,

$$\mathbf{u} \cdot \mathbf{v} = u_1v_1 + u_2v_2 + u_3v_3.$$

Multiply matching components, add. The answer is a number, not a vector, which is why it is also called the scalar product.

The geometric reading. The same number equals

$$\mathbf{u} \cdot \mathbf{v} = |\mathbf{u}||\mathbf{v}|\cos\theta,$$

where $\theta$ is the angle between the two vectors. The two formulas agreeing is the content of this lesson: an arithmetic rule with no angle in it computes a cosine. The proof is the law of cosines applied to the triangle with sides $\mathbf{u}$, $\mathbf{v}$ and $\mathbf{u} - \mathbf{v}$, together with the identity $\mathbf{w} \cdot \mathbf{w} = |\mathbf{w}|^2$.

The test. Since the lengths are never negative, the sign of the dot product is the sign of $\cos\theta$:

Orthogonality being exactly a dot product of zero is the single most used fact in the rest of this course: it defines a normal to a plane, a tangent to a level curve, and the frame that travels along a curve.

Projection. How much of $\mathbf{u}$ lies along $\mathbf{v}$?

$$\operatorname{comp}_{\mathbf{v}}\mathbf{u} = \frac{\mathbf{u} \cdot \mathbf{v}}{|\mathbf{v}|}, \qquad \operatorname{proj}_{\mathbf{v}}\mathbf{u} = \frac{\mathbf{u} \cdot \mathbf{v}}{\mathbf{v} \cdot \mathbf{v}}\,\mathbf{v}.$$

The first is a number, the second a vector; they differ by one factor of $|\mathbf{v}|$, and mixing them up is the commonest slip in the unit. Work is the same idea in physics: a constant force $\mathbf{F}$ through a displacement $\mathbf{d}$ does work $\mathbf{F} \cdot \mathbf{d}$, because only the part of the force along the motion does anything.

Direction cosines. Dotting $\mathbf{v}$ with each of $\mathbf{i}$, $\mathbf{j}$, $\mathbf{k}$ and dividing by $|\mathbf{v}|$ gives the cosines of the angles with the three axes; they are the components of the unit vector, and their squares add to $1$.

Another way: picture

Shine a light straight down onto $\mathbf{v}$ and watch the shadow $\mathbf{u}$ casts on it. The length of that shadow is the scalar projection, and the dot product is that length multiplied by $|\mathbf{v}|$. When $\mathbf{u}$ stands straight up, the shadow has collapsed to nothing and the dot product is zero; when $\mathbf{u}$ leans backwards, the shadow falls on the far side and the number goes negative.

Another way: steps

To find the angle between two vectors:

  1. Compute $\mathbf{u} \cdot \mathbf{v}$ from components.
  2. Compute $|\mathbf{u}|$ and $|\mathbf{v}|$.
  3. Divide: $\cos\theta = \dfrac{\mathbf{u} \cdot \mathbf{v}}{|\mathbf{u}||\mathbf{v}|}$.
  4. Check the answer lies between $-1$ and $1$; if it does not, the arithmetic is wrong, because the inequality is a theorem.
  5. Take the inverse cosine only if the angle itself is wanted; very often the sign or the cosine is the whole answer.

5. Why the two formulas agree

Put $\mathbf{u}$ and $\mathbf{v}$ tail to tail. The third side of the triangle they make is $\mathbf{u} - \mathbf{v}$, and the law of cosines says

$$|\mathbf{u} - \mathbf{v}|^2 = |\mathbf{u}|^2 + |\mathbf{v}|^2 - 2|\mathbf{u}||\mathbf{v}|\cos\theta.$$

Now expand the left side with components. Every squared term regroups into $|\mathbf{u}|^2 + |\mathbf{v}|^2$, and what is left over is exactly $-2(u_1v_1 + u_2v_2 + u_3v_3)$. Comparing the two lines gives

$$u_1v_1 + u_2v_2 + u_3v_3 = |\mathbf{u}||\mathbf{v}|\cos\theta,$$

which is the whole theorem. Two consequences are worth having by name. The first is the Cauchy–Schwarz inequality $|\mathbf{u} \cdot \mathbf{v}| \le |\mathbf{u}||\mathbf{v}|$, which is just $|\cos\theta| \le 1$ read backwards and is a free check on any dot product you compute. The second is that the argument never used three dimensions, so the dot product and the angle it measures make sense in any number of them — unlike the cross product of the next lesson.

6. Where this goes wrong

Expecting a vector. $\mathbf{u} \cdot \mathbf{v}$ is a number. Writing $(\mathbf{u} \cdot \mathbf{v}) \cdot \mathbf{w}$ is meaningless, because the left factor is not a vector.

Dividing by the wrong thing in a projection. The scalar projection divides by $|\mathbf{v}|$; the multiplier in the vector projection divides by $\mathbf{v} \cdot \mathbf{v}$. Ask what kind of object the answer must be and the choice makes itself.

Reading a large negative value as a small angle. A dot product of $-40$ is not nearly orthogonal; it is well past a right angle and heading for opposite.

Calling the zero vector perpendicular to things. It has a zero dot product with everything and no direction at all, so orthogonal is the honest word and the reason this course uses it. A third coordinate is not a third term bolted onto a two-dimensional formula. The cross product exists only in space, a plane is fixed by a direction rather than by a slope, and a curve in space can bend without ever leaving a surface. Checking a new formula against the plane is worth doing; assuming the plane's formula still governs is how most of the errors in this course begin.

7. A dot product is not a length and not a projection

It is tempting to read $\mathbf{u} \cdot \mathbf{v}$ as how much of $\mathbf{u}$ points along $\mathbf{v}$, because that is roughly what the shadow picture shows. It is that shadow multiplied by $|\mathbf{v}|$, and the extra factor matters: doubling $\mathbf{v}$ doubles the dot product while changing nothing about the angle or the shadow.

So a dot product on its own reports no geometry. What reports geometry is the dot product divided by something: by $|\mathbf{u}||\mathbf{v}|$ it is a cosine, by $|\mathbf{v}|$ it is the scalar projection, by $\mathbf{v} \cdot \mathbf{v}$ it is the multiplier that rebuilds the vector projection. Writing down which of the three you meant, before dividing, is what keeps the answer's units honest.

8. An angle from two dot products and two lengths

  1. Let $\mathbf{u} = \langle 2, 1, 2 \rangle$ and $\mathbf{v} = \langle 6, 3, -2 \rangle$. Then $\mathbf{u} \cdot \mathbf{v} = 12 + 3 - 4 = 11$.

    Matching components, multiplied and added.

  2. The lengths are $|\mathbf{u}| = 3$ and $|\mathbf{v}| = 7$, so $\cos\theta = \tfrac{11}{21}$.

    Divide the dot product by the product of the lengths.

  3. That is between $-1$ and $1$, as it must be, and it is positive, so the angle is under a right angle — about $58$ degrees. The check is free and it catches almost every arithmetic slip.

    A cosine outside the interval means the arithmetic is wrong.

9. Work done by a force at an angle

  1. A crate is dragged $\langle 10, 0, 0 \rangle$ metres by a force $\mathbf{F} = \langle 12, 0, 5 \rangle$ newtons.

    The rope pulls partly upwards, partly along.

  2. The work is $\mathbf{F} \cdot \mathbf{d} = 120 + 0 + 0 = 120$ joules.

    Only the component along the motion contributes.

  3. The upward $5$ newtons did nothing at all, because the crate never rose. The dot product performed that bookkeeping without anybody having to resolve the force into components by hand — which is what makes it the definition of work rather than a way of computing it.

    The formula throws away the perpendicular part automatically.

10. Your turn: is the triangle with corners at the origin, $(4, 3, 0)$ and $(0, 0, 5)$ right-angled at the origin?

  1. The two edges from the origin are $\mathbf{a} = \langle 4, 3, 0 \rangle$ and $\mathbf{b} = \langle 0, 0, 5 \rangle$.

    A right angle at a corner is an angle between the two edges there.

  2. Their dot product is $0 + 0 + 0 = 0$.

  3. Your turn: work this step out. Its working is at the end of the packet.

    So the angle at the origin is exactly a right angle. Note how little work that took: no lengths, no inverse cosine, no picture. Testing a right angle is the one angle question that never needs the lengths at all.

11. Guided practice

For $\mathbf{u} = \langle 4, -1, 3 \rangle$ and $\mathbf{v} = \langle 0, 2, 3 \rangle$, fill in the three dot products.

Value
The dot product of u with v
The dot product of v with u
The dot product of u with itself

12. Guided practice

Here $|\mathbf{u}| = 4$ and $|\mathbf{v}| = 7$. Match each reported value of $\mathbf{u} \cdot \mathbf{v}$ to what it says about the angle.

The angle is less than a right angleThe two vectors are perpendicularThe angle is more than a right angleThe two vectors point the same way
A positive value, smaller than $28$
Exactly $0$
A negative value
Exactly $28$

13. Practice

For what value of $t$ is $\langle -1, 0, 1 \rangle$ perpendicular to $\langle -4, 5, t \rangle$?

Answer:

14. Practice

The projection of $\mathbf{u} = \langle 1, -4, -3 \rangle$ onto $\mathbf{v} = \langle 1, 2, 2 \rangle$ is a multiple of $\mathbf{v}$. What is the multiplier?

Answer:

15. Practice

For $\mathbf{u} = \langle -5, -3, 3 \rangle$ and $\mathbf{v} = \langle 1, 0, -1 \rangle$, fill in the three dot products.

Value
The dot product of u with v
The dot product of v with u
The dot product of u with itself

16. Somewhere new

A drone's heading is $\mathbf{h}$ and the displacement to a beacon $40$ metres away is $\mathbf{d}$. The flight computer reports $\mathbf{h} \cdot \mathbf{d} < 0$. What does that say?

17. Lesson test

Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.

18. Test question

Here $|\mathbf{u}| = 5$ and $|\mathbf{v}| = 8$. Match each reported value of $\mathbf{u} \cdot \mathbf{v}$ to what it says about the angle.

The angle is less than a right angleThe two vectors are perpendicularThe angle is more than a right angleThe two vectors point the same way
A positive value, smaller than $40$
Exactly $0$
A negative value
Exactly $40$

19. What you can do now

You can compute a dot product, read its sign as an angle, and use it to project one vector onto another. Next: the product that returns a vector instead of a number, and exists only in space.

Working for the steps left to you

10. Your turn: is the triangle with corners at the origin, $(4, 3, 0)$ and $(0, 0, 5)$ right-angled at the origin?, step 3