The potential energy of a particle with displacement X is U(X). The motion is simple harmonic, when (K is a positive constant)
U = -
U =
U=K
U=KX
F = - kx ⇒ dW = F dx = - kxdx
So ∫W0dW=∫x0−kxdx⇒W=U=−12kx2