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 . 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 the answer is the nearer one, and for 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 . 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 there, every point of B goes to that root. The image is computed with the mean-value form
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 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.
| call | returns |
|---|---|
| newtonBasins(coefficients, { re, im, width, height, maxIter, depth }) | PixelGrid: kind (0 undecided, k for root k), roots (with their proved boxes), unproved, counts |
@ratmath/chaos and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.