Vectors: dot and cross product

Mathematics · First-year university mathematics · about 10 min

A vector has magnitude and direction. The dot product combines two vectors into a scalar that tells you about their alignment. The cross product combines two vectors in three dimensions into a perpendicular vector. These operations appear in geometry, work, torque and many engineering calculations.

The key idea

For vectors a\mathbf a and b\mathbf b with angle θ\theta between them,

a⋅b=∣a∣∣b∣cos⁡θ\boxed{\mathbf a\cdot\mathbf b=|\mathbf a||\mathbf b|\cos\theta} ∣a×b∣=∣a∣∣b∣sin⁡θ\boxed{|\mathbf a\times\mathbf b|=|\mathbf a||\mathbf b|\sin\theta}

The dot product is a scalar. The cross product is a vector perpendicular to both inputs.

Draw an x-y coordinate plane. Draw vector a as an arrow from the origin O=(0,0) to A=(3,0), pointing right. Draw vector b as an arrow from O to B=(1,2), pointing up and right. Draw a circular angle arc centred at O, radius 0.65 units, from the positive x-axis counterclockwise to the direction of b, approximately 1.107 radians. Put θ beside that arc. Use equal scales on x and y; place the vector names close to their respective arrowheads.
The dot product depends on the angle between two vectors.

Try it yourself

Rotate two vectors and compare their dot product, cross product and angle.

Dot product and angles

For three-dimensional vectors a=(ax,ay,az)\mathbf a=(a_x,a_y,a_z) and b=(bx,by,bz)\mathbf b=(b_x,b_y,b_z), calculate a⋅b=axbx+ayby+azbz\mathbf a\cdot\mathbf b=a_xb_x+a_yb_y+a_zb_z. To find the angle, rearrange to cos⁡θ=(a⋅b)/(∣a∣∣b∣)\cos\theta=(\mathbf a\cdot\mathbf b)/(|\mathbf a||\mathbf b|), provided neither vector is zero. A positive dot product means an acute angle, a negative result means an obtuse angle, and zero means perpendicular nonzero vectors. Magnitudes come from ∣a∣=ax2+ay2+az2|\mathbf a|=\sqrt{a_x^2+a_y^2+a_z^2}. The dot product also measures how strongly one vector points in the direction of another.

Cross product and direction

In three dimensions, a×b=(aybz−azby, azbx−axbz, axby−aybx)\mathbf a\times\mathbf b=(a_yb_z-a_zb_y,\ a_zb_x-a_xb_z,\ a_xb_y-a_yb_x). The resulting vector is perpendicular to both original vectors. Use the right-hand rule to determine its direction; reversing the order reverses the sign, so b×a=−a×b\mathbf b\times\mathbf a=-\mathbf a\times\mathbf b. Its magnitude is the area of the parallelogram formed by the two vectors. For parallel vectors this area is zero, so their cross product is the zero vector. Do not confuse the vector result with its magnitude.

Draw a flat x-y coordinate system with +x pointing right and +y pointing up. Draw vector a from the origin (0,0) to (2,0), pointing right. Draw vector b from (0,0) to (0,2), pointing up. At the origin, add a circled dot symbol indicating a vector pointing out of the page in the +z direction. Place a small label a×b next to that circled dot without covering the axes. This picture represents a×b along +z for right-handed x, y, z axes. Do not draw a vector pointing into the page.
The right-hand rule makes the cross product point out of the plane.

Choosing the right product

Use the dot product for an angle, a projection or a component of force along a displacement. For constant force, work is W=F⋅sW=\mathbf F\cdot\mathbf s, a scalar. Use the cross product for a perpendicular direction, an oriented area or a moment such as τ=r×F\boldsymbol\tau=\mathbf r\times\mathbf F. Check units as well as direction: if both vectors have length units, the dot product has units of area, and the cross-product magnitude also has units of area. The choice depends on what quantity the question asks for.

Worked example: Angle and perpendicular vector

Two vectors are a=(2,−1,2)\mathbf a=(2,-1,2) and b=(1,3,0)\mathbf b=(1,3,0). Calculate their dot product, the angle between them to two decimal places, their cross product a×b\mathbf a\times\mathbf b, and the magnitude of that cross product.

Show the solution

Step 1: Calculate the dot product.

a⋅b=2(1)+(−1)(3)+2(0)=−1.\mathbf a\cdot\mathbf b=2(1)+(-1)(3)+2(0)=-1.

Step 2: Calculate the angle. The magnitudes are

∣a∣=4+1+4=3,∣b∣=1+9+0=10.|\mathbf a|=\sqrt{4+1+4}=3,\qquad |\mathbf b|=\sqrt{1+9+0}=\sqrt{10}.

Therefore

θ=cos⁡−1 ⁣(−1310)≈1.68 rad.\theta=\cos^{-1}\!\left(\frac{-1}{3\sqrt{10}}\right)\approx1.68\,\mathrm{rad}.

Step 3: Form the cross product in component order.

a×b=((−1)(0)−2(3), 2(1)−2(0), 2(3)−(−1)(1))=(−6,2,7).\begin{aligned}\mathbf a\times\mathbf b&=((-1)(0)-2(3),\ 2(1)-2(0),\ 2(3)-(-1)(1))\\&=(-6,2,7).\end{aligned}

Step 4: Find its magnitude and check.

∣a×b∣=(−6)2+22+72=89≈9.43.|\mathbf a\times\mathbf b|=\sqrt{(-6)^2+2^2+7^2}=\sqrt{89}\approx9.43.

As a check, ∣a×b∣2=∣a∣2∣b∣2−(a⋅b)2=9(10)−1=89|\mathbf a\times\mathbf b|^2=|\mathbf a|^2|\mathbf b|^2-(\mathbf a\cdot\mathbf b)^2=9(10)-1=89.

Answers: dot product −1\boldsymbol{-1}, angle 1.68 rad\boldsymbol{1.68\,\mathrm{rad}}, cross product (−6,2,7)\boldsymbol{(-6,2,7)}, and magnitude 89≈9.43\boldsymbol{\sqrt{89}\approx9.43}.

Common mistakes

Treating the dot product as a vector.

Remember that adding pairwise component products produces one scalar.

Reversing the cross product without changing its sign.

Write the vector order explicitly and use the right-hand rule.

Forgetting to divide by both magnitudes when finding an angle.

Use cos⁡θ=(a⋅b)/(∣a∣∣b∣)\cos\theta=(\mathbf a\cdot\mathbf b)/(|\mathbf a||\mathbf b|).

Confusing a cross product with its magnitude.

Report three components for the vector, or a nonnegative number for its magnitude.

Check your understanding

1. Find (1,2,0)⋅(3,−1,4)(1,2,0)\cdot(3,-1,4).

2. Using right-handed unit vectors, what is i×j\mathbf i\times\mathbf j?

3. What is ∣(2,0,0)×(0,3,0)∣|(2,0,0)\times(0,3,0)|?

Still not sure? Talk it through.

Waypoint Mentor's tutor explains this out loud, works through your own problems on a whiteboard, and checks you've got it. Free to start.

Explain this to me

Related topics