---
title: "Duffing Oscillator Laboratory Interactive Lab | Sandbox Physics"
description: "Why can the same forcing frequency produce different responses? A nonlinear spring can support more than one stable response to the same drive. Which one you get depends on how the motion started, and in a frequency sweep on whether you came from below or from above. Sweep up and then down, and the response jumps at different places, leaving a band where either response can appear."
canonical_url: "https://sandboxphysics.com/labs/duffing-oscillator/"
language: "en"
page_type: "lab"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/labs/duffing-oscillator/"
last_modified: "2026-10-22"
---

M069 · Vibration design

# Duffing Oscillator Laboratory

**Why can the same forcing frequency produce different responses?** A nonlinear spring can support more than one stable response to the same drive. Which one you get depends on how the motion started, and in a frequency sweep on whether you came from below or from above. Sweep up and then down, and the response jumps at different places, leaving a band where either response can appear.

In a three-dimensional scene, a cart rides on a spring with a cubic term, a dashpot and a force actuator, set up as a hardening spring, a locally softening spring or a double well. Drag the cart to choose the basin it starts in, record phase portraits and samples at a fixed drive phase, and compare the measured fundamental with a single-harmonic approximation. Then sweep the frequency up and down, with each run starting from where the last one ended.

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

The linear stiffness has a fixed size of sixteen newtons per metre, and you choose its sign; the reference frequency uses its size. The cubic term is the only nonlinearity. With positive linear stiffness and a negative cubic term, the spring makes a local well with no outer wall. Recording stops when the cart reaches the saddle or the two-metre edge of the display, rather than clipping the position. The eight-cycle measurement removes the mean first; its residual includes higher harmonics and transients and is not an uncertainty estimate. The retained fixed-phase samples alone do not prove chaos. The sweep runs 48 cycles at each frequency, discards the first 40, and starts the next run, a whole number of cycles long, from the final state of the last. A difference between sweep directions over these finite runs does not identify every attractor or prove an adiabatic bifurcation. Single-harmonic solutions are approximate, and their stability is not determined. Scene lengths are rescaled for each experiment; the coil shape, mass size and actuator stroke are schematic. The spring wire, the actuator’s own response and collisions are not simulated. A fixed Earth gravity is cancelled vertically by an equal reaction from the track. Green outlines mark the stable equilibria without forcing inside the model’s range. Force and velocity arrows use separate scales. Energy review uses the recorded motion, with work and heat integrated separately.

Physics tutorial

## A spring that remembers the sweep direction

**Background** A cubic stiffness term makes the frequency depend on the amplitude. With damping and forcing, the same settings can settle into different bounded responses, depending on the history.

**Why it matters** Brown University’s Duffing tutorial and York University’s computational physics notes cover cubic restoring forces, phase portraits and forcing. This Lab adds an explicit harmonic projection of the measured motion, escape from a local well, and a finite frequency sweep in which each run starts from the end state of the previous one.

Start with the essentials

- **Focus question**: When sweeping up and sweeping down give different results, is that a real stable branch or an effect of the finite recording?
- **One-sentence intuition**: Measure the fundamental, the mean and the nonharmonic residual separately, and compare sweeps that carry the state forward at the same drive phase.

### Core mathematical model

#### Spring and damping forces, and the wells without forcing

$$
F_s=-kx-\alpha x^3,\quad F_d=-c\dot x,\quad x_*=\pm\sqrt{-k/\alpha}\quad(k<0,\ \alpha>0)
$$

Green outlines mark the potential minima without forcing that lie inside the recording range. The drive can carry the mass away from them.

#### Equation of motion with a cubic spring

$$
m\ddot x+c\dot x+kx+\alpha x^3=F_0\cos\omega t
$$

The sign of the linear stiffness and the cubic stiffness together decide whether the spring hardens, softens locally or forms a double well.

#### Potential and energy

$$
U(x)=\tfrac12kx^2+\tfrac14\alpha x^4,\quad E=\tfrac12m\dot x^2+U(x)
$$

The model uses the full potential, not its quadratic approximation near a minimum.

#### Single-harmonic amplitude relation

$$
A^2\left[\left(k-m\omega^2+\tfrac34\alpha A^2\right)^2+(c\omega)^2\right]=F_0^2
$$

This approximation assumes motion centered on zero and ignores the mean and higher harmonics. It does not say which solutions are stable.

#### Saddle of the locally softening spring

$$
x_b=\sqrt{-k/\alpha}\quad(k>0,\ \alpha<0)
$$

Outside this local well the potential falls without limit, so recording stops at the saddle.

#### Work and heat integrated separately

$$
\dot W=F_0\cos(\omega t)\dot x,\quad \dot Q=c\dot x^2,\quad E-E_0=W-Q
$$

The drive work, which can be positive or negative, and the heat, which is always positive, are integrated along with the motion.

### Common difficulties

#### An approximate solution is not necessarily an attractor

**Typical misconception** Every solution of the harmonic-balance equation is a stable response you will measure.

**Better mental model** The approximation drops higher harmonics. A simulated release lands in one particular basin and still carries transients.

#### The memory effect depends on the sweep settings

**Typical misconception** A gap between sweep directions proves an adiabatic bifurcation.

**Better mental model** Each point uses only 48 cycles, so the frequency spacing and the settling time can change the result.

#### Irregular points need stronger evidence

**Typical misconception** A scattered Poincaré record proves chaos.

**Better mental model** A finite record that may still contain transients cannot, by sampling alone, establish a positive long-term exponent.

### Run the experiment

1. 01

   #### Check the linear limit

   Look at the 3D force vectors, acquire the full record for Linear benchmark and compare the harmonic amplitude. Switch to the energy view to follow the actuator’s work and the heat.

   **What to observe:** With the cubic term at zero, the response settles onto the linear result, which is known independently.

2. 02

   #### Measure the effect of sweep direction

   Choose Hardening spring and run the full sweep up and down.

   **What to observe:** Each run starts from the end state of the previous one, at the same drive phase, so the history carries over.

3. 03

   #### Compare an open well with a closed one

   Compare Local softening with Double-well release.

   **What to observe:** The softening spring has an edge the cart can escape over, while the quartic double well keeps it confined.

4. 04

   #### Record a finite section

   Choose Irregular double-well record, acquire the full record and check the residuals.

   **What to observe:** The mean, the fundamental and the retained fixed-phase points each describe a different part of the signal.

Physical conclusion

A harmonic approximation and a finite record help you interpret the motion, but they cannot identify every attractor or prove chaos.

Motion & dynamics · Starter path

## From a falling ball to an orbit

Start by measuring gravity and splitting motion into components. Then add contact forces and collisions, and follow the same laws all the way to an orbit.

[Start here → **Free Fall & Measuring Gravity** Capture a few drops and fit the camera positions to estimate gravitational acceleration. Then add air damping and watch the fit drift from the truth. Observe · 14 min](https://sandboxphysics.com/labs/free-fall/)

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)
