Skip to content
EN - Language: English
MathematicsHigh school

Dot product and cross product of vectors - explained step by step

· 17 min read

In short

The dot product u · v = u₁v₁ + u₂v₂ + u₃v₃ is a number - the length of u times the shadow of v on the line of u, or |u||v| cos θ. For non-zero vectors it is 0 exactly when they are perpendicular. The cross product u × v is a vector perpendicular to both, and its length |u||v| sin θ is the area of the parallelogram they span.

Words to know

Vector
An arrow with a length and a direction. In space it has three coordinates, for example (2, 0, 0).
Length of a vector
For u = (u₁, u₂, u₃), the length is |u| = √(u₁² + u₂² + u₃²).
Angle between two vectors
The angle θ between the two arrows drawn from one point. It is between 0° and 180°.
Shadow (projection)
Drop a perpendicular from the tip of v onto the line of u. The part of the line from the start of v to its foot is the shadow of v on u.
Scalar
A single number, as opposed to a vector. The dot product is a scalar, so it is also called the scalar product.
Right-hand rule
Point the fingers of your right hand along u and curl them towards v. Your thumb then points along u × v.

What do you think?

The vector u=(3,0,0)\mathbf{u} = (3, 0, 0) points along the xx-axis, and v=(0,5,0)\mathbf{v} = (0, 5, 0) along the yy-axis. What is their dot product u⋅v\mathbf{u} \cdot \mathbf{v}?

The idea: one product measures along, the other across

Two vectors that start at the same point can be multiplied in two ways, and the two answers tell you different things.

The dot product u⋅v\mathbf{u} \cdot \mathbf{v} is a number. It tells you how far v\mathbf{v} goes in the direction of u\mathbf{u}, multiplied by the length of u\mathbf{u}. Imagine light falling at right angles onto the line of u\mathbf{u}: the shadow that v\mathbf{v} casts on that line is what counts. Physics uses exactly this. When a constant force F\mathbf{F} pulls a sledge along a path s\mathbf{s}, only the part of the force along the path does work, and the work is W=F⋅sW = \mathbf{F} \cdot \mathbf{s}.

The cross product u×v\mathbf{u} \times \mathbf{v} is a vector. It stands at right angles to both u\mathbf{u} and v\mathbf{v}, and its length is the area of the parallelogram that the two vectors span. That area depends on how far v\mathbf{v} goes across u\mathbf{u} - the height of the parallelogram - and not on how far it goes along it.

Watch the two products

Go through the animation step by step with the buttons or the arrow keys. At first you see the floor from straight above, like squared paper. In the last two steps the view tilts, so that you can see what sticks up out of the floor.

xyθvuO

u = (2, 0, 0); v = (1, 2, 0); θ ≈ 63.4°

Step 1 of 8
Steps of the animation. Arrow keys move between steps.

Two vectors start at the point O: u = (2, 0, 0) and v = (1, 2, 0). Both lie flat on the floor, the plane z = 0, and the angle between them is θ ≈ 63.4°.

The coordinates and the picture always agree. For any two vectors, multiplying matching coordinates and adding them gives ∣u∣ ∣v∣cos⁡θ|\mathbf{u}|\,|\mathbf{v}| \cos\theta, and ∣v∣cos⁡θ|\mathbf{v}| \cos\theta is the length of the shadow of v\mathbf{v} on u\mathbf{u}. You can work out the dot product without drawing anything.

Try it yourself: two vectors in space

Set the three coordinates of u\mathbf{u} and of v\mathbf{v} with the sliders, and choose which product to look at. Turn the view and raise or lower it to see the vectors from another side. The readouts under the picture work out the products from the coordinates.

xyzθvuO
Show
Vector u = (2, 0, 0)
u₁ = 2
u₂ = 0
u₃ = 0
Vector v = (1, 2, 0)
v₁ = 1
v₂ = 2
v₃ = 0
−35°
25°
u · v = u₁v₁ + u₂v₂ + u₃v₃
2·1 + 0·2 + 0·0 = 2
shadow of v on u, (u · v) / |u|
1
angle θ between u and v
63.4°
the angle is
acute: u · v > 0

What to notice:

  • with u=(2,0,0)\mathbf{u} = (2, 0, 0) and v=(v1,2,0)\mathbf{v} = (v_1, 2, 0), move only v1v_1: the dot product 2v12v_1 changes, but the parallelogram keeps its area 44, because its height stays 22,
  • make v1=0v_1 = 0, so that v=(0,2,0)\mathbf{v} = (0, 2, 0): the dot product is 00 and the angle is a right angle,
  • in the cross product view, (u×v)⋅u(\mathbf{u} \times \mathbf{v}) \cdot \mathbf{u} and (u×v)⋅v(\mathbf{u} \times \mathbf{v}) \cdot \mathbf{v} are always 00, whatever vectors you set: the cross product is perpendicular to both,
  • make v\mathbf{v} parallel to u\mathbf{u}, for example v=(3,0,0)\mathbf{v} = (3, 0, 0): the parallelogram is flat, and u×v=(0,0,0)\mathbf{u} \times \mathbf{v} = (0, 0, 0),
  • lift v\mathbf{v} off the floor with v3v_3: the cross product tilts, but it stays perpendicular to both vectors.

The definition

A vector in space has three coordinates, u=(u1,u2,u3)\mathbf{u} = (u_1, u_2, u_3). Its length is

∣u∣=u12+u22+u32.|\mathbf{u}| = \sqrt{u_1^2 + u_2^2 + u_3^2}.

The dot product. The dot product, or scalar product, of u\mathbf{u} and v\mathbf{v} is the number

u⋅v=u1v1+u2v2+u3v3.\mathbf{u} \cdot \mathbf{v} = u_1v_1 + u_2v_2 + u_3v_3.

The same number comes from the lengths and the angle θ\theta between the vectors, with 0°≤θ≤180°0° \le \theta \le 180°:

u⋅v=∣u∣ ∣v∣cos⁡θ.\mathbf{u} \cdot \mathbf{v} = |\mathbf{u}|\,|\mathbf{v}| \cos\theta.

Here ∣v∣cos⁡θ|\mathbf{v}| \cos\theta is the shadow of v\mathbf{v} on the line of u\mathbf{u}, with a minus sign when the shadow points away from u\mathbf{u}. So the dot product is the length of u\mathbf{u} times that shadow. In the plane everything works the same, with two coordinates instead of three.

  • The order does not matter: u⋅v=v⋅u\mathbf{u} \cdot \mathbf{v} = \mathbf{v} \cdot \mathbf{u}.
  • A vector times itself gives its length squared: u⋅u=∣u∣2\mathbf{u} \cdot \mathbf{u} = |\mathbf{u}|^2.
  • For non-zero vectors, the sign gives the angle away: u⋅v>0\mathbf{u} \cdot \mathbf{v} > 0 for an acute angle, u⋅v=0\mathbf{u} \cdot \mathbf{v} = 0 for perpendicular vectors and u⋅v<0\mathbf{u} \cdot \mathbf{v} < 0 for an obtuse angle.
  • Divide by the lengths and you get the angle:
cos⁡θ=u⋅v∣u∣ ∣v∣.\cos\theta = \frac{\mathbf{u} \cdot \mathbf{v}}{|\mathbf{u}|\,|\mathbf{v}|}.

The cross product. The cross product, or vector product, is defined for vectors in three-dimensional space. It is the vector

u×v=(u2v3−u3v2u3v1−u1v3u1v2−u2v1).\mathbf{u} \times \mathbf{v} = \begin{pmatrix} u_2v_3 - u_3v_2 \\ u_3v_1 - u_1v_3 \\ u_1v_2 - u_2v_1 \end{pmatrix}.

You can remember it as a determinant with the unit vectors i\mathbf{i}, j\mathbf{j}, k\mathbf{k} in its first row. When you expand it along that row, the middle term gets a minus sign, and that gives the middle coordinate above.

u×v=∣ijku1u2u3v1v2v3∣\mathbf{u} \times \mathbf{v} = \begin{vmatrix} \mathbf{i} & \mathbf{j} & \mathbf{k} \\ u_1 & u_2 & u_3 \\ v_1 & v_2 & v_3 \end{vmatrix}
  • u×v\mathbf{u} \times \mathbf{v} is perpendicular to u\mathbf{u} and to v\mathbf{v}.
  • Its length is ∣u×v∣=∣u∣ ∣v∣sin⁡θ|\mathbf{u} \times \mathbf{v}| = |\mathbf{u}|\,|\mathbf{v}| \sin\theta, the area of the parallelogram spanned by u\mathbf{u} and v\mathbf{v}. A triangle with sides u\mathbf{u} and v\mathbf{v} has half that area.
  • Its direction follows the right-hand rule. For the unit vectors along the axes, i×j=k\mathbf{i} \times \mathbf{j} = \mathbf{k}.
  • Swapping the order turns it round: v×u=−(u×v)\mathbf{v} \times \mathbf{u} = -(\mathbf{u} \times \mathbf{v}).
  • u×v=0\mathbf{u} \times \mathbf{v} = \mathbf{0} exactly when u\mathbf{u} and v\mathbf{v} are parallel, or one of them is the zero vector.

Example 1: the angle between two vectors

Find the angle between u=(1,2,2)\mathbf{u} = (1, 2, 2) and v=(3,0,4)\mathbf{v} = (3, 0, 4).

Step 1. Work out the dot product

We multiply matching coordinates and add the products.

u⋅v=1⋅3+2⋅0+2⋅4=3+0+8=11\begin{aligned} \mathbf{u} \cdot \mathbf{v} &= 1 \cdot 3 + 2 \cdot 0 + 2 \cdot 4 \\ &= 3 + 0 + 8 \\ &= \boxed{11} \end{aligned}

Step 2. Find the lengths of both vectors

We square the coordinates, add them and take the square root.

∣u∣=1+4+4=9=3∣v∣=9+0+16=25=5\begin{aligned} |\mathbf{u}| &= \sqrt{1 + 4 + 4} \\ &= \sqrt{9} = \boxed{3} \\ |\mathbf{v}| &= \sqrt{9 + 0 + 16} \\ &= \sqrt{25} = \boxed{5} \end{aligned}

Step 3. Divide the dot product by the lengths

The quotient is the cosine of the angle.

cos⁡θ=113⋅5=1115≈0.733\begin{aligned} \cos\theta &= \frac{11}{3 \cdot 5} \\ &= \frac{11}{15} \approx 0.733 \end{aligned}

Step 4. Find the angle

We use the inverse cosine on a calculator.

θ≈42.8°\theta \approx 42.8°

Answer

θ≈42.8°\theta \approx 42.8°. The dot product is positive, so the angle has to be acute, and 42.8°42.8° is.

Example 2: the area of a triangle in space

Find the area of the triangle with vertices A=(1,1,0)A = (1, 1, 0), B=(3,2,0)B = (3, 2, 0) and C=(1,2,3)C = (1, 2, 3).

Step 1. Write the sides as vectors from A

We subtract the coordinates of AA from those of BB and of CC.

AB→=(3−12−10−0)=(210)AC→=(1−12−13−0)=(013)\begin{aligned} \overrightarrow{AB} &= \begin{pmatrix} 3 - 1 \\ 2 - 1 \\ 0 - 0 \end{pmatrix} = \begin{pmatrix} 2 \\ 1 \\ 0 \end{pmatrix} \\[6pt] \overrightarrow{AC} &= \begin{pmatrix} 1 - 1 \\ 2 - 1 \\ 3 - 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \\ 3 \end{pmatrix} \end{aligned}

Step 2. Work out the cross product coordinate by coordinate

We use the formula from the definition, one coordinate per line.

1⋅3−0⋅1=30⋅0−2⋅3=−62⋅1−1⋅0=2\begin{aligned} 1 \cdot 3 - 0 \cdot 1 &= 3 \\ 0 \cdot 0 - 2 \cdot 3 &= -6 \\ 2 \cdot 1 - 1 \cdot 0 &= 2 \end{aligned}

So the cross product is

AB→×AC→=(3,−6,2)\boxed{\overrightarrow{AB} \times \overrightarrow{AC} = (3, -6, 2)}

Step 3. Find its length

The length of the cross product is the area of the parallelogram spanned by the two sides.

∣(3,−6,2)∣=9+36+4=49=7\begin{aligned} |(3, -6, 2)| &= \sqrt{9 + 36 + 4} \\ &= \sqrt{49} = \boxed{7} \end{aligned}

Step 4. Take half for the triangle

The triangle is half of that parallelogram.

S=72=3.5S = \frac{7}{2} = 3.5

Answer

The area of the triangle ABCABC is 3.53.5, half of the length of AB→×AC→\overrightarrow{AB} \times \overrightarrow{AC}.

Your turn

Take u=(2,1,−2)\mathbf{u} = (2, 1, -2) and v=(1,2,2)\mathbf{v} = (1, 2, 2). Show that the vectors are perpendicular, work out u×v\mathbf{u} \times \mathbf{v} and find the area of the parallelogram they span. Then check the area in another way.

Hintshow

Perpendicular vectors have a dot product of 00. For perpendicular vectors sin⁡90°=1\sin 90° = 1, so the area is simply ∣u∣⋅∣v∣|\mathbf{u}| \cdot |\mathbf{v}|.

Solutiontry it on your own first

Step 1. Work out the dot product

We multiply matching coordinates and add the products.

u⋅v=2⋅1+1⋅2+(−2)⋅2=2+2−4=0\begin{aligned} \mathbf{u} \cdot \mathbf{v} &= 2 \cdot 1 + 1 \cdot 2 \\ &\quad + (-2) \cdot 2 \\ &= 2 + 2 - 4 \\ &= 0 \end{aligned}

The dot product is 00, so the vectors are perpendicular.

Step 2. Work out the cross product

We call the cross product w\mathbf{w} and use the formula from the definition, one coordinate at a time.

w1=1⋅2−(−2)⋅2=2+4=6w2=(−2)⋅1−2⋅2=−2−4=−6w3=2⋅2−1⋅1=4−1=3\begin{aligned} w_1 &= 1 \cdot 2 - (-2) \cdot 2 \\ &= 2 + 4 = 6 \\ w_2 &= (-2) \cdot 1 - 2 \cdot 2 \\ &= -2 - 4 = -6 \\ w_3 &= 2 \cdot 2 - 1 \cdot 1 \\ &= 4 - 1 = 3 \end{aligned}

So the cross product is

u×v=(6,−6,3)\boxed{\mathbf{u} \times \mathbf{v} = (6, -6, 3)}

Step 3. Find the area

The area is the length of the cross product.

∣(6,−6,3)∣=36+36+9=81=9\begin{aligned} |(6, -6, 3)| &= \sqrt{36 + 36 + 9} \\ &= \sqrt{81} = \boxed{9} \end{aligned}

Step 4. Check it with the lengths

Both vectors have length 33, and the angle is 90°90°, so sin⁡θ=1\sin\theta = 1.

∣u∣=4+1+4=3∣v∣=1+4+4=33⋅3⋅1=9\begin{aligned} |\mathbf{u}| &= \sqrt{4 + 1 + 4} = 3 \\ |\mathbf{v}| &= \sqrt{1 + 4 + 4} = 3 \\ 3 \cdot 3 \cdot 1 &= 9 \end{aligned}

Answer

u⋅v=0\mathbf{u} \cdot \mathbf{v} = 0, so the vectors are perpendicular. u×v=(6,−6,3)\mathbf{u} \times \mathbf{v} = (6, -6, 3), and the parallelogram has area 99 - the same as ∣u∣⋅∣v∣|\mathbf{u}| \cdot |\mathbf{v}|, as it must be for perpendicular vectors.

Common mistakes

  • “The dot product is a vector.” It is a number. For (1,2,3)⋅(4,−1,0)(1, 2, 3) \cdot (4, -1, 0) the answer is 4−2+0=24 - 2 + 0 = 2. Multiplying the coordinates but not adding them gives (4,−2,0)(4, -2, 0), which is not the dot product.
  • “The order does not matter in the cross product.” It does: v×u=−(u×v)\mathbf{v} \times \mathbf{u} = -(\mathbf{u} \times \mathbf{v}). In the animation u×v=(0,0,4)\mathbf{u} \times \mathbf{v} = (0, 0, 4) points up, and v×u=(0,0,−4)\mathbf{v} \times \mathbf{u} = (0, 0, -4) points down.
  • Cosine and sine swapped. The dot product uses cos⁡θ\cos\theta, the length of the cross product sin⁡θ\sin\theta. For perpendicular vectors the dot product is 00, and for parallel ones the cross product is 0\mathbf{0}.
  • The wrong sign in the middle coordinate. It is u3v1−u1v3u_3v_1 - u_1v_3. Written the other way round in example 2, it gives (3,6,2)(3, 6, 2), and that vector is not perpendicular to AB→\overrightarrow{AB}: (3,6,2)⋅(2,1,0)=12(3, 6, 2) \cdot (2, 1, 0) = 12.
  • The whole parallelogram for a triangle. The length of the cross product is the area of the parallelogram. A triangle has half of it.

In exams and at university

In England, A-level Mathematics works with vectors in two and three dimensions: their magnitude and direction, adding them and multiplying them by a number, position vectors and the distance between two points. The dot product is not part of it. It comes in A-level Further Mathematics, in the core content that every exam board must include. There the scalar product is used to find the angle between two lines, between two planes, or between a line and a plane, to check whether two vectors are perpendicular and to write the equation of a plane. The vector product is not in that common core, but an exam board may add it to its own course, for example to find the area of a triangle.

In the United States, AP Precalculus covers the dot product in its last unit, Functions Involving Parameters, Vectors, and Matrices: as a sum of products of components, as ∣a∣ ∣b∣cos⁡θ|\mathbf{a}|\,|\mathbf{b}| \cos\theta, and as 00 for perpendicular vectors. That unit is not tested on the AP exam.

At university, both products are part of courses on linear algebra and multivariable calculus. In the open textbook A First Course in Linear Algebra by Ken Kuttler, they belong to the chapter on vectors in Rn\mathbb{R}^n. The dot product comes after the length of a vector and parametric lines, and the cross product two sections later, after planes.

Check yourself

Test yourself

What is (1,2,3)⋅(4,−1,0)(1, 2, 3) \cdot (4, -1, 0)?

Two non-zero vectors have u⋅v<0\mathbf{u} \cdot \mathbf{v} < 0. What can you say about the angle between them?

∣u∣=3|\mathbf{u}| = 3, ∣v∣=4|\mathbf{v}| = 4 and the angle between them is 30°30°. How long is u×v\mathbf{u} \times \mathbf{v}?

u×v=(1,−2,3)\mathbf{u} \times \mathbf{v} = (1, -2, 3). What is v×u\mathbf{v} \times \mathbf{u}?

For which kk are u=(2,k,1)\mathbf{u} = (2, k, 1) and v=(3,1,−4)\mathbf{v} = (3, 1, -4) perpendicular?

Flashcards for review

Flip a card and say whether you knew the answer. The ones you did not know come back at the end of the deck. Why it pays to come back to them in a few days is explained in the guide Spaced repetition.

Flashcards

  1. How do you work out u⋅v\mathbf{u} \cdot \mathbf{v} from the coordinates?

    u1v1+u2v2+u3v3u_1v_1 + u_2v_2 + u_3v_3: multiply matching coordinates and add. The result is a number.
  2. What is u⋅v\mathbf{u} \cdot \mathbf{v} in terms of the lengths and the angle?

    ∣u∣ ∣v∣cos⁡θ|\mathbf{u}|\,|\mathbf{v}| \cos\theta - the length of u\mathbf{u} times the shadow of v\mathbf{v} on the line of u\mathbf{u}.
  3. Two non-zero vectors have u⋅v=0\mathbf{u} \cdot \mathbf{v} = 0. What does that mean?

    They are perpendicular.
  4. What does the sign of u⋅v\mathbf{u} \cdot \mathbf{v} tell you about the angle?

    Positive: an acute angle. Negative: an obtuse angle. Zero: a right angle.
  5. What is u⋅u\mathbf{u} \cdot \mathbf{u}?

    ∣u∣2|\mathbf{u}|^2, the length of u\mathbf{u} squared.
  6. How do you find the angle between two vectors?

    cos⁡θ=u⋅v∣u∣ ∣v∣\cos\theta = \dfrac{\mathbf{u} \cdot \mathbf{v}}{|\mathbf{u}|\,|\mathbf{v}|}, then the inverse cosine.
  7. What is the length of u×v\mathbf{u} \times \mathbf{v}?

    ∣u∣ ∣v∣sin⁡θ|\mathbf{u}|\,|\mathbf{v}| \sin\theta - the area of the parallelogram spanned by u\mathbf{u} and v\mathbf{v}. A triangle has half of it.
  8. Which way does u×v\mathbf{u} \times \mathbf{v} point?

    At right angles to both u\mathbf{u} and v\mathbf{v}, as the right-hand rule says: fingers along u\mathbf{u}, curled towards v\mathbf{v}, thumb along u×v\mathbf{u} \times \mathbf{v}.
  9. What is v×u\mathbf{v} \times \mathbf{u}?

    −(u×v)-(\mathbf{u} \times \mathbf{v}): the same length, the opposite direction.
  10. When is u×v\mathbf{u} \times \mathbf{v} the zero vector?

    When u\mathbf{u} and v\mathbf{v} are parallel, or one of them is the zero vector.

Sources

We checked the facts on this page against these sources. All of them may be reused freely: they carry an open licence or are not covered by copyright.

  1. Ken Kuttler (Lyryx) - A First Course in Linear Algebra, 4.7 The Dot Product (the sum of products of coordinates, u · v = |u||v| cos θ, perpendicular vectors, u · u = |u|², u · v = v · u, the projection) · CC BY 4.0
  2. Ken Kuttler (Lyryx) - A First Course in Linear Algebra, 4.9 The Cross Product (the coordinates, the determinant with i, j, k, perpendicular to both vectors, |u × v| = |u||v| sin θ, the area of the parallelogram and of a triangle, the right-hand rule, v × u = −(u × v)) · CC BY 4.0
  3. David Austin - Understanding Linear Algebra, 6.1 The dot product (the dot product is a scalar, its link with the angle, perpendicular vectors) · CC BY 4.0
  4. Benjamin Crowell - Mechanics, 13.3 The dot product (work W = |F||d| cos θ, the component parallel to a vector) and 15.8 Angular momentum in three dimensions (the cross product, |A × B| = |A||B| sin θ, the right-hand rule, A × B = −B × A) · CC BY-SA 3.0
  5. Wikibooks - Calculus/Vectors (the dot product and the angle, the cross product as a determinant, perpendicular to both vectors, the area of the parallelogram, the right-hand rule) · CC BY-SA 4.0
  6. Wikipedia - Dot product (coordinates, |a||b| cos θ, the scalar projection, perpendicular vectors, a · a = |a|²) · CC BY-SA 4.0
  7. Wikipedia - Cross product (coordinates, the determinant, perpendicular to both, the area of the parallelogram, the right-hand rule, anticommutative, zero for parallel vectors, torque) · CC BY-SA 4.0

More explainers