Lesson goal: Damped Harmonic Oscillations

Previous: Scatter plots and linear regression | Home | Next: Introduction to data files

When a pendulum swings through the air or a guitar string vibrates, the motion doesn't continue forever. Friction, air resistance, and internal viscosity dissipate energy, causing the vibration to gradually fade away.

In physics and engineering, this is modeled as a Damped Harmonic Oscillator: $$y(t) = A \cdot e^{-\gamma t} \cdot \cos(\omega t)$$ where:
  • $A$ is the initial release amplitude.
  • $\gamma$ is the damping decay coefficient (higher $\gamma$ means faster energy loss).
  • $\omega$ is the angular frequency ($T = \frac{2\pi}{\omega}$ is the period between oscillations).


Notice that the equation is the product of two functions:
  1. The cosine wave $\cos(\omega t)$ oscillates rapidly between $+1$ and $-1$.
  2. The exponential decay $e^{-\gamma t}$ forms an upper boundary (envelope) $y_{\text{env}}(t) = +A e^{-\gamma t}$.


The vibrating curve is trapped inside this decaying envelope! Using plot2(), we can plot the physical oscillation alongside its bounding envelope on the same chart.
plot2(t,y,envelope,label1,label2)
Move the mouse over a dotted box for more information.

Now you try. Try increasing gamma from 0.2 to 0.8 to see heavy damping in action!

Type your code here:


See your results here: