What f_poincare taught us for f_apollonian and f_conformal_fill
Status: 🔵 lessons note from the f_poincare build, for f_apollonian and f_conformal_fill; no module of its own (2026-11-28, Claude, offline, from the note's own header).
Written 2026-11-07, at Matt's request, at the end of the f_poincare build. Sources are the Record in .specify/stable/f_poincare/tasks.md (task ids in brackets), the codebox src/f_poincare/codebox_poincare.gen and the mirror tests/modules/poincare/poincare_mirror.py. Observed = measured offline by Claude in float64 or float32, or on the GPU bench / live by Matt, as the tasks Record says; inferred = worked out and not run. f_apollonian is paused (gate P-moebius-tiling): this note does not resume it, it records what a future resume or spec could reuse.
For f_apollonian (paused, ADR-8: the parity-tracking bug)
- Build a float64 mirror before the codebox, and test it against closed forms the mirror does not use. Poincare's geometry was checked by two independent hyperbolic-trigonometry derivations, the camera by isometry (hyperbolic distance preserved), the folds by "settled points lie outside every edge circle" [T002]. Apollonian's bug lived only in Max:
use_mapped=4(zero error) anddebug_ok(pass) never agreed and the session ended without reconciling them (.specify/paused/f_apollonian/plan.mdADR-8 record). Recommendation (not tested): reproduce the accumulated-transform loop in NumPy first and compare the two views offline, where a mismatch can be isolated. - The mirror caught a hidden dependency: the order of the circles. When a point lies inside more than one edge circle, the settled position depends on which circle wins; lowest-index-wins and highest-index-wins disagree on a large share of points. The cause is inferred (at {4,5} the tile is not a strict fundamental domain) [T002]. Apollonian's ring-plus-centre construction also has overlapping candidates, so check order-dependence in the mirror before trusting any orientation or parity claim.
- Branchless settle works on the GPU; an early exit is not needed.
f_poincareruns a fixed 32 iterations with each step multiplied by ahasflag (a no-op once settled) [T010, T011]. This answers the fallback inideas/f_apollonian.md(thebreakquestion, still untested) with a working pattern. Also verified on the GPU: a multi-return call inside aforloop, and a user function that calls another (compiled first time) [T011, T022]. - Test only the three circles nearest by angle, not all N. Index the circle by
atan2sector and test it plus its two neighbours, lowest index wins. Observed to equal the full p-circle chain on every pixel both settle at all 56 pairs p, q in 3..10; one nearest (19.7% wrong at {4,5}) and two nearest (fails at q = 3) were rejected; nearest by hyperbolic distance was worse [T005]. The same trick should cut the cost of Apollonian's N-circle ring (inferred: its overlap count is not measured). - Tangent points are knife-edges: give "settled" a tolerance. Pixels on a mirror line of the group land exactly on an edge circle; float64 called them unsettled and float32 settled.
SETTLE_TOL1e-5 (squared distance) fixed it in both modes [T020]. Apollonian's "rainbow swirl at tangent points" is plausibly the same class of effect (inferred). - The unsettled boundary has a measured policy. Measure the unsettled fraction at 16 / 24 / 32 / 48 iterations and the radius where it starts, then fade unsettled pixels to black from just inside it [T004]: <= 0.04% unsettled at 32 iterations, fade from 0.99. Apollonian's non-converged fractal boundary is the same question ("what do unsettled pixels show"); use the same measurement before choosing a count.
- Float32 drift grows with a camera or final inversion that pushes mass toward the rim. With the translation at |a| = 0.99 colour errors jump from about 0.1% of pixels at r 0.9-0.95 to 6-30% at r 0.95-0.98 for {3,7}; the fade start moves in by 0.04 (|a| / 0.99)^2 [T032]. Apollonian's one animated final inversion (
ideas/f_apollonian.md) should be checked the same way. - Per-region texture sampling may not need the mapped-circle machinery.
f_poincaresamples at the settled position of the fold; that position is already a scale-free local frame for the region the pixel ended in, and it needed no accumulated matrix (the scratch patch'sNmatrices anddebug_okwere dropped [T001, spec]). Apollonian's flat-disc colouring does need a true containment test (ADR-8); its texture sampling (production item 2) might not. Inferred, untested. - Practical rules re-learned: name Params so they do not collide with
jit.gl.pixattributes (fold_mode, notmode) and never one letter (p_sides,q_vertex); one codebox for two looks stays well under the parser budget (about 85 statements against 250 / 450) [T021]; a ramp test texture (R = u, G = v, B = u v) makes the sampled colour BE the settled position, so one bench comparison checks position and colour (tests/modules/poincare/bench_poincare.py).
For f_conformal_fill (captured, not specced)
- The "thin consumer" half already exists, almost.
f_poincareis camera, then fold, then sample. Its start isz0 = normrescaled; for a conformal fill,z0is instead read from the precomputed field (a float32 texture, complex value in R and G, shape mask in a spare channel). Everything after that line is reusable as it stands (inferred: not built or benched with a field input). The offline solver is then the only novel part. - The camera answers two open questions. (a) Pole choice: a conformal map of a simply connected shape onto the disk is unique up to the three-parameter family of disk automorphisms (a rotation and a translation), which is exactly
rot,cam_x,cam_y. So the two boundary points the paper fixes need not be a user decision; any choice gives the same tiling up to a camera move (theory, not tested). (b) Live animation: the solve stays static per shape, but flying through the tessellation inside the shape costs nothing extra, because only the post-lookup isometry changes. Observed onf_poincare: smooth at 60 fps live, and the zero camera is bit-exact [T030, T033]. - The shape's edge is the disk's rim, with all its problems. Pixels near the boundary have unbounded fold depth and float32 error is worst there [T004, T032]. Policy to reuse: unsettled pixels fade to black, a fade from about 0.99 of the disk radius (earlier under a camera). Consequence worth checking: how many pixels near the shape's outline that fade covers depends on the local conformal scaling, so the inset could be uneven (inferred). A float32 field texture is needed, and a low-resolution solve upsampled bilinearly looks safe in the interior but the boundary band is where interpolation error would be amplified (inferred, matters for the paper's resolution question).
- Test the consumer without the solver. Feed the codebox a synthetic field (the identity, or an analytic Möbius map, written as a texture) and compare with the float64 mirror, exactly as
bench_poincare.pydoes. Test the solver separately with invariants that do not use its own formula: the discrete harmonic residual, angle preservation, and "a disk-shaped input maps to a disk automorphism". That keeps the two builds independently verifiable, which is howf_poincarewas kept honest. - Texture mapping choices carry over: crop, not warp, with
tile_scalesetting the texture extent [T006]; Whole and Sliver both take live p and q, and the validity guard (1/p + 1/q < 1/2, q raised to the minimum) is reusable as written.
Not learned (so nobody assumes it was)
Nothing here tests half-plane or other models, a non-disk generating set, N-matrix tracking, the Apollonian packing itself, or any solve. f_poincare is closed-form per pixel; the harmonic solve is untouched.