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 points along the -axis, and along the -axis. What is their dot product ?
The dot product multiplies matching coordinates and adds them up: . The two vectors are perpendicular, and the dot product of perpendicular vectors is always . The number belongs to the other product: the cross product of these vectors has length , the area of the by rectangle they span.
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 is a number. It tells you how far goes in the direction of , multiplied by the length of . Imagine light falling at right angles onto the line of : the shadow that casts on that line is what counts. Physics uses exactly this. When a constant force pulls a sledge along a path , only the part of the force along the path does work, and the work is .
The cross product is a vector. It stands at right angles to both and , and its length is the area of the parallelogram that the two vectors span. That area depends on how far goes across - 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.
u = (2, 0, 0); v = (1, 2, 0); θ ≈ 63.4°
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 , and is the length of the shadow of on . You can work out the dot product without drawing anything.
Try it yourself: two vectors in space
Set the three coordinates of and of 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.
- 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 and , move only : the dot product changes, but the parallelogram keeps its area , because its height stays ,
- make , so that : the dot product is and the angle is a right angle,
- in the cross product view, and are always , whatever vectors you set: the cross product is perpendicular to both,
- make parallel to , for example : the parallelogram is flat, and ,
- lift off the floor with : the cross product tilts, but it stays perpendicular to both vectors.
The definition
A vector in space has three coordinates, . Its length is
The dot product. The dot product, or scalar product, of and is the number
The same number comes from the lengths and the angle between the vectors, with :
Here is the shadow of on the line of , with a minus sign when the shadow points away from . So the dot product is the length of times that shadow. In the plane everything works the same, with two coordinates instead of three.
- The order does not matter: .
- A vector times itself gives its length squared: .
- For non-zero vectors, the sign gives the angle away: for an acute angle, for perpendicular vectors and for an obtuse angle.
- Divide by the lengths and you get the angle:
The cross product. The cross product, or vector product, is defined for vectors in three-dimensional space. It is the vector
You can remember it as a determinant with the unit vectors , , 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.
- is perpendicular to and to .
- Its length is , the area of the parallelogram spanned by and . A triangle with sides and has half that area.
- Its direction follows the right-hand rule. For the unit vectors along the axes, .
- Swapping the order turns it round: .
- exactly when and are parallel, or one of them is the zero vector.
Example 1: the angle between two vectors
Find the angle between and .
Step 1. Work out the dot product
We multiply matching coordinates and add the products.
Step 2. Find the lengths of both vectors
We square the coordinates, add them and take the square root.
Step 3. Divide the dot product by the lengths
The quotient is the cosine of the angle.
Step 4. Find the angle
We use the inverse cosine on a calculator.
Answer
. The dot product is positive, so the angle has to be acute, and is.
Example 2: the area of a triangle in space
Find the area of the triangle with vertices , and .
Step 1. Write the sides as vectors from A
We subtract the coordinates of from those of and of .
Step 2. Work out the cross product coordinate by coordinate
We use the formula from the definition, one coordinate per line.
So the cross product is
Step 3. Find its length
The length of the cross product is the area of the parallelogram spanned by the two sides.
Step 4. Take half for the triangle
The triangle is half of that parallelogram.
Answer
The area of the triangle is , half of the length of .
Your turn
Take and . Show that the vectors are perpendicular, work out and find the area of the parallelogram they span. Then check the area in another way.
Hintshow
Perpendicular vectors have a dot product of . For perpendicular vectors , so the area is simply .
Solutiontry it on your own first
Step 1. Work out the dot product
We multiply matching coordinates and add the products.
The dot product is , so the vectors are perpendicular.
Step 2. Work out the cross product
We call the cross product and use the formula from the definition, one coordinate at a time.
So the cross product is
Step 3. Find the area
The area is the length of the cross product.
Step 4. Check it with the lengths
Both vectors have length , and the angle is , so .
Answer
, so the vectors are perpendicular. , and the parallelogram has area - the same as , as it must be for perpendicular vectors.
Common mistakes
- “The dot product is a vector.” It is a number. For the answer is . Multiplying the coordinates but not adding them gives , which is not the dot product.
- “The order does not matter in the cross product.” It does: . In the animation points up, and points down.
- Cosine and sine swapped. The dot product uses , the length of the cross product . For perpendicular vectors the dot product is , and for parallel ones the cross product is .
- The wrong sign in the middle coordinate. It is . Written the other way round in example 2, it gives , and that vector is not perpendicular to : .
- 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 , and as 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 . 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 ?
Two non-zero vectors have . What can you say about the angle between them?
, and the angle between them is . How long is ?
. What is ?
For which are and 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
Question
Answer
How do you work out from the coordinates?
: multiply matching coordinates and add. The result is a number.What is in terms of the lengths and the angle?
- the length of times the shadow of on the line of .Two non-zero vectors have . What does that mean?
They are perpendicular.What does the sign of tell you about the angle?
Positive: an acute angle. Negative: an obtuse angle. Zero: a right angle.What is ?
, the length of squared.How do you find the angle between two vectors?
, then the inverse cosine.What is the length of ?
- the area of the parallelogram spanned by and . A triangle has half of it.Which way does point?
At right angles to both and , as the right-hand rule says: fingers along , curled towards , thumb along .What is ?
: the same length, the opposite direction.When is the zero vector?
When and 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.
- 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
- 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
- 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
- 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
- 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
- Wikipedia - Dot product (coordinates, |a||b| cos θ, the scalar projection, perpendicular vectors, a · a = |a|²) · CC BY-SA 4.0
- 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