Todd W. answered 09/08/20
Experienced Math and Engineering Tutor
While I've drawn the system in the horizontal direction, the same approach applies to a vertical system, the difference being that Δx would then be the displacement from the rest position (e.g. the position where the the mass rests under it's own weight) rather than the change in the length of the spring from it's unstressed length.