# Reconciling 2 general solutions to second order ODE

A spring-mass system's behavior is described by the following ODE:

$$m{\ddot x}+kx=mg$$

Where dots indicate differentiation with respect to time, $t$. I have found two different general solutions from two different sources:

$$x(t) = A {\cos ({\sqrt {\frac k m}}t}) +B{\sin ({\sqrt {\frac k m}}t}) +{\frac {mg} k}$$

and,

$$x(t) = C{\sin ({\sqrt{\frac k m}}}t+{\arctan({\sqrt{\frac k m}{\frac {x_0} {v_0}}}}))+{\frac {mg} k}$$

Where $A,B,C, k ,m,v_0,x_0,g$ are all constants and $t$ is the independent variable. I cannot figure out how to reconcile the two general solution and rewrite one as the other. There is no trigonmetric identity to relate the two and I am sure they must be the same expression as they plot very similarly. Can anyone provide some indications as to how I can rewrite the first form as the second form of the solution or vice versa?

• Hint: use $$\sin{(\alpha +\beta)}=\sin{\alpha}\cos{\beta}+\cos{\alpha}\sin{\beta}$$ $$1+\tan^2{\gamma}=\frac{1}{\cos^2{\gamma}}$$ substitute $\gamma=\textrm{atan}{\alpha}$ for $\sin{(\textrm{atan}\alpha)}$ and do simmilar things with the $\cos{(\textrm{atan}\alpha)}$ – HBR Dec 11 '16 at 17:19
• Another hint: simplify your notation. Recommendations: $$\omega=\sqrt{k/m}$$ $$\phi_0=\omega x_0/v_0$$ One always will treat nicely the simplified expressions. – HBR Dec 11 '16 at 17:27
• You cannot reconcile your two solutions $$x(t) = A {\cos ({\sqrt {\frac k m}}t}) +B{\sin ({\sqrt {\frac k m}}t}) +{\frac {mg} k}$$ $$x(t) = C{\sin ({\sqrt{\frac k m}}}t+{\arctan({\sqrt{\frac k m}{\frac {x_0} {v_0}}}}))+{\frac {mg} k}$$ because the first is general (they are made of two independent fonctions of $t$) while the second isn't the general solution (one function of $t$ only). Moreover, the second is false : if you put it into the ODE, you observe that it doesn't agree. Probably a typo or a mistake. Why don't you show what you have done ? – JJacquelin Dec 11 '16 at 18:22
• I've updated the original question to show the work I've done. Thanks. – user32882 Dec 12 '16 at 7:40
• @JJacquelin Consider the equation of harmonic oscillator $\ddot{x} + \omega^2 x = 0$. Its general solution is $x(t) = C_1 \cos(\omega t) + C_2 \sin (\omega t)$ which also can be rewritten as $x(t) = \mathcal{A} \sin (\omega t + \varphi)$ :) The second independent function just hides in this form which is exactly what OP has. – Evgeny Dec 12 '16 at 15:38

I think I just found the full solution. Bear with me as it is quite long-winded:

We will need the following trigonmetric identity: \begin{align} \sin (\alpha + \beta) = \sin \alpha \cos \beta + \sin \beta \cos \alpha \tag 1\\ \end{align}

We will only look at the homogeneous solution and ignore $\frac {mg}k$, the particular part:

\begin{align} x_h(t) = A\cos (\sqrt \frac k m t)+B\sin(\sqrt \frac k m t) \tag 2\\ \end{align}

Factor out $\sqrt {A^2+B^2}$ from right hand side: \begin{align} x_h(t)= \sqrt {A^2+B^2} \left( \frac A {\sqrt {A^2+B^2}}\cos (\sqrt \frac k m t) + \frac B {\sqrt {A^2+B^2}}\sin (\sqrt \frac k m t) \right) \tag 3\\ \end{align}

Now, note that:

\begin{align} \left( \frac A {\sqrt {A^2+B^2}}\right)^2+\left( \frac B {\sqrt {A^2+B^2}}\right)^2 = 1 \tag 4\\ \end{align}

And also that:

\begin{align} x_h(t)= \cos^2\phi+\sin^2\phi=1 \tag 5\\ \end{align}

Therefore, there exists an angle $\phi$ such that $\frac A {\sqrt {A^2+B^2}}=\sin \phi$ and such that $\frac B {\sqrt {A^2+B^2}}=\cos \phi$. Substituting these back into Eqn (3) we obtain:

\begin{align} x_h(t)= \sqrt {A^2+B^2} \left( \sin \phi \cos (\sqrt \frac k m t) + \cos \phi \sin (\sqrt \frac k m t) \right) \tag 6\\ \end{align}

We can now use the trigonometric identity (Eqn (1)) to simplify Eqn (6) to the following:

\begin{align} x_h(t)= \sqrt {A^2+B^2}\sin(\phi + \sqrt \frac k m t) \tag 7\\ \end{align}

Now, $\tan \phi = \frac {\sin \phi} {\cos \phi} = \frac A B$ (Refer to Eqns 4 and 5). Therefore $\phi=\arctan \frac A B$. and substituting this into Eqn. (7) we end up with:

\begin{align} x_h(t)= \sqrt {A^2+B^2}\sin(\arctan \frac A B + \sqrt \frac k m t) \tag 8\\ \end{align}

What remains is to solve for constants $A$ and $B$. This is most easily done by using initial conditions below:

$$x(0) = x_0$$ and, $$\dot x(0) = v_0$$ Where the dot symbolizes differentiation with respect to t. We take our full solution $x(t) = x_h(t)+x_p(t)$ where $x_p(t) = \frac {mg} k$ and apply the initial conditions.

\begin{align} x(t) = A\cos (\sqrt \frac k m t)+B\sin(\sqrt \frac k m t) +\frac {mg} k \tag 9\\ \end{align}

\begin{align} \dot x(t) = B \sqrt{\frac{k}{m}} \cos \left(t \sqrt{\frac{k}{m}}\right)-A \sqrt{\frac{k}{m}} \sin \left(t \sqrt{\frac{k}{m}}\right) \tag {10}\\ \end{align}

Substituting initial conditions:

\begin{align} x(0)=x_0 = A+\frac{g m}{k} \tag {11}\\ \end{align}

And \begin{align} \dot x(0) = v_0 = B \sqrt{\frac{k}{m}} \tag {12}\\ \end{align}

Which yields $A = x_0-\frac {mg} k$ and $B = v_0 \sqrt \frac m k$