Let the force applied on a body vary with time or position; of the body. The work done is given by


W = ∫ F ds where F is instantaneous force and ds is infinitesimally small displacement in time interval dt.
The work done by a variable force equals the area under force vs displacement graph. Fig. shows F vs S graph. For displacement from S1 to S2 .
The work done, W = Area of the shaded part of the F vs S graph
The area above the displacement axis is taken as positive and below it as negative.
Net work done for a displacement from the origin O to S1 (Fig. b) is given by
W = W1 – W2 .