Complex polynomial toy (with derivatives) documentation

This is the documentation for the complex polynomial toy (with derivatives), an interactive program for domain coloring of polynomials and their derivatives, along with a feature to experiment with the idea behind a proof that every non-constant polynomial has at least one complex root. Plotting derivatives is meant to illustrate the Gauss-Lucas theorem.

The program was created September 2018 as a modification of an earlier program with only domain coloring. A version with an expanded palette of functions is zgraph.

This documentation has been barely modified from earlier documentation.

1. Basic usage

Type in a polynomial (for instance, x(x+2i)^2+1) in the text box in the upper left corner and press Enter. Drag the radius of the circle (reiθ) on the left side around to see its image (p(reiθ)) on the right.

One reason every polynomial has a root is that for large radii the image will wrap around zero degp times, but for very small radii the image will wrap tightly around p(0) — and, if it is not already the case that p(0)=0, somewhere in between the image must pass through zero. Arrow keys animate the domain coloring.

Left click
Places the radius point for the circle.
Right click
Places the center point for the circle.
Scroll wheel
Moves the radius point around the center.
Left arrow and Right arrow
Adjust the animation speed of the argument coloring. Right arrow makes the rainbow rotate counterclockwise around zeros.
Down arrow and Up arrow
Adjust the animation speed of the contour lines. Up arrow makes the contours move away from zeros.

2. Details

This is a description of the earlier version of the program. This particular version uses domain coloring of a polynomial of a polar grid superimposed on the domain coloring of the derivative of the polynomial.

The left view is the domain of the polynomial, and the right view is the codomain. For the codomain, as in an Argand diagram, each pixel corresponds to a particular complex number, where the hue represents the argument of the complex number, and where the magnitude is represented via gray contours of constant magnitude. The contours are logarithmically spaced, meaning the magnitude changes by a constant multiplicative factor between consecutive contours.

For the domain, each pixel is colored by “pulling back” the coloring of the codomain through the polynomial p. Concretely, to color a given a pixel, consider its corresponding complex number x, calculate p(x), and see what color would lie under p(x) in the codomain.

The codomain has a hue singularity at 0, where the rainbow wraps around it once. Everywhere you see a similar hue singularity in the domain you are seeing a root of the polynomial. You can experiment with this by moving around the radius of the circle as a test point, since its position in the codomain is its image.

Some things to try:

The roots of the derivative p(x) appear in the form of cusps on the image curve.

3. The fundamental theorem of algebra

Polynomials are what you get through addition, subtraction, and multiplication of constants and unknowns. Many problems come down to finding roots, the values you can assign to the unknown so that polynomial evaluates to 0. Some polynomials apparently have no roots, for instance x2+1, which is positive for all real numbers x. Like the invention of negative numbers, we can just imagine this polynomial to have roots at some imaginary numbers, i and i, where i is formally the square root of 1.

This is not particularly intuitive on the face of it, but there is some intuition to be found.

Question: what does multiplication by 1 really do to the number line? The first option is that we imagine multiplication by 1 reflects the number line through 0, which is a defensible position. But consider the second option, where multiplication is rotation by 180 through something outside the real numbers. The square root of a rotation by 180 is counterclockwise rotation by 90 or by 90, since performing such a quarter turn twice yields a half turn.

The complex numbers are a two-dimensional number system extending the real numbers with additional numbers for rotations. Multiplication by a real number corresponds to scaling the real line, whereas multiplication by complex numbers corresponds scaling and rotation of the complex plane.

Where real numbers can be thought of as being 1×1 transformation matrices, one way to imagine complex numbers is as 2×2 transformations matrices that are linear combinations of a scaling matrix and a rotation matrix. Every such matrix is of the form

(abba)=a(1001)+b(0110), which is a linear combination of the identity matrix and a rotation by 90 counterclockwise. In the terser, more classical notation, this is represented as a+bi. Polar form reiθ is the representation of a complex number as a product (rather than a sum) of a scaling matrix and a rotation matrix, where we define eiθ=cosθ+isinθ, whose matrix is rotation by θ counterclockwise.

The vague intuition is that the additional rotations let us go around things, letting us encircle and thereby bind the roots for us to isolate. The real numbers merely gave us the power to sometimes be on the other side of something (giving the Intermediate Value Theorem).

For varying θ, reiθ traces out a circle on the complex plane, where we plot numbers a+bi as points (a,b). We can feed this circle to a polynomial, yielding some closed loop p(reiθ). The winding number of the loop p(reiθ) is the net number of times this loop wraps around 0=0+0i, assuming the loop does not pass through 0, where we count counterclockwise wrappings positively and clockwise wrappings negatively. There is a line integral to calculate winding number. For large enough r, one can show that the winding number equals the degree of the polynomial (the largest exponent in the expanded form of the polynomial). For r=0, the winding number is 0, supposing p(0)0. Since the winding number is an integer, somewhere in between a catastrophe must occur, where the closed loop actually passes through 0. This is indicates a root.

4. Language reference

The program accepts standard computer math notation for expressions that are a polynomial in the variable x. Due to the way the program is implemented, the maximum degree for polynomials is arbitrarily set to 22. For the following language description, let a and b represent valid expressions.

x
The variable the expression is a function of.
a sequence of digits 09 with at most one decimal point
Interpreted as the corresponding floating-point number.
i
The imaginary unit i=1, which we imagine to be ninety degrees counterclockwise from 1.
a + b
Addition.
a - b
Subtraction.
-a
Negation.
+a
Unary plus (no effect).
a b or a * b
Multiplication.
a / b
Division, where b must be a nonzero constant.
a ^ b
Exponentiation, where b must be a non-negative integer constant.
(a)
Parenthetical grouping.

This is the formal grammar:

sum = ["+"|"-"] prod {("+"|"-") prod}.
prod = exp {["*"|"/"] exp}.
exp = term ["^" "num"].
term = "(" sum ")" | "num" | "x" | "i".