antifold

Theory

Shapes, Paths, and Patterns: Simple Visuals

Hands‑on pictures that make symmetry, shapes, and motion easy to see and understand.

Hover here for connections.

Below, colonies of digital insects demonstrate six algorithms at the heart of modern computing. These are not simplified analogies. Every ant and fly runs real mathematical code and produces metrics you can measure. Toggle the controls, watch the numbers shift, and see how nature's strategies became some of humanity's most powerful computational tools.

How to use this page

  • Each section has a live canvas and controls; try them.
  • Read the short "How to use" under each graphic for guidance.
  • Equations use LaTeX; hover blue terms for quick tooltips.

The Mirror Dance: Group Theory in Action

Imagine searching for your keys in a square room. You check the northeast corner -- nothing. Without symmetry, you would have to inspect all four corners one by one. But a square has exactly eight symmetries: four rotations and four reflections. Mathematicians call this collection D₄, the dihedral group of the square. It means that every test you run in one corner automatically tells you the result in seven other positions.

The ant colony below makes this visible. With symmetry mode OFF, the ants laboriously probe every inch of space. Flip it ON, and finding food in one location instantly reveals seven symmetric positions. No simulation trick -- this is the same group theory that powers facial recognition and helps physicists decode crystal structures.

Area Explored
0%
Food Found
0
baseline
Efficiency
1.0x
+0%
Steps Saved
0
Mode: OFF - Ants explore all paths | Time: 0s | Colony Size: 20 ants
How to use:
  • Click “Add Food Source”, then “Toggle Symmetry Mode”.
  • Optionally show pheromone trails; watch efficiency and steps saved.
  • Reset to compare symmetry OFF vs ON.
The Mathematical Foundation

The dihedral group \(D_4\) has eight elements: the identity, three rotations \((90^\circ,180^\circ,270^\circ)\), and four reflections. When an ant at \((x,y)\) finds food, symmetry implies food exists at all points in its \(D_4\)-orbit.

Mathematically, with rotation \(r\) and reflection \(s\), \[ D_4 = \{e,\; r,\; r^2,\; r^3,\; s,\; sr,\; sr^2,\; sr^3\}. \] This yields the \(\approx 8\times\) speedup you see. In ML, CNNs exploit translation symmetry: \( f(Tx) = T(fx) \).

Flies on a Sphere: Navigation on Curved Surfaces

Here is a thought experiment: you are a fly walking on a perfectly spherical balloon. You want to reach a sugar crystal on the opposite side. Your fly-brain says "walk straight," but what does "straight" mean on a curved surface? This is not just a philosophical question -- it is the foundation of everything from GPS navigation to training neural networks. In machine learning, parameter spaces are almost always curved: optimization on manifolds shows up in word embeddings, pose estimation, and the geometry of loss landscapes.

The fly below is performing Riemannian gradient descent, though it has no idea. Watch it trace a geodesic -- the shortest path on a curved surface -- that looks curved from our 3D vantage but feels perfectly straight to the fly. The same mathematics explains why a plane from New York to London follows what looks like a curved arc on a flat map.

Sphere Rotation:
Path Length
0
geodesic
vs Euclidean
1.0x
+0%
Curvature
0.67
Convergence
0%
How to use:
  • Toggle 2D/3D view and drag the rotation slider.
  • Click “Show Geodesic Path” to highlight the great-circle route.
  • Release a small swarm to see multiple paths.
The Geometry of Curved Optimization

Optimize \(f(x,y,z)\) subject to \(x^2+y^2+z^2=1\). The Euclidean gradient \(\nabla f\) points off the sphere, so project onto the tangent plane: \[ \tilde{\nabla} f = \nabla f - (\nabla f \cdot n)\,n, \quad n=\text{surface normal}. \]

This is Riemannian gradient descent. The sphere has constant curvature \(K=1/r^2\); shortest paths are great circles.

The Cooling Colony: Temperature and Optimization

In 1953, metallurgists at IBM noticed something peculiar: when they slowly cooled molten metal, atoms would settle into perfect crystal lattices, finding the global minimum energy configuration among quintillions of possibilities. But cool it too quickly, and you get a brittle mess of local arrangements. This observation would revolutionize computer science.

Watch the ant colony below search for the lowest point in a rugged landscape. The "temperature" slider controls their jumpiness: at high temperatures, ants make wild leaps, even uphill. As temperature drops, they grow conservative, eventually freezing into the deepest valley they have found. This is simulated annealing -- the method your computer uses to solve problems that brute force could not crack before the heat death of the universe.

Temperature: 100
Current Energy
Global Best
0%
Accept Rate
0%
vs Random
1.0x
better
Temperature: 100° | Iterations: 0 | Local Minima Escaped: 0 | Cooling Rate: 0.995
How to use:
  • Click “Start Annealing” and watch average and best energy.
  • Use the slider to set starting temperature; toggle heatmap/trails.
  • Reset to sample a fresh landscape.
The Metropolis Algorithm and Statistical Mechanics

Accept move \(s\to s'\) with probability \(\min\{1,\; e^{-\Delta E/T}\}\), where \(\Delta E=E(s')-E(s)\) and \(T\) is temperature.

At temperature \(T\), equilibrium follows Boltzmann: \(P(s)\propto e^{-E(s)/T}\). High \(T\) explores widely; as \(T\to 0\), mass concentrates on minima.

With logarithmic cooling \(T(t)=c/\log t\) it converges (probability 1). In practice we use geometric cooling \(T_{t+1}=\alpha T_t\) with \(\alpha\approx 0.995\).

Ghost Flies: Quantum Tunneling Through Barriers

Classical physics says it is impossible: a ball rolling toward a hill needs enough energy to climb over, or it rolls back. End of story. But in 1927, quantum mechanics revealed nature's cheat code: particles can tunnel through barriers they classically cannot cross. This is not a theoretical curiosity -- it is happening inside your body right now, where enzymes exploit tunneling for catalysis, and inside every transistor in your computer.

Our quantum flies below demonstrate this ghostly behavior. Watch flies with insufficient energy somehow appear on the other side of the barrier. The tunneling probability is tiny but never zero. Adjust the barrier height and watch how tunneling probability changes exponentially. This is the principle behind scanning tunneling microscopes, radioactive decay, and the quantum computers that might soon make current encryption obsolete.

Barrier Height: 50   Width: 60px
Tunnel Rate
0%
Classical Pass
0%
Quantum Advantage
0x
waiting
Wave Coherence
100%
Barrier/Energy Ratio: 1.0 | Total Attempts: 0 | De Broglie λ: 2.1nm | Transmission Coefficient: 0.001
How to use:
  • Click “Release Quantum Flies”. Adjust height and width sliders.
  • Toggle wave function to see packets; compare classical vs quantum.
  • Watch tunneling rate react exponentially to width and height.
The Quantum Mechanical Foundation

For a rectangular barrier, a convenient approximation is \[ T \;\approx\; 16\,\frac{E}{V}\Bigl(1-\frac{E}{V}\Bigr) e^{-2\kappa L},\quad \kappa=\frac{\sqrt{2m(V-E)}}{\hbar}. \] The exponential in \(\kappa L\) drives the dramatic width/height sensitivity.

WKB for arbitrary barriers: \[ T \;\approx\; \exp\Bigl(-2\int\limits_{\text{forbidden}} \frac{\sqrt{2m\,(V(x)-E)}}{\hbar}\,dx\Bigr). \]

In quantum annealing computers like D-Wave, qubits tunnel through energy barriers to find optimal solutions, potentially solving certain optimization problems exponentially faster than classical computers. The quantum advantage isn't universal; it depends on the barrier structure. Problems with tall, thin barriers favor quantum approaches, while those with short, wide barriers might favor classical thermal annealing. Understanding this landscape is key to the future of computation.

The Social Network: Distributed Intelligence

How does a rumor spread through a social network? How do neurons in your brain reach consensus about what you're seeing? How does corrupted data get corrected in wireless transmission? The answer to all three questions is the same: message passing on graphs, one of the most powerful algorithmic frameworks ever discovered.

Watch our ant colony form a network where each ant only knows its immediate neighbors. Inject information at one node and observe it propagate, with each ant updating its beliefs based on messages from friends. This is belief propagation in action, the algorithm that powers everything from error correction in 5G networks to inference in artificial intelligence systems.

Network Density: 30%
Convergence
0%
Message Rounds
0
active
Network Efficiency
0%
optimal
Info Spread
0%
Nodes: 20 | Edges: 0 | Avg Degree: 0 | Diameter: | Clustering: 0.00
How to use:
  • Create the network, then start message passing.
  • Inject information at random nodes; try different densities.
  • Toggle layout to see structure vs force-directed motion.
Message Passing and Graphical Models

Belief propagation on factor graphs: node \(i\) maintains \(b_i(x_i)\) and sends messages \(m_{i\to j}(x_j)\) to neighbors. Update rule: \[ m_{i\to j}(x_j) = \sum_{x_i} \psi_{ij}(x_i, x_j)\,\phi_i(x_i) \prod_{k\in N(i)\setminus j} m_{k\to i}(x_i). \]

On trees, BP computes exact marginals in \(\mathcal{O}(n)\); on loopy graphs it is approximate but often excellent (e.g., modern error-correcting codes).

The universality of message passing is stunning. A neuron in your cortex sums weighted inputs from its neighbors; a person on social media updates beliefs after reading a friend's post; an amino acid nudges the one beside it toward a different fold; an entangled photon instantly constrains its distant partner. All of these are instances of the same mathematics. Graph neural networks -- the latest revolution in AI -- take this further by learning their own update rules through gradient descent, rather than relying on rules designed by hand. The future of AI may well look like colonies of simple units exchanging messages, much like the digital ants above.