⭕ Apollonian Gasket

Descartes' Circle Theorem · Recursive tangent-circle packing · Curvature = 1/radius

Recursion

Display

Statistics

Circle count0
Min radius reached0
Max curvature0

Descartes' Theorem

(k₁+k₂+k₃+k₄)² = 2(k₁²+k₂²+k₃²+k₄²)
k = curvature = 1/radius (negative for the bounding circle)

⭕ What It Demonstrates

An Apollonian gasket is a fractal formed by starting with three mutually tangent circles and recursively inscribing a new circle into every curved triangular gap left between them, forever. This simulator uses the real Descartes' Circle Theorem, first stated by René Descartes in 1643: for any four mutually tangent circles with curvatures k₁, k₂, k₃, k₄ (curvature = 1/radius, taken negative for a circle that encloses the others), (k₁+k₂+k₃+k₄)² = 2(k₁²+k₂²+k₃²+k₄²). Solving this quadratic for the fourth curvature given three known circles yields k₄ = k₁+k₂+k₃ ± 2√(k₁k₂+k₂k₃+k₃k₁), and a matching complex-number formula locates its centre. The simulator applies this solver at every recursion level, so every circle you see is a genuine solution to the tangency constraints, not an approximation.

Starting from one large enclosing circle and two inner circles, each new gap generates a fresh triple of mutually tangent circles, and the theorem is applied again — curvatures grow rapidly and radii shrink toward zero as recursion deepens, producing the self-similar lattice of shrinking circles that gives the gasket its fractal structure.

How to Use

Did You Know?

When the four starting curvatures of an Apollonian gasket are all integers, every single circle in the entire infinite gasket also has an integer curvature — a remarkable fact connected to the arithmetic of quadratic forms and modern number theory. The classic (0, 0, 1, 1) and (−1, 2, 2, 3) "integral Apollonian gaskets" have been studied extensively for the number patterns that appear among their curvatures, and Apollonian circle packings also appear in ancient Greek geometry — Apollonius of Perga solved the general tangent-circle problem around 200 BCE, long before the fractal interpretation was understood.

About this simulation

This simulator builds a real Apollonian gasket by solving Descartes' Circle Theorem at every recursion level. Starting from a large bounding circle and two inner circles, every triple of mutually tangent circles is fed into the theorem's formula to compute the exact curvature and centre of the circle that fits the remaining gap — no fixed lookup table, no approximation, just the genuine tangency equations solved live.

🔬 What it shows

Given curvatures k1, k2, k3 of three mutually tangent circles, the fourth tangent circle satisfies k4 = k1+k2+k3 ± 2√(k1k2+k2k3+k3k1). A matching complex-number formula z4·k4 = z1k1+z2k2+z3k3 ± 2√(k1k2z1z2+k2k3z2z3+k3k1z3z1) gives its centre. Both roots are solved and the new, non-duplicate circle is kept and recursed into further.

🎮 How to use

The Depth slider (0–6) sets how many recursive generations are solved and drawn. Toggle colouring by curvature or by generation depth, and enable curvature numbers to label circles directly. The Randomize button perturbs the two starting inner-circle radii to generate new gasket layouts while keeping all circles mutually tangent.

💡 Did you know?

If the four starting curvatures are whole numbers, Descartes' theorem guarantees every descendant circle in the entire infinite gasket also has a whole-number curvature — an integral Apollonian gasket, connected to deep results in number theory about quadratic forms.

Frequently asked questions

What is Descartes' Circle Theorem?

It relates the curvatures of four mutually tangent circles: (k1+k2+k3+k4)² = 2(k1²+k2²+k3²+k4²), where curvature k equals 1/radius and is taken negative for a circle that curves the opposite way, enclosing the others. Solving this equation for the unknown fourth curvature, given three known ones, gives the formula used throughout this simulator.

Why is curvature negative for the outer circle?

Curvature measures how sharply a circle bends, with sign indicating orientation. The bounding circle wraps around all the inner circles rather than being tangent from outside, so by convention it is assigned a negative curvature, flipping the sign so the same formula correctly produces both interior and boundary circles.

How is the centre of each new circle found?

A complex-number version of Descartes' theorem treats each circle's centre as a complex number. The identity z4·k4 = z1k1+z2k2+z3k3 ± 2√(k1k2z1z2+k2k3z2z3+k3k1z3z1) gives the curvature-weighted centre of the new circle directly from the three known circles, matching whichever curvature root (k4) was chosen.

Why does the circle count grow so fast with depth?

Every new circle created in a gap forms two new triangular gaps with its neighbours, so the number of circles added per generation grows roughly geometrically. This is why recursion depth is capped at 6 in this simulator — beyond that, circle counts and computation time increase very quickly while circles become smaller than a pixel anyway.

What is an integral Apollonian gasket?

It is a gasket whose four starting circles all have integer curvatures. Descartes' theorem is a quadratic equation with integer coefficients when the inputs are integers, so every subsequent curvature generated by the recursive process is also guaranteed to be an integer, producing striking patterns studied in number theory.