It is interesting to know that the forces we encounter everyday are mostly variable in nature which is defined as a variable force and we rarely encounter a constant force.
A force is said to perform work on a system if there is displacement in the system upon application of the force in the direction of the force. The work done by a constant force of magnitude F, as we know, that displaces an object by Δx can be given as,
W = F.Δx
In case of a variable force, the is calculated with the help of integration. For example, in the case of a spring, the force acting upon any object attached to a horizontal spring can be given as
Fs = -kx, where k is the spring constant and x is the displacement of the object attached.
We can see that this force is proportional to the displacement of the object from the equilibrium position, hence the force acting at each instant during the compression and extension of the spring will be different. Thus, the infinitesimally small contributions of work done during each instant are to be counted in order to calculate the total work done.
The graphical interpretation of force in this Force-Displacement plot will help us understand this concept more clearly.