Written by Alexei Gilchrist, updated some time ago
The motion for a harmonic oscillator is derived using Newton's second law. Different parametrizations of the solution, the velocity, acceleration and energy are also determined.
Level: 2, Subjects: Oscillators

## 1 Equation of motion

In 1-D, what is the simplest mathematical form a force on an object can take? Well, ok, $$F=0$$, but that's trivial — there is no force, and the object will move at a constant velocity. The next simplest would be $$F=k$$ where $$k$$ is a constant. In this case Newton's second law would read $$m a = k$$, in other words such a force would produce motion under constant acceleration and it would lead to the kinematic equations.

Arguably the next simplest form would be write $$F = k x$$ where $$k$$ is a positive constant. Now, if the object moves a little in the positive $$x$$ direction the force with push it increasingly hard in that direction and the object will fly off to $$+\infty$$ with its acceleration increasing linearly with distance from the origin. The same holds if the object moves a little in the negative direction. Now the force becomes increasingly strong and negative so the object flies off to $$-\infty$$. Still rather boring behaviour as objects go.

However if the constant is negative, or alternatively if the force has the form $$F = -k x$$ for a positive $$k$$, then something new happens. Motion away from the origin in either direction produces a force back to the origin. Now Newton's second law reads $$F = m a = - k x.$$ The acceleration is of course $$a = d^2 x/dt^2$$, which we'll write as $$a = \ddot{x}$$ for compactness, and so we can write down the equation of motion for the object: $$\label{eq:eqmotion} \ddot{x} + \omega_0^2\; x = 0,$$ where $$\omega_0 = \sqrt{k/m}$$.

Example:
A great example to have in mind is a mass on a spring. If we extend or compress the spring by a distance $$x$$ from its equilibrium position then by Hooke's law the spring will exhert a force $$F_s = -k x$$, where $$k$$ is the spring constant.
Mass on a spring.
This is exactly in the form that we have been considering and the equation of motion from considering Newton's second law will be $$m \ddot{x} + k x = 0.$$

## 2 Solution

Equation \eqref{eq:eqmotion} is an example of a second order linear homogeneous differential equation and we are in luck because we can write a closed solution for such an equation. The general solution to such an equation is $$x(t) = A \cos(\omega_0 t + \phi_1),$$ where $$A$$ and $$\phi_1$$ are constants that are determined by the initial conditions. The object will oscillate harmonically with an angular frequency of $$\omega_0$$.

There are a number of equivalent ways of writing this solution:

1. $$x(t) = A \cos(\omega_0 t + \phi_1)$$,
2. $$x(t) = B \sin(\omega_0 t + \phi_2)$$,
3. $$x(t) = C \cos(\omega_0 t) + D \sin(\omega_0 t)$$,
4. $$x(t) = E e^{i \omega_0 t} + E^* e^{-i \omega_0 t}$$, for $$E$$ complex where $$^*\equiv$$ complex conjugation.
Note that in each case there are two real constants that need to be determined by the initial conditions. This is a consequence of the equation of motion being second order. Which form you choose to use is a matter of convenience.

Parameters of the harmonic oscillator solutions. Each of the three forms describes the same motion but is parametrized in different ways. $$E_r$$ and $$E_i$$ are the real and imaginary parts of the $$E$$ parameter.

## 3 Velocity and Acceleration

Since we have $$x(t)$$ we can just differentiate once to get the velocity and twice to get the acceleration. Notice that the solutions are all cosines of the same frequency, only the amplitude and phase changes: \begin{align} x(t) &= A \cos(\omega_0 t + \phi_1) & \\ v(t) &= \dot{x}(t) = -\omega_0 A \sin(\omega_0 t + \phi_1) = \omega_0 A \cos(\omega_0 t + \phi_1 + \pi/2) & \\ a(t) &= \ddot{x}(t) = -\omega_0^2 A \cos(\omega_0 t + \phi_1) = \omega_0^2 A \cos(\omega_0 t + \phi_1 + \pi) \end{align} So the velocity will lead the displacement by $$\pi/2$$ and the acceleration will lead by $$\pi$$.

Using Euler's formula: \begin{equation*} e^{i \omega_0 t} = \cos(\omega_0 t) + i \sin(\omega_0 t), \end{equation*} we can view the cosine terms as the real parts of the complex exponentials \begin{align} x(t) &= A \Re\{e^{i \omega_0 t + \phi_1}\} & \\ v(t) &= A \omega_0 \Re\{e^{i \omega_0 t + \phi_1 + \pi/2}\} & \\ a(t) &= A \omega_0^2 \Re\{e^{i \omega_0 t + \phi_1 + \pi}\} \end{align} each of which we can represent as a vector in the complex plane.

The kinetic energy is simply $$\label{eq:T} T = \frac{1}{2}m v^2 = \frac{1}{2}m A^2 \omega_0^2 \sin^2(\omega_0 t + \phi_1)$$
The potential energy is \begin{equation*} U = -\int F dx = k\int x dx = \frac{1}{2}k x^2 = \frac{1}{2}A^2 k\cos^2(\omega_0 t + \phi_1). \end{equation*} Using $$\omega_0^2 = k/m$$ we can write this as $$\label{eq:U} U = \frac{1}{2}m A^2 \omega_0^2 \cos^2(\omega_0 t + \phi_1).$$ So that the total energy is the sum of \eqref{eq:T} and \eqref{eq:U}, $$E = T + U = \frac{1}{2}m A^2 \omega_0^2$$ since $$\sin^2\theta+\cos^2\theta = 1$$. The total energy is conserved as might be expected for a closed system.
The kinetic energy $$T(t)$$ and potential energy $$U(t)$$ vary in such a way that the total energy $$E(t)$$ is constant. For comparison the position of the oscillator $$x(t)$$ is shown as a dashed line. The Potential energy is maximum at the extremes of the motion and the kinetic is maximum when the oscillator crosses the mid point.