When working with a variable force, the total work done from an initial position $x_i$ to a final position $x_f$ is given by:
The NCERT text explicitly states: 'Thus, for a varying force the work done can be expressed as a definite integral of force over displacement: $W = \int_{x_i}^{x_f} F(x) dx$.'