Sub topic 10
Phase and initial conditions
This chapter assumes you know the SHM equation a = -ω²x, the solution x(t) = A cos(ωt + φ), and the derivatives of sine and cosine. It also assumes you can use radians and atan2. The chapter covers what the phase constant φ means, how to get A and φ from a starting position and velocity, and where sign and quadrant mistakes come from.
Why the solution has two free constants
The SHM equation d²x/dt² = -ω²x is a second-order differential equation. Its general solution has two independent constants. In the cosine form they are the amplitude A and the phase constant φ:
x(t) = A cos(ωt + φ)
The constants have different origins:
- ω comes from the system. For a spring it is √(k/m).
- A and φ come from how the motion started.
The same spring and mass can oscillate with any amplitude and any phase, and the period stays 2π/ω in every case. This is why the period of ideal SHM does not depend on amplitude.
What the phase constant means
The argument ωt + φ is the phase, measured in radians. At t = 0 the phase equals φ, so φ says where in its cycle the oscillator is at the moment you start the clock.
Changing φ shifts the whole curve along the time axis without changing its shape. Writing the solution as x = A cos(ω(t - t₀)) shows that t₀ = -φ/ω. A negative φ delays the motion, so the oscillator reaches its maximum later. A positive φ advances it.
Deriving A and φ from initial conditions
Differentiate the solution to get the velocity:
- x(t) = A cos(ωt + φ)
- v(t) = -Aω sin(ωt + φ)
Set t = 0 and call the starting values x₀ and v₀:
- x₀ = A cos φ
- v₀/ω = -A sin φ
The second line divides v₀ by ω so both equations have the units of length. Square and add them. Because cos²φ + sin²φ = 1:
A = √(x₀² + (v₀/ω)²)
Divide the second equation by the first to get tan φ = -v₀/(ωx₀). Use atan2 rather than atan to find φ:
φ = atan2(-v₀/ω, x₀)
A plain arctangent returns only angles between -π/2 and π/2. It cannot tell (x₀ > 0, v₀ < 0) from (x₀ < 0, v₀ > 0), because the ratio is the same in both cases. atan2 looks at the signs of both arguments and returns the correct quadrant.
The same result has a sine-and-cosine form with no phase constant:
x(t) = x₀ cos ωt + (v₀/ω) sin ωt
This form is convenient when you only need the solution. The cosine form with φ is better when you need the amplitude or want to compare the phases of two oscillators.
Worked example
Take the 0.5 kg mass on the 20 N/m spring, so ω = √40 ≈ 6.325 rad/s. At t = 0 the mass is 0.10 m to the right of equilibrium and moving right at 0.30 m/s.
- v₀/ω = 0.30 / 6.325 ≈ 0.0474 m
- A = √(0.10² + 0.0474²) = √0.01225 = 0.110 m
- φ = atan2(-0.0474, 0.10) ≈ -0.443 rad, which is about -25.4°
The mass starts to the right of equilibrium and still moving right. It has not yet reached its right-hand extreme, which is 0.110 m. Its cosine peak therefore comes after t = 0, and φ is negative. The code below confirms the numbers.
import math
def shm_constants(x0, v0, omega):
"""Return amplitude A and phase phi (radians) for x = A cos(omega t + phi)."""
u = v0 / omega
A = math.hypot(x0, u)
phi = math.atan2(-u, x0)
return A, phi
k, m = 20.0, 0.5
omega = math.sqrt(k / m)
x0, v0 = 0.10, 0.30
A, phi = shm_constants(x0, v0, omega)
print(f"omega = {omega:.3f} rad/s")
print(f"A = {A:.4f} m, phi = {phi:.3f} rad = {math.degrees(phi):.1f} deg")
def x(t):
return A * math.cos(omega * t + phi)
def v(t):
return -A * omega * math.sin(omega * t + phi)
print(f"x(0) = {x(0):.4f} m, v(0) = {v(0):.4f} m/s")The last line should print x(0) = 0.1000 m, v(0) = 0.3000 m/s. Always run a check like this after you derive constants. It catches sign errors immediately.
Standard starting conditions
Some starting conditions come up often enough to memorize.
| Starting condition at t = 0 | x₀ | v₀ | φ | Form of x(t) |
|---|---|---|---|---|
| Released from rest at positive extreme | +A | 0 | 0 | A cos ωt |
| At equilibrium, moving in the positive direction | 0 | +Aω | -π/2 | A sin ωt |
| Released from rest at negative extreme | -A | 0 | π | -A cos ωt |
| At equilibrium, moving in the negative direction | 0 | -Aω | +π/2 | -A sin ωt |
Released from rest is the most common case, because you pull the mass aside and let go. Then v₀ = 0, A = |x₀|, and φ is either 0 or π.
Phase relationships between x, v and a
Rewrite the derivatives using the identity -sin θ = cos(θ + π/2):
- x = A cos(ωt + φ)
- v = Aω cos(ωt + φ + π/2)
- a = Aω² cos(ωt + φ + π)
Velocity leads position by a quarter cycle (π/2). Acceleration is exactly out of phase with position (a shift of π), which is just a = -ω²x written in terms of phase. The velocity is largest when the position is zero, and the velocity is zero at the extremes.
Two oscillators of the same frequency can also be compared by their phase difference Δφ. If Δφ = 0 they are in phase. If Δφ = π they are in antiphase, so one is at its maximum while the other is at its minimum. Oscillators of different frequency do not have a fixed phase difference.
Common errors
- Degrees in the cosine. Use radians for ωt + φ. Calculators and
math.cosassume radians unless you convert. - Dropping the minus sign. The formula is φ = atan2(-v₀/ω, x₀). Using +v₀/ω gives a phase with the wrong sign, which describes motion in the opposite direction.
- Forgetting to divide by ω. v₀ and x₀ have different units. Only v₀/ω compares with x₀.
- Using
ataninstead ofatan2. The result is wrong by π whenever x₀ < 0. - Mixed conventions. Some books write cos(ωt - φ) or sin(ωt + φ). All of these are valid, but the value of φ differs between them. State your convention, and convert when you compare answers with a source.
- Letting A go negative. A is positive by definition. A minus sign belongs in φ, because -cos θ = cos(θ + π).
Using the constants
Once you have A and φ, every other quantity in SHM follows without more work. The maximum speed is Aω and the maximum acceleration is Aω². The total energy is ½kA². You can also find the time of the first maximum, t = -φ/ω, if you add 2π to φ when it is negative so that the time is positive. In the worked example above, φ = -0.443 rad, so the first right-hand extreme occurs at t = 0.443/6.325 ≈ 0.070 s.
Exercise
A mass on a spring has ω = 4.0 rad/s. At t = 0 it is at x₀ = -0.060 m and moving in the positive direction at v₀ = +0.24 m/s. Find A and φ, then write x(t).
Show answer
First, v₀/ω = 0.24/4.0 = 0.060 m. So A = √((-0.060)² + 0.060²) = 0.060√2 ≈ 0.085 m. Next, φ = atan2(-0.060, -0.060). Both arguments are negative, so the angle is in the third quadrant: φ = -3π/4 ≈ -2.36 rad (equivalent to 5π/4). So x(t) = 0.085 cos(4.0t - 2.36) m. Check: x(0) = 0.085 cos(-3π/4) = -0.060 m, and v(0) = -0.085 × 4.0 × sin(-3π/4) = +0.24 m/s.
Exercise
Two identical oscillators have x₁ = A cos(ωt) and x₂ = A cos(ωt + π/2). Which one reaches its positive maximum first, and by what fraction of a period?
Show answer
Oscillator 2 reaches its maximum first. Its maximum occurs when ωt + π/2 = 0, so at t = -π/(2ω), which is a quarter period before oscillator 1 (T = 2π/ω, so π/(2ω) = T/4). Oscillator 2 leads by a quarter cycle. For the same reason, velocity leads position by π/2.