Assume I have a spring with a mass hanging from it such that the mass pulls the spring down until it just about touches the floor, but no force is applied by the mass to the floor itself.
I want to find the distance of the mass from the spring equilibrium. Since the force of the spring cancels out the force of gravity on the mass, I know that $ky = mg$, and so, the distance from the equilibrium must be $mg/k$.
However, why doesn't the principle of energy conservation work? I know that at the equilibrium, the energy is only the potential energy of gravity, which is $mgh$, and when it reaches the floor, it will only have the potential energy of the spring, and since there is no velocity, there is no kinetic energy.
And so, we get the formula:
$$mgy = \frac{ky^2}{2}$$
Which is wrong? Why?