# Harmonic oscillator differential equation solution [closed]

My math book explains how to solve second order equations like :
$$\ddot{x} + \omega^2x = 0$$

but I end up with the general solution : $$A\cos(\omega t) + iB\sin(\omega t).$$

Now my physics book says the solution is $$\rho\cos(\omega t + \phi)$$

How can I get there from the general solution?

• The last formula is just another representation of the general solution. To relate the two possibilities expand $\cos{(\omega t+\phi)}$ by the formula for the cosine of sum and then try to chose parameters $\rho,\phi$ such that the obtained expression coincides with your own solution. – Weather Report Sep 26 '14 at 19:42
• Why is there an $i$ in front of the $\sin$ term? – DanielSank Sep 26 '14 at 21:02
• @DanielSank You can choose B to be $-iC, C \in \mathbb{R}$ and you will have a real solution. – Void Sep 26 '14 at 22:24

Using the sum rule for cosines, we find $$\rho \cos(\omega t + \phi) = \rho \cos(\phi) \cos(\omega t) - \rho \sin(\phi) sin(\omega t).$$ So we see that $\rho \cos(\omega t + \phi)$ is the same as $A\cos(\omega t) + iB\sin(\omega t)$ when $$A = \rho \cos(\phi)$$ and $$B = i\rho \sin(\phi).$$
• If $B$ is complex, it means the position could be complex too, right? – Mohammad Areeb Siddiqui Nov 30 '17 at 15:04
• Yes, if $A$ and $B$ are arbitrary complex numbers, then the solution of the differential equation will be complex. So we must additionaly constrain $A$ and $B$ so that the solution is real. In practice, this reality of the solution is enforced by allowing arbitrary $A$ and $B$ and then taking the real part of the solution, which of course is real, but still satisfies the original differential equation. – Brian Moths Nov 30 '17 at 18:01