Show that the combined spring energy and gravitational energy for a mass m hanging from a light spring of force constant k can be expressed as 1/2 ky2, where y is the distance above or below the equilibrium position.
Figure shows a block connected to spring, where equilibrium is, and where the spring’s unstretched position is. The distance from unstretched position to equilibrium is defined as h. From equilibirum to mass is y.
The answer starts off as
U = 1/2 k(h+y)2 – mg((h/2) +y)
From there it says mg=kh and substitutes for mg then solves.
I’m confused how U equals all that. I get how potential energy of a spring is 1/2 kx^2 for a spring or mgh in other cases, but this is quite confusing.
Then where did the 1/2 from h/2 come from?