Essential University Physics: Volume 1 (4th Edition)

According to law of conservation of energy $(\frac{1}{2})kx^2=mgh+mgx$ This can be rearranged as: $x^2-(\frac{2mg}{k})x-(\frac{2mgh}{k})=0$ This simplifies to: $x=\frac{(\frac{2mgh}{k})+\sqrt{(\frac{2mg}{k})^2+(4)(\frac{2mgh}{k})}}{2}$ $\implies x=(\frac{mg}{k})(1+\sqrt{1+\frac{2kh}{mg}})$