# Movement equation for the Simple harmonic oscillator

According to Wikipedia the only force working on a simple harmonic oscillator when it is extended from its position of rest the force of the oscillator itself. However if we consider the Newtonic axiom

then its for suppose the $$y$$ Axis $$m.a_y = - mg + D(x_0 - x_1)$$ however in books and internet pages it is often to be seen that the gravitational force is completely ignored, sadly no explination or reasoning for why this is done.

I asked my tutor and he said it is because the gravitational force only change the position of rest. However I would like to have a nice mathematical view of why I can write 0 there.

I found a video explaining this.

The force of the harmonic oscillator is written as $$F_{ho} = - D \cdot (x - x_0)$$ where $$D$$ is the so called spring constant and $$x_0$$ is the location of reference, where the mass does not experience any force. Now, let's add a constant force, like gravity. The total force acting on the mass $$m$$ reads $$F_{total} = F_{g} + F_{ho} = -m g - D \cdot (x - x_0) = - D \cdot (x - \tilde x_0)$$ where we used $$\tilde x_0 := x_0 - \frac{mg}{D}$$. Thus, by adding a constant term, we simply change the reference position.
Okay, so, look at it like this. In the equation you described, shown below, $$x_0$$ is a constant, being the resting point of the spring under zero gravity. $$m\cdot a_y = - mg + D \cdot (x_0 - x_1)$$ We also know that $$D$$, $$m$$, and $$g$$ are similarly, constant values under normal circumstances, which means we can rewrite your original function as follows: $$m\cdot a_y = D \cdot (x_0' - x_1)$$ with $$x_0'$$ the new resting point under constant acceleration (in this case, gravity): $$x_0'= x_0 - \frac{m \cdot g}{D}$$ Note that this result holds more generally, so long as the acceleration is constant in time and position. For gravity, it only holds because at the surface of the earth, the difference in position between an extended spring and an non-extended spring is negligible when compared to the distance to the center of mass of the earth.
As you asked, here is a mathematical argument to why gravitational force can be ignored. In general your equation would look like: $$x''=-\frac{k}{m}x+C$$ $$x''+\omega^2x=C$$ with $$\omega^2=\frac{k}{m}$$.
The solutions can be written as a solution of the homogeneous asociated equation (RHS =0) plus a particular solution. The homogeneous solution is, as you know, $$x_h(t)= Ae^{i\omega t}$$, $$A\in\mathbb{C}$$. Now you have to get a particular solution, with the method you like the most. In this case, a trivial solution is $$x_p(t)=C\frac{m}{k}$$ which is constant. So, the final solution (taking the real part) is: $$x(t)=x_h(t)+x_p(t)$$ $$x(t)=Acos(\omega t+\phi)+C\frac{m}{k}$$ I don't know what it would be in your case, because I don't understand what $$(x_0 - x_1)$$ is.
Edit: Now I understand you meant a spring-mass system haging vetically In that case, you would have: $$x''=-\frac{D(x-x_0)+mg}{m}$$ where $$x_0$$ would be the equilibrium position without gravity $$x''=-\frac{D}{m}x+\frac{Dx_0-mg}{m}$$ $$k=D$$ $$C=\frac{Dx_0-mg}{m}$$ $$\Rightarrow x(t)= Acos(\sqrt{\frac{D}{m}}t+\phi)+x_0-\frac{mg}{D}$$