Skip to content

rotblauer/tv-math

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TV Math

Beautiful mathematics, ten feet tall. A native Apple TV app that turns the living-room screen into an interactive mathematical exhibition — built in Swift and SwiftUI, driven entirely by the Siri Remote.

The opening exhibit is a deep exploration of the logistic map, xₙ₊₁ = r·xₙ(1−xₙ): the one-knob population model whose bifurcation diagram contains period-doubling cascades, universal constants, chaos, and infinitely many worlds within worlds.

Guided tour

The exhibit

Guided tour

Ten curated stops fly the camera through the diagram with cinematic zooms: the whole story, the period-doubling cascade, Feigenbaum universality, the edge of chaos at r∞, band mergers and veils, the period-5 and period-3 windows, the self-similar microcosm, the interior crisis, and solvable chaos at r = 4. Each stop pairs the picture with the mathematics that explains it. Press ⏯ for an ambient auto-tour.

Feigenbaum cascade Bands and veils Self-similarity

Explore

Free-flight over the (r, x) plane: pan with the remote, zoom to ×10⁹ magnification (Double-precision limited), with a live readout of the crosshair's parameter, state, local Lyapunov exponent, and magnification — plus a minimap and toggleable veil curves, the forward images of the critical point x = ½ that trace every band edge and caustic in the chaos.

Explore

Orbit lab

A live cobweb plot with an animated staircase, fixed-point stability markers, a time-series strip, and a field guide of hand-picked parameters — watch intermittency breathe just below the period-3 tangency, or full chaos at r = 4.

Orbit lab

The stage

Every bifurcation view is backed by a progressive CPU density renderer (700 → 14 000+ samples per column, antialiased in both axes, with an attracting-cycle shortcut that makes periodic regions essentially free) tone-mapped through a log/percentile transfer curve into the "Ember" palette. An aligned Lyapunov strip under the plot shows λ(r) — order below zero, chaos above — with cusps at every bifurcation. Landmark annotations appear progressively as you zoom.

Mathematical accuracy

Every constant displayed on screen is re-derived from its defining equation by the test suite (Packages/TVMathKit/Tests/LogisticCoreTests). If a number on screen is wrong, CI fails.

Value r Method
First period doubling 3 (exact) 2-var Newton on cycle + multiplier = −1
Second doubling 1+√6 ≈ 3.449490 exact form, Newton-checked
4→8, 8→16, 16→32 3.5440904, 3.5644073, 3.5687594 Newton
Feigenbaum point r∞ 3.5699456719 literature (OEIS A098587), cross-checked by δ-extrapolation of the cascade
Feigenbaum δ, α 4.6692016, 2.5029079 OEIS A006890/A006891; δ re-measured from the computed cascade
Band merges 4→2, 2→1 3.5925722, 3.6785735 Newton on Misiurewicz conditions (f⁵(½) hits the 2-cycle; f³(½) hits the fixed point)
Period-6 / period-5 windows 3.6265532, 3.7381724 bisection on attracting-cycle onset
Period-3 window 1+√8 ≈ 3.828427 (exact) tangency verified numerically on both sides
Superstable 2- and 3-cycles 1+√5, 3.8318741 Newton on fᵖ(½) = ½
Interior crisis ≈ 3.8568007 bisection on attractor width
λ at r = 4 ln 2 measured against the sin²(2ⁿπθ) conjugacy

Controls

Mode ◀ ▶ ▲ ▼ Select Menu
Tour ◀▶ stops · ▲ toolbar · ▼ orbit lab (linked stops) take the controls (explore) auto-tour toolbar / back
Explore pan zoom in ×2 zoom out ×2 toolbar / back
Orbit lab ◀▶ tune r · ▲ toolbar · ▼ field guide cycle speed pause toolbar / back

Building & running

Requirements: Xcode 16+ with the tvOS SDK (developed against Xcode 26 / tvOS 26.5).

open TVMath.xcodeproj      # select an Apple TV simulator and Run

or from the command line:

xcodebuild -project TVMath.xcodeproj -scheme TVMath -configuration Release \
  -destination 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation) (at 1080p)' build

Use Release when judging visuals — the renderer is ~10× faster than Debug.

Deep links for development and screenshots:

xcrun simctl launch booted dev.jlanej.tvmath -mode tour -poi 6
xcrun simctl launch booted dev.jlanej.tvmath -mode explore -viewport 3.7,3.9,0.1,0.98
xcrun simctl launch booted dev.jlanej.tvmath -mode cobweb -cobweb-r 3.8275

On a real Apple TV: open the project in Xcode, pair the device (Xcode ▸ Window ▸ Devices and Simulators, with the Apple TV in Settings ▸ Remotes and Devices ▸ Remote App and Devices), set your development team on the TVMath target, and Run.

Tests

# Math core: dynamics, renderer, and constant-verification (runs natively on macOS)
swift test -c release --package-path Packages/TVMathKit

# Interaction grammar: simulated Siri Remote driving the real app
xcodebuild test -project TVMath.xcodeproj -scheme TVMath \
  -destination 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation) (at 1080p)'

Architecture

TVMath.xcodeproj          thin shell (app target + UI-test target)
App/                      @main entry, asset catalog (icon is generated — see below)
UITests/                  XCUIRemote walkthrough tests
Packages/TVMathKit/
  Sources/LogisticCore/   pure math: map dynamics, Newton/bisection solvers,
                          verified constants, progressive density renderer,
                          colormaps, critical curves, viewport algebra
  Sources/TVMathUI/       tvOS SwiftUI: home gallery, experience shell,
                          bifurcation stage + overlays, tour content,
                          explore HUD, orbit lab  (all `#if os(tvOS)`)
  Sources/assetforge/     macOS tool that renders the layered tvOS app icon
                          and top-shelf art from the real renderer:
                          swift run -c release --package-path Packages/TVMathKit assetforge .
  Tests/LogisticCoreTests/

Almost everything lives in the Swift package, so the hand-written project.pbxproj never needs to change as the app grows. The rendering pipeline is progressive and cancellable: the camera flies by re-projecting the last image on the GPU while background passes refine the density field, so navigation stays at 60 fps.

Adding the next exhibit

The lobby already reserves spots. To add one: create Sources/TVMathUI/<Exhibit>/ with an experience view, add a Route case in RootView, and swap its "in the workshop" card for a featured card. LogisticCore's viewport algebra, colormaps, and progressive-render scaffolding are exhibit-agnostic.

On the bench, in order of affection:

  • The Mandelbrot Set — the natural sequel: the logistic map is conjugate to z² + c on the real line, so this diagram is the Mandelbrot set's spine unfolded — its periodic windows are the mini-Mandelbrots on the real axis.
  • The Lorenz Attractor — chaos in continuous time.
  • Chladni Resonances — standing waves and the geography of sound.

License

MIT — see LICENSE.

Releases

Packages

Contributors

Languages