In the case of an undamped oscillator, the work done by the system is written as ( assume initial position is 0 ) :
W = - \Delta U = - K \frac{x^2}{2}
But to verify this , we must assume that the force acting on the oscillator is constant , which is not true as F = f(x) according to...