Enhanced Modular Rings — Interactive Visualization

Farey sequences, Stern-Brocot trees, and modular arithmetic visualization

PayPal

Enhanced Modular Lifting Rings

Visualize how numbers behave under modular arithmetic through concentric rings. Each ring represents a different modulus, with points colored by their relationships (coprime, composite, zero divisors). Watch patterns emerge as you explore different modular structures—from simple powers to prime sequences. Rotate, zoom, and inspect the deep patterns that connect number theory to geometry.

QUICK RANGE PRESETS
Core Settings
Visual Controls
Analysis Tools
Advanced Options
Audio & Harmonic Analysis +

2D Modular Rings: θ = 2πr/M

2D Rings: Concentric rings showing residue classes mod M. Gold points = coprime residues (GCD=1). Each ring represents a modulus from min to max. Click any point to see details below.

Live Statistics

Show:

Stern-Brocot Tree (Sector)

Quick Mod:
Find Path:
/
Tree depth: 0 | Nodes: 0

Arnold Tongues (Phase-Locking Regions)

⚠️ Epistemic Status: Heuristic Analogy

This visualization uses dynamical system structures (Arnold tongues) as an analogy for rational enumeration in number theory. This is exploratory visualization for intuition, NOT a proven equivalence.

Useful for teaching and pattern exploration. Not useful for proving theorems.

Arnold Tongues show regions of phase-locking in dynamical systems. Each tongue corresponds to a rational rotation number p/q. The width of tongue p/q grows with coupling strength ε. Points inside tongue p/q exhibit periodic orbits with rotation number exactly p/q.
Play:
Tongues: 0 | Max q: 8

Frequency Ratio Distribution

Distribution of frequency ratios across all coprime points. X-axis: frequency ratio (relative to base). Y-axis: count. Peaks correspond to simple ratios (consonant intervals).
Points: 0 | Range: 0-0

Farey Neighbors in Sector (|ad-bc|=1)

Loading...

Enhanced Lifting Rings Theory

θ = 2πr/M  |  Gap g: r₂ - r₁ ≡ g (mod M) with gcd(r₁,M) = gcd(r₂,M) = 1

Gap analysis reveals prime pair patterns: Gap 2 (Twin Primes), Gap 4 (Cousin Primes), Gap 6 (Sexy Primes). Coprime residue classes that differ by gap g correspond to admissible prime pair patterns. The φ(M) coprime classes form (ℤ/Mℤ)×, with structure revealed by direct lifts between moduli.

Multiplication Table — Ring Structure of Z/mZ (click to expand)
The Ring Z/mZ

For any positive integer m, the set Z/mZ = {0, 1, 2, ..., m-1} forms a commutative ring under addition and multiplication modulo m. The multiplication table visualizes this complete structure.

Units
Elements a where gcd(a,m)=1
Have multiplicative inverses
Count = φ(m)
Zero Divisors
Non-zero a where ab≡0 (mod m)
for some non-zero b
Count = m - φ(m) - 1
Idempotents
Elements where a²≡a (mod m)
Always include {0, 1}
Count = 2^ω(m)
Nilpotents
Elements where a^n≡0
Only exist when m has
repeated prime factors
Table Types
  • Multiplication (axb mod m): Full m×m table showing ring structure
  • Cayley Table (Units): Restricted to φ(m) invertible elements — the group (Z/mZ)×
  • Addition (a+b mod m): Always forms cyclic group of order m
Color Schemes
  • Rainbow: hue = (value/m) × 360° — reveals periodic patterns
  • Divisibility: Intensity by divisor count — darker = fewer divisors
  • Zero Divisors: Blue=units, Red=zero divisors, Gray=zero
  • Idempotents: Gold=idempotent elements, Gray=others
Element Inspector

Enter any element to analyze:

  • Units: Order (smallest k where a^k≡1), inverse, powers, generated subgroup
  • Non-units: Zero divisor pairs, nilpotent detection (a^n≡0)
  • Primitive roots: Units with order=φ(m) that generate all units
Prime vs Composite Moduli
Prime m (Field)
  • Only 0 gives 0 products
  • Every row is a permutation
  • All non-zero elements are units
  • Exactly 2 idempotents: {0,1}
Composite m (Ring)
  • Multiple zero divisor products
  • Some rows have gaps/repeats
  • Has non-invertible elements
  • 2^ω(m) idempotents
Mathematical Presets
m=6 (Basel) m=12 (φ=4) m=17 (Prime Field) m=30 (Primorial) m=60 (Highly Composite) m=31 (Mersenne Prime)

Step-by-Step Sector Count Verification

Formula Derivation

1. Farey sequence |FQ| = 1 + Σk=1Q φ(k)
2. Asymptotic: Σφ(k) ≈ 3Q²/π² (Mertens)
3. Sector Sn = (1/(n+1), 1/n) has width 1/(n(n+1))
4. Relative width = [1/(n(n+1))] / 1 = 1/(n(n+1))
5. Count ≈ |FQ| × [1/(n(n+1))]
C(n,N) ≈ 3N²/(π²·n(n+1))

Error Analysis

Primary: Σφ(k) ≠ 3Q²/π² exactly
Error term: O(Q log Q)
Secondary: Boundary effects
Fractions at 1/n, 1/(n+1) edges
Combined: O(N log N / n²)
Reliability degrades as n→∞

Worked Example: S₂ with N=30

Step Calculation Result
Asymptotic estimate3×30²/(π²×2×3)45.57
Angular range360°/3 to 360°/2120° - 180°
Fraction range1/3 < p/q ≤ 1/2width = 1/6
Root mediant(1+1)/(3+2)2/5 @ 144°
Error boundO(30·log(30)/4)~25
Author: Wessen Getachew | GitHub | @7dview

𝔻 Farey Explorer — Unit Disk & Upper Half-Plane

FAREY SEQUENCE & CUSTOM POINTS

F_n max = current modulus m. Option to include 0/n for each n.
Adds all fractions k/m for k = 0 to m-1 (includes 0/m)
0 POINTS
No points added yet
Format: numerator/denominator (e.g., 1/3, 2/5, 3/7)

CONNECTION OPTIONS

1.0×
𝔻 Farey Unit Disk Explorer
Interactive Poincare Disk — Farey Fractions on Unit Circle
Farey points plotted on unit circle. Angular position: θ = 2π·(numerator/denominator). Colors by GCD value. Click points for details.
Total
0
points
COPRIME
0
0%
Max Q
denom
Min Q
denom
AVG Q
mean
Min P/Q
frac
Max P/Q
frac
Span
range
Max P
numerator
MEDIAN Q
50th %ile
σ STD DEV Q
variance
Q Range
max-min
NON-COPRIME
0%
FAREY DEPTH
F_n

Harmonic Analysis System — Complete Guide

Overview

The Enhanced Modular tool integrates music theory with number theory, revealing deep connections between Farey sequences, the Stern-Brocot tree, and musical consonance. Every coprime fraction p/q corresponds to a musical interval, and the tool provides comprehensive analysis including audio playback, consonance metrics, and chord building.

Audio Controls

  • Base Frequency: Reference pitch in Hz (default 440 = A4). All intervals calculated relative to this.
  • Volume: Master volume control (0-100%)
  • Duration: Note length from Short (0.15s) to 1 second
  • Waveform: Sine (pure), Triangle, Square, or Sawtooth oscillator

Interval Playback

Quick buttons for fundamental intervals:

  • Perfect Fifth (3:2): 702 cents — most consonant after unison/octave
  • Perfect Fourth (4:3): 498 cents — inversion of the fifth
  • Major Third (5:4): 386 cents — defines major tonality
  • Minor Third (6:5): 316 cents — defines minor tonality
  • Major Sixth (5:3): 884 cents — inversion of minor third
  • Octave (2:1): 1200 cents — same note, double frequency

Chord Builder

Build and play chords from selected fractions:

  • Chord Mode: Enable to add clicked points to chord instead of replacing selection
  • Play Chord: Play all selected notes simultaneously
  • Arpeggio: Play notes in sequence (lowest to highest)
  • Quick Chords: Preset major (4:5:6), minor (10:12:15), major 7th, power chord

Tip: In Chord Mode, click multiple coprime points on the canvas to build custom chords!

Consonance Metrics

For any selected fraction p/q, the tool calculates:

Cents1200 × log₂(p/q) — standard musical measurement
Tenney Heightlog₂(p) + log₂(q) — lower = simpler interval
Benedetti Heightp × q — multiplicative complexity (Benedetti, 1585)
Euler GradusΓ(p) + Γ(q) - 1 — "degree of sweetness" (Euler, 1739)
Harmonic EntropyInformation-theoretic smoothness (Erlich model)
Prime LimitLargest prime in factorization of p·q

Harmonic Color Schemes

Four specialized color modes for harmonic analysis:

Harmonic (by q) Colors by denominator: q=1 q≤4 q≤8 q≤16 q>16
Prime Limit 2-limit 3-limit 5-limit 7-limit 11-limit higher
Tenney Height Gradient from simple (low complexity) to complex (high Tenney value)
Consonance Perfect Imperfect Dissonant

Prime Limits Explained

LimitSystemIntervalsMusical Era
2-limitOctaves only2/1Universal
3-limitPythagorean3/2, 4/3, 9/8Ancient Greece
5-limitJust Intonation5/4, 6/5, 5/3Renaissance
7-limitSeptimal7/4, 7/6, 8/7Blues, Barbershop
11-limitUndecimal11/8, 11/9Microtonal

Stern-Brocot Tree & Music

The Stern-Brocot tree organizes all positive rationals by simplicity — exactly what musicians need:

  • Mediant Property: Between a/b and c/d, the mediant (a+c)/(b+d) is the simplest fraction — used to find intermediate pitches
  • Path = Continued Fraction: The L/R path encodes the CF [a₀; a₁, ...], connecting to best approximations
  • Depth ≈ Complexity: Tree depth correlates with Tenney height — deeper = more complex interval
  • Path Sonification: Play the S-B path as an arpeggio to "hear" the approach to any fraction

Famous Tuning Commas

Commas are small intervals revealing tuning incompatibilities:

Syntonic (81/80)21.5¢ — Four 5ths vs M3+2 octaves
Pythagorean23.5¢ — 12 fifths vs 7 octaves
Diesis (128/125)41.1¢ — Octave vs three M3s
Septimal (64/63)27.3¢ — 7th harmonic discrepancy

These explain why perfect tuning is mathematically impossible — you can't stack simple ratios and return exactly to the start.

Quick Start Guide

  1. Select Harmonic (by q) or Prime Limit color scheme
  2. Click any gold coprime point to hear its frequency
  3. View Harmonic Metrics panel for full consonance analysis
  4. Enable Chord Mode and click multiple points to build chords
  5. Click Play Chord to hear all selected notes together
  6. Use S-B Path to visualize and sonify the path to any fraction
  7. Try the Manual p/q input to explore specific intervals
  8. Compare Quick Chords (Major, Minor, Maj7, Power) to hear harmonic structure

Mathematical Foundation

The deep connection: when two frequencies f₁ and f₂ have ratio p/q (in lowest terms), their combined waveform repeats every q cycles of f₁ (or p cycles of f₂). Simple ratios create short, regular patterns — perceived as consonance. Complex ratios create long, irregular patterns — perceived as dissonance.

This is why the Farey sequence and Stern-Brocot tree — which organize rationals by simplicity — are fundamentally musical structures. The 6/π² coprime density means roughly 61% of random frequency pairs form "primitive" (irreducible) intervals.