Sub topic 3
Phase and Initial Conditions
This chapter assumes you know Newton's second law, sine and cosine in radians, kinetic and potential energy, and the derivatives of sine and cosine.
Phase and initial conditions
The solution x(t) = A cos(ωt + φ) has three parameters. A is the amplitude, ω is the angular frequency, and φ is the phase. The phase fixes where the oscillation is at t = 0. Given the starting position x0 and velocity v0, the constants are A = √(x0² + (v0/ω)²) and tan φ = −v0/(ω·x0).
Velocity and acceleration over a cycle
Differentiating gives v(t) = −Aω sin(ωt + φ) and a(t) = −ω²x(t). Velocity is zero at the turning points and largest at equilibrium. Acceleration is largest in magnitude at the turning points.
Energy exchange in SHM
The total energy E = ½mv² + ½kx² stays constant at ½kA². The speed at position x is v = ω√(A² − x²). Energy moves between kinetic and potential forms, but the total does not change in an ideal oscillator.
Vertical springs and springs in series and parallel
A vertical spring shifts the equilibrium point under gravity, but ω stays √(k/m). For springs in parallel, keff = k1 + k2. For springs in series, 1/keff = 1/k1 + 1/k2.
When the pendulum is not simple harmonic
The period T = 2π√(L/g) holds only when sin θ ≈ θ, which requires a small swing angle. At 30 degrees, the exact period is about 1.7% longer. At 90 degrees, it is about 18% longer.
import math
def agm(a, b):
while abs(a - b) > 1e-12:
a, b = (a + b) / 2, math.sqrt(a * b)
return a
def pendulum_period(L, g, theta0):
# exact period for amplitude theta0 (radians)
return 2 * math.pi * math.sqrt(L / g) / agm(1.0, math.cos(theta0 / 2))
L, g = 1.0, 9.81
T0 = 2 * math.pi * math.sqrt(L / g)
for deg in (5, 30, 90):
T = pendulum_period(L, g, math.radians(deg))
print(f"{deg:>3} deg: T = {T:.4f} s, T/T0 = {T / T0:.4f}")Simulating oscillators in code
The following code steps a spring-mass system forward in time and compares the result with the analytic solution at t = 1 s. Shrinking dt narrows the gap.
import math
k, m = 20.0, 0.5
x, v = 0.10, 0.0 # start at rest, displaced 0.10 m
dt = 0.001
steps = 1000 # simulate 1 second
for _ in range(steps):
a = -(k / m) * x
v += a * dt # update velocity first (semi-implicit Euler)
x += v * dt
t = steps * dt
analytic = 0.10 * math.cos(math.sqrt(k / m) * t)
print(f"numerical x = {x:.4f} m, analytic x = {analytic:.4f} m")Damping, driving, and resonance
Friction removes energy, so the amplitude decays over time. A periodic driving force near the natural frequency ω causes the amplitude to grow large. This effect is called resonance. The SHM model does not describe these effects without extra terms.
> callout
Exercise
A 0.5 kg mass on a 20 N/m spring is released from rest at x0 = 0.10 m. What is the phase φ?
Show answer
Since v0 = 0 and x0 is positive, φ = 0, so x(t) = 0.10 cos(ωt) with ω = √(20/0.5) ≈ 6.325 rad/s.