Turtles and polynomials

Posted on May 25, 2026

One of my favorite books is the Oulipo inspired book 99 variations on a proof by Philip Ording. The main character of the book is the cubic polynomial

$$\relax p(x)=x^3-6x^2+9x-4.$$

In each of the 99 chapters of the book, Ording shows that the roots of p are λ = 1 and λ = 4. I was particularly caught by the geometric construction in proof 60 - a construction devised by the Austrian engineer Eduard Lill in 1867. I had a lot of fun playing around with it and understanding how and why it works. This is what I want to share with you here. We will take Ordings polynomial as our example when going through the construction.

Imagine a turtle seen from above looking to the right. Why a turtle? Well, while Lill probably didn’t think about turtles when he came up with his construction, it fits well into what is today known as turtle geometry - a way of exploring space by moving around a turtle in straight line segments. Originally, the turtle was a small educational robot.

We want the turtle to walk in a way which encodes the polynomial of interest, and we will record its path. We will refer to the resulting path as the turtle path. Here is how the turtle path is constructed:

Given a polynomial of degree n, the turtle will walk to the right the distance of the coefficient for the xn term. It then turns $90\degree$ counterclockwise before it walks the distance of the coefficient in front of the xn − 1 term. This process is then repeated going through the terms from the highest to the lowest degree (including those with 0 as coefficent). At each step the turtle first turns and then walks in the direction it is facing. When a coefficient is negative, the turtle walks backwards.

For Ordings polynomial, here is what that means:

Notice that the path here consists of 4 segments. This is because Ordings polynomial is of degree 3 and thus has 3 + 1 terms. A polynomial of degree n would yield a path consisting of n + 1 segments.

Now, the turtle has a baby turtle that was left where its parent started off. To get to its parent, it will walk like this: It starts off at some angle θ with respect to the first segment in its parents path and walks towards the line which extends the second segment. When it reaches this line, it turns at a right angle and walks towards the line which extends the third segment.

We’ll take θ to be a number between $-90\degree$ and $90\degree$, and we’ll use the convention that θ is positive in the counterclockwise direction. In the illustration above to the right, where θ is positive, the baby turtle doesn’t actually meet the second segment in its parents path. But this is OK. It will just bounce off the line which extends the second segment.

The baby turtle repeats walking in this way until it meets the line extending the final segment in its parents path. Where on this line it ends up depends on the starting angle θ. In the illustration below, you see 3 possible paths: In the red path, the baby turtle starts off at an angle of $10\degree$. In the blue path the starting angle is $-20\degree$ and in the green it is $-76\degree$.

Of course, the baby turtle wants to end up in the same position as its parent. If the starting angle θ is such that the baby turtle succeeds, then

$$\relax\lambda=-\tan(\theta)$$

is a root of the polynomial. Neat, isn’t it? But wait. It gets better!

The path of the baby turtle is itself a turtle path. Only it is rotated. It has one segment less than its parents path, so it is a turtle path for a polynomial of one degree less. In our case, the baby turtle has walked the path of a second degree polynomial. This means we can iterate the construction but now with the new path. So say there is a second baby turtle. The younger baby turtle will follow the same rules as its older sibling bouncing of the older siblings path. If it succeeds, its starting angle will give us a second root. We can keep iterating this process each time getting another root and a new turtle path belonging to a polynomial of one degree less.

Above, we have labelled the angles θ1, θ2 and θ3. The roots are thus

$$\relax\lambda_1=-\tan(\theta_1), \qquad\lambda_2=-\tan(\theta_2)\qquad\text{and}\qquad\lambda_3=-\tan(\theta_3).$$

So why does it work? One way to understand this is by watching the movement of the end point in the baby turtles path as the starting angle varies.

The video below shows an animation of the turtle construction where the starting angle θ varies from approximately $9.6\degree$ to $-78.2\degree$. Next to the construction is a coordinate system where we plot the polynomial as a function of $\relax x=-\tan(\theta)$. Play it and watch what happens. The video can be paused, played or replayed by clicking on it again.

We see that the vertical positions of the two points are perfectly aligned throughout the animation. So not only does the correct starting angles give us the roots of the polynomial. It is even better! The construction tracks the polynomial.

To get the perfect vertical alignment of the two points in the animation, the coordinatesystem is scaled so that one unit length equals one unit length in the turtle construction. And it is placed so that the x-axis is aligned with the vertical position of the end point of the parent turtle. Hence, what we see in the animation confirms our proposition: When the θ is such that the baby turtle ends up in the same position as its parent, the polynomial evaluated at $\relax-\tan{\theta}$ is zero.

Of course, it remains to understand why the vertical positions of the two points are aligned. To this end, we need to know the positions where the baby turtle hits each of the lines extending the segments in its parents path.

We start by looking at the second segment in the turtle path, which is the first segment that the baby turtle meets. We can view the line extending this segment as a copy of the real line — we just need to define where zero is and which direction is positive. We set zero at the end point of the segment (the point where the next segment intersects), and we will let the positive direction be opposite to the direction in which the turtle was facing when it walked the segment. The start point of the segment is then at a2.

Keeping track of the signs is a bit tricky. Remember that the angle θ is positive in the counterclockwise direction. In the illustration above, θ and a2 are both negative. We see that the baby turtle meets the copy of the real line in the point

$$\relax a_2-\tan(\theta).$$

Now we do the same for the remaining segments in the turtle path. We view the line extending each segment as a copy of the real line pointing in the direction opposite to the one the turtle was facing and with zero at the end point of the segment.

Generally, the baby turtle will meet the copy of the real line line extending the segment for the coefficient ak in the point ak minus $\relax \tan(\theta)$ times its previous meeting point. In the example, the baby turtle meets the copy of the real line extending the segment for the coefficient a0 in the point

$$\relax a_0-\left(a_1-\left(a_2-\tan(\theta)\right)\cdot\tan(\theta)\right)\cdot\tan(\theta).$$

As a function of $\relax x=-\tan(\theta)$, the above becomes

$$\relax a_0+\left(a_1+\left(a_2+x\right)\cdot x\right)\cdot x$$

$$\relax =x^3+a_2x^2+a_1x+a_0.$$

And that is the polynomial we started with! So this is why the end point of the baby turtle tracks the polynomial. The reason for the perfect alignment in the video was, that we had aligned and scaled our coordinate system so that it’s y-axis was aligned with the final copy of the real line in our construction.

References: