How to solve harmonic oscillator differential equation: $\dfrac{d^2x}{dt^2} + \dfrac{kx}{m} = 0$

I am able to solve simple differential equations like :

$$\dfrac{dy}{dx} = 3x^2 + 2x$$

We simply bring $dx$ to other site and integrate.

But how do we find solutions of differential equations like :

$$\frac{d^2x}{dt^2} + \dfrac{kx}{m} = 0$$

?

We have been told the solution is $x(t) = A\cos ( \omega t + \phi_o)$ where $\omega\ =\sqrt{\dfrac{k}{m}}$

but how do we actually find it?

For convenience, $$x''+\omega^2x=0.$$

Solution 1:

Multiply by $$2x'$$, to get

$$2x'x''+2\omega^2xx'=0=(x'^2+\omega^2x^2)'.$$

After integration we get a separable equation

$$x'^2+\omega^2x^2=C^2,$$ or $$\frac{x'}{\sqrt{A^2-x^2}}=\omega.$$

Integrating,

$$\arcsin\left(\frac x{A}\right)=\omega t+\phi.$$

Solution 2:

Let $$D$$ denote the differentiation operator. We can rewrite the equation as

$$(D^2+\omega^2)x=0$$ and factor

$$(D-i\omega)(D+i\omega)x=0.$$

Indeed, $$(D-i\omega)(D+i\omega)x=(D-i\omega)(x'+i\omega x)=x''+i\omega x'-i\omega(x'+i\omega x)=x''+\omega^2x$$.

If we define $$y=(D+i\omega)x$$, we need to solve

$$(D-i\omega)y=0,$$ i.e.

$$\frac{y'}y=i\omega.$$

The solution is easily found to be

$$y=Ce^{i\omega t}.$$

Now we need to solve

$$(D+i\omega)x=y=Ce^{i\omega t}.$$

The solution is found by combining the general solution of the homogenous equation, $$C'e^{-i\omega t}$$, found similarly, and a particular solution of the non-homogeneous equation.

When trying $$y=C''e^{i\omega t}$$, we have

$$C''i\omega e^{i\omega t}+C''i\omega e^{i\omega t}=Ce^{i\omega t}$$ which is a valid solution.

Then

$$x=C'e^{-i\omega t}+C''e^{i\omega t}.$$

As the solution must be real, it can be rewritten as

$$x=C'\cos(\omega t)+C''\sin(\omega t)=A\sin(\omega t +\phi).$$

Solution 3:

We recall that $$(\sin(t))''=-\sin(t)$$ and $$(\cos(t))''=-\cos(t)$$.

Then scaling with the coefficient $$\omega$$, $$(\sin(\omega t))''=-\omega^2\sin(\omega t)$$ and $$(\cos(\omega t))''=-\omega^2\cos(\omega t)$$.

These are two independent solutions of the differential equation, and as the equation is of the second order, the linear combination of these two functions is the general solution

$$x=C\cos(\omega t)+S\sin(\omega t).$$

Solution 4:

The characteristic equation is $$\lambda^2+\omega^2=0$$ and has the solutions $$\lambda=\pm i\omega$$. Hence the general solution

$$C_+e^{i\omega t}+C_-e^{-i\omega t}.$$

As we want a real solution, after expansion and cancelling of the imaginary part,

$$x=C\cos\omega t+S\sin\omega t.$$

Solution 5:

The equation is autonomous (no explicit appearance of time).

Let $$v:=x'$$. We have $$x''=\dfrac{dv}{dt}=\dfrac{dv}{dx}\dfrac{dx}{dt}=v\dfrac{dv}{dx}$$. The equation turns to

$$v\frac{dv}{dx}+\omega^2 x=0$$ or $$v^2+\omega^2 x^2=C$$ and we join the solution 1.

HINT:

$$x''(t)+\frac{kx(t)}{m}=0\Longleftrightarrow$$ $$\frac{\text{d}^2x(t)}{\text{d}t^2}+\frac{kx(t)}{m}=0\Longleftrightarrow$$

Assume a solution will be proportional to $e^{\lambda t}$ for some constant $\lambda$.

Substitute $x(t)=e^{\lambda t}$ into the differential equation:

$$\frac{\text{d}^2}{\text{d}t^2}\left(e^{\lambda t}\right)+\frac{ke^{\lambda t}}{m}=0\Longleftrightarrow$$

Substitute $\frac{\text{d}^2}{\text{d}t^2}\left(e^{\lambda t}\right)=\lambda^2e^{\lambda t}$:

$$\lambda^2e^{\lambda t}+\frac{ke^{\lambda t}}{m}=0\Longleftrightarrow$$ $$e^{\lambda t}\left(\lambda^2+\frac{k}{m}\right)=0\Longleftrightarrow$$

Since $e^{\lambda t}\ne 0$ for any finite $\lambda$, the zeros must come from the polynomial:

$$\lambda^2+\frac{k}{m}=0\Longleftrightarrow$$ $$\frac{k+m\lambda^2}{m}=0\Longleftrightarrow$$ $$\lambda=\pm\frac{i\sqrt{k}}{\sqrt{m}}$$

• Assuming that it has the exponential form feels a bit like cheating. – Justpassingby Dec 14 '15 at 15:20
• We can use Laplace Transform but I don't know if the OP is familiar with that – Jan Dec 14 '15 at 15:22
• how did you guess that it will be proportional to $e^{\lambda t}$ ? – Max Payne Dec 14 '15 at 15:27
• I didn't guess that, It is! – Jan Dec 14 '15 at 15:28
• For a systematic approach to this kind of problem (= linear differential equations with constant coefficients) there are special tools. For instance, there is the notion of "Fourier transform": writing an unknown member of a fairly general class of functions as some kind of infinite linear combination of sines and cosines. For this particular equation it turns out that the solutions are linear combinations of only one cosine and one sine wave, both with the exact frequency $\sqrt{k/m}/2\pi.$ – Justpassingby Dec 14 '15 at 15:34

Basically, you are solving $\ddot{x}=-\omega_0^2x$. Double dot over $x$ means double derivative wrt time $t$. This is easily seen to be equivalent to $$\Big(\frac{d}{dt}+i\omega_0\Big)\Big(\frac{d}{dt}-i\omega_0\Big)x=0.$$ This would imply $$\Big(\frac{d}{dt}-i\omega_0\Big)x= const$$ You can take it from here using the method you use by transferring $dt$ on the other side and integrating.

• Thank you this solution seems easiest for me, but how can we take $\frac{d}{dt}$ outside? is it a term? – Max Payne Dec 14 '15 at 15:30
• you can put $\Big(\frac{d}{dt}-i\omega_0\Big)x= 0$. Then the equation is satisfied. Then it follows that $\frac{d}{dt}=i\omega_0x$. – vnd Dec 14 '15 at 15:35
• How is this supposed to work? $$\int 1/x(t) dx=\int (\mathrm{const}/x(t)+i\omega_0) dt$$. The RHS contains the solution Im looking for – OD IUM Sep 9 '18 at 12:35

The equation:

$$y'' = -k^2 \cdot y$$

Has the completesolution:

$$y = f(x) = c_1 \cos(kx) + c_2 \sin(kx)$$

Proof:

First we define two function g(x) and h(x)

$$g(x)=f(x)\cos(kx)-\frac{1}{k}f'(x)\sin(kx)$$

$$h(x) = f(x)\sin(kx)+\frac{1}{k}f'(x)\cos(kx)$$

We differentiate g(x) and h(x): (Using the product and chain rule)

$$g'(x)=f'(x)\cos(kx)-f(x)k\sin(kx)-\frac{1}{k}(f''(x)\sin(kx)+f'(x)k\cos(kx))$$

$$h'(x)=f'(x)\sin(kx)+f(x)k\cos(kx)+\frac{1}{k}(f''(x)\cos(kx)-f'(x)k\sin(kx))$$

Now comes the critical point. Lets assume the function f(x) is a solution to the differentialequation. If and only if f(x) is a solution the we can write:

$$f''(x)=-k^2f(x)$$

We can use this in the g(x) and h(x) functions and substitute for f''(x) and reduce the expression:

$$g'(x)=f'(x)\cos(kx)-f(x)k\sin(kx)-\frac{1}{k}(\color{red}{-k^2f(x)}\sin(kx)+f'(x)k\cos(kx)) \Leftrightarrow$$

$$g'(x)=0$$

$$h'(x)=f'(x)\sin(kx)+f(x)k\cos(kx)+\frac{1}{k}(\color{red}{-k^2f(x)}\cos(kx)-f'(x)k\sin(kx)) \Leftrightarrow$$

$$h'(x)=0$$

When the derivative of the functions are 0, then the functions themself must be constants:

$$g(x)=c_1 \;\;\;$$ and $$\;\;\;h(x)=c_2$$

So we insert this in the two first equations:

$$c_1=f(x)\cos(kx)-\frac{1}{k}f'(x)\sin(kx)$$

$$c_2 = f(x)\sin(kx)+\frac{1}{k}f'(x)\cos(kx)$$

We multiply the $$c_1$$ equation with cos(kx) and we multiply the $$c_2$$ equation with sin(kx):

$$c_1 \cos(kx)=f(x)\cos(kx)^2-\frac{1}{k}f'(x)\sin(kx)\cos(kx)$$

$$c_2 \sin(kx) = f(x)\sin(kx)^2+\frac{1}{k}f'(x)\cos(kx)\sin(kx)$$

We then add the two equations:

$$c_1 \cos(kx) + c_2 \sin(kx) = f(x)\cos(kx)^2-\frac{1}{k}f'(x)\sin(kx)\cos(kx) + f(x)\sin(kx)^2+\frac{1}{k}f'(x)\cos(kx)\sin(kx) \Leftrightarrow$$

$$c_1 \cos(kx) + c_2 \sin(kx) = f(x)\cos(kx)^2 + f(x)\sin(kx)^2 \Leftrightarrow$$

$$c_1 \cos(kx) + c_2 \sin(kx) = f(x)(\cos(kx)^2 + \sin(kx)^2) \Leftrightarrow$$

$$c_1 \cos(kx) + c_2 \sin(kx) = f(x)(1) \Leftrightarrow$$

$$c_1 \cos(kx) + c_2 \sin(kx) = f(x)$$

All that is left is to test if this is a solutions by inserting in the differential equation. If you do that, you will find it is a solution.

Q.E.D