Work done by a variable force

A hand stretching a spring feels the pull grow stronger with every centimetre — the force is not the same throughout the motion. The formula W=FScos⁡θW = FS\cos\theta from constant-force work quietly assumes FF never changes, so it simply cannot answer "how much work did I do stretching this spring by 15 cm?" Physics fixes this by chopping the displacement into infinitesimally small steps, treating the force as constant over each sliver, and adding up (integrating) the tiny bits of work. The same idea has a picture: plotting force against position turns work into the area under the curve, so even a spring's straight-line force graph gives its work as the area of a simple triangle. This article builds the integral definition of variable-force work, connects it to the force-displacement (F-S) graph, and applies both routes — calculus and geometry — to a linear force and to a stretching spring, checking that they agree.

The core insight

When force varies with position, work is found not from FScos⁡θFS\cos\theta but from the integral W=∫F dxW = \int F\,dx, which equals the area under the force-displacement graph.

The core idea

Why the constant-force formula breaks down. W=FScos⁡θW = FS\cos\theta treats FF as a single fixed number multiplying the whole displacement. The moment FF depends on position — a spring's tension, a rocket's thrust, air drag on a falling body — that formula has nothing to multiply by, because there is no single "the force" for the whole journey.

Slicing the motion. The fix is to break the total displacement into infinitesimally small steps dS⃗d\vec S, so small that over each one the force is essentially unchanged. The work done in one such tiny step is:

dW=F⃗⋅dS⃗dW = \vec F \cdot d\vec S

where: dWdW is the infinitesimal work in one slice, F⃗\vec F is the force during that slice (treated as constant), and dS⃗d\vec S is the tiny displacement vector of the slice. Adding up every slice between the starting position S1S_1 and the final position S2S_2 gives the total work as an integral:

W=∫S1S2F⃗⋅dS⃗W = \int_{S_1}^{S_2} \vec F \cdot d\vec S

For straight-line motion where the force component along the motion is a function F(x)F(x) of position xx, this becomes the one-dimensional form used throughout this topic:

W=∫x1x2F(x) dxW = \int_{x_1}^{x_2} F(x)\,dx

where: F(x)F(x) is the force as a function of position, and x1x_1, x2x_2 are the initial and final positions. This is exactly what integration means physically here — summing infinitely many "force times tiny displacement" contributions.

The graphical shortcut. Plot FF on the vertical axis against displacement SS on the horizontal axis. Because W=∫F dxW = \int F\,dx is literally the definite integral of the F-S curve, the work done between two positions is the area under the graph between them, above the S-axis counting as positive work and any area below the axis (negative FF) counting as negative work. This matters practically: for graphs made of straight-line segments — as with a spring's tension — the area is often just elementary geometry (a triangle or trapezium), no calculus required.

Figure
A force displacement graph with a straight rising line through the origin and the triangular area beneath it shaded to represent the work done in stretching a spring
Work as area under the F-S graph — a spring's straight line extension x force F = kx F = kx at x x area = W = half k x squared 0

The spring case. For a spring stretched by xx from its natural length, Hooke's law gives the restoring force needed as F=kxF = kx, where kk is the spring constant. This is a straight line through the origin on the F-S graph, so the work done in stretching from 00 to xx is the area of a right triangle — leading directly to the elastic potential energy result U=12kx2U = \tfrac12 kx^2, worked out below.

Derivation AWork done in stretching a spring by x

The goal is to find the work done in stretching a spring of force constant kk from its natural length to an extension xx, using the fact that the applied force must grow in step with the extension, and to show that the calculus route (W=∫F dxW = \int F\,dx) and the geometric route (area of a triangle on the F-S graph) give the identical answer, confirming why the work is half, not all, of the final-force-times-extension product that a careless reading of W=FxW = Fx would suggest.

Step 1. Write the variable force. By Hooke's law, to hold the spring stretched by an amount yy (a running variable between 00 and the final extension xx) requires a force F(y)=kyF(y) = ky, growing linearly from zero at y=0y=0 to kxkx at y=xy=x.

Step 2. Integrate to get the work. W=∫0xF(y) dy=∫0xky dy=k[y22]0x=12kx2W = \displaystyle\int_0^x F(y)\,dy = \int_0^x ky\,dy = k\left[\dfrac{y^2}{2}\right]_0^x = \dfrac{1}{2}kx^2. The factor of one-half appears because the force was not constant at its final value kxkx throughout — it started at zero.

Step 3. Confirm with the area under the graph. On the F-S graph, F(y)=kyF(y) = ky is a straight line through the origin ending at the point (x,kx)(x, kx). The region under it, from y=0y=0 to y=xy=x, is a right triangle with base xx and height kxkx, so its area is 12×base×height=12×x×kx=12kx2\tfrac12 \times \text{base} \times \text{height} = \tfrac12 \times x \times kx = \tfrac12 kx^2 — identical to Step 2.

Step 4. State the result. W=12kx2W = \tfrac12 kx^2 is the work done in stretching (or compressing) a spring by xx from its natural length; it is not kx⋅x=kx2kx \cdot x = kx^2 because the force is only kxkx at the very end of the stretch, averaging to 12kx\tfrac12 kx over the whole motion.

Worked example

The force acting on a body moving along the x-axis varies as F(x)=(5+2x) NF(x) = (5 + 2x)\ \text{N}, with xx in metres. Find the work done as the body moves from x=0x = 0 to x=4 mx = 4\ \text{m}, and confirm the answer using the F-S graph.

Step 1. Set up the integral. Since FF varies linearly with xx, W=∫04(5+2x) dxW = \displaystyle\int_0^4 (5 + 2x)\,dx.

Step 2. Evaluate. W=[5x+x2]04=(5×4+42)−0=20+16=36 JW = \left[5x + x^2\right]_0^4 = (5\times 4 + 4^2) - 0 = 20 + 16 = 36\ \text{J}.

Step 3. Check with the graph. F(x)F(x) is linear, so the F-S graph is a straight line from F=5 NF = 5\ \text{N} at x=0x = 0 to F=5+2(4)=13 NF = 5 + 2(4) = 13\ \text{N} at x=4 mx = 4\ \text{m}. This region is a trapezium, with area W=(5+13)2×4=9×4=36 JW = \dfrac{(5+13)}{2}\times 4 = 9 \times 4 = 36\ \text{J}. Both routes agree: W=36 JW = 36\ \text{J}.

Competitive stretch

A spring of force constant k=200 N/mk = 200\ \text{N/m} is stretched from its natural length by 0.15 m0.15\ \text{m}. Using the spring result derived above, W=12kx2=12(200)(0.15)2=12(200)(0.0225)=2.25 JW = \tfrac12 kx^2 = \tfrac12 (200)(0.15)^2 = \tfrac12(200)(0.0225) = 2.25\ \text{J}. Equivalently, the triangular area on the F-S graph has base 0.15 m0.15\ \text{m} and height F=kx=200×0.15=30 NF = kx = 200 \times 0.15 = 30\ \text{N}, giving W=12×0.15×30=2.25 JW = \tfrac12 \times 0.15 \times 30 = 2.25\ \text{J} — the same 2.25 J.

Common traps

  • Using W=FScos⁡θW = FS\cos\theta directly when FF depends on position — this constant-force formula is only valid when FF does not change over the displacement; a varying force needs W=∫F dxW = \int F\,dx or the area-under-graph method.
  • Using the wrong limits of integration, especially when motion does not start at x=0x = 0; the limits must be the actual initial and final positions, not 00 and the extension by default.
  • Reading the F-S graph as if the work equals the force value at some point — it is the area between the curve and the x-axis over the interval, not a single ordinate, and area below the axis represents negative work.
  • Writing a spring's stretching work as Fx=kx⋅x=kx2Fx = kx \cdot x = kx^2 instead of 12kx2\tfrac12 kx^2 — this ignores that the force grows from zero, so its average over the stretch is 12kx\tfrac12 kx, not kxkx.

Ask the tutor: Want a few extra F(x) integration or spring-stretching problems to practise the calculus-versus-geometry check?

Why is the work done stretching a spring half of the final force times the extension, and not just Fx?

Because the force is not constant during the stretch — it starts at zero when the spring is at its natural length and grows to kxkx only at the final extension. The work is the area under the F-S line, which is a triangle, not a rectangle. A rectangle of height kxkx and width xx would give kx2kx^2, but that assumes the full force acted throughout the motion, which it did not. The triangle's area, 12×base×height=12kx2\tfrac12 \times \text{base} \times \text{height} = \tfrac12 kx^2, correctly uses the average force 12kx\tfrac12 kx over the stretch.

When can I just use the area-under-graph method instead of integrating?

Whenever the F-S graph is made of straight-line segments — a linear force like a spring's, or a force given piecewise as straight lines — the area is a triangle, rectangle, or trapezium, and elementary geometry gives the exact answer with no calculus needed. If the graph is curved (for example FF varying as x2x^2 or some other nonlinear function), you either integrate directly or estimate the area under the curve (for instance by counting grid squares), since simple geometric shapes will not fit it exactly.

How do I know which limits to use when the motion does not start at x equals zero?

The limits of the integral (or the endpoints of the region whose area you take) must always be the actual starting and ending positions of the body, not 00 and the total distance moved by default. If a body moves from x=2 mx = 2\ \text{m} to x=6 mx = 6\ \text{m} under a force F(x)F(x), the work is ∫26F(x) dx\int_2^6 F(x)\,dx, evaluated using those exact limits — plugging in 00 and 44 (the displacement) instead would silently compute the work over the wrong stretch of the force function.

Before this

Where this leads