The Riemann sphere and conformal maps
Stereographic projection wraps the plane round a sphere with the point at infinity at the top, and it is a rational map: a complex rational goes to a point of the sphere with rational coordinates. The standard conformal maps between the disc and the half-plane are Möbius maps, so they are exact too.
toSphere("3/4"); // [24/25, 0, −7/25]
fromSphere([0, 0, 1]); // infinity
cayley(); // z ↦ (z − i)/(z + i): upper half-plane onto the disc
discAutomorphism("1/2", "3/5 + 4/5i"); // a self-map of the disc sending 1/2 to 0
joukowski(2); // 5/4
gridImage(cayley(), { re: [-1, 1], im: [0, 2], step: "1/2" }); // exact circles, for a picture
Stereographic projection
Put the unit sphere with its equator on the unit circle and project from the north pole. The point z = x + iy goes to
a point with rational coordinates whenever z is a complex rational, and ∞ goes to the pole. The inverse is . Circles on the sphere become circles or lines in the plane (lines are the circles through the pole), which is why Möbius maps send generalized circles to generalized circles. The chordal distance, the straight-line distance between the two points of the sphere, is exact too: squared, it is .
Rotations of the sphere
A Möbius map with matrix proportional to a unitary one, , turns the Riemann sphere rigidly. isSphereRotation tests this exactly, and such a map keeps every chordal distance. The group of these maps is SU(2) modulo ±1, the rotation group of space, which is the same fact as the quaternion rotations seen from another side.
Conformal maps of standard regions
cayley(): maps the upper half-plane onto the unit disc and the real line onto the unit circle.halfPlaneToDisc(z0): does the same and sends a chosen point to 0.discAutomorphism(a, u): with |a| < 1 and |u| = 1. Every conformal map of the disc onto itself has this form, and with a rational unit u, such as (3 + 4i)/5, it is exact.joukowski(z): maps the outside of the unit disc onto the plane cut along [−1, 1], sending the circle |z| = r to an ellipse with semi-axes . It is not a Möbius map, but it is still rational.
Maps that need exp or log, such as a strip onto a half-plane, use the certified functions with their branches reported (see Branches). regions tests exactly whether a point is in the disc, the upper or right half-plane, or the first quadrant.
Hooks for pictures
Pictures are drawn by the graphics package, and this package supplies the data. gridImage(T) sends each line of a grid to its exact image circle under a Möbius map. sampleGrid(f) evaluates a Möbius map, or any function of two doubles, on a grid for domain colouring, and says kind: "estimated".
| call | returns |
|---|---|
| toSphere(z), fromSphere([X, Y, Z]), chordal2(z, w) | Exact rationals; a Complex or infinity |
| cayley(), halfPlaneToDisc(z0), discAutomorphism(a, u) | Mobius maps |
| joukowski(z), regions | A Complex; exact membership tests |
| gridImage(T, { re, im, step }), sampleGrid(f, { re, im, width, height }) | { kind: "exact", lines }; { kind: "estimated", values } |
@ratmath/complex and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.