Complex analysis

Zeros and the argument principle

How many zeros does a function have inside a contour? The answer is a whole number, and a whole number can be proved by enclosing it in an interval narrower than 1. From counting comes finding: every zero in a rectangle, each in its own small box, with its multiplicity.

import { argumentPrinciple, countZeros, zeros, Contour, rect } from "@ratmath/complex";

argumentPrinciple("z^3 - 1", Contour.circle(0, 2));   // 3
argumentPrinciple("tan(z)", Contour.circle(0, 2));    // -1: one zero, two poles

const r = zeros("exp(z) - 3z", rect([-1, 3], [-2, 2]));
r.count;                 // 2, proved
r.zeros[0].enclosure;    // 0.61906128673594511 + 0i ± 2.6e-23
r.zeros[1].enclosure;    // 1.5121345516578425 + 0i ± 1.1e-22

The argument principle

For ff meromorphic inside a simple closed contour CC and with no zero or pole on it,

12πi∮Cf′(z)f(z) dz=Z−P, \frac{1}{2\pi i}\oint_C \frac{f'(z)}{f(z)}\,dz = Z - P,

the number of zeros inside minus the number of poles, each counted with its multiplicity. The left side is the number of times the image curve f(C)f(C) winds round 0, and that is how it is computed here, with no derivative.

Cover a piece of CC with a disc and take a Taylor model of ff there. If the model's range is a disc that misses 0, then on that piece ff stays inside a half-plane, its argument changes by less than half a turn, and the change is exactly the principal argument of f(end)/f(start)f(\text{end})/f(\text{start}). Those are enclosed, added up round the contour and divided by 2π2\pi. The total is an interval a tiny fraction wide around a whole number. Where the range does not miss 0 the piece is halved; a zero on the contour itself is refused and located.

Finding the zeros in a rectangle

zeros(f, rect) cuts the rectangle into cells and settles each one with a model on the disc around it. Three proofs are tried.

  • No zero. The model's range misses 0.
  • Exactly k zeros (Rouché). If one coefficient of the model outweighs all the others and ε together, ff has as many zeros in the disc as that one term, which is its index k. For k ≥ 2 the disc is then shrunk around the zeros' centroid for as long as it still holds all k.
  • Exactly one simple zero (Newton). For the disc DD with centre cc, form N=c−f(c)/f′(D)N = c - f(c)/f'(D), where f′(D)f'(D) is a disc holding every value of the derivative. Since f(z)=f(c)+(z−c)gf(z) = f(c) + (z - c)g with gg in the convex hull of f′(D)f'(D), every zero in DD lies in NN. If NN is inside DD there is exactly one, and repeating the step shrinks its enclosure quadratically.

A cell that none of these settles is cut in four. What is still unsettled at the tolerance is grouped and counted by the argument principle on a small frame.

What comes back

callreturns
zeros(f, rect, opts){ zeros, count, complete, unresolved }
zeros[k].enclosureA Rect holding the zero (or the cluster)
zeros[k].multiplicity, .simpleThe total multiplicity in the enclosure. simple is true for one simple zero. Otherwise the enclosure holds either one zero of that order or several closer together than the working precision can separate, and the total is what is proved.
zeros[k].isolatingA larger disc in which those are the only zeros
zeros[k].boundaryTrue when the enclosure straddles the rectangle's edge; such zeros are listed but not counted
count, completeThe proven number of zeros in the rectangle, when complete is true
unresolvedParts that could not be settled, with reasons: a singularity of f, or the work budget
argumentPrinciple(f, contour), countZeros(f, contour)The winding number of f(contour) round 0: zeros minus poles

Options: bits (digits of each simple zero, default 64), tolerance (how closely two zeros are told apart, default 2⁻²⁰), order, modelBits, maxCells.

The function must be analytic on the rectangle for the count to mean zeros. That is checked, not assumed: a cell on which no model can be built is reported in unresolved, so a pole inside leaves complete false and says where the trouble is.

Try itEdit the code and run it with @ratmath/complex and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs