# Harmonic oscillator > On the **[[PORTAL_Acoustics|Acoustics]]** vibration spine · article face [[Acoustics]]. Microsim first, then the physics. A **harmonic oscillator** is a system that, when pushed away from equilibrium, feels a restoring [[Force|force]] proportional to the displacement, `F = −kx`, and therefore swings back and forth at a [[Frequency|frequency]] fixed by its stiffness and inertia alone. Add friction and it becomes a damped oscillator whose swing dies away; add a periodic push and it becomes a driven oscillator that can [[Resonance|resonate]]. The same equation describes a mass on a spring, a [[Pendulum|pendulum]] at small angles, a series RLC circuit and the air in the neck of a bottle, which is why it is the first model reached for in [[Vibration|vibration]], [[Sound|sound]] and circuit design. On section 2 of the Acoustics portal the article carries the three.js microsim *The damped, driven harmonic oscillator*, in which the reader sets the damping ratio and the drive frequency and watches a shaken mass beat, settle, and land on its resonance and phase curves; the older p5.js sketch below remains as its companion. ## Microsims — p5.js <div class="microsim-player"> <iframe src="https://editor.p5js.org/sciencenibber/full/4YJFtvZAg" width="100%" height="620" frameborder="0" loading="lazy" sandbox="allow-scripts allow-same-origin" title="Harmonic oscillator — p5.js microsim"></iframe> </div> <div class="microsim-fallback"><em>Live p5.js microsim (desktop) · <a href="https://editor.p5js.org/sciencenibber/sketches/4YJFtvZAg">open / fork the sketch in the p5.js editor</a></em></div> **Harmonic oscillator (p5.js).** The microsim is a velocity-Verlet integrator of the damped, driven equation $m\,\ddot x + c\,\dot x + k\,x = F_0\cos(\omega t)$, displayed three ways at once: a spring-and-mass animation along the top, a phase-portrait of $(x, v)$ in the lower-left, and a time scope of $x(t)$ and $F(t)$ in the lower-right. Five sliders (mass, spring constant, damping, drive amplitude, drive frequency) plus a reset button let the reader sweep across the three damping regimes and across the resonance peak; live readouts of $\omega_0$, $\zeta$, $Q$, and the regime label make the math visible. ## Overview The harmonic oscillator is the workhorse model of classical and quantum [[Physics|physics]]: any [[System|system]] whose restoring [[Force|force]] is linear in displacement, $F = -k\,x$, behaves as one near equilibrium. The free case obeys $m\,\ddot{x} + k\,x = 0$ with sinusoidal solutions of natural [[Angular_frequency|angular frequency]] $\omega_0 = \sqrt{k/m}$. Add a [[Velocity|velocity]]-proportional [[Damping|damping]] term and the full equation becomes $m\,\ddot{x} + c\,\dot{x} + k\,x = F(t)$, which captures everything from a mass on a spring to an LRC circuit, a [[Pendulum|pendulum]] near vertical, a tuning fork, an atom vibrating in a crystal lattice, or a microwave cavity. The damping ratio $\zeta = c/(2\sqrt{mk})$ partitions behavior into three regimes: underdamped ($\zeta<1$, ringing decay), critically damped ($\zeta=1$, fastest non-oscillatory return), and overdamped ($\zeta>1$, sluggish return). Driven by a sinusoid at frequency $\omega$, the steady-state amplitude peaks near $\omega_0$; the sharpness of that peak is the quality factor $Q = 1/(2\zeta)$. Because *almost every* smooth potential well looks parabolic at its minimum, the harmonic oscillator is the universal first-order approximation for [[Vibration|vibration]], [[Sound|sound]], light, and the lowest energy states of molecules, lattices, and quantum fields. ## On the Acoustics spine Neighbours on the vibration spine: [[Sound]] · [[Wave]] · [[Oscillation]] · [[Vibration]] · [[Acoustic_wave]] · [[Mechanical_wave]]. Bridge portal [[PORTAL_Acoustics]] · index [[PORTAL_INDEX]] · systems root [[PORTAL_Systems]]. <!-- SPINEPATH:BEGIN g20 — shortest chain of Wikipedia links between local articles to a Compendium Main article; do not hand-edit inside --> *Connected to the Apex Spine:* Harmonic oscillator → [[Coriolis_force|Coriolis force]] → [[Fluid_dynamics|Fluid dynamics]] — [[WT!Thury_Hydrodynamics_Compendium|Compendium]] section 1, *Fluid dynamics*. <!-- SPINEPATH:END --> ## Simple harmonic oscillator With no friction and no outside push, [[Newton's_laws_of_motion|Newton's second law]] for a mass `m` on a spring of stiffness `k` reads `m x'' = −k x`. Its solution is the sinusoid `x = A cos(ω0 t + φ)`, the [[Simple_harmonic_motion|simple harmonic motion]] of the [[Oscillation|oscillation]] article, with natural [[Angular_frequency|angular frequency]] `ω0 = √(k/m)`. The amplitude `A` and phase `φ` come from how the motion was started; the frequency does not. That independence of frequency from amplitude, called isochronism, is why a guitar string sounds the same note whether it is plucked gently or hard.[^up15-1] A worked case fixes the scale. A 0.25 kg mass on a 100 N/m spring has `ω0 = √(100/0.25) = 20 rad/s`, a frequency of 3.18 Hz and a period of 0.314 s. Pulled out 5 cm and released, it carries a total [[Energy|energy]] of `½kA² = 0.125 J`, which it trades back and forth between the spring and its own motion, reaching a top speed of `ω0 A = 1.0 m/s` as it passes through equilibrium. Plotted as position against velocity, the motion traces a closed ellipse in [[Phase_space|phase space]], one lap per period, and the area of that ellipse is fixed by the energy. ## Damped harmonic oscillator Real oscillators lose energy. When the loss comes from a fluid drag proportional to [[Velocity|velocity]], `−c x'`, the equation becomes `m x'' + c x' + k x = 0`, and one number, the damping ratio `ζ = c / (2√(mk))`, sorts every solution. Below `ζ = 1` the system is underdamped: it still oscillates, at the slightly lowered frequency `ωd = ω0 √(1 − ζ²)`, inside an exponential envelope `e^(−ζ ω0 t)`. At `ζ = 1` it is critically damped and returns to rest in the shortest time without overshooting, which is the setting sought for car shock absorbers. Above 1 it is overdamped and creeps back more slowly.[^up15-5] The [[Damping|damping]] article follows these three regimes in detail. The microsim's default, `ζ = 0.05` on a 1 Hz oscillator (`ω0 = 2π rad/s`), shows how little light damping changes the frequency and how much it changes the story. The damped frequency is 0.9987 of the natural one, a shift of 0.13 percent that no eye can see. The envelope, though, has a time constant `1/(ζ ω0) = 3.18 s`, and each swing is `e^(−0.315) = 0.73` of the one before; the exponent 0.315 is the logarithmic decrement `2πζ/√(1 − ζ²)`. The same oscillator has a [[Q_factor|quality factor]] `Q = 1/(2ζ) = 10`. Viscous damping is a modeling choice. A block sliding on a dry surface loses energy to kinetic friction of fixed size, which shifts the equilibrium toward the start of each half-swing instead of scaling with speed. The amplitude then falls by the same amount every half-cycle, a straight-line decay rather than an exponential one, and the block stops at a finite position when static friction can hold it. For a 1 s oscillator with a friction coefficient of 0.1 released from 0.18 m, each half-swing loses 2 × 0.0248 m and the motion ends after four half-periods.[^gea-11] ## Driven harmonic oscillators A driven oscillator obeys `m x'' + c x' + k x = F(t)`. Because the equation is linear, the response to a complicated force is the sum of the responses to its pieces, so two standard inputs, a step and a sinusoid, tell the whole story. In the language of a [[Linear_time-invariant_system|linear time-invariant system]], the oscillator is the [[Transfer_function|transfer function]] `H(s) = 1/(m s² + c s + k)`, and the [[Laplace_transform|Laplace transform]] turns the differential equation into algebra. ### Step input A constant force `F0` switched on at `t = 0` does not change the frequency; it moves the equilibrium to the static deflection `x_st = F0/k`, exactly as gravity only lowers the rest point of a hanging mass.[^gea-11] The system then oscillates about that new point. An underdamped oscillator overshoots it by the fraction `e^(−πζ/√(1 − ζ²))`: 85 percent at `ζ = 0.05`, 4.6 percent at `ζ = 0.7`, and none at `ζ = 1`. It settles to within 2 percent after roughly `4/(ζ ω0)`, which is 12.7 s for the microsim's 1 Hz oscillator at its default damping. The compromise between a fast rise and a small overshoot is why measuring instruments, from a moving-coil meter to the "oscillator in a box" accelerometer, are damped close to but below critical.[^gea-11] ### Sinusoidal driving force A force `F0 cos(ωt)` produces, once the start-up motion has died out, a steady swing at the drive frequency `ω`, not at `ω0`. Its amplitude is `A = F0 / √(m²(ω0² − ω²)² + c²ω²)`, largest when the drive frequency is close to the natural frequency and smallest far from it on either side.[^up15-6] Written with the frequency ratio `r = ω/ω0`, the amplitude in units of the static deflection is `A/x_st = 1/√((1 − r²)² + (2ζr)²)`, and the displacement lags the force by `φ = atan2(2ζr, 1 − r²)`. These two curves are the lower panels of the microsim. At its default setting, `ζ = 0.05` and `r = 0.85`, the steady amplitude is 3.45 times the static deflection and the lag is 17.0°. Moving the drive to `r = 1` raises the amplitude to exactly `Q = 10` and the lag to 90°: the force then pushes in step with the velocity and feeds in energy on every cycle. At `r = 2` the mass moves only a third as far as a slow push would move it (0.333 `x_st`) and swings almost in opposition to the drive, with a lag of 176°. The peak of the amplitude curve sits slightly below `ω0`, at `r = √(1 − 2ζ²)`, and above `ζ = 1/√2 ≈ 0.71` there is no peak at all. The phenomenon of a small drive producing a large response near `ω0` is [[Resonance|resonance]], the subject of the next section of the portal; a paddle ball on a rubber band and a piano string answering a sung note are the textbook cases.[^up15-6] ## Parametric oscillators A parametric oscillator is driven not by an outside force but by a periodic change in one of its own parameters, its stiffness or its length. The standard model is the Mathieu equation, `x'' + 2ζω0 x' + ω0²[1 + h cos(Ωt)] x = 0`, named for Émile Mathieu's 1868 study of vibrating elliptical membranes.[^mathieu1868] The equation is still linear in `x` but no longer time-invariant, and it behaves very differently from a forced oscillator: a displacement that starts at zero stays at zero, while any small displacement grows exponentially if the parameter is modulated near twice the natural frequency, `Ω ≈ 2ω0`. For a stiffness modulated by the fraction `h` at exactly `2ω0`, the growth rate is `hω0/4`, so the motion grows only when that rate beats the damping rate `ζω0`, that is when `h > 4ζ`.[^ll27] For the microsim's `ζ = 0.05` the stiffness would have to swing by more than 20 percent. The classic demonstrations are old. Michael Faraday reported in 1831 that a liquid layer shaken vertically forms surface ripples at half the shaking frequency, and Lord Rayleigh's 1883 paper on maintained vibrations explained both Faraday's ripples and Franz Melde's experiment, in which a string tied to one prong of a tuning fork is set swinging at half the fork's frequency when the fork pulls along its length.[^faraday1831][^rayleigh1883] A child who pumps a swing by standing and crouching twice per cycle changes the effective length of the pendulum at `2ω0` and is a parametric oscillator too. In [[Electronics|electronics]], parametric amplifiers use the same instability deliberately, modulating a capacitance to transfer energy from a pump into a weak signal. ## Universal oscillator equation Every linear oscillator with viscous damping and a sinusoidal drive can be written in one dimensionless form. Measuring time in units of the natural period, `τ = ω0 t`, and displacement in units of the static deflection, `q = x/x_st`, turns the equation into `q'' + 2ζ q' + q = cos(rτ)`. Two numbers remain: the damping ratio `ζ` and the frequency ratio `r`. A 1 Hz mass on a spring, a 660 Hz wine glass and a megahertz radio circuit with the same `ζ` and `r` trace the same curves, which is why the microsim needs only those two sliders and runs its oscillator at 1 Hz so that the motion can be watched in real time. ### Transient solution The transient is the solution of the equation with the right-hand side set to zero: the free, damped oscillation at `ωd` inside the envelope `e^(−ζτ)`. Its amplitude and phase depend on the starting conditions, and it carries no memory of the drive frequency. It is called transient because it always decays; at `ζ = 0.05` it falls to 1 percent of its starting size in `ln(100)/(ζ ω0) = 14.7 s`. ### Steady-state solution The steady state is the particular solution that keeps pace with the drive, `q = A(r) cos(rτ − φ)`, with the amplitude and lag given in the section on the sinusoidal driving force. It does not depend on how the motion began. The amplitude and phase curves drawn in the microsim's lower panels are the steady-state solution for every `r` at once, with a white dot marking the current drive. ### Full solution The full solution is the transient plus the steady state, with the transient's two constants chosen so that the sum matches the starting position and velocity. A mass released at rest must have its transient start at almost the same size as the steady swing and in the opposite phase, so the two cancel at `t = 0` and then drift in and out of step. The result is a beat at the difference frequency. At the default `r = 0.85`, the transient runs at 0.999 Hz and the drive at 0.85 Hz, so the swing waxes and wanes every 6.7 s, and the beats fade as the transient decays over its 14.7 s lifetime, leaving the steady amplitude marked by the orange bracket. With the drive switched off, only the transient remains, and the trace becomes the ringing decay of the damped oscillator.[^up15-6][^beats-fwd] *Try: set the drive frequency w/w0 near 0.95 and the damping ratio zeta at its lowest (0.02) and press reset to watch slow, long-lived beats build to Q = 25; then raise zeta above 0.71 and see the peak vanish from the amplitude curve, or untick drive on to see the free ring-down alone.* ## Equivalent systems The same second-order equation governs systems that share no hardware, only the roles of inertia, loss and stiffness. This is the basis of the [[Lumped-element_model|lumped-element model]] used across [[Electrical_engineering|electrical engineering]] and acoustics: a circuit can stand in for a mechanical structure, or an acoustic cavity for a circuit, as long as each element stays small compared with a wavelength. | System | Coordinate | Inertia | Loss | Stiffness | Drive | Natural frequency `ω0` | |---|---|---|---|---|---|---| | Mass on a spring | displacement `x` | mass `m` | damping coefficient `c` | spring constant `k` | force `F` | `√(k/m)` | | Torsion pendulum | angle `θ` | moment of inertia `I` | torsional damping `cθ` | torsion constant `κ` | torque `τ` | `√(κ/I)` | | Series RLC circuit | charge `q` | inductance `L` | resistance `R` | inverse capacitance `1/C` | voltage `V` | `1/√(LC)` | | Helmholtz resonator | volume flow through the neck | air mass in the neck | radiation and viscous loss | compressibility of the air in the cavity | outside sound pressure | `c √(S/(V l))` | In the last row `c` is the speed of sound, `S` and `l` the area and effective length of the neck, and `V` the cavity volume; the [[Helmholtz_resonance|Helmholtz resonance]] and [[Acoustic_resonance|acoustic resonance]] articles work that case through. The damping ratio translates too: for the series circuit it is `(R/2)√(C/L)`. ## Application to a conservative force The harmonic oscillator matters beyond springs because almost every stable equilibrium looks like one up close. Near a minimum `x0` of any smooth potential energy `U(x)`, a Taylor expansion gives `U ≈ U(x0) + ½ U''(x0)(x − x0)²`; the linear term vanishes because the force is zero at equilibrium. The curvature of the potential plays the role of the spring constant, `k = U''(x0)`, and small motions about the minimum are simple harmonic at `ω0 = √(U''(x0)/m)`. A pendulum shows the method. Its potential is `U = mgL(1 − cos θ)`, whose curvature at the bottom is `mgL`; dividing by the moment of inertia `mL²` gives `ω0 = √(g/L)`. The two atoms of a [[Diatomic_molecule|diatomic molecule]] sit in the well of their bond potential and vibrate the same way, as do atoms in a [[Crystal_structure|crystal lattice]]. In [[Quantum_mechanics|quantum mechanics]] the same parabola gives evenly spaced energy levels `(n + ½)ħω0`, with a nonzero [[Zero-point_energy|zero-point energy]] in the lowest state. The approximation fails when the amplitude is large enough to feel the potential's higher terms; the motion is then that of a [[Nonlinear_system|nonlinear system]], whose frequency depends on amplitude. ## Examples ### Simple pendulum For small swings a pendulum of length `L` has the period `T = 2π√(L/g)`, independent of the mass and, to first order, of the amplitude.[^up15-4] A "seconds pendulum," which takes 1 s per swing and so 2 s per full period, needs `L = g/π² = 0.994 m` at `g = 9.81 m/s²`. Isochronism is only approximate. At a 20° amplitude the period is about `θ0²/16 = 0.76` percent longer than the small-angle value, enough to cost a clock about 11 minutes a day if the swing were allowed to vary. [[Christiaan_Huygens|Christiaan Huygens]] took up that problem in his 1673 *Horologium Oscillatorium*, showing that a bob guided along a cycloid swings with exactly the same period at any amplitude.[^huygens1673] ### Spring/mass system A mass on a spring is the model the equation was written for. Hung vertically, the mass stretches the spring until the spring force balances its weight; gravity then drops out of the equation of motion, and the mass oscillates about the lowered point at the same frequency it would have on a horizontal table.[^gea-11] The microsim drives its mass through the top of the spring: a shaker moves the spring's upper end by `y_s = x_st cos(ωt)`, which is equivalent to a force of amplitude `F0 = k x_st` on the mass, so the drawn motion is measured directly in units of the static deflection. A dashpot below the mass supplies the viscous damping. ## Definition of terms | Symbol | Name | Meaning | |---|---|---| | `m` | mass | inertia of the moving part, kg | | `k` | spring constant | restoring force per unit displacement, N/m | | `c` | damping coefficient | drag force per unit velocity, N·s/m | | `ω0 = √(k/m)` | natural angular frequency | rate of free, undamped oscillation, rad/s; `f0 = ω0/2π` in Hz | | `ζ = c/(2√(mk))` | damping ratio | 1 at critical damping | | `ωd = ω0√(1 − ζ²)` | damped angular frequency | rate of free oscillation with damping | | `Q = 1/(2ζ)` | quality factor | peak gain at resonance; `ω0` divided by the half-power bandwidth | | `r = ω/ω0` | frequency ratio | drive frequency in units of the natural frequency | | `x_st = F0/k` | static deflection | displacement a steady force of the drive's size would cause | | `φ` | phase lag | how far the displacement trails the drive, 0° to 180° | ## See also - [[Damping]] - [[Q_factor]] - [[Oscillation]] (Acoustics portal section 1) - [[Resonance]] (section 3) - [[Vibration]] (section 4) - [[Acoustic_resonance]] (section 14) ## References [^up15-1]: Ling, Samuel J.; Sanny, Jeff; Moebs, William (2016). *University Physics Volume 1*. OpenStax, Rice University. §15.1 "Simple Harmonic Motion," pp. 710–718 (isochronism of the plucked guitar string). https://openstax.org/details/books/university-physics-volume-1. Book 077 on the [[PORTAL_Acoustics]] shelf. [^up15-4]: Ling, Sanny and Moebs (2016), *University Physics Volume 1*, §15.4 "Pendulums," pp. 728–734. [^up15-5]: Ling, Sanny and Moebs (2016), *University Physics Volume 1*, §15.5 "Damped Oscillations," pp. 734–737, Eq. 15.23–15.26 and Fig. 15.27 (underdamped, critically damped and overdamped cases; car shock absorbers as the critically damped example). [^up15-6]: Ling, Sanny and Moebs (2016), *University Physics Volume 1*, §15.6 "Forced Oscillations," pp. 737–741, Eq. 15.27–15.29 (transients, steady state, amplitude against driving frequency), Fig. 15.29 (paddle ball), Fig. 15.28 (piano strings answering a sung note), Fig. 15.31–15.32 (resonance curves and quality). [^gea-11]: Gea-Banacloche, Julio (2019). *University Physics I: Classical Mechanics*. University of Arkansas Open Educational Resources. §11.2.2 "Harmonic oscillator subject to an external, constant force," pp. 260–262; §11.5.1 "Oscillator in a box (a basic accelerometer!)," p. 268; §11.6.1 "Mass on a spring damped by friction with a surface," pp. 272–273 (worked case T = 1 s, μk = 0.1, A = 0.18 m). https://scholarworks.uark.edu/oer/3. Book 076 on the [[PORTAL_Acoustics]] shelf. [^ll27]: Landau, L. D.; Lifshitz, E. M. (1976). *Mechanics* (Course of Theoretical Physics, vol. 1), 3rd ed. Pergamon Press. §27 "Parametric resonance" (growth rate and threshold for a frequency modulated near twice its natural value). [^mathieu1868]: Mathieu, Émile (1868). "Mémoire sur le mouvement vibratoire d'une membrane de forme elliptique." *Journal de Mathématiques Pures et Appliquées*, 2nd series, 13: 137–203. (Volume and pages as commonly cited; not checked against a scan in this run.) [^faraday1831]: Faraday, Michael (1831). "On a peculiar class of acoustical figures; and on certain forms assumed by groups of particles upon vibrating elastic surfaces." *Philosophical Transactions of the Royal Society of London* 121: 299–340. https://doi.org/10.1098/rstl.1831.0018 [^rayleigh1883]: Rayleigh, Lord (Strutt, J. W.) (1883). "On maintained vibrations." *Philosophical Magazine*, 5th series, 15 (94): 229–235. (Treats Melde's string experiment and Faraday's crispations as parametric resonance; issue number as commonly cited.) [^huygens1673]: Huygens, Christiaan (1673). *Horologium Oscillatorium sive de motu pendulorum ad horologia aptato demonstrationes geometricae*. Paris: F. Muguet. [^beats-fwd]: The beat pattern is standard superposition of two sinusoids of nearby frequency; see Ling, Sanny and Moebs (2016), *University Physics Volume 1*, §17.6 "Beats," pp. 838–840, and the portal's [[Beat_(acoustics)]] section. <!-- ACOUSIM:BEGIN g22 — Acoustics portal microsim (framework build, specs/acoustics/sims/Harmonic_oscillator.json); do not hand-edit inside --> **Microsim — three.js (Wikitube framework):** *Harmonic oscillator* <div class="wt-sim" data-src="https://wikitube-3d-microsims.netlify.app/acoustics/Harmonic_oscillator.html" data-title="Harmonic oscillator"></div> *Built from `MICROSIM_GUIDE/specs/acoustics/sims/Harmonic_oscillator.json`; part of the [[PORTAL_Acoustics|Acoustics portal]] spine (section sims and See-also variants).* <!-- ACOUSIM:END --> <!-- MATTERSIM:BEGIN g33 — Matter & Energy Cluster microsim (framework build, specs/sims/Harmonic_oscillator.json); do not hand-edit inside --> **Microsim — three.js (Wikitube framework):** *Harmonic oscillator* <div class="wt-sim" data-src="https://wikitube-3d-microsims.netlify.app/matter/Harmonic_oscillator.html" data-title="Harmonic oscillator"></div> *Built from `MICROSIM_GUIDE/specs/sims/Harmonic_oscillator.json`; part of the [[PORTAL_Matter|Matter portal]] spine (section sims and See-also variants).* <!-- MATTERSIM:END --> ## Wikipedia : Wikitube **Strict pair:** [Wikipedia](https://en.wikipedia.org/wiki/Harmonic_oscillator) : [Wikitube](https://en.wikitube.io/wiki/Harmonic_oscillator) Body sections (Simple harmonic oscillator through Definition of terms) mirror the pair skeleton pinned to revision [1373924880](https://en.wikipedia.org/w/index.php?oldid=1373924880) (2026-09-11). --- *Repopulated 2026-08-05 · microsim-first transfer from legacy GENERATIVE lane · p5 sciencenibber/4YJFtvZAg · 0 deletions.* <!-- hub tags: GENERATIVE; Centers_of_Excellence; PORTAL_Acoustics section 2 -->