Sub topic 8
Work as a dot product of force and displacement
This chapter assumes you know how to write a vector in components, that you have met W = F d cos θ, and that you can do basic trigonometry. The calculus section near the end also assumes definite integrals.
The earlier chapters defined work with an angle: W = F d cos θ. That formula works when you know the magnitudes and the angle between the vectors. In many problems you know components instead, such as a force of (30, 40) N and a displacement of (6, 2) m. The dot product gives the same quantity directly from components, without finding any angle.
The definition
For two vectors A and B, the dot product (also called the scalar product) is a single number:
A · B = |A| |B| cos θ
Here θ is the angle between the vectors when they are placed tail to tail, from 0° to 180°. The result is a scalar, so it has a size and a sign but no direction.
Work is the dot product of the force and the displacement:
W = F · d
This is the same formula as W = F d cos θ. The dot product is a compact way to write it, and it comes with an algebra that makes calculations easier.
Computing from components
If F = (Fx, Fy, Fz) and d = (dx, dy, dz) in the same coordinate system, then:
W = Fx dx + Fy dy + Fz dz
Each component of the force is multiplied by the matching component of the displacement, and the products are added.
This works because you can split each vector into perpendicular parts. Only force and displacement along the same axis combine to give work. Cross terms such as Fx dy never appear, because the x and y axes are perpendicular and perpendicular directions contribute nothing to each other.
Worked example
A force F = (30, 40) N acts on an object that moves through d = (6, 2) m.
- Multiply the x components: 30 × 6 = 180.
- Multiply the y components: 40 × 2 = 80.
- Add them: W = 260 J.
To recover the angle, use the definition. |F| = 50 N and |d| = √40 ≈ 6.325 m. So cos θ = 260 / (50 × 6.325) ≈ 0.822, which gives θ ≈ 34.7°. As a check, F points at atan(40/30) = 53.1° and d points at atan(2/6) = 18.4°. The difference is 34.7°.
import math
def dot(a, b):
"""Dot product of two equal-length sequences of numbers."""
return sum(x * y for x, y in zip(a, b))
def norm(a):
"""Magnitude (length) of a vector."""
return math.sqrt(dot(a, a))
F = (30.0, 40.0) # N
d = (6.0, 2.0) # m
w = dot(F, d)
theta = math.degrees(math.acos(w / (norm(F) * norm(d))))
w_check = norm(F) * norm(d) * math.cos(math.radians(theta))
print(w, round(theta, 1)) # 260.0 34.7
print(round(w_check, 1)) # 260.0The dot function works for any number of dimensions, so the same code handles 2D and 3D problems.
Algebraic properties that help with work
The dot product follows three rules. Each one has a direct use in work problems.
| Property | Statement | What it means for work |
|---|---|---|
| Commutative | A · B = B · A | Order does not matter. F · d and d · F are the same work. |
| Distributive | A · (B + C) = A · B + A · C | The work of several forces equals the sum of their individual works. |
| Scalar multiplication | (kA) · B = k (A · B) | Doubling the force doubles the work. Doubling the displacement doubles the work. |
The distributive rule is the reason net work can be found in two ways:
- Add up the work done by each force separately.
- Add the forces as vectors first to get the net force, then take its dot product with the displacement.
Both give the same answer:
Wnet = F1 · d + F2 · d + ... = (F1 + F2 + ...) · d = Fnet · d
This holds as long as every force acts on the same object and that object undergoes one displacement.
Worked example: a block on an incline
A 2.0 kg block slides 4.0 m down a frictionless incline that makes 30° with the horizontal. Take x as horizontal and y as up, with g = 9.8 m/s².
- Displacement: d = (4 cos 30°, −4 sin 30°) ≈ (3.46, −2.00) m.
- Gravity: F_g = (0, −mg) = (0, −19.6) N.
- Normal force: it has magnitude mg cos 30° and points perpendicular to the surface, in the direction (sin 30°, cos 30°).
Gravity does W = (0)(3.46) + (−19.6)(−2.00) = 39.2 J. The normal force is perpendicular to the displacement, so its dot product with d is zero. The net work is therefore 39.2 J, the same as the work done by gravity alone.
import math
def dot(a, b):
return sum(x * y for x, y in zip(a, b))
m, g, s = 2.0, 9.8, 4.0
angle = math.radians(30)
d = (s * math.cos(angle), -s * math.sin(angle))
gravity = (0.0, -m * g)
normal = tuple(m * g * math.cos(angle) * c
for c in (math.sin(angle), math.cos(angle)))
w_gravity = dot(gravity, d)
w_normal = dot(normal, d)
f_net = tuple(a + b for a, b in zip(gravity, normal))
print(round(w_gravity, 1)) # 39.2
print(math.isclose(w_normal, 0.0, abs_tol=1e-9)) # True
print(round(dot(f_net, d), 1)) # 39.2The output shows the two routes to net work agreeing. The normal force contributes nothing to the sum.
Reading the sign from the dot product
The sign of F · d is the sign of cos θ. This gives you the same classification you learned earlier, now written as a rule about the dot product.
| Angle θ between F and d | cos θ | F · d | Effect on the object |
|---|---|---|---|
| 0° ≤ θ < 90° | positive | positive | Force adds energy. The object speeds up along the motion. |
| θ = 90° | zero | zero | No energy transfer. |
| 90° < θ ≤ 180° | negative | negative | Force removes energy. The object slows. |
A component-based sign check is often faster than finding θ. If Fx dx + Fy dy comes out negative, the force opposes the motion on balance, even if one component happens to point the same way as the motion.
Perpendicularity gives a useful test. Two nonzero vectors are perpendicular exactly when their dot product is zero. A condition such as "the force does no work on this displacement" becomes the equation F · d = 0, which you can solve for an unknown component.
Example: finding an unknown component
A force F = (Fx, 5.0) N acts on an object that moves through d = (2.0, 3.0) m. For what Fx is the work zero?
Set W = 2.0 Fx + 15.0 = 0, so Fx = −7.5 N. The force then points at an angle of exactly 90° from the displacement.
A decision guide
You now have three ways to find the work of a constant force. Choose by what the problem gives you.
All three constant-force branches are the same dot product written in different forms.
When the force or path changes
The formula W = F · d needs a constant force and a straight-line displacement. When either condition fails, apply the dot product to a tiny piece of the path and add up the pieces. For a small displacement dr, the work is dW = F · dr, and the total is the line integral:
W = ∫ F · dr
For motion along the x-axis with a force Fx(x), this reduces to W = ∫ Fx dx, the area under the force-versus-position curve. For a curved path, the direction of dr changes from point to point, so the angle between F and dr changes too. The dot product handles this automatically, because you evaluate F · dr at each point.
A numerical version is a sum of F · Δr over many short straight steps:
import math
def dot(a, b):
return sum(x * y for x, y in zip(a, b))
def work_along_path(force_fn, points):
"""Approximate W = integral of F . dr along a path given as a list of
(x, y) points. The force is evaluated at the midpoint of each segment."""
total = 0.0
for p, q in zip(points, points[1:]):
dr = (q[0] - p[0], q[1] - p[1])
mid = ((p[0] + q[0]) / 2, (p[1] + q[1]) / 2)
total += dot(force_fn(*mid), dr)
return total
# Constant force (0, -9.8) N (gravity on a 1 kg mass) along a quarter circle
# of radius 1 m, from (1, 0) up to (0, 1).
n = 2000
path = [(math.cos(math.pi / 2 * i / n), math.sin(math.pi / 2 * i / n))
for i in range(n + 1)]
w = work_along_path(lambda x, y: (0.0, -9.8), path)
print(round(w, 2)) # -9.8The work depends only on the vertical rise of 1 m, because the force has only a y component. The result is −9.8 J. For this kind of force, the path between the endpoints does not change the answer.
Common mistakes and edge cases
- Using the wrong angle. θ is the angle between the force vector and the displacement vector. It is not the angle of the incline or the angle of the force above the horizontal, unless the displacement happens to lie along the horizontal. When in doubt, use components.
- Degrees versus radians. Python's
math.cosexpects radians. Convert withmath.radiansfirst. A calculator in the wrong mode gives the same kind of error. - Mixing coordinate systems. Every component must come from the same axes. If the force is given along an incline and the displacement is given horizontally, rotate one of them before multiplying components.
- Confusing the dot product with the cross product. A · B is a scalar and uses cos θ. A × B is a vector and uses sin θ. Work always uses the dot product.
- Expecting a direction. Work has no direction. A negative result means energy leaves the object. It does not mean the work points backwards.
- Zero vectors. If F = 0 or d = 0, then W = 0, and the angle is undefined. Guard against division by zero when you compute θ from components, as in
acos(w / (norm(F) * norm(d))). - Floating-point noise. Perpendicular vectors in code often give a result like 1e-16 instead of exactly 0. Compare with
math.iscloseand an absolute tolerance. - Rounding in
acos. For nearly parallel vectors, the ratio can land slightly above 1.0 and makemath.acosraise an error. Clamp it withmax(-1.0, min(1.0, ratio))when working with real data.
Why the dot-product form matters
The dot product makes three things easier.
- Components. You can compute work from numbers you already have in a coordinate system, with no trigonometry.
- Net work. The distributive property turns "sum of works" and "work of the sum" into the same calculation. The next chapters use this when they apply the work-energy theorem.
- Generalization. The same expression, F · dr, extends from straight lines to curved paths, and later to the power formula P = F · v.
Exercise
A force F = (4.0, −3.0) N acts on an object that moves through d = (5.0, 2.0) m. Find the work done, and say whether the force adds energy to the object or removes it.
Show answer
W = Fx dx + Fy dy = (4.0)(5.0) + (−3.0)(2.0) = 20.0 − 6.0 = 14.0 J. The work is positive, so the force adds energy to the object.
Exercise
Two forces act on a crate as it moves through d = (3.0, 0.0) m. F1 = (10.0, 5.0) N and F2 = (−4.0, 8.0) N. Find the net work by (a) summing the work of each force and (b) adding the forces first. Confirm they agree.
Show answer
(a) W1 = (10.0)(3.0) + (5.0)(0.0) = 30.0 J. W2 = (−4.0)(3.0) + (8.0)(0.0) = −12.0 J. The sum is 18.0 J. (b) Fnet = (6.0, 13.0) N, and Fnet · d = (6.0)(3.0) + (13.0)(0.0) = 18.0 J. Both routes give 18.0 J.
Exercise
A force F = (Fx, 6.0) N acts on an object that moves through d = (3.0, −2.0) m. What value of Fx makes the force perpendicular to the displacement, so that it does no work?
Show answer
Set F · d = 3.0 Fx + (6.0)(−2.0) = 0. Then 3.0 Fx = 12.0, so Fx = 4.0 N.
Exercise
A student computes the angle between F = (1.0, 0.0) N and d = (−2.0, 0.0) m using only the magnitudes and gets 0°. Use the dot product to find the correct angle and the sign of the work.
Show answer
F · d = (1.0)(−2.0) + (0)(0) = −2.0 J. |F| = 1.0 and |d| = 2.0, so cos θ = −2.0 / (1.0 × 2.0) = −1, which gives θ = 180°. The vectors point in opposite directions, so the work is negative. Magnitudes alone cannot give the angle, because they carry no direction.