# Help solving differential equation

I want to solve the following differential equation:

$y[t]$ : vertical position (height) of the object at time t
$y_c$ : height of the ceiling
$y_e$ : equilibrium point, the height at which the mass will stop at the end of its movement.
$a[t]$ : acceleration at time t
$t$ : time
$k$ : spring coefficient
$m$ : mass of the object
$G$ : gravity

\begin{align} &F = -ky[t] - mG \\ \Leftrightarrow &ma[t] = -ky[t] -mG \\ \Leftrightarrow&my''[t] = -ky[t] -mG\\ \Leftrightarrow&y''[t] = -\dfrac{k}{m}y[t] -G \end{align} subject to:
$$y[0] = y_c\\y'[0] = 0$$

I'm not really sure how to do so. The equation is for modeling the movement of a falling object that is attached to a spring that is attached to the ceiling, thus gravity ($G$) is involved. appreciate your help:

Appreciate your help :)

-
There are a variety of ways to solve it. Are you looking for an analytical solution or a numerical one? Also, have you consulted any introductory ordinary differential equations books? This is a classic problem with well studied properties and I'm sure you can find more detailed information in a good undergraduate textbook. –  Paul Aug 23 '12 at 15:33
Hi, I'm not sure, I'm a programmer, not a mathematician, I just want a formula that would produce the y of the object for a given time. –  Israel Aug 23 '12 at 15:38

## 2 Answers

Let $\omega = \sqrt{k/m}$ so that the differential equation we wish to solve is $$y'' + \omega^2 y = -G$$ Given any two solutions $y_1, y_2$, their difference satisfies $y'' + \omega^2 y = 0$, and the general solution of this is given by $y(t) = A cos(\omega t) + B \sin(\omega t)$. Hence the general solution of the original equation is $$y(t) = A \cos(\omega t) + B \sin (\omega t) + y_p(t)$$ where $y_p(t)$ is any particular solution to the original equation. However, the equation is easy enough that we can guess a solution using the method of undetermined coefficients. In this case we can guess $y_p(t) = c$ where $c$ is a constant. Plugging it into the differential equation yields: $$\omega^2 c = - G$$ hence $c = -G / \omega^2$. So the general solution to the original equation is $$y(t) = A \cos(\omega t) + B \sin(\omega t) - \frac{G}{\omega^2}$$

Setting $t=0$, we find $$y_0 = A - \frac{G}{\omega^2}$$ and $$y'_0 = B \omega$$ so that $$y(t) = \left(y_0 + \frac{G}{\omega^2} \right) \cos(\omega t) + \frac{y'_0}{\omega} \sin(\omega t) - \frac{G}{\omega^2}$$

-
Thanks! What a wonderful explanation! :) –  Israel Aug 24 '12 at 18:57

I have not checked your derivation of the final differential equation, but assuming we start from

$$y''=-\frac k m y - G$$ Where $k,m,G$ are constants, we can use the annihilator method, considering the linear differential operator $L=D(D^2+\frac k m)$. This has the general solution $y(t)=-\frac k m G+c_1\cos{\sqrt \frac k m t}+c_2\sin{\sqrt\frac k m t}$, and the coefficients $c_1,c_2$ can easily be found by plugging in your initial conditions.

-