Mechanics

Simple Harmonic Motion

Restoring force proportional to displacement — sinusoidal oscillation, the foundation of all wave physics

Simple harmonic motion (SHM) is oscillation under a restoring force proportional to displacement (F = -kx). The equation of motion is ẍ = -ω²x, with solutions x(t) = A·cos(ωt + φ) — sinusoidal oscillation at angular frequency ω = √(k/m). Springs, pendulums (small angles), molecular vibrations, AC circuits, and quantum oscillators all follow SHM. The simplest model of any system near equilibrium.

  • Equation of motionẍ = -ω²·x
  • Solutionx(t) = A·cos(ωt + φ)
  • Angular frequencyω = √(k/m)
  • PeriodT = 2π/ω = 2π·√(m/k)
  • Frequencyf = 1/T = ω/(2π)
  • EnergyE = ½kA² (constant; oscillates between KE and PE)

Interactive visualization

Press play, or step through manually. The visualization is yours to drive — try it before reading on.

Open visualization fullscreen ↗

Watch the 60-second explainer

A condensed visual walkthrough — narrated, captioned, under a minute.

The setup

An object of mass m is connected to a spring with spring constant k. The spring exerts a restoring force F = -k·x (Hooke's law), where x is displacement from equilibrium.

From Newton's 2nd law: m·ẍ = -k·x → ẍ = -(k/m)·x = -ω²·x

where ω = √(k/m). This is the differential equation of simple harmonic motion.

The solution

The general solution is:

x(t) = A·cos(ω·t + φ)

where A is the amplitude (max displacement from equilibrium) and φ is the phase (depends on initial conditions). Equivalently: x(t) = a·cos(ωt) + b·sin(ωt) for arbitrary constants a, b.

Velocity and acceleration:

x(t) = A·cos(ωt + φ)
v(t) = -A·ω·sin(ωt + φ)
a(t) = -A·ω²·cos(ωt + φ) = -ω²·x(t)  ✓

Period and frequency

QuantitySymbolFormulaUnit
Angular frequencyω√(k/m)rad/s
PeriodT2π/ω = 2π·√(m/k)s
Frequencyf1/T = ω/(2π)Hz
AmplitudeA(initial conditions)m

Energy in SHM

Total mechanical energy:

E = ½k·x² + ½m·v² = ½k·A² (constant)

Distribution oscillates between KE and PE:

PositionxvKEPE
At equilibrium0±A·ω (max)½kA² (max)0
At ±A (turning points)±A00½kA² (max)
At ±A/2±A/2±A·ω·√3/2(3/4)·½kA²(1/4)·½kA²

Common SHM systems

Systemω formulaWhat's restoring it?
Mass on spring√(k/m)Hooke's law spring force
Simple pendulum (small angle)√(g/L)Gravity component
Physical pendulum√(mgd/I)Gravity torque about pivot
Torsional pendulum√(κ/I)Spring constant of twisted wire
LC circuit1/√(LC)Inductor + capacitor
Molecule (diatomic)√(k_eff/μ)Bond elasticity (μ = reduced mass)
Particle in parabolic potential√(k/m) where U = ½kx²Quantum harmonic oscillator

Damping — real-world oscillation

With friction or air resistance proportional to velocity (F_drag = -b·v):

m·ẍ + b·ẋ + k·x = 0

Three regimes based on damping ratio ζ = b/(2√(mk)):

RegimeConditionBehavior
Underdampedζ < 1Oscillates with exponentially decaying amplitude
Critically dampedζ = 1Returns to equilibrium in shortest time, no oscillation
Overdampedζ > 1Slow exponential decay, no oscillation

Engineers tune damping (shock absorbers, door dampers) to be critically damped for fastest settling without overshoot.

JavaScript — SHM simulation

// Analytical solution: x(t) = A·cos(ωt + φ)
function shm(amplitude, omega, phase, t) {
  return {
    x: amplitude * Math.cos(omega * t + phase),
    v: -amplitude * omega * Math.sin(omega * t + phase),
    a: -amplitude * omega * omega * Math.cos(omega * t + phase)
  };
}

// Mass-spring period
function springPeriod(mass, k) {
  return 2 * Math.PI * Math.sqrt(mass / k);
}

console.log(`1 kg, k = 100 N/m: T = ${springPeriod(1, 100).toFixed(2)} s`); // 0.63
console.log(`1 kg, k = 25 N/m: T = ${springPeriod(1, 25).toFixed(2)} s`);   // 1.26 (4× softer = 2× longer)

// Energy distribution
function shmEnergy(mass, k, amplitude, x) {
  const PE = 0.5 * k * x * x;
  const v = Math.sqrt(k / mass) * Math.sqrt(amplitude * amplitude - x * x);
  const KE = 0.5 * mass * v * v;
  return { PE, KE, total: PE + KE };
}

console.log(shmEnergy(1, 100, 0.1, 0));    // x=0: all KE (~0.5 J)
console.log(shmEnergy(1, 100, 0.1, 0.1));  // x=A: all PE (~0.5 J)

// Damped oscillator simulation
function dampedShm(m, k, b, x0, v0, dt = 0.001, t_max = 10) {
  let x = x0, v = v0;
  const result = [];
  for (let t = 0; t < t_max; t += dt) {
    const F = -k * x - b * v;  // spring + damping
    const a = F / m;
    v += a * dt;
    x += v * dt;
    if (Math.abs(t * 100 - Math.round(t * 100)) < dt) {
      result.push({ t, x, v });
    }
  }
  return result;
}

// Underdamped: oscillates while decaying
const underdamped = dampedShm(1, 100, 1, 0.1, 0);
// Critically damped: b = 2√(mk) = 20
const critical = dampedShm(1, 100, 20, 0.1, 0);
// Overdamped: b = 100
const overdamped = dampedShm(1, 100, 100, 0.1, 0);

// Inspect amplitude decay
console.log('Underdamped at t=1:', underdamped.find(p => p.t > 1)?.x);

Where SHM shows up

  • Mechanical systems. Springs, pendulums, swinging signs, vibration in machinery and bridges.
  • Acoustics and music. Air molecules in sound waves, instrument strings (with boundary modes), drum heads.
  • Electromagnetic. LC circuits oscillate at 1/√(LC); used in radio tuning, oscillators in circuits.
  • Optics. Light is electromagnetic oscillation; Maxwell's equations give wave equation, solutions are SHM-like.
  • Quantum mechanics. Quantum harmonic oscillator — exact eigenstates of parabolic potential. Foundation of phonon, photon, and field theory.
  • Atomic and molecular vibrations. IR spectroscopy probes vibrational modes (~10¹³ Hz). Each bond is approximately a spring with characteristic ω.
  • Engineering — vibration analysis. Buildings, vehicles, aircraft analyzed for natural frequencies; resonance avoidance is critical.

Common mistakes

  • Confusing angular frequency ω with frequency f. ω = 2πf. ω in rad/s, f in Hz. Don't mix them in formulas.
  • Forgetting it's only valid for SMALL displacements. Real springs deviate from F = -kx for large x. Pendulums deviate from SHM for large angles (>~15°).
  • Using SHM for non-linear systems. Many "oscillating" systems aren't SHM — non-linear pendulum, double pendulums, anharmonic potentials. SHM is small-amplitude approximation.
  • Wrong period formula. Mass-spring: T = 2π√(m/k). Pendulum: T = 2π√(L/g). They look similar but have different physics. Pendulum period is independent of mass.
  • Confusing damping regimes. Critically damped is the BORDERLINE case — fastest return without oscillation. Underdamped systems still oscillate (just decreasingly).
  • Treating energy as oscillating differently. Total energy is constant (½kA²). KE and PE individually oscillate, but their sum is fixed.

Frequently asked questions

Why is the motion sinusoidal?

Because the equation of motion ẍ = -ω²x has solutions of the form A·cos(ωt + φ). The second derivative of cos(ωt) is -ω²·cos(ωt), satisfying the equation. Geometrically — a rotating vector projected onto a line gives sinusoidal motion. This pattern is universal for any force that grows linearly with displacement near equilibrium.

What's the period of a mass-spring system?

T = 2π·√(m/k). Larger mass — slower oscillation (more inertia, takes longer). Stiffer spring — faster oscillation (more force per displacement). Doubling mass increases T by factor √2 ≈ 1.41. Quadrupling stiffness halves T.

How is energy distributed in SHM?

Total energy E = ½kA² is constant. At maximum displacement (x = A), all energy is potential (PE = ½kx²). At equilibrium (x = 0), all energy is kinetic (KE = ½mv²). The two oscillate sinusoidally between extremes. Average KE = average PE = ½E.

Why is SHM so common in nature?

ANY system displaced slightly from a stable equilibrium experiences a restoring force linear in displacement (Taylor expansion: F(x) ≈ -k·x near equilibrium). This is the leading approximation for small oscillations of: pendulums, molecular bonds, atoms in crystals, AC circuit components, planetary perturbations, etc. SHM is the universal "small-oscillation" model.

How does SHM relate to circular motion?

SHM is the projection of uniform circular motion onto a line. A point moving in a circle at constant ω, viewed edge-on, traces sinusoidal motion. Mathematically — x(t) = A·cos(ωt) is the x-coordinate of a point at angle ωt on a circle of radius A. This is why phasors (rotating vectors) are useful for AC circuit analysis.

What if there's friction (damping)?

With damping force F = -bv (proportional to velocity), the motion becomes damped harmonic oscillation. Three regimes — underdamped (oscillates with decreasing amplitude), critically damped (returns to equilibrium fastest without oscillation, used for shock absorbers), overdamped (slow exponential return, no oscillation). Real systems are mostly underdamped (oscillate while losing energy).

How do you drive an oscillator?

Apply a periodic external force F(t) = F₀·cos(Ω·t). The system oscillates at the driving frequency Ω, but with amplitude that depends on how close Ω is to the natural frequency ω. At Ω = ω (resonance), amplitude is maximum (limited only by damping). This is how every musical instrument works, why bridges can collapse from synchronized marching, and how MRI machines work.