Simple harmonic motion (source code)

= Simple harmonic motion
{title2=$\ddot x+\omega^2x=0$}
{wiki}

= Simple harmonic oscillator
{synonym}

= Harmonic oscillator equation
{synonym}

= Harmonic oscillator
{synonym}

<Simple harmonic motion> is motion in which the <acceleration> is proportional to the <displacement> from <equilibrium> and points back towards it:
$$
\ddot x=-\omega^2x,\qquad \omega>0.
$$
Here $x$ is measured from <equilibrium>, and $\omega$ is the constant <angular frequency>. For a <point mass> attached to an ideal <spring>, <Hooke's law> gives the restoring <force> $F=-kx$, with stiffness $k>0$, and <Newton's second law> yields $\omega=\sqrt{k/m}$. The minus sign matters: for $x>0$ the <force> is negative, and for $x<0$ it is positive. A restoring <force> need not oppose <velocity>; on the return towards <equilibrium> it increases <speed>.

The general solution is
$$
x(t)=A\cos(\omega t+\varphi),\qquad
v(t)=-A\omega\sin(\omega t+\varphi),\qquad
P=\frac{2\pi}{\omega}.
$$
The <amplitude> $A\geq0$ and <oscillation phase> $\varphi$ encode the <initial conditions>. We use $P$ for the <oscillation period> to distinguish it from <kinetic energy> $T$. For $A>0$, the <oscillation period> is independent of <amplitude>, the property of <isochronous harmonic motion>. At $A=0$ the body remains at <equilibrium>. https://ocw.mit.edu/courses/8-01sc-classical-mechanics-fall-2016/mit8_01scs22_chapter23.pdf[MIT mechanics, Chapter 23, sections 23.2 and 23.3]{ref}

Choose $m=0.5\,\mathrm{kg}$, $k=2\,\mathrm{N/m}$, and release the <mass> from rest at <displacement> $A=0.3\,\mathrm m$. Then $\omega=2\,\mathrm{s^{-1}}$, $P=\pi\,\mathrm s$, and $\varphi=0$. Writing <time> $t$ in seconds,
$$
x(t)=0.3\cos(2t)\,\mathrm m,\qquad
v(t)=-0.6\sin(2t)\,\mathrm{m/s}.
$$
At $t=0$ the <velocity> vanishes, but the <acceleration> is $-1.2\,\mathrm{m/s^2}$: a <turning point> is not a state of rest that persists. At $t=\pi/4\,\mathrm s$, the body crosses <equilibrium> with <velocity> $-0.6\,\mathrm{m/s}$ and zero <acceleration>. At $t=\pi/2\,\mathrm s$ it reaches the opposite <turning point>, $x=-0.3\,\mathrm m$.

Taking <potential energy> zero at <equilibrium>, the same solution gives
$$
V(t)=\frac12kx(t)^2=0.09\cos^2(2t)\,\mathrm J,\qquad
T(t)=\frac12mv(t)^2=0.09\sin^2(2t)\,\mathrm J,
\qquad E=T+V=0.09\,\mathrm J.
$$
At each <turning point> all <mechanical energy> is <potential energy>; at each <equilibrium> crossing it is <kinetic energy>. Both repeat twice during one complete <position> cycle because squaring removes the sign. At $t=\pi/8\,\mathrm s$, for example, each contributes $0.045\,\mathrm J$.

\Image[/mechanical-energy-oscillation.png]
{title=Position, velocity, phase ellipse and energy exchange for a mass of 0.5 kg on a spring of stiffness 2 N/m}

The physical <position> trace covers a line segment, $-0.3\leq x\leq0.3$ in metres. In the <phase plane>, the paired <position> and <velocity> instead trace the <ellipse>
$$
\frac{x^2}{(0.3\,\mathrm m)^2}+\frac{v^2}{(0.6\,\mathrm{m/s})^2}=1.
$$
This is precisely $mv^2/2+kx^2/2=E$, rewritten: the single conserved <mechanical energy> fixes the <amplitude> and the whole <ellipse>. It does not fix the starting <oscillation phase>. At $x=0$ both $v=-0.6\,\mathrm{m/s}$ and $v=+0.6\,\mathrm{m/s}$ lie on it; <position> alone cannot distinguish them. Replacing $v$ by <momentum> $p=mv$ gives the equivalent <phase-space trajectory>. The arrows show increasing <time>, clockwise in $(x,v)$ coordinates.

This closed <ellipse> assumes a time-independent <spring> and no <damping> or applied drive. Adding a resisting <force> $-bv$, $b>0$, gives $m\ddot x+b\dot x+kx=0$ and $dE/dt=-bv^2\leq0$. An underdamped <damped harmonic oscillator> spirals inward in the <phase plane>, crossing successively smaller <energy> contours. The ideal <harmonic oscillator> is also useful beyond <springs>: near a smooth <potential energy> minimum with $V''(0)>0$, its <Taylor expansion> begins with $V(0)+V''(0)x^2/2$. For sufficiently small <displacements>, this gives the same restoring <force> to leading order, explaining why <small oscillations> share one solvable pattern.