spsch said:
... hmm, this gives me trouble, I have to ponder about this a bit.
It looks like the big picture may still elude you. Remember that the zero of potential energy is arbitrary. The gravitational energy of mass ##m## at height ##y## above ground is ##U_g=mg(y-y_0)##; it is zero when ##y=y_0##. The elastic energy of a spring stretched (or compressed) by amount ##x## from its relaxed position is ##U_s=\frac{1}{2}k(x^2-x_0^2)##; it too is zero when ##x=x_0##. Note that ##x## in this context denotes "displacement of the spring from equilibrium", it does
not denote position. The total potential energy is ##U_{tot}=U_g+U_s=mg(y-y_0)+\frac{1}{2}k(x^2-x_0^2)##.
Case 1. A horizontal spring-mass system
For the vertical motion
(a) you can choose the position of the origin, ##Y_{or}## at the vertical height of the mass
(b) you can choose the zero of potential energy at the origin (##y_0=0##)
Then ##U_g =mg(0-0)=0## throughout the motion.
For the horizontal motion
(a) you can choose the horizontal location of the origin, ##X_{or}## at the mass when the spring is unstretched. Remembering that ##x## stands for the displacement of the spring from the origin, clearly it also stands for the displacement of the mass from the origin. At this point you still have to choose the zero of spring energy.
(b) A common and useful choice is ##x_0=0##,
but it could be anything you want.
With all of the above in mind, if the mass has speed ##v_0## when the spring is unstretched, the mechanical energy at some arbitrary ##x## is $$ME=K+U_g+U_s=\frac{1}{2}mv^2+0+\frac{1}{2}kx^2.$$Because mechanical energy is conserved and we have chosen the zero spring potential energy to be where the speed is maximum at ##x=0##, this becomes the familiar $$ME=\frac{1}{2}mv^2+\frac{1}{2}kx^2=\frac{1}{2}mv_0^2~~~~~(1)$$
Case 2. A vertical spring-mass system
Start with the most general expression for the mechanical energy and then you need to choose three quantities, the position of the origin ##Y_{or}##, the zero of gravitational potential energy ##y_0## and the zero of spring potential energy ##x_0##.$$ME=\frac{1}{2}mv^2+mg(y-y_0)+\frac{1}{2}k(x^2-x_0^2)~~~~~(2)$$
Suppose you choose the origin ##Y_{or}## to be at the position of the mass when the net force acting on it is zero, i.e. ##kx_{eq}-mg=0##. Then ##x_{eq}=\frac{mg}{k}## below the unstretched position of the spring. The displacement of the mass from this origin is the same as the
additional stretch (or compression) of the spring call that quantity, ##\xi##, that is ##y=\xi##.
We choose the zero of gravitational potential energy to be at ##Y_{or}##. Then ##y_0=0##.
We also choose the zero of spring potential energy to be not where the spring is unstretched but where the additional stretch ##\xi = 0##. That occurs at ##x_{eq}## as we have previously found, that is ##x_0=x_{eq}=\frac{mg}{k}##.
Finally, the stretch of the spring from the equilibrium position ##x## is related to the additional stretch ##\xi## by$$x=\xi-\frac{mg}{k}.$$With all this equation (2) becomes$$ME=\frac{1}{2}mv^2+mg\xi-\frac{1}{2}k\left[\left(\xi- \frac{mg}{k}\right)^2-\left(\frac{mg}{k}\right)^2\right]$$This simplifies to$$ME=\frac{1}{2}mv^2+\frac{1}{2}k\xi^2~~~~~(3)$$
If we compare equations (1) and (2) for the mechanical energy of a spring-mass system, we see that they are identical in that, by judicious choices of the origin and the zeroes of the two potential energies, (a) the spring potential energy depends quadratically on the displacement relative to the (force) equilibrium position and (b) the potential energy contribution can be written out of the picture.