Questing · 2026-07-04 · Physics · Chaos Theory · Zero Dependencies
BOUNCE
Drag a slider from circle to stadium. Watch a single trajectory go from tracing an orderly annular band to filling every corner of the space. This is Bunimovich's theorem — and it explains why statistical mechanics works.
Open Bounce →What Is Bounce?
Bounce is a real-time visualizer of the transition between two fundamentally different kinds of dynamical systems. A billiard ball bouncing inside a shape follows simple rules — straight-line motion, angle-of-incidence equals angle-of-reflection — but the long-term behavior depends entirely on the shape of the boundary.
Set the slider to zero: the boundary is a circle. Every trajectory traces an ordered annular band — the same ring, forever. The ball is predictable, constrained, “integrable.” Now drag the slider: the circle stretches into a Bunimovich stadium (a rectangle capped by semicircles). Watch the trajectory slowly fill the entire interior. Given enough time, the ball visits every point equally — it is ergodic.
The Bunimovich Stadium
In 1974, Soviet mathematician Yakov Sinai proved that the billiard in certain shapes is ergodic. In 1979, Leonid Bunimovich showed that a remarkably simple shape — a rectangle with semicircular ends — is fully chaotic and ergodic. This was surprising: the semicircles alone (a circle) are integrable; the rectangle alone is integrable; but the combination destroys all conserved quantities.
The stadium shape is parametrized by a single number α:
a = α × R
α = 0 → circle of radius R (integrable)
α > 0 → stadium: two semicircles of radius R
joined by two parallel flat walls of half-length a
When α = 0: angular momentum L = (x·vy − y·vx) is conserved.
When α > 0: the flat walls destroy L as a conserved quantity.Why Circles Are Integrable
The conserved quantity
In a circular billiard, every reflection preserves the angle the velocity makes with the radius at the point of impact. This is because the normal at every boundary point points directly toward the center — the geometry has perfect rotational symmetry. The perpendicular distance from the center to the ball's current trajectory (the “impact parameter”) is an exactly conserved quantity.
Consequence: if you start the ball at impact parameter b, it stays at impact parameter b forever. The trajectory traces an annulus with inner radius b. The ball never reaches the center and never hugs the wall more closely than its initial approach angle allows. This is why the density map for a circle shows a ring — the outer bright band where the ball spends most time near the boundary, and darkness in the center it can never reach.
L = r × p⊥ = |x·vy − y·vx| (conserved for all α = 0) Impact parameter: b = L / |v| Inner radius of annulus: rᵢₙ = b (ball never crosses inward of this)
Why Stadiums Are Ergodic
Defocusing chaos
When the ball hits a flat wall, the reflection is specular (angle in = angle out), but the outgoing ray has a different impact parameter relative to the center than the incoming ray did. The flat wall neither focuses nor defocuses nearby trajectories — it preserves their separation. But the semicircular caps are defocusing: two nearby parallel rays hitting a convex circular boundary diverge after reflection.
The interplay between the neutral flat walls and the defocusing circular caps creates hyperbolicity in the dynamics — small angle differences amplify exponentially over many reflections. This is Bunimovich's key insight: convex caps are not stable (focusing) — they destabilize trajectories and generate chaos. The Lyapunov exponent of the stadium billiard is positive for almost all trajectories.
Positive Lyapunov exponent λ > 0: two nearby trajectories with initial angle separation δθ₀ diverge as ~ δθ₀ · eλt Ergodic theorem (Birkhoff, 1931): time average = space average (for ergodic systems) lim(T→∞) (1/T) ∫₀ᵀ f(x(t)) dt = ∫_phase_space f dμ
Why This Matters: Statistical Mechanics
The reason physicists care deeply about ergodicity is that it is the foundation of statistical mechanics. When Boltzmann and Maxwell derived the statistical behavior of gases, they assumed (without proof) that a gas molecule would, over a long enough time, visit all positions and velocities consistent with its total energy. This assumption — the Ergodic Hypothesis — justifies replacing time averages with ensemble averages.
The stadium billiard is one of the few concrete, analytically provable examples where ergodicity can be rigorously demonstrated. It shows that the hypothesis is not a vague assumption but a real, measurable property of a dynamical system — one you can watch happen in a browser, trajectory by trajectory.
The coverage percentage in Bounce's HUD is literally measuring ergodicity: for a circle (α = 0) it plateaus well below 100% (the unreachable inner disk). For a stadium (α > 0), it climbs steadily toward 100% as the trajectory explores every available corner.
Technical Implementation
Bounce uses exact analytic reflection at every boundary — no approximations, no step-and-check:
- Time-to-wall: for each trajectory segment, solves analytically for the earliest boundary intersection. Flat walls → linear equation. Semicircular caps → quadratic (circle-line intersection). The minimum positive root is the next collision.
- Reflection law: outward normal computed exactly. Flat walls: (0, ±1). Semicircle caps: unit vector from cap center to impact point. Velocity reflected: v_new = v − 2(v·n̂)n̂.
- Density map: a Float32Array[CW×CH] accumulates path density. Each segment is rasterized by stepping along it at sub-pixel resolution (1.5 samples per pixel). On reset, refilled to zero.
- Color mapping: log₁₊(d) / log₁₊(max_d) maps density to a 3-stop phosphor palette: background (#010d1a) → deep teal → phosphor green → white. Log scale prevents early high-traffic points from washing out low-density regions.
- Coverage: total pixels with nonzero density divided by estimated stadium interior area (πR² + 4aR). Serves as a live ergodicity meter.
- 12 segments per animation frame (each segment is a full wall-to-wall straight line). The ball travels quickly enough to fill a circle in ~5 seconds and a stadium in ~30 seconds.
What to Watch
- Start at α = 0. The trajectory draws a ring. The center stays dark — the ball cannot reach it. Coverage plateaus at ~60–80% depending on the initial angle.
- Drag the slider to α = 0.1 (barely not-a-circle). The annular band immediately starts breaking down — the trajectory begins wandering slightly outside its original ring.
- At α = 0.5, the trajectory is visibly chaotic — it fills the stadium haphazardly with no visible structure. Coverage climbs steadily.
- At α = 1.0 (full stadium), coverage approaches 100% over ~30 seconds. Watch the corners fill last — they are the hardest to reach as the trajectory needs a specific angle to bounce into them.
- Hit New Ball to add a second trajectory without clearing the existing density — watch two independent paths weave through the same space.
- Hit Reset to clear the density and start fresh. The regime label switches between INTEGRABLE (α = 0) and ERGODIC (α > 0).
Why It's Different
Bounce is the first Questing toy about ergodicity — the foundational assumption of statistical mechanics. Unlike Sync (synchronized oscillators) and Chirp (gravitational waves), the interesting thing here is not a phase transition or a wave pattern — it is the slow, inexorable filling of space by a deterministic trajectory that has nowhere left to avoid. The circle and the stadium look almost identical, separated by a single slider tick, but their long-run behavior is qualitatively different. That gap — between order and ergodic chaos — is Bunimovich's theorem, proved in 1974, visible in thirty seconds.