# A-level Physics (Advancing Physics)/Simple Harmonic Motion/Mathematical Derivation

The following second-order differential equation describes simple harmonic motion:

$\frac{d^2x}{dt^2} = \frac{-kx}{m}$

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

Since we have a second derivative, we cannot separate the variables, so let:

$x = e^{zt}$

Therefore:

$\frac{dx}{dt} = ze^{zt}$

$\frac{d^2x}{dt^2} = z^2e^{zt}$

By substitution:

$z^2e^{zt} + \frac{ke^{zt}}{m} = 0$

$e^{zt}\left (z^2 + \frac{k}{m}\right )$

ezt is asymptotic at 0, so ezt cannot equal 0, and we can therefore get away with dividing by ezt:

$z^2 + \frac{k}{m} = 0$

$z^2 = \frac{-k}{m}$

$z = \pm\sqrt{\frac{-k}{m}} = \pm i\sqrt{\frac{k}{m}}$

Therefore:

$x = Pe^{it\sqrt{\frac{k}{m}}} + Qe^{-it\sqrt{\frac{k}{m}}}$,

where P and Q are constants of integration. At this point, it is useful to clean things up a bit by letting:

$\omega^2 = \frac{k}{m}$

$x = Pe^{i\omega t} + Qe^{-i\omega t}$

It has been proven elsewhere (de Moivre's Theorem) that, when n is a constant:

$e^{ni\theta} = \cos{n\theta} + i\sin{n\theta}$ and $e^{-ni\theta} = \cos{n\theta} - i\sin{n\theta}$

Therefore:

$x = P(\cos{\omega t} + i\sin{\omega t}) + Q(\cos{\omega t} - i\sin{\omega t})$

$x = (P + Q)\cos{\omega t} + (P - Q)i\sin{\omega t}$

Let: $R = P + Q$

$S = P - Q$

So, the general solution of the differential equation is:

$x = R\cos{\omega t} + Si\sin{\omega t}$

This describes what the simple harmonic oscillator will do given any possible situation. However, we don't want an equation which will cover anything and everything. We want to give our oscillator a starting position - let's say, at a position where x = A at t = 0:

$A = R\cos{(\omega \times 0)} + Si\sin{(\omega \times 0)}$

$A = R\cos{0} + Si\sin{0}$

Therefore, R = A and S = 0.

So, the specific solution is:

$x = A\cos{\omega t}$