In recent posts I’ve presented the complex numbers and the complex plane. Those were just stepping stones to this post, which involves a basic fact about the Mandelbrot set. It’s something that I stumbled over recently (after tip-toeing around it many times, because math).
This is one of those places where something that seems complicated turns out to have a fairly simple (and kinda cool) way to see it when approached the right way. In this case, it’s the way multiplication rotates points on the complex plane. This allow us to actually visualize certain equations.
With that, we’re ready to move on to the “heart” of the matter…
To begin with, here’s what inspired these posts:
Don’t worry, it’s not as bad as it looks (although I admit I tip-toed around it myself). It turns out there’s a way of thinking about it visually that makes it a lot less mysterious.
What the formula describes is a cardioid curve drawn on the complex plane. When graphed, it looks like this:
That red curve happens to also be the boundary of the main cardioid of the Mandelbrot. All points inside the curve are guaranteed to be in the Mandelbrot set. (Which is why I was interested in all this. Normally these points have to be calculated to the max iteration limit to show they’re in the set. That takes time.)
In the equation above, the two variables, c and u, each represent an infinite set of complex numbers. The result, c, is all the points on the cardioid curve. The input, u, is all the points of the unit circle.
[The unit circle is just a circle with a radius of one centered on the origin. It is related to the unit square mentioned last time in that points inside operate differently from points outside.]
We can’t compute with infinite sets, so how this actually works is that, as explained in the last post, we generate a bunch of points for u — the more we generate, the finer the resolution (the smoother the curve) of the cardioid we’ll create.
We might, for example, generate a point for every degree around the circle. That gives us 360 points (complex numbers). Then we execute the formula above with each point, which gives us 360 results — 360 points that are in the cardioid.
We can do this with more or fewer points, depending on how smooth we want the cardioid curve to be. (The graph above was done with 360 points along each curve.)
None of which involves the simple way to see what’s happening.
It describes the algorithmic process of generating a cardioid curve, but it doesn’t provide much sense of how or why the curve emerges.
To see that we need to think visually about what the formula means.
We start with the set of infinite points represented by u — the unit circle.
When we see u in the equation, we visualize a circle with a radius of one centered on the origin. Then we ask what the equation does to that circle.
The first thing that happens is that u, in both cases, is divided by 2. Conceptually, what might a circle-divided-by-two be? Invert the idea; what might it mean to multiply a circle by some number?
One logical result is to make the circle bigger or smaller. Dividing is inverse multiplying, so it would likewise affect the circle’s size.
Therefore, u/2 in the equation means a half-sized circle. Now when we see u/2 in the equation, we think of a circle with a radius of one-half (still centered on the origin).
The graph above shows the half-size circle in gray.
Now we can consider the part inside the parentheses. What does one-minus-a-half-circle mean?
We can again think about this in a different form: what about adding one to the circle? What would that do?
There’s a fine point in the section above I skipped past. Previously I said that multiplying points on the complex plane rotates them, but here I said multiplying the point of the unit circle changes the size.
Recall that, in addition to rotating, multiplying also changes the distance from the center (“magnitude”) unless one (or both) of the points has a magnitude of 1.0. By definition, all points in the unit circle do have a magnitude of 1.0 — that’s what the unit circle is.
When we divide by 2, what we’re really dividing by is the complex number (+2, 0i), which lies on the positive x-axis — therefore its angle is zero. So the multiplication preserves the angle of the points in the circle while the real value shrinks or expands the size.
Likewise, when we add one, we’re really adding the complex number (+1, 0i). Addition is member-wise, so this just adds 1.0 to the real parts of all the points in the unit circle. That shifts each point to the right by 1.0 — the whole circle shifts right.
Subtracting the circle from (+1.0, 0i) has a slightly different effect. Think about what we get with four key points (the four cardinal points):
- “12 o’clock”: (+1.0, 0.0i) – (0.0, +0.5i) = (+1.0, -0.5i)
- “3 o’clock”: (+1.0, 0.0i) – (+0.5, 0.0i) = (+0.5, 0.0i)
- “6 o’clock”: (+1.0, 0.0i) – (0.0, -0.5i) = (+1.0, +0.5i)
- “9 o’clock”: (+1.0, 0.0i) – (-0.5, 0,0i) = ( +1.5, 0.0i)
The right edge of the circle stays where it is, the center moves right to 1.0, and the left edge moves from -0.5 all the way right to +1.5. Also, the top is flipped to the bottom and vice versa.
The circle has again moved one unit to the right, and it has been reversed both horizontally and vertically.
On the gray half-size circle (also on the light blue unit circle), the point at “3 o’clock” is the start of the circle, the point with the angle zero. The angle of the circle increases moving counter-clockwise, so “12 o’clock” is 90°, “9 o’clock” is 180°, and “6 o’clock” is 270°.
The red circle is reversed, so its zero angle is at its “9 o’clock”. The angle still increases in the counter-clockwise direction, so “6 o’clock” is 90° and so on.
Remember that the zero-angle point of both circles is the same — it’s where the two circles touch.
So our equation amounts to a half-size circle multiplied by another half-size circle that’s been reflected to the right.
All we have to do now is figure out what it means to multiply one circle by another.
Previously we modified the circle with a fixed quantity — dividing by two or adding one. Now we’re multiplying two circles. What does that even mean?
It means we multiply points in one by the matching points in the other. How do we match up points to multiply? By their angle. We multiply together points with the same angle.
What makes it a little interesting is that, while the points on the centered half-size circle (gray) have the angles just described, since the reflected circle (red) is no longer centered, the angle to its points is different:
The diagram above shows the angle to eight points around the reflected circle. Angle is always from the origin. (So is magnitude.)
Remember that the red circle “starts” at the “9 o’clock” position and goes counter-clockwise from there. So the point angle slowly increases in the negative direction and then returns to zero at the “3 o’clock” position.
The angle to the points on the upper half of the circle is positive, again slowly increasing and then returning to zero.
Note that when determining which points match, we use the original angles as first described above. But when multiplying points, we consider their actual angles as described here.
Note also the lengths (magnitudes) of the red lines. Roughly half of them have a magnitude less than 1.0 and half of them are greater. The ones that are less will shrink the magnitudes of points we multiply, and the ones that are greater will increase the magnitude. This is part of where the shape of the cardioid comes from.
The idea is the same as described for generating points to draw the cardioid. Conceptually infinite points, but we pick as many actual points as makes sense for our need.
It turns out that when we multiply these points, the resulting set of points describe a cardioid curve.
Remember that multiplying one point by another creates a new point that sums the angles and multiplies the magnitudes.
On the centered half-size circle (gray) the magnitude is always 0.5, so one part of that multiplication is one-half times something. The other part, the reflected circle (red), as we saw above, offers magnitudes that change from 0.5 to 1.5 and back.
This immediately gives us some sense that the resulting curve will be lopsided, starting with a smaller magnitude that grows to maximum at the 180° point and then gets smaller. Exactly like a cardioid.
We can also see that the angle of the cardioid points is retarded in the first half (by the negative angle to the red circle) and advanced (by the positive angle) in the second half. These effects on magnitude and angle give us the cardioid curve.
Some specific cases to illustrate how we do this:
The first points are where the two half-sized circles touch, the (original) zero angle. The point is: [+0.5, 0i].
Both points have zero angle, both have magnitudes of 0.5. Multiplying them rotates by zero degrees. Multiplying the magnitudes gives us 0.25, so the new point is [+0.25, 0i]. And, sure enough, that’s the “widow’s peak” of the cardioid.
To keep things easy, if we jump to the opposite side of both circles, the first point is [-0.5, 0i] (with an angle of 180°) and the second point is [+1.5, 0i], with an angle of zero, so there is no rotation, and the resulting point has the same 180° angle as the first point.
We’re multiplying a magnitude of -0.5 times +1.5, which gives us -0.75, so the resulting point, halfway around the cardioid, is at [-0.75, 0i] (which turns out to be a special point in the Mandelbrot; more on that another time).
Now a slightly harder one, the “12 o’clock” point on the first circle matches the “6 o’clock” point on the second. The first point has an angle of 90° and the other (from the origin to the bottom of the red circle) has an angle of just over -26° and a magnitude just under 1.12.
So the new point is rotated backwards (clockwise) by -26° and has a magnitude of about 0.56. Here’s what that looks like:
The purple point is the point on the cardioid curve. Its angle is the the 90° of the blue point plus the negative angle of the red point.
The magnitude of the red point is a bit greater than 1.0, so the purple point has a larger magnitude than the blue point. You can see it’s just beyond the half-size circle boundary.
This turned out to be harder to explain than I’d anticipated, so I made an animation to show the process:
Note how the purple point is always between the blue and red points (because it combines their angles).
All-in-all, I thought it was an interesting illustration of the geometric nature of the complex plane. It’s also a good example of how, at least sometimes, we can think about math visually.
BTW: If you look at the Wiki page for cardioid, you’ll find there are many ways to generate this curve. It is, in some regards, a fundamental emergent structure.
Stay heartful, my friends!