# Taking the general solution for simple harmonic motion and turning it into the conventional equation? [closed]

I was reading a question on the general solution to a simple harmonic oscillator and I never realized I derived it that way myself, so I decided to try. I have some questions on the process. After my derivation, my question is two-fold (I've also decided to make it in a quote box for aesthetic purposes and clarity):

To find an expression for the position of an object undergoing simple harmonic motion, we start with Hooke's Law:

$$F = -kx$$

In which $k$ is the spring constant.

Now, we begin to solve the second-order ordinary differential equation:

$$x'' + \frac{k}{m}x = 0$$

$$e^{\lambda t}\Big(\lambda^2 + \frac{k}{m}\Big)= 0$$

Thus:

$$\bbox{ \lambda^2 = -\frac{k}{m} }$$

$$\lambda = \mp i\sqrt\frac{k}{m}$$

Giving us a general solution of:

$$C_1e^{\alpha t}\cos(\beta t) + C_2e^{\alpha t}\sin(\beta t)$$

Since $\alpha = 0$ and $\beta = \sqrt\frac{k}{m}$ , we have:

$$\bbox[5px,border:2px solid red] { x(t) = C_1\cos\bigg(\sqrt\frac{k}{m} t\bigg) + C_2\sin\bigg(\sqrt\frac{k}{m} t\Bigg) }$$

As a general solution. Hopefully I did that right.

-

## 1. How do we get to $x(t) = x_0cos(\omega t + \phi)$ from my derivation?

• And what do we do with the constants to get there?
• I've heard by making $c_1 = x_0$ and $c_2 = v$ as boundary conditions, we can arrive to it, since if we make $x_0 = x_{max}$ and $v_0 = 0$ we arrive at that formula, more or less, but why can we just say "I'm making $c_1$ and $c_2$, which are constants, equal to variables"? Huh?

## 2. Why is $\omega = \sqrt\frac{k}{m}$?

• It just seems to be a frequency scalar. Why and how has it been defined as the angular velocity?

## closed as off-topic by Bill N, David Hammen, Jon Custer, peterh, Qmechanic♦Jun 20 '17 at 10:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Homework-like questions should ask about a specific physics concept and show some effort to work through the problem. We want our questions to be useful to the broader community, and to future users. See our meta site for more guidance on how to edit your question to make it better" – Jon Custer, Qmechanic
If this question can be reworded to fit the rules in the help center, please edit the question.

• Note that $c_2$ must have dimensions of length and so $c_2$ cannot be equal to the initial velocity on dimensional grounds. – Alfred Centauri Jun 19 '17 at 20:37

## 2 Answers

Start with $$x(t)=c_1\cos(\omega t)+c_2\sin(\omega t) \tag{1}$$ and take the second derivative to get $$\ddot{x}=-\omega^2 \left(c_1\cos(\omega t)+c_2\sin(\omega t)\right)=-\omega^2 x.$$ Thus inserting (1) in the differential equation \begin{align} \ddot{x}+\frac{k}{m}x&=0\, \\ \left(-\omega^2 +\frac{k}{m}\right)x&=0\, . \end{align} Since this must hold for any $x$ it follows that $\omega^2=k/m$. Note that by expanding \begin{align} x(t)=x_0\cos(\omega t+\phi)&=x_0\left(\cos\omega t)\cos\phi-\sin(\omega t)\sin\phi\right)\, ,\\ &= x_0\cos\phi \cos\omega t-x_0\sin\phi\sin\omega t \tag{2} \end{align} you recover (1) with $c_1=x_0\cos\phi$ and $c_2=-x_0\sin\phi$.

• I see. Two questions with that: 1) Can you explain the first bit again, with how you got $-\omega^2 x+\frac{k}{m}x=0$? And 2), do we define $c_1$ and $c_2$ as such because they'll be a percentage, for lack of a better word, at best 100% of a maximum initial displacement based on $\phi$? – sangstar Jun 19 '17 at 18:30
• @sangstar I've added a bit. $c_1$ and $c_2$ are not "defined" in this way: this just follows from comparing (2) with (1). Indeed $c_1$ and $c_2$ are arbitrary constants determined by the initial conditions: $x(0)=c_1$ and $\dot{x}(0)=\omega c_2$. – ZeroTheHero Jun 19 '17 at 18:58
• @sangstar A way that always helped me to think about differential equations is that you are trying to find a solution for your original equation. For the case of simple harmonic oscillators, we need something where the second derivative of a quantity is equal to the quantity itself. You can then consider the cos and sin equations, because we know that $\frac {d^2}{dt^2} sin (t) = sin (t)$ (same with cos) so we can start from there and using the conditions we know we have, we can solve for what constants will make our $x(t)$ satisfy our $\frac {-d^2 x}{dt^2} = \frac km x$. – JMac Jun 19 '17 at 20:44
• @JMac indeed this is the best way to justify the ansatz $x=Ae^{\lambda t}$ since the exponential is self-reproducing under derivative. – ZeroTheHero Jun 19 '17 at 23:58

I'll try to answer both of your questions be showing how I would derive the general solution. As is typical for this type of differential equation, we assume a solution of the form

$$x(t) = Ae^{rt}$$

Then

$$\dot x(t) = rAe^{rt} = rx(t)$$

$$\ddot x(t) = r^2Ae^{rt} = r^2x(t)$$

Inserting into the differential equation yields

$$\ddot x(t) + \frac{k}{m}x(t) = \left(r^2 + \frac{k}{m}\right)x(t) = 0$$

So, our assumption that $Ae^{rt}$ is a solution is true for $r = \pm i\sqrt{\frac{k}{m}}$. The general solution is then the weighted sum of the two independent solutions

$$x(t) = A^+e^{+i\omega t} + A^-e^{-i\omega t},\qquad \omega \equiv \sqrt{\frac{k}{m}}$$

where we define the angular frequency $\omega$. Now, for $x(t)$ to be real, the coefficients must be complex conjugates, $A^- = (A^+)^*$, and so let

$$A^+ = \frac{\alpha}{2}e^{i\phi},\qquad A^- = \frac{\alpha}{2}e^{-i\phi}$$

for some $\alpha$ and $\phi$ that are real numbers and then we can rewrite the general solution as

$$x(t) = \frac{\alpha}{2}e^{i\phi}e^{+i\omega t} + \frac{\alpha}{2}e^{-i\phi}e^{-i\omega t} = \alpha\frac{e^{i(\omega t + \phi)} + e^{-i(\omega t + \phi)}}{2}= \alpha \cos(\omega t + \phi)$$

where we have used the identity $\cos \theta = \frac{e^{i\theta} + e^{-i\theta}}{2}$. Setting $t = 0$ yields

$$x(0) = \alpha \cos\phi \rightarrow \alpha = \frac{x(0)}{\cos\phi}$$

Taking the time derivative and evaluating at $t = 0$ yields

$$\dot x(0) = -\omega \alpha \sin\phi = -\omega \tan\phi \; x(0) = \rightarrow \phi = -\tan^{-1}\left(\frac{\dot x(0) }{\omega x(0)}\right)$$

• +1 for your answer, Alfred. Few questions. 1) Why is it $\frac{\alpha}{2}$ for the constants, and 2) I'm confused by the signage of $A^-$ and $A^+$. What is that indicating? – sangstar Jun 20 '17 at 7:22
• @sangstar, (1) in anticipation of the factor of $\frac{1}{2}$ in the identity $\cos \theta = \frac{e^{i\theta} + e^{-i\theta}}{2}$ and (2) I chose plus and minus superscripts to remind me that, e.g, $A^+$ goes with the $r = +\sqrt{\frac{k}{m}}$ solution. – Alfred Centauri Jun 20 '17 at 11:38