I thought this would be a particularly simple problem but it is turning out to be quite the opposite. I am sure I am doing a very simple mistake.
The problem statement is that there is a mass which is just barely kept on the spring (help by the force equal to the weight of the spring) such that the spring is uncompressed. As soon as I let the object go, it will compress the spring and come to rest at some height. The energy stored in the spring will be equal to the difference in the potential energy at the two height of the spring (compressed and uncompressed),
$$mgh_i -mgh_f= 1/2 kx^2$$ Furthermore, the compression of the spring would just be the difference in the $h_f -h_i$. This gives me two roots for compression,
$$ x=0 $$ And the second would be, $$ mg=1/2kx $$ But then by this, $kx=2mg$ and $kx$ is force by Hooks law, but then does it means that the force compressing the spring is twice the weight of the object? That sounds odd. I was expecting I would just recover Hooks law but I guess I am doing something wrong here. But I am not sure what that is.
Any help will be much appreciated.
P.S. This is not a homework problem. We are designing a project for our school.
Thanks for your time.