Topic

Newton basins

Newton's method for z³ − 1 sends almost every starting point to one of the three cube roots of 1, but the boundaries between the three basins are fractal: at every point of the boundary all three basins meet.

newtonBasins(["1", "0", "0", "-1"]);        // z³ − 1: three labelled basins
newtonBasins(["1", "0", "-1"], { width: 40, height: 20 });   // z² − 1: two half-planes
newtonBasins(["1", "0", "1", "0", "-1"]);   // z⁴ + z² − 1, coefficients highest first

Newton's map

For a polynomial p, Newton's method iterates N(z)=z−p(z)/p′(z)N(z) = z - p(z)/p'(z). Near a simple root it converges quadratically, but far from the roots the behaviour is a dynamical system in its own right. Cayley asked in 1879 which root a starting point goes to; for z2−1z^2 - 1 the answer is the nearer one, and for z3−1z^3 - 1 the boundary of each basin is the boundary of all three, a Julia set of the rational map N.

What is proved

For each root the library builds a small box B around a float approximation and checks, in interval arithmetic, that N(B)⊂BN(B) \subset B. By Brouwer's theorem N then has a fixed point in B, which is a root of p, and since B is small enough that ∣N′∣<1|N'| < 1 there, every point of B goes to that root. The image is computed with the mean-value form

N(Z)⊆N(m)+N′(Z) (Z−m),N′=p p′′(p′)2, N(Z) \subseteq N(m) + N'(Z)\,(Z - m), \qquad N' = \frac{p\,p''}{(p')^2},

where m is the centre of the box; evaluating N directly on a box loses too much to the dependency problem. A pixel gets label k when its interval Newton orbit enters the k-th proved box, so every point of the pixel converges to root k. Pixels are split up to depth times when the whole cannot be followed. Boundary pixels, and pixels near a critical point of p where p′p' vanishes, stay undecided.

Coefficients are exact (complex ones written "1/2 + 3i"). A root that could not be proved, a multiple root for instance, is listed under unproved and its basin is not labelled.

callreturns
newtonBasins(coefficients, { re, im, width, height, maxIter, depth })PixelGrid: kind (0 undecided, k for root k), roots (with their proved boxes), unproved, counts
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