Dot and cross products

Multiply vectors in the two ways physics uses.

You can add two vectors, and you can stretch one by a number. Can you multiply two of them together? Physics does it in two ways, and they answer different questions. The dot product asks how much of one arrow lies along the other, and its answer is a plain number. The cross product asks how much the two arrows spread apart, and its answer is a new arrow. Work is the first kind. Torque and the force from a magnet are the second.

Drag the tips of the two arrows. They snap to whole numbers, so the sum of components comes out exactly. The coloured bar is one arrow's shadow on the other, cast by light falling square onto it: amber when it lies along that arrow, blue when it falls behind its tail.
  • Drag the tip of \(\mathbf{b}\) slowly round. The amber bar is \(\mathbf{b}\)'s shadow on \(\mathbf{a}\), and the dot product is that shadow times the length of \(\mathbf{a}\). Beside the picture, two quite different sums land on the same number every time. (The first is worked from the lengths rounded to two places, so it says ≈ unless it comes out exactly.)
  • Leave \(\mathbf{a}\) at \((4, 1)\) and put \(\mathbf{b}\) at \((-1, 4)\). The arrows are square to each other, \(\mathbf{b}\) casts no shadow along \(\mathbf{a}\), and the product is 0.
  • Carry \(\mathbf{b}\) on round to \((-3, 1)\). The shadow now falls behind \(\mathbf{a}\)'s tail and turns blue. It counts as negative, and the product is \(-11\).
  • Put \(\mathbf{b}\) on top of \(\mathbf{a}\), at \((4, 1)\). The shadow is the whole arrow, and the product is 17: the length of \(\mathbf{a}\), squared.
  • Move \(\mathbf{b}\) back to \((2, 3)\), where its shadow on \(\mathbf{a}\) is 2.67 long. Now tick "Swap the shadow", so that \(\mathbf{a}\) casts its shadow on \(\mathbf{b}\) instead. That shadow is 3.05 long, but the product is still 11.

The dot product: how much lies along

Shine a light square onto \(\mathbf{a}\), and \(\mathbf{b}\) casts a shadow along it. If the angle between the two arrows is \(\theta\), that shadow has length \(|\mathbf{b}|\cos\theta\). It's the same right-angled triangle that gave you components, with \(\mathbf{a}\) standing in for the \(x\) axis. The dot product is the shadow times the length of the arrow it falls on:

\[ \mathbf{a}\cdot\mathbf{b} = |\mathbf{a}|\,|\mathbf{b}|\cos\theta \]

The answer is a number, not a vector. Everything you saw in the figure is the cosine at work:

Nothing in the formula says which arrow casts the shadow, which is why swapping them changed nothing: \(\mathbf{a}\cdot\mathbf{b} = \mathbf{b}\cdot\mathbf{a}\).

The same number from components

Measuring an angle is a nuisance. The second sum in the figure never needs one: multiply the two \(x\) components, multiply the two \(y\) components, and add. Here's why that gives the same number.

Write each arrow using its length and its angle from the \(x\) axis. Call those angles \(\alpha\) for \(\mathbf{a}\) and \(\beta\) for \(\mathbf{b}\).

\[ \mathbf{a} = \big(|\mathbf{a}|\cos\alpha,\; |\mathbf{a}|\sin\alpha\big) \qquad \mathbf{b} = \big(|\mathbf{b}|\cos\beta,\; |\mathbf{b}|\sin\beta\big) \]

Multiply the matching components and add them. Both terms contain \(|\mathbf{a}||\mathbf{b}|\), so take it outside a bracket.

\[ \begin{aligned} &a_x b_x + a_y b_y \\ &\quad = |\mathbf{a}|\,|\mathbf{b}|\,\big(\cos\alpha\cos\beta + \sin\alpha\sin\beta\big) \end{aligned} \]

The bracket is one of the angle formulas: it's \(\cos(\alpha - \beta)\). And \(\alpha - \beta\) is the angle between the two arrows, \(\theta\). (If it comes out negative, or bigger than \(180^\circ\), it doesn't matter: the cosine is the same as for the angle between them.)

\[ a_x b_x + a_y b_y = |\mathbf{a}|\,|\mathbf{b}|\cos\theta \]

So far every vector has had two components. Space has three directions, so a vector in space has three, \((a_x, a_y, a_z)\), and nothing else changes. You still add component by component. The length is Pythagoras used twice, \(|\mathbf{a}| = \sqrt{a_x^2 + a_y^2 + a_z^2}\). And the dot product gains one more term.

\[ \mathbf{a}\cdot\mathbf{b} = |\mathbf{a}|\,|\mathbf{b}|\cos\theta = a_x b_x + a_y b_y + a_z b_z \]

Zero means the two are at right angles.

Having both forms is what makes it useful. Work the product out from the components, divide by the two lengths, and you have \(\cos\theta\): the angle between any two arrows, with no protractor. A vector dotted with itself is its length squared, \(\mathbf{a}\cdot\mathbf{a} = |\mathbf{a}|^2\), because its shadow on itself is all of it.

Work is a dot product

In work and energy, work was force times distance, with a warning: only the part of the force along the motion counts. The dot product is that warning turned into a formula. If a steady force \(\mathbf{F}\) acts on something while it moves in a straight line from one place to another, and the arrow from start to finish is \(\mathbf{d}\), then

\[ W = \mathbf{F}\cdot\mathbf{d} \]
  • In the figure, untick "Swap the shadow" and choose "A move d and a force F". A crate slides along \(\mathbf{d}\) while \(\mathbf{F}\) acts on it. The coloured arrow riding on the crate is the part of \(\mathbf{F}\) along the move, and the bar beside the picture fills as the work adds up.
  • Point the force square to the move: with \(\mathbf{d} = (4, 1)\), put \(\mathbf{F}\) at \((-1, 4)\). It does no work at all. That's your upward pull on a suitcase carried along a level platform.
  • Lean the force back against the move, at \((-3, 1)\). The work is \(-11\) J: the force is taking energy out of the crate, as friction does to anything that slides.

The cross product: how much they span

The second way to multiply gives a vector, and it lives in three dimensions.

Two arrows lying in a level plane, seen from above and to one side. Drag their tips, which snap to whole numbers. The amber arrow is their cross product, drawn 0.3 squares tall for each unit of area, and the view sways a little so that you can see it stand up out of the plane. Any two arrows lie flat in some plane, so this is the general case, turned to suit.
  • Drag the tip of \(\mathbf{b}\) around. The shaded parallelogram is the area the two arrows span, and the amber arrow is as long as that area is big.
  • With \(\mathbf{a}\) at \((3, 0)\), lay \(\mathbf{b}\) along it at \((2, 0)\). The parallelogram shuts and the product is zero. Point \(\mathbf{b}\) the opposite way, \((-2, 0)\): still zero.
  • Put \(\mathbf{b}\) square to \(\mathbf{a}\), at \((0, 3)\). The area is 9. Now stretch it to \((3, 3)\). It's longer, but the area is still 9, because only the part of \(\mathbf{b}\) square to \(\mathbf{a}\) counts.
  • Take \(\mathbf{b}\) across to the other side of \(\mathbf{a}\), to \((1, -2)\). The amber arrow dives under the plane.
  • Tick "Swap the order". The parallelogram is the same and the arrow flips. Unlike any multiplying you've met before, the order matters.
  • Slide "Turn the view" all the way round. From every side the amber arrow stands straight up out of the plane the other two lie in.

Two arrows from the same point span a parallelogram. A parallelogram's area is its base times its height. Take \(\mathbf{a}\) as the base. The height is the part of \(\mathbf{b}\) that is square to \(\mathbf{a}\), which is \(|\mathbf{b}|\sin\theta\). So the area is \(|\mathbf{a}||\mathbf{b}|\sin\theta\). Where the dot product keeps the part of \(\mathbf{b}\) along \(\mathbf{a}\), the cross product keeps the part square to it.

The cross product \(\mathbf{a}\times\mathbf{b}\) is a vector with that area as its length. For its direction, it leans towards neither arrow: it stands square to both of them, straight out of the plane they lie in. That still leaves two choices, up or down, and a convention picks one: the right-hand rule. Curl the fingers of your right hand the way \(\mathbf{a}\) would turn to reach \(\mathbf{b}\) by the shorter route. Your thumb points along \(\mathbf{a}\times\mathbf{b}\).

Swap the two and your fingers curl the other way, so your thumb turns over:

\[ \mathbf{b}\times\mathbf{a} = -\,\mathbf{a}\times\mathbf{b} \]

And any vector crossed with itself, or with anything along the same line, is zero: there's no area.

The cross product from components

For two arrows lying flat in the \(x\)-\(y\) plane, as in the figure, the product points straight along \(z\). The same trick as before finds its size.

Try the combination the figure shows: the \(x\) component of one times the \(y\) component of the other, minus the other way round. Use the lengths and angles from before.

\[ \begin{aligned} &a_x b_y - a_y b_x \\ &\quad = |\mathbf{a}|\,|\mathbf{b}|\,\big(\cos\alpha\sin\beta - \sin\alpha\cos\beta\big) \end{aligned} \]

This bracket is the other angle formula, \(\sin(\beta - \alpha)\). And \(\beta - \alpha\) is the angle turned through in going from \(\mathbf{a}\) to \(\mathbf{b}\).

\[ a_x b_y - a_y b_x = |\mathbf{a}|\,|\mathbf{b}|\sin(\beta - \alpha) \]

So it has the right size, the area. It also has the right sign: positive when \(\mathbf{b}\) is anticlockwise from \(\mathbf{a}\), which is when the right-hand rule says up, and negative when it's clockwise.

\[ \mathbf{a}\times\mathbf{b} = \big(0,\; 0,\; a_x b_y - a_y b_x\big) \]

Two arrows that point anywhere in space have a cross product with all three components. Each one is built in the same way, from the other two directions:

\[ \begin{aligned} \mathbf{a}\times\mathbf{b} = \big(\,&a_y b_z - a_z b_y, \\ &a_z b_x - a_x b_z, \\ &a_x b_y - a_y b_x\,\big) \end{aligned} \]

Its length is \(|\mathbf{a}||\mathbf{b}|\sin\theta\), the area the two span. It is square to both, by the right-hand rule.

The three rows are its \(x\), \(y\) and \(z\) parts. You don't have to memorise three formulas. Learn the last one, \(a_x b_y - a_y b_x\) for the \(z\) part, and get the others by moving every letter one place round the circle \(x \to y \to z \to x\). A quick check that the signs are right: \((1, 0, 0)\times(0, 1, 0) = (0, 0, 1)\). One step along \(x\) crossed with one step along \(y\) gives one step along \(z\). This assumes the usual axes: seen from the \(z\) side, turning from \(x\) to \(y\) is anticlockwise. The figure's are drawn that way.

Where physics uses it

Torque. In rotation, torque was \(rF_\perp\): the distance from the axis times the part of the force square to it. That is the size of a cross product. With \(\mathbf{r}\) the arrow from the axis to where the force acts,

\[ \boldsymbol{\tau} = \mathbf{r}\times\mathbf{F} \]

The vector says more than the number did. It points along the axis the force is trying to turn things about, and the right-hand rule gives the direction of the turn. Take the spanner from that lesson: 0.30 m long, pushed with 150 N at \(60^\circ\) to its length. Lay the spanner along \(x\), so \(\mathbf{r} = (0.30, 0, 0)\) and \(\mathbf{F} = (150\cos 60^\circ,\; 150\sin 60^\circ,\; 0) = (75,\; 129.9,\; 0)\). Then the \(z\) part of \(\mathbf{r}\times\mathbf{F}\) is \(0.30 \times 129.9 - 0 \times 75 \approx 39\) N·m, the same 39 N·m as before, and it points up out of the page: anticlockwise. Choose "r and F: torque" in the figure to see one.

The magnetic force. A charge \(q\) moving with velocity \(\mathbf{v}\) through a magnetic field \(\mathbf{B}\) feels a force

\[ \mathbf{F} = q\,\mathbf{v}\times\mathbf{B} \]

That's for the magnetic fields lesson, but you can already read a strange fact off it. A cross product is square to both of its parts, so this force is always square to the velocity. Then \(\mathbf{F}\cdot\mathbf{v} = 0\): the force never has any part along the motion, and it does no work. A magnetic field can bend the path of a charge but can't speed it up or slow it down.

These two products run through the rest of physics. Work, and the flow of a field through a surface, are dot products, and the next lessons add them up along paths and over surfaces. Torque, angular momentum (\(\mathbf{L} = \mathbf{r}\times\mathbf{p}\)) and the magnetic force are cross products. Maxwell's equations are written with a dot and a cross applied to the gradient symbol \(\nabla\). And in quantum mechanics, "how much of one state lies along another" is a dot product in a space with more directions, and the square of its size is the chance of a measurement coming out that way.

Problems

Which of these pairs are at right angles? \((1, 2)\) and \((-4, 2)\). \((3, 1)\) and \((1, 3)\). \((2, -1, 2)\) and \((1, 4, 1)\).

Answer

A pair is at right angles when its dot product is zero.

\((1, 2)\cdot(-4, 2) = -4 + 4 = 0\): yes.

\((3, 1)\cdot(1, 3) = 3 + 3 = 6\): no.

\((2, -1, 2)\cdot(1, 4, 1) = 2 - 4 + 2 = 0\): yes, though you'd struggle to see it in a drawing.

For \(\mathbf{a} = (2, 3)\) and \(\mathbf{b} = (4, -1)\), find \(\mathbf{a}\cdot\mathbf{b}\), the two lengths, and the angle between the arrows. Check it on the first figure.

Answer

\(\mathbf{a}\cdot\mathbf{b} = 2 \times 4 + 3 \times (-1) = 5\). The lengths are \(\sqrt{2^2 + 3^2} = \sqrt{13} \approx 3.61\) and \(\sqrt{4^2 + 1^2} = \sqrt{17} \approx 4.12\). So \(\cos\theta = \frac{5}{\sqrt{13}\sqrt{17}} = \frac{5}{\sqrt{221}} \approx 0.3363\), and \(\theta \approx 70.3^\circ\). Keep the square roots until the end: with the lengths rounded to 3.61 and 4.12 first, you'd get \(70.4^\circ\).

You pull a sledge 20 m across level snow with a rope that makes \(30^\circ\) with the ground. The pull in the rope is 50 N. How much work do you do? Then: a force \(\mathbf{F} = (3, -2)\) N acts on a puck while it moves \(\mathbf{d} = (4, 1)\) m. How much work does it do?

Answer

Sledge: \(W = Fd\cos\theta = 50 \times 20 \times \cos 30^\circ \approx 866\) J. The rope's upward part does nothing, since the sledge doesn't move upwards.

Puck: \(W = \mathbf{F}\cdot\mathbf{d} = 3 \times 4 + (-2) \times 1 = 10\) J.

For \(\mathbf{a} = (3, 0, 0)\) and \(\mathbf{b} = (1, 2, 0)\), find \(\mathbf{a}\times\mathbf{b}\) and \(\mathbf{b}\times\mathbf{a}\). What's the area of the parallelogram they span? Check all three on the second figure, which starts with these two arrows.

Answer

Both arrows are flat in the \(x\)-\(y\) plane, so only the \(z\) part survives: \(a_x b_y - a_y b_x = 3 \times 2 - 0 \times 1 = 6\). So \(\mathbf{a}\times\mathbf{b} = (0, 0, 6)\), pointing up, and \(\mathbf{b}\times\mathbf{a} = (0, 0, -6)\), pointing down. The area is 6 either way: a base of 3 and a height of 2.

Find \(\mathbf{a}\times\mathbf{b}\) for \(\mathbf{a} = (1, 2, 3)\) and \(\mathbf{b} = (4, 5, 6)\). Then use the dot product to check that your answer is square to both.

Answer

Take the three parts in turn.

\(x\) part: \(a_y b_z - a_z b_y = 2 \times 6 - 3 \times 5 = -3\).

\(y\) part: \(a_z b_x - a_x b_z = 3 \times 4 - 1 \times 6 = 6\).

\(z\) part: \(a_x b_y - a_y b_x = 1 \times 5 - 2 \times 4 = -3\).

So \(\mathbf{a}\times\mathbf{b} = (-3, 6, -3)\). Check: its dot product with \(\mathbf{a}\) is \(-3 + 12 - 9 = 0\), and with \(\mathbf{b}\) it is \(-12 + 30 - 18 = 0\). Square to both.

A proton (charge \(q = 1.6 \times 10^{-19}\) C) moves at \(\mathbf{v} = (2 \times 10^5,\; 0,\; 0)\) m/s through a magnetic field \(\mathbf{B} = (0,\; 0,\; 0.5)\) T. (The tesla, T, is the unit of magnetic field: a newton for each coulomb and each metre per second.) Find the force on it, \(\mathbf{F} = q\,\mathbf{v}\times\mathbf{B}\). Which way does it point? Show that it does no work on the proton.

Answer

First \(\mathbf{v}\times\mathbf{B}\). The \(x\) part is \(v_y B_z - v_z B_y = 0\). The \(y\) part is \(v_z B_x - v_x B_z = 0 - 2 \times 10^5 \times 0.5 = -1 \times 10^5\). The \(z\) part is \(v_x B_y - v_y B_x = 0\).

So \(\mathbf{F} = 1.6 \times 10^{-19} \times (0,\; -1 \times 10^5,\; 0) = (0,\; -1.6 \times 10^{-14},\; 0)\) N. It points along \(-y\), square to both the velocity (along \(x\)) and the field (along \(z\)).

In any short moment the proton moves a small step along \(\mathbf{v}\), and the work done is the force dotted with that step. But \(\mathbf{F}\cdot\mathbf{v} = 0 \times 2 \times 10^5 + (-1.6 \times 10^{-14}) \times 0 + 0 \times 0 = 0\): the force has no part along the motion, so it does no work. It only turns the proton, which ends up going round in a circle at a steady speed.

Learn more

An unhandled error has occurred. Reload 🗙