Potential Energy of Springs

An external force is required to compress or stretch a given spring. Let there be a spring of force constant k. This spring is compressed by a distance x. work done by the external force to compress the spring is given by

W = ½kx²

This work is stored in the spring as elastic potential energy. When the spring is left free, it bounces back and the elastic potential energy of the spring is converted into kinetic energy of the mass m.