Consider a spring initially at its un-stretched length. To stretch the spring to an extension of x, we have to apply an external force to overcome the spring force.
If we choose to imagine the external force Fext to be exactly equal to the spring force Fspring, then the elastic potential energy stored in the spring is simply equal to the amount of work done by Fext.
If the spring obeys Hooke’s Law, then Fspring will increase according to the formula , where k is the force constant of the spring (aka spring constant). To match the spring force at every point of the stretch, Fext that must also increase according to .
The work done by the external force is thus given by a triangular area under the F-x graph. The elastic potential energy of a spring (EPE) is thus given by the formula
Unlike GPE which increases linearly with height, EPE increases quadratically with extension.