How this calculation works
Count enclosed polynomial zeros with multiplicity using argument change and adaptive numerical boundary exclusion.
N=(1/2π)Δarg p(z) on a simple positively oriented zero-free contour.A worked example
z³−1 inside the square[−2,2]×[−2,2] gives argument change6π and zero count3.
Good to know
Complex ascending coefficient pairs degree1–10,simple polygon3–50vertices,nonzero boundary exclusion by derivative disks and subdivision. Floating safety margin,not formal interval certification;unresolved boundaries error.
Reference: MIT argument principle notes (opens in a new tab) ↗
Count enclosed roots without locating each one
The argument principle counts polynomial zeros enclosed by a closed contour using the change in complex argument around its boundary. Multiplicities are included. This page applies that idea to a simple polygon and a polynomial with complex coefficients,without claiming to identify each individual enclosed root.
A real-root interval count answers a different question. A contour can enclose nonreal roots,and its boundary orientation changes the signed winding even though the unsigned number of enclosed zeros stays the same. The page reports both quantities so those conventions are explicit.
Compare this with the Sturm sequence calculator for a real-root count in an interval. Count complex polynomial zeros enclosed by a simple polygon contour,not real roots in an interval.
Specify coefficients and a simple boundary
Enter one real,imaginary pair for each coefficient,starting with the constant term. The leading coefficient must be nonzero and the degree at most ten. Polygon vertices are also real,imaginary coordinate pairs,listed in traversal order;the last vertex is joined to the first automatically.
The contour must be simple,with nonzero area and no consecutive duplicate vertices. Crossings and self contacts are rejected because their winding interpretation differs from the ordinary inside-region count promised here. A repeated final copy of the first vertex is removed before the boundary checks.
Why boundary zeros are excluded
A polynomial that vanishes on the contour has no continuous nonzero argument along that boundary,so the ordinary argument-principle count is not defined in this form. A near-boundary root can also make a numerical winding estimate unreliable unless subdivision controls the image of each segment.
The implementation therefore does more than sample a fixed set of angles. It attempts to prove local exclusion using a derivative bound and subdivides where that test is unresolved. Reaching the depth or work limit raises an error rather than rounding an uncertain angular sum into a convincing integer.
Control each segment's image
For a straight segment,the midpoint polynomial value is compared with a disk radius derived from a bound on the polynomial derivative over the segment. If that disk excludes zero,its image stays in a region with an unambiguous argument increment. The endpoint arguments can then be joined without guessing a branch jump.
The derivative bound uses coefficient magnitudes and the maximum endpoint modulus,which bounds moduli along the segment. It is conservative and can require many subdivisions. The calculations use floating arithmetic and a safety margin,so this is a numerical exclusion diagnostic,not formal outward-rounded interval certification.
A cubic gives three enclosed zeros
The default polynomial is z³−1 and the contour is the square with corners(−2,−2),(2,−2),(2,2),(−2,2). All three unit-circle roots lie inside. Counterclockwise traversal gives total argument change6π and signed winding three,so the reported zero count is three.
Reversing the vertex order changes the argument sum to−6π and the signed winding to minus three. The ordinary enclosed-root count remains three because the polygon orientation is accounted for. This is a useful independent convention check that does not require displaying the complex roots themselves.
Consistency checks remain distinct from proof
The final angular sum divided by2π must lie close to an integer,and its sign must agree with the polygon orientation. These checks catch unresolved winding or branch inconsistencies. They do not make every floating derivative estimate a theorem,which is why the output explicitly states its numerical character.
Repeated roots are counted with multiplicity because that is how the polynomial winds near a zero. Poles are absent for a polynomial;the routine is not a general meromorphic zero-minus-pole counter. A rational-function extension would need to handle denominator zeros and boundary exclusion separately.
Use the result under its contour assumptions
The returned count,orientation,argument change and number of accepted segments describe the completed boundary calculation. A count of zero means no polynomial zeros lie in the contour interior under the successful numerical checks;it is not a statement about the entire complex plane or about nearby perturbed coefficients.
For roots extremely close to the contour,move the boundary away when mathematically appropriate or use a certified complex-root package. Preserve the coefficient order,polygon vertices,orientation and any exclusion warning with the result. Never replace an unresolved boundary-zero error with a manually rounded winding number.
A few questions, answered
Are repeated roots counted once?
They are counted with algebraic multiplicity.
Does clockwise order change the root count?
It reverses signed winding,but the orientation-corrected enclosed count is unchanged.
What if a zero is on the boundary?
The method cannot return the ordinary interior count;boundary exclusion remains unresolved and errors.
Does the page locate the roots?
No. It counts enclosed zeros without returning each root location.