The idea: the spring always pulls back
Fix a spring to a wall, hang a mass m on its free end on a smooth floor, pull the mass out a distance A and let go. Measure x from where the mass sits at rest (the equilibrium, x = 0). A stretched spring pulls back, a squeezed one pushes back, and the force grows with the stretch. That is Hooke's law:
F = −k·x k = spring constant (stiffness), in N/m
The minus sign is the whole story: the force always points back to x = 0. The mass overshoots, the spring turns it around on the other side, and it swings back and forth forever (there is no friction on this page).
Why a cosine: m·x″ = −k·x
Newton's second law F = m·a with a = x″ (the second derivative of x) gives
m·x″ = −k·x so x″ = −(k/m)·x
We need a function whose second derivative is a negative multiple of itself. cos(ωt) does it: (cos ωt)″ = −ω²·cos ωt. So ω² = k/m, and every solution is
x(t) = A·cos(ωt + φ) ω = √(k/m)
The spring and the mass fix ω. How hard you pulled (A) and when you started the clock (φ) are your choice. The cosine itself is on Cosine Waves: What a, b, c, d Do.
ω, f and T: one number, three units
All three say how fast the mass swings. Set any one and the other two follow:
| name | unit | meaning | start value |
|---|---|---|---|
| angular frequency ω = √(k/m) | rad/s | how fast the angle ωt + φ turns | 4 rad/s |
| frequency f = ω / 2π | Hz = swings per second | how many full swings in one second | ≈ 0.64 Hz |
| period T = 1/f = 2π/ω | s | how long one full swing takes | ≈ 1.57 s |
Put together: T = 2π·√(m/k). When you set T, f or ω on the page, the mass stays and the spring is changed to match, k = m·ω²: a second chip carries the new k into its box. (Demo 4: set f = 1 Hz, then T = 2 s: f = 1 Hz needs k = 4π² ≈ 39.48 N/m; T = 2 s needs k = π² ≈ 9.87 N/m.)
What m and k do
A stiffer spring pulls harder, so the mass turns around sooner: T goes down as 1/√k. A heavier mass is harder to speed up and slow down: T goes up as √m. Because of the square root, doubling k does not halve T, it divides it by √2 ≈ 1.41.
| change | ω | T | on the page |
|---|---|---|---|
| k × 2 (16 → 32 N/m) | × √2 | ÷ √2: 1.57 → 1.11 s | Demo 1 |
| k × 4 | × 2 | ÷ 2 | Demo 6 sweeps k from 4 to 64 |
| m × 4 (1 → 4 kg) | ÷ 2 | × 2: 1.57 → 3.14 s | Demo 2 |
| m and k both × 2 | same | same | only the ratio k/m counts |
A does not change the period
Pull the mass out twice as far and the spring pulls twice as hard, so the mass is twice as fast all the way. Twice the distance at twice the speed takes the same time: T has no A in it. This is called isochronism, and it is why springs keep time in watches (the balance spring). What A does change is the speed and the energy: v_max = Aω and E = ½kA² grows with the square of A. (Demo 3: bigger A, same T: A from 0.1 to 0.4 m, T stays 1.57 s, v_max 0.4 → 1.6 m/s, E × 16.)
φ: where the swing starts
φ is the phase: it says where in its swing the mass is at t = 0.
- φ = 0: x(0) = A, pulled out and let go (the start of the page).
- φ = −π/2: x = A·sin ωt, it starts at x = 0 moving right at full speed, as if it had been hit. (Demo 5)
- φ = ±π: x(0) = −A, pushed in and let go.
In general x(0) = A·cos φ and v(0) = −Aω·sin φ. φ moves the curve sideways; T, A and the energy stay.
Speed, acceleration and energy
Differentiate x = A·cos(ωt + φ) once and twice:
v = −Aω·sin(ωt + φ) v_max = Aω (at x = 0)
a = −Aω²·cos(ωt + φ) = −ω²·x a_max = Aω² (at x = ±A)
The energy moves back and forth between the spring and the mass, and the total never changes:
E = ½·k·x² + ½·m·v² = ½·k·A² start: ½ · 16 · 0.2² = 0.32 J
Watch the arrows when you press Watch one period: the red force arrow is longest at the turning points, where the green velocity arrow is gone, and the other way round at x = 0.
See also
A pendulum swings the same way for small angles, with ω = √(g/L) instead of √(k/m): see Simple Pendulum. Add friction and the swings die away inside an envelope A·e^(−γt): see Damped Oscillation: What A, γ, ω, φ Do. Solving x″ = −(k/m)·x step by step on a computer is on Euler's Method.
Each point of a vibrating guitar string moves in simple harmonic motion like this mass; the string's frequency is set by its tension, mass per metre and length in Standing Waves on a String.
Add damping and push the mass with F₀·cos ωt and you get Driven Oscillator: the swing becomes huge when ω matches ω₀ = √(k/m) (resonance).
An inductor and a capacitor swap energy the same way a mass and a spring do: L plays the mass and 1/C the stiffness, so ω₀ = 1/√(LC). See RLC Circuits.
Seen from the side, a satellite on a circular orbit moves as x = r·cos(ωt), the same simple harmonic motion: see Orbital Motion.
Simulating this motion step by step is a test for ODE solvers: Euler's method spirals outward and gains energy, while RK4 stays on the circle; see Runge–Kutta vs Euler.
What the page leaves out
Friction and damping (see Damped Oscillation), a driving force and resonance, a vertical spring (gravity only moves the rest position down by mg/k; T is the same), the mass of the spring itself, stretching so far that Hooke's law no longer holds, and several masses and springs coupled together. The page keeps 0.25 ≤ m ≤ 8 kg, 0.05 ≤ A ≤ 0.4 m and 1 ≤ ω ≤ 16 rad/s so one period fits the 8-second graph.