The cat map and the horseshoe
Two maps of the plane can be done with no approximation at all, and they are the two that explain the rest: the cat map, where chaos is linear algebra, and the horseshoe, where it is counting words.
const cat = catMap(); // (x, y) → (2x + y, x + y) mod 1
cat.period(["3/101", "7/101"]).period; // 25: every rational point is periodic
cat.floatPartsAt(["3/101", "7/101"]); // 38: the step at which doubles have lost that orbit
cat.fixedPointCount(5); // 121n points fixed by the fifth iterate
cat.entropy().text; // "log((3 + √5)/2)"
const hs = horseshoe();
hs.periodicPoint("011"); // [9/13, 3/13], the point whose itinerary is 011011011…
hs.orbitCount(6); // 9 orbits of least period 6
The cat map
Arnold's cat map acts on the torus, the unit square with opposite sides glued:
The matrix has whole entries and determinant 1, so the map is invertible and keeps areas. Its eigenvalues are and : every small disc is stretched by along one direction and squeezed along the other, at every point, in the same directions. eigen() gives the eigenvalues and the slopes of the two directions as exact numbers in ; the slopes are irrational, which is why the stretched disc winds densely round the torus instead of closing up.
Rational points. A point with coordinates goes to another such point, and there are only of them, so (the map being invertible) every rational point is periodic. period(p) finds the period by exact iteration and periods(q) tabulates all points of denominator . These are the famous pictures of a cat that reassembles after a few hundred steps: the pixels are rational points.
What doubles do. The same orbit in doubles is not periodic. Each step multiplies the rounding error by , so after steps an error of has grown to , which reaches the size of the torus near . floatPartsAt reports that step. The true orbit of returns after 25 steps for ever; the double orbit never returns.
Counting. The fixed points of the -th iterate are the solutions of , and there are exactly of them: 1, 5, 16, 45, 121, … (fixedPointCount). They grow like , and the growth rate is the map's topological entropy and its Lyapunov exponent, which entropy() returns as a formula and an enclosure.
torusMap(matrix) takes any 2 × 2 matrix of whole numbers; hyperbolic says whether it has an eigenvalue on the unit circle (a rotation by a quarter turn does, and is not chaotic).
The horseshoe
Smale's horseshoe takes a square, squeezes it to a third of its width, stretches it to three times its height, folds it and lays it back over the square. In the piecewise linear form used here,
and a point with leaves the square. The points that stay for steps form horizontal strips (strips(n)), the stages of the middle-thirds Cantor set; the points that have been in the square for the last steps form vertical strips. The points that never leave in either direction are a product of two Cantor sets, of dimension .
Symbolic dynamics. Write 0 or 1 according to which strip the point is in at each step. Every sequence of 0s and 1s is the itinerary of exactly one point of the invariant set, and applying shifts the sequence. So the horseshoe contains, exactly:
- a periodic point for every periodic sequence:
periodicPoint("011")solves the affine fixed-point equation along the word and returns a rational point; there are points fixed by , andorbitCount(n)orbits of least period (2, 1, 2, 3, 6, 9, …); - orbits that come arbitrarily close to every point of the set (take a sequence that contains every finite word);
- sensitive dependence: two points whose sequences first differ at step are in different strips at step .
The horseshoe matters because it is found inside other systems. Wherever a map stretches and folds a region across itself, a horseshoe sits inside, and with it all of the above. The saddle periodic orbits of the Hénon map and of the Lorenz system on the neighbouring pages are the visible part of such sets.
| call | returns |
|---|---|
| catMap(), torusMap(matrix) | TorusMap |
| T.at(p), T.orbit(p, n), T.floatOrbit(p, n) | exact points of the torus; doubles |
| T.period(p) | { period, preperiod, cycle } |
| T.periods(q) | Map from period to the number of points of denominator q with it |
| T.fixedPointCount(n) | bigint, |det(Aⁿ − I)| |
| T.eigen() | [{ value, text, direction, directionText, expanding }] |
| T.entropy() | { text, value: RationalInterval } |
| T.floatPartsAt(p) | the step at which the double orbit has left the true one |
| horseshoe() | Horseshoe |
| S.at(p), S.itinerary(p, n) | the image or null; a string of 0s and 1s |
| S.periodicPoint(word), S.periodicPoints(n), S.orbitCount(n) | exact points; all 2ⁿ with word and least period; a count |
| S.strips(n), S.dimension | exact intervals; { text, value } |
@ratmath/chaos and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.