Topic

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:

(xy)↦(2111)(xy) mod 1. \begin{pmatrix} x \\ y \end{pmatrix} \mapsto \begin{pmatrix} 2 & 1 \\ 1 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} \bmod 1 .

The matrix has whole entries and determinant 1, so the map is invertible and keeps areas. Its eigenvalues are λ=3+52≈2.618\lambda = \tfrac{3+\sqrt5}{2} \approx 2.618 and 1/λ1/\lambda: every small disc is stretched by λ\lambda 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 Q(5)\mathbb{Q}(\sqrt5); 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 i/q,j/qi/q, j/q goes to another such point, and there are only q2q^2 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 qq. 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 λ\lambda, so after nn steps an error of 10−1610^{-16} has grown to 10−16λn10^{-16}\lambda^n, which reaches the size of the torus near n=38n = 38. floatPartsAt reports that step. The true orbit of (3/101,7/101)(3/101, 7/101) returns after 25 steps for ever; the double orbit never returns.

Counting. The fixed points of the nn-th iterate are the solutions of (An−I)p≡0(A^n - I)p \equiv 0, and there are exactly ∣det⁡(An−I)∣|\det(A^n - I)| of them: 1, 5, 16, 45, 121, … (fixedPointCount). They grow like λn\lambda^n, and the growth rate log⁡λ\log\lambda 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,

H(x,y)={(x/3,  3y)y≤1/3(symbol 0)(1−x/3,  3−3y)y≥2/3(symbol 1) H(x, y) = \begin{cases} (x/3,\; 3y) & y \le 1/3 \quad \text{(symbol 0)} \\ (1 - x/3,\; 3 - 3y) & y \ge 2/3 \quad \text{(symbol 1)} \end{cases}

and a point with 1/3<y<2/31/3 < y < 2/3 leaves the square. The points that stay for nn steps form 2n2^n horizontal strips (strips(n)), the stages of the middle-thirds Cantor set; the points that have been in the square for the last nn steps form 2n2^n vertical strips. The points that never leave in either direction are a product of two Cantor sets, of dimension 2log⁡2/log⁡32\log 2/\log 3.

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 HH 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 2n2^n points fixed by HnH^n, and orbitCount(n) orbits of least period nn (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 nn are in different strips at step nn.

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.

callreturns
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.dimensionexact intervals; { text, value }
Try itEdit the code and run it with @ratmath/chaos and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs