Work Done by a Variable Force (Spring)

April 12, 2026

Problem

A spring with k = 100 N/m is compressed by 0.5 m. Calculate the work done.

Explanation

Compressing or stretching a spring requires more force the further you push — the spring "fights back" harder. So the work done isn't a simple Force × Distance product; it requires integrating the variable force over the displacement.

The Physics

Hooke's Law says the spring force is proportional to its displacement from equilibrium:

F(x)=kxF(x) = k\,x

where kk is the spring constant (in N/m) and xx is the compression (or extension). The work done against the spring as you compress it from 00 to x0x_{0} is:

W=0x0F(x)dx=0x0kxdxW = \int_{0}^{x_{0}} F(x)\,dx = \int_{0}^{x_{0}} k\,x\,dx

Step-by-Step Solution

Given: k=100  N/mk = 100\;\text{N/m}, compression x0=0.5  mx_{0} = 0.5\;\text{m}.

Find: The work WW done in compressing the spring.


Step 1 — Write the spring force.

F(x)=100x(in newtons)F(x) = 100\,x \quad\text{(in newtons)}

At x=0x = 0 the force is 00 N. At x=0.5x = 0.5 m the force is 5050 N.

Step 2 — Set up the work integral.

W=00.5100xdxW = \int_{0}^{0.5} 100\,x\,dx

Step 3 — Pull the constant out and find the antiderivative.

W=10000.5xdx=100x2200.5W = 100\int_{0}^{0.5} x\,dx = 100 \cdot \dfrac{x^{2}}{2}\bigg|_{0}^{0.5}

Step 4 — Evaluate at the bounds.

=100((0.5)220)= 100 \cdot \left(\dfrac{(0.5)^{2}}{2} - 0\right)

=1000.252= 100 \cdot \dfrac{0.25}{2}

=1000.125= 100 \cdot 0.125

=12.5  J= 12.5\;\text{J}

Step 5 — Recognize the elastic-PE formula.

That entire calculation collapses into the famous formula:

W=12kx02=12(100)(0.5)2=12(100)(0.25)=12.5  JW = \dfrac{1}{2}k\,x_{0}^{2} = \dfrac{1}{2}(100)(0.5)^{2} = \dfrac{1}{2}(100)(0.25) = 12.5\;\text{J}

This is also the elastic potential energy stored in the spring.

Step 6 — Sanity check via average force.

Since the force is linear in xx, the average force is Fˉ=(0+50)/2=25  N\bar F = (0 + 50)/2 = 25\;\text{N}. Multiplying by displacement 0.5  m0.5\;\text{m}:

W=FˉΔx=25×0.5=12.5  J    W = \bar F \cdot \Delta x = 25 \times 0.5 = 12.5\;\text{J} \;\;\checkmark

For a constant-force problem you'd just write W=FdW = F \cdot d, but for a linear force you can use Fˉ\bar F. For more complex forces you must integrate.


Answer: The work done in compressing the spring by 0.5 m is

  W=12.5  J  \boxed{\;W = 12.5\;\text{J}\;}

This is also the elastic potential energy stored — and it would be released as kinetic energy if the spring were allowed to push something free.

Try It

  • Adjust the spring constant widget — see the work scale linearly.
  • Adjust the compression distance — work scales quadratically (x02x_{0}^{2}), so doubling the compression quadruples the work.
  • The right panel shows the force-vs-displacement graph; the shaded triangle under the line equals the work done.
  • Notice the formula W=12kx2W = \tfrac{1}{2}kx^{2} is exactly the area of a triangle with base xx and height kxkx.

Interactive Visualization

Parameters

100.00
0.50
Your turn

Got your own math or physics problem?

Turn any problem into an interactive visualization like this one — powered by AI, generated in seconds. Free to try, no credit card required.

Sign Up Free to Try It30 free visualizations every day
Work Done by a Variable Force (Spring) | MathSpin