Skip to main content

Simple Harmonic Motion Calculator: Spring & Pendulum Period

Analyze ideal Simple Harmonic Motion for mass-spring systems and simple pendulums. Calculate angular frequency, period, and frequency. Optionally evaluate displacement, velocity, and acceleration at any time. Compare up to 3 scenarios.

Last Updated: February 13, 2026

The Sinusoidal Backbone: Why SHM Traces a Cosine Wave

A student plugged m = 2 kg and k = 50 N/m into a simple harmonic motion calculator and got T = 1.26 s, but their measured period was 1.42 s. The mistake? They weighed the spring itself at 0.3 kg and ignored it—adding effective mass pushed the real period up 12%. Before trusting any SHM result, confirm that the "mass" in your formula includes everything that oscillates. The core insight of simple harmonic motion is that any system where the restoring force is proportional to displacement (F = −kx for springs, F ≈ −(mg/L)x for small-angle pendulums) traces out a perfect cosine curve: x(t) = A cos(ωt + φ). That sine wave isn't a mathematical convenience—it's the unique solution to the differential equation m(d²x/dt²) = −kx. Every real oscillator approximates SHM when you linearize around equilibrium.

Once you internalize the cosine picture, the rest falls into place. Velocity is the time derivative of position: v(t) = −Aω sin(ωt + φ), peaking at equilibrium where displacement crosses zero. Acceleration is the derivative of velocity: a(t) = −Aω² cos(ωt + φ) = −ω²x(t), always pointing toward equilibrium and proportional to how far away you are. These phase relationships—position and acceleration 180° out of phase, velocity 90° ahead of position—show up on every oscilloscope trace of a mass-spring system.

Labeled Diagram: Position, Velocity, Acceleration vs Time


       x(t), v(t), a(t)
          │
      +A ─┼─────────x(t) = A cos(ωt)─────────────────────────────
          │        ╱                  ╲                      ╱
          │       ╱                    ╲                    ╱
       0 ─┼──────●──────────────────────●──────────────────●───► t
          │     ╱│╲                    ╱│╲                ╱
          │    ╱ │ ╲                  ╱ │ ╲              ╱
     −A ─┼───╱──│──╲────────────────╱──│──╲────────────╱───────
          │     │                      │
          │     v(t) max here          v(t) max (neg) here
          │     (x = 0, moving +)      (x = 0, moving −)
          │
          └─────┬────────┬────────┬────────┬────────► time
               T/4      T/2     3T/4       T

  Key Points:
  ─────────────────────────────────────────────────────────────
  • Position x(t) = A cos(ωt + φ): max at t = 0, zero at T/4
  • Velocity v(t) = −Aω sin(ωt + φ): zero at t = 0, max (neg) at T/4
  • Acceleration a(t) = −ω²x(t): max (neg) at t = 0, zero at T/4
  • v leads a by 90° (quarter period); x and a are 180° out of phase
  • At x = 0: velocity maximal, acceleration zero (equilibrium)
  • At x = ±A: velocity zero, acceleration maximal (turning points)
              

Diagram Caption: The three curves—position (blue), velocity (red), acceleration (green)—maintain fixed phase offsets throughout the motion. Position and acceleration are anti-phase: when the mass is at +A, acceleration is −Aω² (pointing back toward equilibrium). Velocity is 90° ahead: it peaks when the mass crosses equilibrium. The T/4 spacing between extrema is why "quarter-period" appears so often in SHM problems.

Reading Period from System Parameters: Mass-Spring vs Pendulum

Mass-Spring: T = 2π√(m/k)

For a mass m on a spring with constant k, angular frequency is ω = √(k/m). Stiffer springs (larger k) give shorter periods; heavier masses give longer periods. Double the mass and the period increases by √2 ≈ 1.41. Quadruple the spring constant and the period halves.

Example: m = 0.5 kg, k = 200 N/m

ω = √(200/0.5) = √400 = 20 rad/s

T = 2π/20 = 0.314 s

f = 1/T = 3.18 Hz

Simple Pendulum: T = 2π√(L/g)

For a point mass on a massless string of length L, the period depends only on length and gravity—not on mass or amplitude (small-angle limit). A 1-meter pendulum on Earth has T ≈ 2.0 s. On the Moon (g = 1.62 m/s²), the same pendulum has T ≈ 4.9 s.

Example: L = 0.25 m, g = 9.81 m/s²

ω = √(9.81/0.25) = √39.24 = 6.26 rad/s

T = 2π/6.26 = 1.00 s

A 25-cm pendulum on Earth has a 1-second period (classic "seconds pendulum" is 99.4 cm for T = 2 s)

The Isochronism Principle: Why Amplitude Doesn't Change Period

One of SHM's most counterintuitive properties: whether you stretch a spring 1 cm or 10 cm, the period stays exactly the same. This is isochronism—the oscillation frequency depends only on system parameters (k/m or g/L), not on how far you displace the mass. The mathematics is clear: T = 2π√(m/k) contains no amplitude term.

Physically, larger amplitude means the mass travels farther, but it also moves faster (v_max = Aω). The increased distance and increased speed exactly cancel, preserving the period. This is why pendulum clocks keep accurate time regardless of how much the pendulum swings—as long as angles stay small. For large-amplitude pendulums, the restoring force deviates from linearity, and the period increases slightly (breaking isochronism).

Common Mistake: Students often assume that larger amplitude means longer period ("it has farther to go"). This intuition fails for SHM because velocity scales with amplitude. The period formula contains mass and spring constant—not amplitude. Check your answer: if your period depends on A, you've made an error.

Worked Visual: Pendulum Clock Escapement Timing

Scenario: A clockmaker needs a pendulum that swings with exactly T = 1.000 s so the escapement advances the gear train once per swing. How long should the pendulum be?

Step 1: Start from T = 2π√(L/g)

Solve for L: L = g(T/2π)²

Step 2: Substitute T = 1 s, g = 9.81 m/s²

L = 9.81 × (1/2π)² = 9.81 × 0.0253 = 0.248 m

Step 3: Convert to practical units

L = 24.8 cm ≈ 9.8 inches

Step 4: Verify with back-calculation

T = 2π√(0.248/9.81) = 2π × 0.159 = 1.000 s ✓

Result: The pendulum needs L = 24.8 cm. The classic "seconds pendulum" (T = 2 s, meaning 1 s per half-swing) requires L = 99.4 cm—nearly a meter. This is why grandfather clocks are tall.

Clockmaker's Insight: Temperature changes length. Brass expands ~19 ppm/°C, so a 1-meter brass pendulum rod grows 0.019 mm per degree. Over 20°C seasonal variation, that's 0.38 mm, enough to lose ~2 seconds per day. Quality pendulum clocks use Invar (low thermal expansion) or compensating mechanisms.

Phase Angle and Initial Conditions: Matching the Starting Point

The phase angle φ in x(t) = A cos(ωt + φ) determines where in the cycle the motion starts at t = 0. Different φ values correspond to different initial positions and velocities:

Phase φx(0)v(0)Physical Interpretation
0+A0Released from max positive displacement
π/2 (90°)0−AωAt equilibrium, moving negative (x = A sin(ωt))
π (180°)−A0Released from max negative displacement
3π/2 (270°)0+AωAt equilibrium, moving positive
−π/2 (−90°)0+AωSame as 3π/2 (x = A sin(ωt))

Converting Initial Conditions to Amplitude and Phase: Given x₀ and v₀, calculate A = √(x₀² + (v₀/ω)²) and φ = arctan(−v₀/(ωx₀)). For example, if x₀ = 0.1 m and v₀ = −0.5 m/s with ω = 10 rad/s: A = √(0.01 + 0.0025) = 0.112 m, φ = arctan(0.5) = 0.464 rad ≈ 27°.

When Ideal SHM Breaks Down: Damping, Large Angles, Nonlinearity

Damping (Air Resistance, Friction)

Real oscillators lose energy. A pendulum in air experiences drag proportional to velocity; the amplitude decays exponentially: A(t) = A₀e^(−γt). The frequency shifts slightly lower. For lightly damped systems (γ ≪ ω), ideal SHM is a good approximation for a few cycles, but amplitude decay is visible over tens of periods. The calculator assumes no damping.

Large Pendulum Angles (θ > 15°)

The small-angle approximation sin(θ) ≈ θ breaks down above ~15°. At 30°, the true period is ~2% longer than T = 2π√(L/g). At 90°, the period is ~18% longer. The exact period requires elliptic integrals: T = 4√(L/g) × K(sin²(θ₀/2)), where K is the complete elliptic integral of the first kind. For high-accuracy timing, keep angles small.

Nonlinear Springs (Beyond Hooke's Law)

Real springs deviate from F = −kx at large extensions. Some springs "stiffen" (hardening spring: period decreases with amplitude), others "soften" (period increases with amplitude). Rubber bands are notoriously nonlinear. If your measured period depends on amplitude, you're outside the linear regime.

Distributed Mass (Spring Mass, Physical Pendulums)

If the spring itself has significant mass m_s, the effective oscillating mass is m_eff ≈ m + m_s/3. For physical pendulums (rigid bodies, not point masses), use T = 2π√(I/(mgd)), where I is moment of inertia about the pivot and d is the distance from pivot to center of mass.

Oscillation References: Authoritative Sources

  • Halliday, Resnick & Walker, Fundamentals of Physics (11th ed., 2018), Chapter 15: Oscillations. Derivation of T = 2π√(m/k) and T = 2π√(L/g) from Newton's second law.
  • Serway & Jewett, Physics for Scientists and Engineers (10th ed., 2018), Chapter 15. Detailed energy analysis showing E = ½kA² and KE ↔ PE exchange.
  • NIST Reference on Constants — Standard gravity g = 9.80665 m/s² (exact by definition). Local g varies ±0.5% with latitude and altitude.
  • HyperPhysics (Georgia State University)hyperphysics.phy-astr.gsu.edu/hbase/shm: Interactive diagrams for mass-spring and pendulum SHM.
  • Marion & Thornton, Classical Dynamics (5th ed., 2003), Chapter 3: Advanced treatment including damped and driven oscillators.

Educational Tool—Not for Engineering Design

  • This calculator models ideal, undamped simple harmonic motion. Real oscillators experience energy loss, nonlinearity, and environmental effects not captured here.
  • Pendulum formulas assume small angles (θ < 15°). For larger amplitudes, the period increases and deviates from T = 2π√(L/g).
  • Spring calculations assume Hooke's law holds exactly. Real springs have nonlinear regions, fatigue, and temperature dependence.
  • For vibration analysis in structures, machinery, or safety-critical systems, consult mechanical engineers using professional simulation tools.

Fixing Common SHM Calculation Mistakes

Real questions from students stuck on spring mass corrections, amplitude independence, negative velocity signs, and period measurement technique.

I calculated T = 1.26 s for my mass-spring system but measured 1.42 s in the lab—where's the 12% error coming from?

Most likely the spring's own mass. The formula T = 2π√(m/k) assumes a massless spring, but real springs have mass that participates in the oscillation. Add roughly one-third of the spring mass to your oscillating mass: m_eff ≈ m + m_spring/3. If your spring weighs 150 g and your mass is 500 g, use m_eff = 500 + 50 = 550 g. That extra 10% mass increases the period by about 5%. Combined with friction and measurement error, you get 12% discrepancy.

My professor keeps saying 'period doesn't depend on amplitude'—but when I swing a pendulum really wide, it clearly takes longer. Who's wrong?

You're both right in different regimes. The formula T = 2π√(L/g) is a small-angle approximation valid for θ < 15°. At 30° amplitude, the true period is about 2% longer; at 90° it's 18% longer. The restoring force F = −mg sin(θ) isn't linear in θ for large angles, breaking the SHM assumption. For homework problems, use the small-angle formula. For precision timing (like grandfather clocks), keep swings small.

I got a negative velocity at t = 0.25 s but the mass is above equilibrium—is that wrong or does negative mean something specific?

Negative velocity means the mass is moving in the negative x-direction, toward equilibrium from above. If x(t) = A cos(ωt) and you're at t = T/4, then v(t) = −Aω sin(ωt) = −Aω sin(π/2) = −Aω. The minus sign tells you direction: the mass just passed through the positive peak and is heading down. Velocity is zero at the extremes (±A) and maximum in magnitude when crossing equilibrium. Your negative result is correct.

The problem says 'a spring with k = 200 N/m compressed 5 cm'—do I use negative 5 cm in the formula?

For period and frequency calculations, sign doesn't matter—amplitude A = 0.05 m regardless of whether the spring starts compressed or stretched. For position at time t, sign encodes where you start: x(0) = +A means released from stretched position, x(0) = −A means released from compressed. If the problem says 'compressed and released,' use x(t) = −A cos(ωt) or equivalently x(t) = A cos(ωt + π). The period formula T = 2π√(m/k) uses only magnitudes.

Why does my calculator show f = 1.59 Hz when I entered ω = 10? I thought angular frequency was the same as frequency.

They're related but different. Angular frequency ω = 10 rad/s means the phase advances 10 radians per second. One full cycle is 2π radians, so frequency f = ω/(2π) = 10/6.28 = 1.59 Hz. Conversely, ω = 2πf. The confusion comes from textbooks using 'frequency' loosely. When you see 'frequency' in physics problems, check units: Hz means f, rad/s means ω. The period T = 2π/ω = 1/f works either way.

I'm trying to find when the mass passes through equilibrium—how do I solve cos(ωt) = 0 for the first three times?

Cosine equals zero at π/2, 3π/2, 5π/2, ... (odd multiples of π/2). So ωt = π/2 gives t₁ = π/(2ω). For ω = 5 rad/s, t₁ = π/10 = 0.314 s, t₂ = 3π/10 = 0.942 s, t₃ = 5π/10 = 1.571 s. Each crossing happens at half-period intervals after the first: T/4, 3T/4, 5T/4, ... If starting from equilibrium (sine function), zeros occur at 0, π/ω, 2π/ω, ... which is 0, T/2, T, ...

The answer key says v_max = 2.5 m/s but I got 2.5 using v_max = Aω and also v_max = √(kA²/m). Are both formulas correct?

Yes, they're identical. Starting from v_max = Aω and using ω = √(k/m): v_max = A√(k/m). Square both sides: v²_max = A²(k/m). Multiply by m: mv²_max = kA². This is energy conservation: ½mv²_max = ½kA², so all kinetic energy at equilibrium equals all potential energy at the extremes. Use whichever form has the variables you know—they're mathematically equivalent.

My pendulum's measured period changes depending on where I start the timer—at the bottom vs at the edge. Which is correct?

Start timing when the pendulum passes through equilibrium (bottom), not at the turning points. At equilibrium, the bob moves fastest and crosses the reference point quickly, giving precise timing. At the edges, it moves slowly and reverses direction, making it hard to pinpoint the exact turnaround. Time 10 or 20 complete swings and divide—this averages out reaction time error. Professional measurements use photogate sensors triggered at equilibrium.

I need to design a spring so a 2 kg mass oscillates at exactly 1 Hz—how do I work backwards to find k?

Rearrange the period formula. f = 1 Hz means T = 1 s. T = 2π√(m/k), so √(m/k) = T/(2π) = 1/6.28 = 0.159. Square it: m/k = 0.0253. Rearrange: k = m/0.0253 = 2/0.0253 = 79.0 N/m. Verify: T = 2π√(2/79) = 2π × 0.159 = 1.00 s ✓. Alternatively, use k = m(2πf)² = 2 × (2π × 1)² = 2 × 39.5 = 79.0 N/m directly.

My physics textbook uses A sin(ωt) but my engineering textbook uses A cos(ωt)—which is the 'official' SHM equation?

Both are correct—they differ only by a phase shift of π/2. x = A cos(ωt) = A sin(ωt + π/2). Physics textbooks often use cosine because it naturally describes 'released from maximum displacement' (x₀ = A, v₀ = 0). Engineering texts sometimes prefer sine for signal processing conventions. The key is consistency: pick one and stick with it. If your initial condition is x₀ = 0, v₀ = +Aω, use sine. If x₀ = A, v₀ = 0, use cosine.

SHM Solver - Spring & Pendulum Period