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:
The cosine wave $\cos(\omega t)$ oscillates rapidly between $+1$ and $-1$.
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:
The code has ???? for damping coefficient gamma. Replace ???? with 0.2 and click Run to plot the decaying oscillation wave and exponential envelopes!
Notes:
Notice that every crest of the wave touches the upper envelope curve, and every trough touches the symmetric lower envelope $-A e^{-\gamma t}$.
The half-life of the amplitude is $t_{1/2} = \frac{\ln(2)}{\gamma} \approx \frac{0.693}{0.2} = 3.47$ seconds.
Engineers design suspension shock absorbers and building earthquake dampers to tune $\gamma$ so oscillations die out quickly without bouncing.
Share your code
Show a friend, family member, or teacher what you've done!