The elastic potential energy of a spring is given by

where k is the spring's constant and x is the displacement with respect to its unstretched position.
The initial potential energy of the spring is zero, because it is in unstretched postion, therefore x=0. The final potential energy is instead, using

and

,

And so, the increase in potential energy is
