Möbius maps
The maps z ↦ (az + b)/(cz + d) are the conformal bijections of the Riemann sphere. With complex rational coefficients they are exact: rational points go to rational points, circles to circles, and the cross-ratio of four points never changes.
const T = mobiusFrom([0, 1, infinity], ["i", 1, -1]); // the one map sending three points to three
T.apply("1/2"); // an exact complex rational
crossRatio(2, "i", 0, infinity); // -2i
concyclic(1, "i", -1, "-i"); // true: the cross-ratio is real
mobius(1, 1, 1, 0).classify(); // "loxodromic"
circle(0, 1).map(cayley().inverse()); // the line y = 0, exactly
The maps
A Möbius map is given by a matrix with , and composing maps multiplies matrices. Multiplying the matrix by a number gives the same map, so equals compares matrices up to a factor. The point at infinity is infinity: goes there, and it goes to .
Any three distinct points can be sent to any three by exactly one Möbius map. mobiusFrom builds it as , where sends to 0, 1, ∞ (any of them may be ∞).
The cross-ratio
is the image of under the map sending to 1, 0, ∞, and so every Möbius map keeps it. It is real exactly when the four points lie on one circle or line, which makes concyclic an exact test.
What kind of map
The number does not change when the matrix is scaled or the map is conjugated, and it decides what the map does near its fixed points:
- parabolic, τ = 4: one fixed point, like z ↦ z + 1;
- elliptic, τ real in [0, 4): a rotation about two fixed points, like z ↦ e^{iθ}z;
- hyperbolic, τ real and greater than 4: a stretch from one fixed point towards the other, like z ↦ 2z;
- loxodromic, otherwise: a stretch and a turn together.
With rational coefficients τ is a complex rational and the test is exact. The fixed points solve . When the square root of the discriminant is a complex rational they are exact; otherwise they come back as certified rectangles, such as the golden ratio for z ↦ 1 + 1/z.
Circles and lines
Write a circle or a line as with A and C rational and B a complex rational. When A ≠ 0 it is the circle with centre and radius² , and when A = 0 it is a line. The form is a Hermitian matrix H, and a Möbius map M sends it to , so the image of a circle is computed exactly, without sampling, and a circle through the pole becomes a line. circle(c, r2), lineThrough and circleThrough build them, and contains tests a point exactly.
| call | returns |
|---|---|
| mobius(a, b, c, d), mobiusFrom(from, to) | Mobius: apply, compose, inverse, equals, det, traceSquared, classify, fixedPoints, isSphereRotation, applyFloat |
| infinity, isInfinity(z) | The point at infinity |
| crossRatio(z1, z2, z3, z4), concyclic(…) | A Complex or infinity; a boolean |
| circle(center, r2), lineThrough(z1, z2), circleThrough(z1, z2, z3) | GCircle: isLine, center, radius2, value, contains, equals, map(T) |
@ratmath/complex and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.