According to Physics Classroom, elastic potential energy is a kind of energy kept in elastic materials due to compression or stretching by an external force. The elastic potential energy formula is P.E = 1/2 kx2.
In the equation above, "P.E" is the elastic potential energy and expressed in joules, "X" is the displacement and "K" is the spring constant.
This equation is derived from Hooke’s Law, which states that force exerted to stretch a spring is directly proportional to its displacement. This is expressed by the formula F= -kx. TutorVista.com states that this energy formula is applied for problems where elasticity, elastic force and displacement are mentioned. In addition, Physics Classroom gives a special equation for springs that shows the amount of elastic potential energy and its relationship with the amount of stretch/compression and the spring constant.
PE(spring) = 0.5*k*x2 In this equation, "K" is spring constant, and "X" is the amount of compression (relative to equilibrium position).