PHYS-230 · Lesson 2 of 12 · 24 min
Simple harmonic motion and energy
Lesson 1 showed that any system near a smooth stable equilibrium behaves like a mass on a spring. This lesson solves that problem completely. We derive the general solution of the equation of motion, fit it to initial conditions, follow the energy as it passes back and forth between kinetic and potential forms, draw the motion in phase space, and meet the same equation in a pendulum swinging about a pivot, a liquid sloshing in a U-tube, a torsion balance and an electrical circuit. We finish by integrating the equation numerically with a method that respects energy conservation, the velocity Verlet algorithm, which is the workhorse of molecular dynamics and orbital simulation.
The equation and its solutions
A mass \(m\) on a spring of stiffness \(k\), sliding without friction, obeys Newton's second law \(m\ddot x = -kx\), or
This is a linear second-order differential equation with constant coefficients. Try \(x = e^{st}\): substituting gives \(s^2 + \omega_0^2 = 0\), so \(s = \pm i\omega_0\). The general solution is a combination \(x = C_1 e^{i\omega_0 t} + C_2 e^{-i\omega_0 t}\), and for \(x\) to be real we need \(C_2 = \bar C_1\). Writing \(C_1 = \tfrac12 A e^{i\phi}\) gives the familiar real form
with \(a = A\cos\phi\) and \(b = -A\sin\phi\). Two constants are exactly what a second-order equation needs: they are fixed by the initial position \(x_0\) and velocity \(v_0\). Setting \(t = 0\) in \(x\) and in \(\dot x = -a\omega_0\sin\omega_0 t + b\omega_0\cos\omega_0 t\) gives \(a = x_0\) and \(b = v_0/\omega_0\), so
Uniqueness matters here. The existence and uniqueness theorem for linear differential equations guarantees that the solution with given \(x_0\) and \(v_0\) is the only one, so once we have found it by any method we are done. The velocity \(\dot x = -A\omega_0\sin(\omega_0 t + \phi)\) leads the displacement by a quarter cycle, and the acceleration \(\ddot x = -\omega_0^2 x\) is exactly opposite the displacement, with magnitude largest at the turning points where the velocity is zero.
There is a picture behind the formula. A point moving at constant angular speed \(\omega_0\) around a circle of radius \(A\) has an \(x\) coordinate \(A\cos(\omega_0 t + \phi)\). Simple harmonic motion is the shadow of uniform circular motion, and the phase \(\omega_0 t + \phi\) is the angle around the circle. This is the phasor of lesson 1 made literal: the complex number \(Ae^{i(\omega_0 t + \phi)}\) rotates in the complex plane and its real part is the motion.
Worked problem
Fitting initial conditions
A 0.40 kg cart on a spring with \(k = 90\ \mathrm{N/m}\) is pulled 5.0 cm from equilibrium and pushed toward equilibrium at 0.60 m/s. Find the amplitude, the phase constant and the first time the cart passes through equilibrium.
Show solution
- \(\omega_0 = \sqrt{90/0.40} = 15\ \mathrm{rad/s}\), so \(T = 2\pi/15 \approx 0.419\ \mathrm{s}\).
- With \(x_0 = 0.050\ \mathrm{m}\) and \(v_0 = -0.60\ \mathrm{m/s}\), \(v_0/\omega_0 = -0.040\ \mathrm{m}\), so \(A = \sqrt{0.050^2 + 0.040^2} = 0.0640\ \mathrm{m}\).
- \(\tan\phi = -v_0/(\omega_0 x_0) = 0.040/0.050 = 0.80\), and since \(\cos\phi = x_0/A > 0\), \(\phi = 0.675\ \mathrm{rad}\).
- Equilibrium is first reached when \(\omega_0 t + \phi = \pi/2\), so \(t = (1.571 - 0.675)/15 \approx 0.0597\ \mathrm{s}\).
Answer: \(A = 6.40\ \mathrm{cm}\), \(\phi = 0.675\ \mathrm{rad}\), and the cart reaches equilibrium after about 60 ms, sooner than a quarter period (105 ms) because it was already moving inward.
Energy
Multiply the equation of motion by \(\dot x\): \(m\dot x\ddot x + kx\dot x = 0\), which is \(\frac{d}{dt}\big(\tfrac12 m\dot x^2 + \tfrac12 kx^2\big) = 0\). The total energy
is constant. Substituting the solution, the kinetic energy is \(\tfrac12 kA^2\sin^2(\omega_0 t + \phi)\) and the potential energy is \(\tfrac12 kA^2\cos^2(\omega_0 t + \phi)\). Each oscillates at twice the frequency of the motion, between zero and \(E\), and they are exactly out of step. Averaged over a cycle each is \(E/2\), because the average of \(\sin^2\) or \(\cos^2\) over a cycle is one half. This equal sharing is special to the quadratic potential; for a potential \(U \propto |x|^n\) the virial theorem gives \(\langle K \rangle = \tfrac n2 \langle U \rangle\), which reduces to equality for \(n = 2\).
Energy also gives the speed at any position without solving for the time dependence: \(v = \pm\omega_0\sqrt{A^2 - x^2}\). The cart in the worked example moves at \(15\sqrt{0.0640^2 - 0.050^2} = 0.60\ \mathrm{m/s}\) at \(x = 5.0\ \mathrm{cm}\), as it should, and at the maximum speed \(\omega_0 A = 0.96\ \mathrm{m/s}\) as it crosses equilibrium.
Phase space
The state of the oscillator at any instant is the pair \((x, \dot x)\), a point in the phase plane. As time passes the point moves around a closed curve. From the energy equation, \(\tfrac12 m\dot x^2 + \tfrac12 kx^2 = E\) is an ellipse with semi-axes \(A\) along \(x\) and \(\omega_0 A\) along \(\dot x\). Plotting \(\dot x/\omega_0\) instead of \(\dot x\) turns the ellipses into circles traversed clockwise at angular speed \(\omega_0\). Larger energies give larger curves, and curves for different energies never cross, because the state at one instant determines the whole future.
For the pendulum the phase portrait shows what the harmonic approximation misses. Small orbits are nearly circles. Larger ones stretch out horizontally, and at energy \(2mg\ell\) they meet the separatrix, a curve through the unstable upright position \(\theta = \pm\pi\) that divides swinging from rotating motion. Above it the pendulum goes over the top and the orbits are wavy lines rather than loops. The phase portrait is the best single picture of what a nonlinear oscillator can do.
The same equation in other systems
A physical pendulum is any rigid body swinging about a pivot. If its mass is \(m\), its moment of inertia about the pivot is \(I\), and its centre of mass is a distance \(d\) below the pivot, the gravitational torque for a small angle is \(-mgd\theta\), and \(I\ddot\theta = -mgd\,\theta\) gives \(\omega_0 = \sqrt{mgd/I}\). A uniform rod of length \(\ell\) pivoted at one end has \(I = \tfrac13 m\ell^2\) and \(d = \ell/2\), so \(\omega_0 = \sqrt{3g/2\ell}\), faster than a simple pendulum of the same length because its mass is spread closer to the pivot.
A torsion pendulum, a disc hanging from a wire that twists, obeys \(I\ddot\theta = -\kappa\theta\) with the torsion constant \(\kappa\) of the wire. Henry Cavendish used one in 1798 to measure the gravitational attraction between lead spheres. Liquid in a U-tube with total length \(\ell\) of liquid column oscillates with \(\omega_0 = \sqrt{2g/\ell}\), because displacing the surfaces by \(x\) creates a height difference \(2x\). A floating object with cross-sectional area \(A\) bobs with \(\omega_0 = \sqrt{\rho g A / m}\). And an inductor \(L\) in series with a capacitor \(C\) obeys \(L\ddot q + q/C = 0\), so the charge oscillates at \(\omega_0 = 1/\sqrt{LC}\), with inductance playing the role of mass and inverse capacitance the role of stiffness.
| System | Coordinate | Inertia | Stiffness | Angular frequency |
|---|---|---|---|---|
| Mass on spring | x | m | k | square root of k over m |
| Simple pendulum | angle | m l squared | m g l | square root of g over l |
| Physical pendulum | angle | I | m g d | square root of m g d over I |
| Torsion pendulum | angle | I | kappa | square root of kappa over I |
| U-tube | x | rho A l | 2 rho g A | square root of 2g over l |
| LC circuit | charge q | L | 1 over C | 1 over square root of LC |
Worked problem
A vertical spring
A 0.25 kg mass hangs from a spring with \(k = 40\ \mathrm{N/m}\). Show that gravity does not change the frequency, and find how far the spring stretches at equilibrium.
Show solution
- With \(y\) measured downward from the unstretched length, \(m\ddot y = mg - ky\).
- Equilibrium is at \(y_e = mg/k = 0.25 \times 9.81/40 \approx 0.0613\ \mathrm{m}\).
- With \(u = y - y_e\), \(m\ddot u = mg - k(u + y_e) = -ku\). Gravity has been absorbed into the new equilibrium.
- So \(\omega_0 = \sqrt{40/0.25} \approx 12.6\ \mathrm{rad/s}\), the same as on a horizontal track.
Answer: The spring stretches 6.1 cm at equilibrium, and the mass oscillates about that point at 12.6 rad/s. A constant force shifts the equilibrium but leaves the frequency unchanged.
Beyond the small-angle limit
For a pendulum the next term in the potential, \(-\theta^4/24\) relative to \(\theta^2/2\), softens the restoring torque at large angles, so the pendulum spends longer near its turning points and the period increases. A perturbation calculation, or the series expansion of the exact elliptic-integral result, gives
At \(\theta_0 = 0.5\) rad, about \(29^\circ\), the correction is \(1 + 0.0156 + 0.0002\), which matches the exact ratio 1.0159. Huygens found the cure for this in 1673: a bob that moves along a cycloid instead of a circle has a period exactly independent of amplitude, a property called tautochronism. In practice clockmakers kept the amplitude small and constant instead.
Integrating the equation numerically
Most oscillators of practical interest have no closed-form solution, so we integrate numerically. The obvious method, Euler's, updates \(x \gets x + v\,\Delta t\) and \(v \gets v + a\,\Delta t\), but for an oscillator it adds energy at every step, so the orbit spirals outward. The velocity Verlet method does much better:
It is time-reversible and symplectic, which means it preserves phase-space area exactly. As a result its energy error stays bounded and oscillates rather than drifting, even over millions of steps. The program integrates a harmonic oscillator with both methods, compares the energy after 100 periods, and then integrates a pendulum at \(60^\circ\) amplitude to measure its period from the zero crossings.
import math
def euler(x, v, acc, dt, n):
for _ in range(n):
x, v = x + v * dt, v + acc(x) * dt
return x, v
def verlet(x, v, acc, dt, n):
a = acc(x)
for _ in range(n):
x = x + v * dt + 0.5 * a * dt * dt
a_new = acc(x)
v = v + 0.5 * (a + a_new) * dt
a = a_new
return x, v
w0 = 2 * math.pi # period 1 s
acc = lambda x: -w0 * w0 * x
energy = lambda x, v: 0.5 * v * v + 0.5 * w0 * w0 * x * x
E0 = energy(1.0, 0.0)
dt, steps = 0.01, 100 * 100 # 100 periods
for name, method in (("Euler", euler), ("Verlet", verlet)):
x, v = method(1.0, 0.0, acc, dt, steps)
print(f"{name:6s}: x = {x:+.5f}, energy ratio after 100 periods = {energy(x, v)/E0:.6f}")
# pendulum at 60 degrees: measure the period from upward zero crossings of theta
g, L = 9.81, 1.0
acc_p = lambda th: -(g / L) * math.sin(th)
th, om, t, dt = math.radians(60), 0.0, 0.0, 1e-4
a = acc_p(th); crossings = []
while len(crossings) < 3:
th_new = th + om * dt + 0.5 * a * dt * dt
a_new = acc_p(th_new)
om = om + 0.5 * (a + a_new) * dt
if th < 0 <= th_new: # crossing zero going up
crossings.append(t + dt * (-th) / (th_new - th))
th, a, t = th_new, a_new, t + dt
T_num = crossings[2] - crossings[1]
T0 = 2 * math.pi * math.sqrt(L / g)
th0 = math.radians(60)
print(f"pendulum at 60 deg: T = {T_num:.5f} s, T/T0 = {T_num/T0:.5f}")
print(f"series 1 + th0^2/16 + 11 th0^4/3072 = {1 + th0**2/16 + 11*th0**4/3072:.5f}")Euler : x = +244002576.66156, energy ratio after 100 periods = 129271963281139616.000000 Verlet: x = +0.99466, energy ratio after 100 periods = 0.999989 pendulum at 60 deg: T = 2.15287 s, T/T0 = 1.07318 series 1 + th0^2/16 + 11 th0^4/3072 = 1.07285
Euler's method multiplies the energy by \(1 + \omega_0^2\Delta t^2\) each step, so after 10,000 steps the energy has grown by a factor of about \(10^{17}\); the cart would have flown off the track. Verlet keeps the energy within about one part in a hundred thousand. For the pendulum at \(60^\circ\) the measured period ratio 1.0732 agrees with the exact value 1.07318 from lesson 1, and the three-term series gives 1.0729, already close.
Common mistakes
MistakeUsing the amplitude as the initial position when the oscillator starts with a nonzero velocity.
InsteadThe amplitude is \(\sqrt{x_0^2 + (v_0/\omega_0)^2}\), larger than \(|x_0|\) whenever \(v_0 \ne 0\).
MistakeGetting the phase constant in the wrong quadrant from \(\tan\phi\).
InsteadUse the signs of \(\cos\phi = x_0/A\) and \(\sin\phi = -v_0/(\omega_0 A)\), or a two-argument arctangent.
MistakeThinking gravity changes the frequency of a vertical spring.
InsteadA constant force only shifts the equilibrium position; \(\omega_0 = \sqrt{k/m}\) still.
MistakeUsing the simple pendulum formula for a swinging rod.
InsteadUse \(\omega_0 = \sqrt{mgd/I}\) with the moment of inertia about the pivot.
MistakeIntegrating an oscillator with Euler's method over many periods.
InsteadEuler steadily adds energy; use velocity Verlet or another symplectic method.
Summary and key terms
- \(\ddot x + \omega_0^2x = 0\) has general solution \(A\cos(\omega_0 t + \phi)\), fixed uniquely by \(x_0\) and \(v_0\).
- Energy \(\tfrac12 kA^2\) is constant and shared equally, on average, between kinetic and potential forms.
- Phase-space orbits are ellipses (circles in \(x, \dot x/\omega_0\)); the pendulum's portrait shows a separatrix between swinging and rotating.
- Physical, torsion and U-tube pendulums, floating bodies and LC circuits all obey the same equation with \(\omega_0 = \sqrt{\text{stiffness}/\text{inertia}}\).
- Large-amplitude pendulum periods exceed \(2\pi\sqrt{\ell/g}\) by about \(\theta_0^2/16\); velocity Verlet integrates oscillators without energy drift.
- simple harmonic motion
- Motion obeying x double dot plus omega squared x equals zero.
- phase constant
- The angle phi that sets where in its cycle an oscillation starts.
- phase space
- The plane of position and velocity, in which each state of an oscillator is a point.
- separatrix
- A phase-space curve dividing qualitatively different motions, such as swinging and rotating.
- physical pendulum
- A rigid body swinging about a fixed pivot under gravity.
- symplectic integrator
- A numerical method that preserves phase-space area and so keeps energy errors bounded.
Practice problems
Work each problem on paper first, then reveal the answer to check.
A 2.0 kg mass on a spring oscillates with period 0.80 s and amplitude 0.12 m. Find \(k\), the maximum speed and the total energy.
Show answer
\(\omega_0 = 2\pi/0.80 = 7.85\ \mathrm{rad/s}\), \(k = m\omega_0^2 = 123\ \mathrm{N/m}\), \(v_{\max} = \omega_0 A = 0.94\ \mathrm{m/s}\), \(E = \tfrac12 kA^2 = 0.89\ \mathrm{J}\).
At what displacement is the kinetic energy of an oscillator equal to its potential energy?
Show answer
When \(\tfrac12 kx^2 = E/2 = \tfrac14 kA^2\), so \(x = \pm A/\sqrt2 \approx \pm0.707A\).
A metre stick pivoted at one end swings with small amplitude. Find its period.
Show answer
\(\omega_0 = \sqrt{3g/2\ell} = \sqrt{3(9.81)/2} = 3.84\ \mathrm{rad/s}\), so \(T = 1.64\ \mathrm{s}\).
An LC circuit has \(L = 10\ \mathrm{mH}\) and \(C = 1.0\ \mathrm{\mu F}\). Find its frequency.
Show answer
\(\omega_0 = 1/\sqrt{10^{-2}\cdot10^{-6}} = 10^4\ \mathrm{rad/s}\), so \(f = 1.59\ \mathrm{kHz}\).
A cylinder of mass 3.0 kg and cross-section 0.010 m² floats upright in water. Find its bobbing period.
Show answer
\(\omega_0 = \sqrt{\rho gA/m} = \sqrt{1000(9.81)(0.010)/3.0} = 5.72\ \mathrm{rad/s}\), \(T = 1.10\ \mathrm{s}\).
Estimate the period of a 1.00 m pendulum released at \(40^\circ\).
Show answer
\(\theta_0 = 0.698\), so \(T \approx 2.006(1 + 0.0305 + 0.0008) = 2.069\ \mathrm{s}\).
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.