Hooke's law, written in a simple equation, is simply this:
where F is the force required to push the spring, k is the spring constant (stiffness), different for every spring and x is the distance the spring is pushed or pulles. If we are pushing, though, the spring will be pushing back on us with an equal and opposite force. This can obviously be expressed as:
where F is the force of the spring pushing back on whatever force is pushing it. This law is accurate for all linear springs so long as x is not too great.
In order to use this in most cases, we must put this force in terms of work, which should be:
Yet 'F' is not a single value, but increases linearly with x.
We must use the average force, which is 0.5(0+kx), or 0.5kx. In other words, we have W=Favgx=(0.5kx)(x)=0.5kx2.
Since the change in potential energy is equivalent to the work done, we can write the elastic potential is this:
This equation works equally well if you're pulling the spring.