Mechanics · 21 April 2026↻ Updated 17 Aug 2026
Simple Harmonic Motion Simulator — Spring and Oscillation
Simple harmonic motion (SHM) is the most fundamental type of oscillation in physics. It occurs whenever a system is displaced from equilibrium and experiences a restoring force proportional to the displacement. Springs, pendulums (for small angles), sound waves, and even atoms vibrating in a crystal lattice all exhibit SHM.
Understanding SHM is essential for waves, optics, quantum mechanics, and electrical circuits — because oscillation is everywhere. The simulator below starts with a 1 kg mass on a 10 N/m spring pulled 1 m from equilibrium, which oscillates with a period of about 1.99 s. Switch between the time series and the phase portrait to see the same motion two different ways.
Period
1.99 s
What Makes Motion "Simple Harmonic"?
Plenty of things in the world go back and forth. Only some of them are simple harmonic, and the distinction is precise.
The Restoring Force Is the Whole Story
SHM requires one condition, and everything else follows from it: the force pulling the system back toward equilibrium must be proportional to how far it has been displaced, and directed opposite to that displacement.
The minus sign is the important part. Pull the mass right and the spring pulls left; push it left and the spring pushes right. The force always opposes the displacement, so the system can never settle anywhere except equilibrium — and because the force grows in exact proportion to displacement, the motion that results is a pure sine wave rather than some lopsided wobble.
A mass bouncing on a trampoline is oscillating, but the restoring force is not proportional to displacement, so the motion is not simple harmonic. A ball rolling in a parabolic bowl is. The test is always the same: is the restoring force linear in the displacement?
Why Amplitude Doesn't Change the Period
This is the property that made SHM the basis of timekeeping for three centuries, and it is genuinely counter-intuitive: pull the mass twice as far and it still takes the same time to complete an oscillation.
Drag the amplitude slider in the simulator and watch the period refuse to budge.
The reason is a cancellation. Doubling the amplitude doubles the distance the mass must travel — but it also doubles the restoring force at every point, which doubles the acceleration, which makes the mass move proportionally faster. The extra distance is covered at proportionally higher speed, and the two effects cancel exactly. Only a force that is linear in displacement produces this cancellation, which is why the property is special to SHM rather than to oscillation generally.
This is called isochronism, and Galileo is said to have noticed it watching a swinging lamp in Pisa cathedral.
The Equation of Motion
For a mass on a spring with spring constant , applying Newton's second law gives:
where the natural angular frequency is:
Reading the Equation Before Solving It
says something worth pausing on: the acceleration is proportional to the position, with a minus sign. We need a function whose second derivative is itself, negated and scaled. Sine and cosine are exactly those functions — which is why SHM produces sinusoids, not as an approximation but as an exact consequence.
The solution is:
where is the amplitude and is the initial phase — the constant that says where in the cycle the motion started.
Notice what is absent from : the amplitude. The frequency depends only on the stiffness of the spring and the mass attached to it. That is isochronism falling straight out of the algebra.
Key Quantities
| Quantity | Formula | Unit |
|---|---|---|
| Angular frequency | rad/s | |
| Period | s | |
| Frequency | Hz | |
| Max velocity | m/s | |
| Max acceleration | m/s² |
Velocity and acceleration are the derivatives of position, so each is a quarter-cycle ahead of the last. Velocity peaks as the mass flies through equilibrium, where displacement is zero. Acceleration peaks at the turning points, where the mass is momentarily stationary and the spring is most stretched. The mass is fastest where the force on it is zero, and motionless where the force is greatest — a good check on whether the picture has clicked.
Where Does the Energy Go?
An undamped oscillator conserves total energy, trading it back and forth between two forms:
At the turning points, all of it is elastic potential energy. At equilibrium, all of it is kinetic. Everywhere in between it is a mixture, and the total never changes.
Because energy depends on , doubling the amplitude quadruples the stored energy — even though, as we saw, it does not change the period at all.
With the simulator's defaults (k = 10 N/m, A = 1 m) the total energy is J, held constant for as long as the damping ratio stays at zero.
What Does the Phase Portrait Show?
The phase portrait plots velocity against displacement rather than either one against time. It throws away the clock and shows the state of the oscillator instead.
For undamped SHM this traces a closed ellipse. Closed is the key word: the system returns to exactly the same combination of position and velocity every cycle, forever. Nothing is lost.
Introduce damping and the ellipse becomes an inward spiral, each loop a little smaller as energy drains away, winding down toward the origin — the state of zero displacement and zero velocity.
Phase portraits become indispensable for systems too complicated to solve on paper; the Lorenz attractor is what one looks like when the motion is chaotic rather than periodic.
How Does Damping Change the Motion?
Real oscillators lose energy to friction and air resistance. Adding a damping term gives:
The damping ratio characterises the decay:
- — undamped. Oscillates forever at . An idealisation, but a useful one.
- — underdamped. Still oscillates, but the amplitude decays exponentially inside an envelope. A plucked guitar string, a child's swing left alone.
- — critically damped. Returns to equilibrium in the shortest possible time without overshooting. This is the target for car suspension and door closers.
- — overdamped. Returns without oscillating, but sluggishly — the extra resistance slows the approach. A door closer set too tight.
The critically damped case is the one engineers usually want, and it is a genuinely delicate target: slightly under and the system rattles, slightly over and it crawls. Push the ζ slider slowly through 1 to watch the oscillation disappear.
How Is a Pendulum Related to SHM?
A simple pendulum is not truly simple harmonic — but for small swings it is close enough that the difference rarely matters.
The restoring force on a pendulum bob is . That is not proportional to θ, so strictly the motion is not SHM. But for small angles, (in radians), and the force becomes effectively linear. Under that approximation the pendulum behaves like a spring with , giving:
The mass cancels out entirely — a heavy bob and a light one on the same string swing at the same rate.
The approximation is better than it has any right to be. At a 15° swing the true period exceeds the formula by only 0.43%; even at 30° the error is just 1.7%. Beyond that the real period grows noticeably longer than predicted, and a pendulum clock swinging too widely runs slow.
Worked Examples
Worked Example
Example 1 — Period of a spring-mass system
A mass of 0.5 kg is attached to a spring with constant k = 20 N/m. What is the period of oscillation?
The mass completes one full oscillation roughly every second.
Worked Example
Example 2 — Maximum velocity and acceleration
For the same system (k = 20 N/m, m = 0.5 kg) with amplitude A = 0.1 m, find the maximum speed and maximum acceleration.
Both maxima occur at different points: at the equilibrium position (), at the turning points ().
Worked Example
Example 3 — Energy in the oscillator
The same system (k = 20 N/m, m = 0.5 kg, A = 0.1 m). What is the total energy, and how fast is the mass moving when it is halfway to the turning point (x = 0.05 m)?
Total energy:
At x = 0.05 m, the potential energy is
so the kinetic energy is J, and
At half the amplitude the mass still has 75% of its energy as kinetic and is moving at 87% of top speed — the energy is concentrated near the turning points far more sharply than intuition suggests.
Worked Example
Example 4 — Length of a seconds pendulum
A "seconds pendulum" ticks once per second, meaning a full back-and-forth period of 2 s. How long must it be, taking g = 9.81 m/s²?
Rearranging :
Just under a metre — which is why grandfather clocks are the height they are. A 1.000 m pendulum gives a period of 2.006 s instead of 2.000 s, and that 0.3% error accumulates: such a clock would lose about 4.4 minutes per day.
Frequently Asked Questions
Related Concepts
Coupled Oscillators →
Two SHM systems connected by a spring — discover normal modes and energy transfer.
Wave Speed, Frequency, Wavelength →
Waves are propagating oscillations — SHM is the building block of every wave.
Newton's Laws of Motion →
SHM is Newton's second law with a restoring force — F = -kx = ma.
Explore more simulations
Every concept on PhysicStuff has an interactive simulation. No login, no setup required.