Lesson 11 of 15

Simple Harmonic Motion

Simple Harmonic Motion

Simple Harmonic Motion (SHM) occurs when a restoring force is proportional to displacement (Hooke's law: F=kxF = -kx). The resulting motion is sinusoidal:

x(t)=Acos(ωt)x(t) = A \cos(\omega t)

  • AA — amplitude (maximum displacement, metres)
  • ω\omega — angular frequency (rad/s): ω=2πf=2π/T\omega = 2\pi f = 2\pi / T
  • tt — time (seconds)

Starting at t=0t = 0, the object is at maximum displacement x=Ax = A.

Key Quantities

T=2πωqquadf=ω2πT = \frac{2\pi}{\omega} qquad f = \frac{\omega}{2\pi}

Velocity and Acceleration in SHM

v(t)=Aωsin(ωt)v(t) = -A\omega \sin(\omega t)

a(t)=Aω2cos(ωt)=ω2xa(t) = -A\omega^2 \cos(\omega t) = -\omega^2 x

The acceleration always opposes displacement — this is the hallmark of SHM.

Examples

AAω\omegattx(t)x(t)
1101.0000 (at maximum)
5205.0000
31π\pi−3.0000 (at minimum)
1012π2\pi10.0000 (back to start)

Your Task

Implement shmX(A, omega, t) returning displacement in metres.

TCC compiler loading...
Loading...
Click "Run" to execute your code.