Apollonian gasket — generated by Descartes’ theorem

What this is?

An SVG drawing of an Apollonian gasket: infinitely many circles packed inside one big circle so that every circle is tangent to its neighbors. We start from one enclosing circle and three interior tangent circles. Every new circle is computed from any three mutually tangent circles using Descartes’ circle theorem with the complex center formula, so both radius and position are exact.

Answer — drawing

Reason

  1. Use curvature (bend) k = ± 1/r (enclosing circle has negative curvature; interior circles have positive curvature). For four mutually tangent circles with curvatures k₁, k₂, k₃, k₄:
    (k₁ + k₂ + k₃ + k₄)² = 2 · (k₁² + k₂² + k₃² + k₄²).
  2. Given three tangent circles with curvatures k₁, k₂, k₃ and complex centers z₁ = x₁ + i y₁, z₂ = x₂ + i y₂, z₃ = x₃ + i y₃, the two possible fourth circles are:
    k₄ = k₁ + k₂ + k₃ ± 2√(k₁k₂ + k₂k₃ + k₃k₁)
    z₄ = ( S ± 2√Q ) / k₄
    with S = k₁z₁ + k₂z₂ + k₃z₃ and Q = k₁k₂ z₁z₂ + k₂k₃ z₂z₃ + k₃k₁ z₃z₁. The same choice of ± is used in both formulas. Replacing one circle in a tangent quadruple by its “other” solution fills the curvilinear gap.
  3. We iterate this replacement throughout the figure and stop when a new circle would be too small to see.

Check

    We verify: containment, no overlaps, curvature–radius consistency and signs, no duplicates, each generated circle is tangent to its three parents, and both Descartes identities (curvature and complex-center) on many sampled quadruples.