# Potential energy of vertical spring

I have an oscillating vertical spring with a mass attached. If I set the resting position of the mass as $x=0$ as the spring oscillates, I will have a graph like this:

If I want to get the potential energy at the Amplitudes of the graph (maximum potential energy), am I correct in saying that it will be $$\frac{kx^2}{2} + mgx?$$ I'm confused at how gravitational potential energy might affect PE and was unable to understand explanations on other sources (they all seemed to assume that the resting position of the spring without the mass to be $x=0$)

• How do you plan to model the damping? – Qmechanic Jan 25 '18 at 13:28
• @Qmechanic If you are asking how I obtained the graph, I conducted experiments where the spring was damped (air, water, oil, syrup, etc.) and tracked the mass using video footage and was able to obtain a graph like the above image. – 선풍기 Jan 25 '18 at 13:46
• Whats wrong with what you have? What did not understand? – ja72 Jan 25 '18 at 15:29
• If you want to use the equilibrium length of the spring with weight attached, then you leave out the gravity term. If you define x relative to the unweighted equilibrium position of the spring, then what you have is correct. I'm curious though--you really used syrup? Can you post a photo of your setup? – Ben51 Jan 25 '18 at 15:35
• @Ben51 Why is it that I need to leave out the gravity term when equilibrium length of the spring with weight attached is defined as 0 displacement? ja72 's answer seems to differ.. – 선풍기 Jan 25 '18 at 16:23

If you want to know how the total potential energy is partitioned between spring energy and gravitational energy, you need to use the unweighted equilibrium position as the zero. If you only care about changes in the total potential energy, shifting the equilibrium position to the weighted location cancels out the force of gravity. The total (net) force acting on the mass (not including damping) is $−kx$.
Once the mass start to oscillate the total energy is the mass potential energy mg(X+/-x) + spring potential energy $kx^2/2$ of course with correct sign.
$E= mg(X+x) + kx^2/2$.