Springs come to their equilibrium condition after being deformed. One limitation for this is the force applied should be small enough.
A box is attached to one end of a spring in Figure 1 and the position of the box is at the origin of our coordinate system without any force being applied. Now an external net force is applied on the box towards positive x-direction. And let the magnitude of the force applied on the spring is
The force applied stretches the spring a distance
In
The force exerted by the spring is equal and opposite to the force applied on the spring according to Newton's third law. The same magnitude of force should be applied on the spring on both of its ends to stretch it. You saw the direct proportionality of the force and the elongation in Eq.
If you suppose an infinitesimally small elongation
Now the total work done within the limits
The Eq.
The work done by a conservative force is the negative of the change in potential energy that is,
If a stretched spring does work on a block and the block moves in the direction of the force, the work done should be positive and this requires that the initial potential energy should be greater than the final potential energy which means