---
title: "Mass–Spring Oscillator Interactive Lab | Sandbox Physics"
description: "What sets the period of a mass bouncing on a spring? Mass and spring stiffness set the period: four times the mass doubles it. Amplitude does not change it. Hanging the spring vertically only moves the equilibrium point down; gravity leaves the stiffness, and with it the period, unchanged."
canonical_url: "https://sandboxphysics.com/labs/mass-spring/"
language: "en"
page_type: "lab"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/labs/mass-spring/"
last_modified: "2026-10-22"
---

M061 · Timing a spring

# Mass–Spring Oscillator

**What sets the period of a mass bouncing on a spring?** Mass and spring stiffness set the period: four times the mass doubles it. Amplitude does not change it. Hanging the spring vertically only moves the equilibrium point down; gravity leaves the stiffness, and with it the period, unchanged.

Set a frictionless cart or a hanging mass oscillating on the same calibrated spring, and view it from any angle in three dimensions. Drag the mass or give it a kick, time its crossings through equilibrium in the positive direction, and compare the measured period with the exact solution. A phase-space plot with equal scales shows what amplitude and gravity really change.

> Interactive simulation: open this page in a web browser to change the parameters and run the model.

The model uses a point mass on a massless spring that obeys Hooke's law, with no friction. Displacement is measured from equilibrium, positive to the right on the track and downward when hanging. For the hanging spring, the energy counts spring and gravitational potential energy measured from equilibrium, up to a constant; the energy view uses the same sum. The scene is rescaled for each setup, and the drawn rest length of the spring is only a reference. The coil shape, the size of the mass, the rails and the supports are schematic; deformation of the spring wire, contact limits and collisions are left out. On the horizontal cart, gravity and the push of the track cancel. Force arrows scale automatically and the velocity arrow has its own scale, but both come from the same numerical state. The RK4 integration is checked against the exact solution and against a run with half the step; that half-step change is a diagnostic, not a certified error bound.

Physics tutorial

## A spring as a clock

**Background** A linear spring pulls back with a force proportional to its stretch. Its motion repeats with a steady period, so it can serve as a clock: with a known mass it measures the stiffness, and with a known spring it measures the mass. Comparing the horizontal cart with the hanging mass shows directly what gravity changes.

**Why it matters** Section 15.1 of OpenStax University Physics Volume 1 gives the ideal simple harmonic solution. This Lab shows that exact solution next to a crossing timer, a phase-space plot and a numerical trajectory solved on its own.

Start with the essentials

- **Focus question**: Does a larger amplitude, a heavier mass or a stronger gravity change the period?
- **One-sentence intuition**: Measure the period from the motion itself before comparing it with theory. Gravity shifts where a hanging spring rests, but not its stiffness around that point.

### Core mathematical model

#### Where the spring rests, and the equation of motion

$$
\ell_{\mathrm{eq}}-\ell_0=\frac{mg}{k},\qquad m\ddot x+kx=0
$$

Gravity shifts the equilibrium of a vertical spring, but the equation for displacement from equilibrium stays the same. Displacement is positive downward when hanging and to the right on the track.

#### Period and the solution for any release

$$
\omega_0=\sqrt{\frac{k}{m}},\quad T_0=\frac{2\pi}{\omega_0},\quad x(t)=x_0\cos(\omega_0t)+\frac{v_0}{\omega_0}\sin(\omega_0t)
$$

Mass and stiffness set the period. In the ideal linear model, amplitude and release phase have no effect on it.

#### Energy and the phase-space circle

$$
E=\frac12mv^2+\frac12kx^2=\frac12kA^2,\qquad x^2+\left(\frac v{\omega_0}\right)^2=A^2
$$

Dividing velocity by the natural angular frequency gives both phase-space axes units of length. With equal scales the path is a circle; plotting raw position against velocity generally gives an ellipse.

#### Measuring the period from zero crossings

$$
\widehat T=\frac{t_{\uparrow,N}-t_{\uparrow,1}}{N-1},\qquad N\ge2
$$

The clock times each moment the numerical trajectory crosses zero in the positive direction, locating it by linear interpolation; it never reads the known period. A mass at rest has no crossings, so it has no measured period.

#### Why gravity drops out for a hanging spring

$$
\Delta U_s=\tfrac12kx^2+mgx,\quad\Delta U_g=-mgx,\quad F_s+mg=-kx
$$

Measure the spring and gravitational energy changes from equilibrium, and their linear terms cancel. The spring force by itself is not the net force.

### Common difficulties

#### Amplitude does not set the period

**Typical misconception** If I pull it farther, it must swing more slowly.

**Better mental model** Compare two amplitudes with the same mass and stiffness. In this linear model the periods are equal.

#### Equilibrium is not the natural length

**Typical misconception** A hanging spring oscillates around its unstretched length.

**Better mental model** The spring stretches until it holds up the weight. Measure displacement from that lower equilibrium point.

#### No motion, no measured period

**Typical misconception** The clock should show the theoretical period even when nothing moves.

**Better mental model** Set both the release displacement and the velocity to zero. The theoretical period is still defined, but the timer has no crossings to time and reports that the mass is stationary.

### Run the experiment

1. 01

   #### Time the horizontal cart

   Choose the horizontal preset and measure eight periods.

   **What to observe:** The measured period agrees with the exact period, and the total energy stays constant.

2. 02

   #### Change the mass and the release

   Double the mass, then compare a larger release with a kick at equilibrium.

   **What to observe:** The mass changes the period. Amplitude and release phase change the size of the circle or where it starts.

3. 03

   #### Move the equilibrium point

   Choose vertical suspension and vary gravity. Use energy review and fine steps to compare the forces during the same motion.

   **What to observe:** The static stretch changes, but the period and the energy relation measured from equilibrium stay the same.

4. 04

   #### Check the numerical solution

   Reduce the maximum step, then look at the error against the exact position and at how much the endpoint moves when the step is halved.

   **What to observe:** The step in use may already be capped for stability. The refinement test halves that actual step.

Physical conclusion

The phase-space circle, the measured period and the energy balance all describe the same linear motion. When all three agree, that is stronger evidence than an animation that merely looks right.

Starter path · Step 5 of 6

## From a falling ball to an orbit

[Next step → **How Orbits Take Shape** Raise the launch speed from circular-orbit speed toward escape speed, and compare the recorded path with the predicted conic section. Transfer · 10 min](https://sandboxphysics.com/labs/orbit/)

1. [1 Free Fall & Measuring Gravity](https://sandboxphysics.com/labs/free-fall/)
2. [2 Projectile Flight Designer](https://sandboxphysics.com/labs/projectile-flight/)
3. [3 Inclined Plane & Friction](https://sandboxphysics.com/labs/inclined-plane/)
4. [4 One-Dimensional Collision Bench](https://sandboxphysics.com/labs/collision-bench/)
5. [5 Mass–Spring Oscillator](https://sandboxphysics.com/labs/mass-spring/)
6. [6 How Orbits Take Shape](https://sandboxphysics.com/labs/orbit/)

[View the full path →](https://sandboxphysics.com/topics/mechanics/#starter-path)
