# Hackery, Math & Design

## Steven Wittens i # How to Fold a Julia Fractal

## A tale of numbers that like to turn

"Take the universe and grind it down to the finest powder and sieve it through the finest sieve and then show me one atom of justice, one molecule of mercy. And yet," Death waved a hand, "And yet you act as if there is some ideal order in the world, as if there is some… some rightness in the universe by which it may be judged."
The Hogfather, Discworld, Terry Pratchett

Mathematics has a dirty little secret. Okay, so maybe it's not so dirty. But neither is it little. It goes as follows:

Everything in mathematics is a choice.

You'd think otherwise, going through the modern day mathematics curriculum. Each theorem and proof is provided, each formula bundled with convenient exercises to apply it to. A long ladder of subjects is set out before you, and you're told to climb, climb, climb, with the promise of a payoff at the end. "You'll need this stuff in real life!", they say, oblivious to the enormity of this lie, to the fact that most of the educated population walks around with "vague memories of math class and clear memories of hating it."

Rarely is it made obvious that all of these things are entirely optional—that mathematics is the art of making choices so you can discover what the consequences are. That algebra, calculus, geometry are just words we invented to group the most interesting choices together, to identify the most useful tools that came out of them. The act of mathematics is to play around, to put together ideas and see whether they go well together. Unfortunately that exploration is mostly absent from math class and we are fed pre-packaged, pre-digested math pulp instead.

And so it also goes with the numbers. We learn about the natural numbers, the integers, the fractions and eventually the real numbers. At each step, we feel hoodwinked: we were only shown a part of the puzzle! As it turned out, there was a 'better' set of numbers waiting to be discovered, more comprehensive than the last.

Along the way, we feel like our intuition is mostly preserved. Negative numbers help us settle debts, fractions help us divide pies fairly, and real numbers help us measure diagonals and draw circles. But then there's a break. If you manage to get far enough, you'll learn about something called the imaginary numbers, where it seems sanity is thrown out the window in a variety of ways. Negative numbers can have square roots, you can no longer say whether one number is bigger than the other, and the whole thing starts to look like a pointless exercise for people with far too much time on their hands.

I blame it on the name. It's misleading for one very simple reason: all numbers are imaginary. You cannot point to anything in the world and say, "This is a 3, and that is a 5." You can point to three apples, five trees, or chalk symbols that represent 3 and 5, but the concepts of 3 and 5, the numbers themselves, exist only in our heads. It's only because we are taught them at such a young age that we rarely notice.

So when mathematicians finally encountered numbers that acted just a little bit different, they couldn't help but call them fictitious and imaginary, setting the wrong tone for generations to follow. Expectations got in the way of seeing what was truly there, and it took decades before the results were properly understood.

Now, this is not some esoteric point about a mathematical curiosity. These imaginary numbers—called complex numbers when combined with our ordinary real numbers—are essential to quantum physics, electromagnetism, and many more fields. They are naturally suited to describe anything that turns, waves, ripples, combines or interferes, with itself or with others. But it was also their unique structure that allowed Benoit Mandelbrot to create his stunning fractals in the late 70s, dazzling every math enthusiast that saw them.

Yet for the most part, complex numbers are treated as an inconvenience. Because they are inherently multi-dimensional, they defy our attempts to visualize them easily. Graphs describing complex math are usually simplified schematics that only hint at what's going on underneath. Because our brains don't do more than 3D natively, we can glimpse only slices of the hyperspaces necessary to put them on full display. But it's not impossible to peek behind the curtain, and we can gain some unique insights in doing so. All it takes is a willingness to imagine something different.

So that's what this is about. And a lesson to be remembered: complex numbers are typically the first kind of numbers we see that are undeniably strange. Rather than seeing a sign that says Here Be Dragons, Abandon All Hope, we should explore and enjoy the fascinating result that comes from one very simple choice: letting our numbers turn. That said, there are dragons. Very pretty ones in fact.

## Like Hands on a Clock

What does it mean to let numbers turn? Well, when making mathematical choices, we have to be careful. You could declare that $1 + 1$ should equal $3$, but that only opens up more questions. Does $1 + 1 + 1$ equal $4$ or $5$ or $6$? Can you even do meaningful arithmetic this way? If not, what good are these modified numbers? The most important thing is that our rules need to be consistent for them to work. But if all we do is swap out the symbols for $2$ and $3$, we didn't actually change anything in the underlying mathematics at all.

So we're looking for choices that don't interfere with what already works, but add something new. Just like the negative numbers complemented the positives, and the fractions snugly filled the space between them—and the reals somehow fit in between that—we need to go look for new numbers where there currently aren't any.

We'll start with the classic real number line, marked at the integer positions, and poke around.
We imagine the line continues to the left and right indefinitely.

$$\class{blue}{2} + \class{green}{3} = \class{red}{5}$$

But there's a problem with this visualization: by picturing numbers as points,
it's not clear how they act upon each other.
For example, the two adjacent numbers $\class{blue}{2} + \class{green}{3}$ sum to $\class{red}{5}$ …

$$\class{blue}{-2} + \class{green}{-1} = \class{red}{-3}$$

… but the similarly adjacent pair $\class{blue}{-2} + \class{green}{-1} = \class{red}{-3}$.
We can't easily spot where the red point is going to be based on the blue and green.

A better solution is to represent our numbers using arrows instead, or vectors.
Each arrow represents a number through its length, pointing right/left for positive/negative.

The nice thing about arrows is that you can move them around without changing them.
To add two arrows, just lay them end to end. You can easily spot why $\class{blue}{-2} + \class{green}{-1} = \class{red}{-3}$ …

… and why $\class{blue}{2} + \class{green}{3} = \class{red}{5}$, similarly.
As long as we apply positives and negatives correctly, everything still works.

$$\times \class{green}{1.5} ...$$

Now let's examine multiplication. We're going to start with $\class{blue}{1}$ and then we'll multiply it by $\class{green}{1.5}$ repeatedly.

With every multiplication, the vector gets longer by 50 percent.
These vectors represent the numbers $\class{red}{1}, \class{red}{1.5}, \class{red}{2.25}, \class{red}{3.375}$, $\class{red}{5.0625}$, a nice exponential sequence.

$$\times (\class{green}{-1.5}) ...$$

Now we're going to do the same, but multiplying by the negative, $\class{green}{-1.5}$, repeatedly.

The vectors still grow by 50%, but they also flip around, alternating between positive and negative.
These vectors represent the sequence $\class{red}{1}, \class{red}{-1.5}, \class{red}{2.25}, \class{red}{-3.375}, \class{red}{5.0625}$.

But there's another way of looking at this. What if instead of flipping from positive to negative, passing through zero, we went around instead, by rotating the vector as we're growing it?

We'd get the same numbers, but we've discovered something remarkable: a way to enter and pass through the netherworld around the number line. The question is, is this mathematically sound, or plain non-sense?

$$+180^\circ$$
$$0^\circ$$

The challenge is to come up with a consistent rule for applying these rotations. We start with normal arithmetic. Multiplying by a positive didn't flip the sign, so we say we rotated by $0^\circ$. Multiplying by a negative flips the sign, so we rotated by $\class{green}{180^\circ}$. The lengths are multiplied normally in both cases.

$$\times \class{green}{1.5 \angle 90^\circ} ...$$
$$+90^\circ$$
$$+270^\circ$$

Now suppose we pick one of the in-between nether-numbers, say the vector of length $1.5$, at a $90^\circ$ angle. What does that mean? That's what we're trying to find out! We'll write that as $\class{green}{1.5 \angle 90^\circ}$ (1.5 at 90 degrees). It could make sense to say that multiplying by this number should rotate by $\class{green}{90^\circ}$ while again growing the length by 50%.

This creates the spiral of points: $\class{red}{1 \angle 0^\circ}$, $\class{red}{1.5 \angle 90^\circ}$, $\class{red}{2.25 \angle 180^\circ}$, $\class{red}{3.375 \angle 270^\circ}$, $\class{red}{5.0625 \angle 360^\circ}$. Three of those are normal numbers: $+1$, $-2.25$ and $+5.0625$, lying neatly on the real number line. The other two are new numbers conjured up from the void.

$$+135^\circ$$
$$+45^\circ$$
$$+225^\circ$$
$$+315^\circ$$
$$\times \class{green}{1 \angle 45^\circ} ...$$

Let's examine this rotation more. We can pick $1$ at a $\class{green}{45^\circ}$ angle. Multiplying by a $1$ probably shouldn't change a vector's length, which means we'd get a pure rotation effect.

By multiplying by $\class{green}{1 \angle 45^\circ}$, we can rotate in increments of $45^\circ$.
It takes 4 multiplications to go from $+1$, around the circle of ones, and back to the real number $-1$.

And that's actually a remarkable thing, because it means our invented rule has created a square root of $-1$.
It's the number $\class{green}{1 \angle 90^\circ}$.

$(\class{green}{1 \angle 90^\circ})^2 = \class{blue}{-1}$

If we multiply it by itself, we end up at angle $\class{green}{90} + \class{green}{90} = \class{blue}{180^\circ}$, which is $\class{blue}{-1}$ on the real line.

But actually, the same goes for $\class{green}{1 \angle 270^\circ}$.

$(\class{green}{1 \angle 270^\circ})^2 = \class{blue}{-1}$

When we multiply it by itself, we end up at angle $\class{green}{270} + \class{green}{270} = \class{blue}{540^\circ}$. But because we went around the circle once, that's the same as rotating by $\class{blue}{180^\circ}$. So that's also equal to $\class{blue}{-1}$.

$$\pm180^\circ$$
$$0^\circ$$
$$-90^\circ$$
$$+90^\circ$$
$$-135^\circ$$
$$-45^\circ$$
$$+135^\circ$$
$$+45^\circ$$
$(\class{green}{1 \angle -90^\circ})^2 = \class{blue}{-1}$

Or we could think of $+270^\circ$ as $-90^\circ$, and rotate the other way. It works out just the same. This is quite remarkable: our rule is consistent no matter how many times we've looped around the circle.

$(\class{green}{1 \angle 90^\circ})^2 = \class{blue}{-1}$
$(\class{green}{1 \angle 270^\circ})^2 = \class{blue}{-1}$

Either way, $\class{blue}{-1}$ has two square roots, separated by $180^\circ$, namely $\class{green}{1 \angle 90^\circ}$ and $\class{green}{1 \angle 270^\circ}$.
This is analogous to how both $2$ and $-2$ are square roots of $4$.

$$\class{blue}{a} \cdot \class{green}{b} = \class{red}{c}$$

Complex multiplication can then be summarized as: angles add up, lengths multiply, taking care to preserve clockwise and counterwise angles. Above, we multiply two random complex numbers a and b to get c.

$$\class{blue}{a} \cdot \class{green}{b} = \class{red}{c}$$

When we start changing the vectors, c turns along, being tugged by both a and b's angles. It wraps around the circle, while its length changes. Hence, complex numbers like to turn, and it's this rule that separates them from ordinary vectors.

$$\hspace{35 pt} +$$
$$- \hspace{35 pt}$$

We can then picture the complex plane as a grid of concentric circles. There's a circle of ones, a circle of twos, a circle of one-and-a-halfs, etc. Each number comes in many different versions or flavors, one positive, one negative, and infinitely many others in between, at arbitrary angles on both sides of the circle.

$$\pm180^\circ$$
$$0^\circ$$
$$+90^\circ$$
$$\hspace{15pt} \class{blue}{i}$$

Which brings us to our reluctant and elusive friend, $\class{blue}{i}$. This is the proper name for $\class{blue}{1 \angle 90^\circ}$, and the way complex numbers are normally introduced: $i^2 = -1$. The magic is that we can put a complex number anywhere a real number goes, and the math still works out, oddly enough. We get complex answers about complex inputs.

Complex numbers are then usually written as the sum of their (real) X coordinate, and their (imaginary) Y coordinate, much like ordinary 2D vectors. But this is misleading: the ugly number $\class{red}{\frac{\sqrt{3}}{2} + \frac{1}{2}i }$ is actually just $\class{green}{1 \angle 30^\circ}$ in disguise, and it acts more like a $1$ than a $\frac{1}{2}$ or $\frac{\sqrt{3}}{2}$. While knowing how to convert between the two is required for any real calculations, you can cheat by doing it visually.

$$\pm180^\circ$$
$$0^\circ$$
$$-90^\circ$$
$$+90^\circ$$
$$-135^\circ$$
$$-45^\circ$$
$$+135^\circ$$
$$+45^\circ$$

$$\class{blue}{+1}$$
$$\hspace{55pt}\class{green}{+i}$$
$$\class{blue}{-1}$$

$$\class{green}{-i}\hspace{55pt}$$

But looking at individual vectors only gets us so far. We study functions of real numbers by looking at a graph that shows us every output for every input. To do the same for complex numbers, we need to understand how these numbers-that-like-to-turn, this field of vectors, change as a whole.
Note: from now on, I'll put $+1$, i.e. $0^\circ$ at the 12 o'clock position for simplicity.

When we apply a square root, each vector shifts. But really, it's the entire fabric of the complex plane that's warping. Each circle has been squeezed into a half-circle, because all the angles have been halved—the opposite of squaring, i.e. doubling the angle. The lengths have had a normal square root applied to them, compressing the grid at the edges and bulging it in the middle.

But remember how every number had two opposite square roots? This comes from the circular nature of complex math. If we take a vector and rotate it $360 ^\circ$, we end up in the same place, and the two vectors are equal. But after dividing the angles in half, those two vectors are now separated by only $180 ^\circ$ and lie on opposite ends of the circle. In complex math, they can both emerge.

Complex operations are then like folding or unfolding a piece of paper, only it's weird and stretchy and circular. This can be hard to grasp, but is easier to see in motion. To help see what's going on, I've cut the disc and separated the positive from the negative angles in 3D.

When we square our numbers to undo the square root, the angles double, folding the plane in on itself. The lengths are also squared, restoring the grid spacing to normal.

After squaring, each square root has now ended up on top of its identical twin, and we can merge everything back down to a flat plane. Everything matches up perfectly.

Thus the square root actually looks like this. New numbers flow in from the 'far side' as we try and shear the disc apart. The complex plane is stubborn and wants to stay connected, and will fold and unfold to ensure this is always the case. This is one of its most remarkable properties.

There's no limit to this folding or unfolding. If we take every number to the fourth power, angles are multiplied by four, while lengths are taken to the fourth power. This results in 4 copies of the plane being folded into one.

However, things are not always so neat. What happens if we were to take everything to an irrational power, say $\frac{1}{\sqrt{2}}$? Angles get multiplied by $0.707106...$, which means a rotation of $360^\circ$ now becomes $\sim 254.56^\circ$.

Because no multiple of $360$ is divisible by $\frac{1}{\sqrt{2}}$, the circular grid never matches up with itself again no matter how far we extend it. Hence, this operation splits a single unique complex number into an infinite amount of distinct copies.

For any irrational power $p$, there are an infinite number of solutions to $z^p = c$, all lying on a circle. For a hint as to why this is so, we can look at Taylor series: an arbitrary function $f(z)$ can be written as an infinite sum $a + bz + cz^2 + dz^3 + ... \,$ When z is complex, such a sum doesn't just represent a finite amount of folds, but a mindboggling infinite origami of complex space.

We've seen how complex numbers are arrows that like to turn, which can be made to behave like numbers: we can add and multiply them, because we can come up with a consistent rule for doing so. We've also seen what powers of complex numbers look like: we fold or unfold the entire plane by multiplying or dividing angles, while simultaneously applying a power to the lengths.

## Pulling a Dragon out of a Hat

With a basic grasp of what complex numbers are and how they move, we can start making Julia fractals.

At their heart lies the following function:

$$f(z) = z^2 + c$$

This says: map the complex number $z$ onto its square, and then add a constant number to it. To generate a Julia fractal, we have to apply this formula repeatedly, feeding the result back into $f$ every time.

$$z_{n+1} = (z_n)^2 + c$$

We want to examine how $z_n$ changes when we plug in different starting values for $z_1$ and iterate $n$ times. So let's try that and see what happens.

Our region of interest is the disc of complex numbers less than $2$ in length. I've marked the circle of ones as a reference.

We take an arbitrary set of numbers, like this grid, and start applying the formula $f(z) = z^2 + c$ to each. Rather than use vectors, I'll just draw points, to avoid cluttering the diagram.

First we square each number. That is, their lengths are squared, their angles are doubled.
The squaring has a dual effect: numbers larger than $1$ grow bigger and are pushed outwards, numbers less than $1$ grow smaller and are pulled inwards.

Next, we reset the grid back to neutral, keeping the numbers in their new place.
We also pick a random value for the constant $\class{green}{c}$, e.g. $\class{green}{0.57 \angle -59^\circ}$.

Now we add $\class{green}{c}$ to each point, completing one round of Julia iteration, $f(z) = z^2 + c$. As a result, some numbers have ended up closer towards the origin (i.e. $0$), others further away from it. The combination of folding + shifting has had a non-obvious effect on the numbers.

We begin the second iteration and square each number again. Any number not inside the critical circle of $1$ in the middle will get pushed out again. The other numbers continue to linger in the middle.

If we zoom out, we can see the larger numbers are spiralling outwards and are permanently lost. The minor nudge by $\class{green}{c}$ won't be enough to bring them back.

Others remain in the middle, being drawn in, but are also at risk of being pushed out of the circle by $\class{green}{c}$.

Resetting the grid again, we add the same value $\class{green}{c}$ to our vectors again to finish. At this point, our original grid of numbers has been completely jumbled up.

If we continued this process would any numbers remain in the middle? Or would they eventually all get flung out? Unfortunately it's very hard to see what's going on while iterating forwards, because we lose track of where each point came from.

So we're going to go backwards instead. We'll establish a safe-zone of all numbers less than $2$, forming a solid disc of all those which aren't irretrievably lost. We want to know where all these numbers can possibly come from. To help track these points, I've coloured one area in a different shade.

First we have to shift the numbers again, this time in the opposite direction to subtract $c$.

Now we apply the square root to find $z_{n-1} = \pm \sqrt{z_n - c}$, which is a Julia iteration in reverse.

After one backwards iteration, the disc has been squished down into an oval at an angle.
These are all the points that will definitely stay in the middle after one iteration.

When we apply the second iteration, a pattern starts to develop. Because of the repeated unfolding, we create two bulges wherever there was previously only one.

At the same time, the square root alters the length of each number as well. As a result, we squeeze in the radial direction, scaling down earlier features as they combine with newly created ones.

After 4 iterations, we start to see the first hints of self-similarity. The shape's lobes are sprouting into spirals.

But all we've really done is narrow down our blue safe-zone to include only those points that 'survive' up to 5 Julia iterations.

Remarkably this seems to distort the fractal evenly: our highlighted circles don't stretch into ovals. This is not a coincidence. Complex operations are indeed stubborn, in that they all preserve right angles everywhere. To do so, the mapping must act like a pure scaling and rotation at every point, without shearing off in any particular direction. This is what allows the fractal to look like itself at different scales.

Skipping ahead to iteration 12, we've definitely abandoned the realm of neat, traditional geometry.
Despite curving wildly, the total mapping $z_{12}$ still has this property of evenness, which is properly referred to as a conformal mapping.

After 128 iterations, we end up with this intricate dragon-like shape, approximating the safe zone for the true fractal map $z_\infty$. The numbers that make up the blue area are the hardiest points that will survive the next 128 attempts on their life. All the others will definitely get flung out.

Yet this complicated shape is merely the result of folding over and over again, adding a simple constant in between. If we perform a forwards Julia iteration, i.e. squaring and shifting, we see this shape matches up with itself, and looks identical before and after.

For different values of $\class{green}{c}$, the fractal morphs into other shapes. There's literally an infinite variety to discover. Some sets are made up of disconnected parts. In this case, $|c|$ is large enough to push the solid disc away from the center in a single iteration, but not so far that some points can't fold back in. If $|c|$ gets much larger, the set vanishes.

For a smaller $c$, Julia sets are solid. Even a small shift in the value of $c$ can accumulate into a large difference. Here we zone in on some fluffy clouds right outside the 'solid zone'. Oddly enough, it seems when $c$ is not inside of its own Julia set, the set is not solid. Note that in this case, 128 iterations is not sufficient: large solid patches remain, which would be divided further with more iterations.

This area of fractal space is dubbed Seahorse Valley, for rather obvious reasons.

Nearby, we find these jewel-like spirals.

Buried deep inside, there are remarkable combinations of shapes, like this pearl necklace covered in something resembling palm trees.

And we can even make snowflakes. The dramatic changes due to $c$ reveal the chaotic nature of fractals. Mathematically, chaos occurs when even the tiniest change can accumulate and blow up to an arbitrarily large effect.

If we change our iteration formula, for example to a fourth power $f(z) = z^4 + c$, the entire shape changes. Because each iteration now turns one bulge into four, the resulting shape has four-fold rotational symmetry.

Again, different values of $\class{green}{c}$ make different shapes, precipitating dramatic changes.

To understand the effect of $c$ we need to make a Mandelbrot set. This is similar to a Julia set, but the formula is applied differently. We'll use $z^2 + c$ again. Instead of different starting values $z_1$, we choose different values of $c$ and start with $z_1 = 0$ every time. Because $c$ is no longer constant, the mapping stops being a simple folding operation. Each iteration is now unique and not so easy to visualize.

Because the Mandelbrot set traverses all possible values of $c$ across its surface, it has a part of every associated Julia set in it. Around any number $\class{green}{c}$ it looks like the Julia set which has that value as its constant. Here, we move towards the three-way cross at the bottom of the Mandelbrot set. The Julia set develops similar features.

Where the Mandelbrot set is round and bulbous, the Julia set is too.

The spirals and seahorses from earlier are located here. You can literally see the shapes on both sides of the valley evolving towards horseheads and spirals respectively. But the Mandelbrot set acts like a map to Julia sets in a much more direct way: anywhere the Mandelbrot set is filled in (blue), the corresponding Julia set is solid too. The white areas are values of $c$ which create disconnected Julia sets.

That the Mandelbrot set is a 'pixel-perfect' map of Julia sets is a big clue. It reflects that they're actually both slices of a single higher dimensional object. By viewing these slices as we travel through, we can get a vague idea of its shape and complexity. In this object, every point in the Mandelbrot set is connected to the center of the corresponding Julia set. Actually picturing this 4D object is a challenge.

But like any fractal, the Mandelbrot set also contains copies of itself, buried inside its edge. This is just one of the many varied copies. As a result, deep Mandelbrot zooms can reach astonishing levels of beauty in complexity. This is best done with specialized software that can calculate with hundreds of digits of precision.

Making fractals is probably the least useful application of complex math, but it's an undeniably fascinating one. It also reveals the unique properties of complex operations, like conformal mapping, which provide a certain rigidity to the result.

However, in order to make complex math practical, we have to figure out how to tie it back to the real world.

## Travelling without Moving

It's a good thing we don't have to look far to do so. Whenever we're describing wavelike phenomena, whether it's sound, electricity or subatomic particles, we're also interested in how the wave evolves and changes. Complex operations are eminently suited for this, because they naturally take place on circles. Numbers that oppose can cancel out, numbers in the same direction will amplify each other, just like two waves do when they meet. And by folding or unfolding, we can alter the frequency of a pattern, doubling it, halving it, or anything in between.

More complicated operations are used for example to model electromagnetic waves, whether they are FM radio, wifi packets or ADSL streams. This requires precise control of the frequencies you're generating and receiving. Doing it without complex numbers, well, it just sucks. So why use boring real numbers, when complex numbers can do the work for you?

$$w(x) = \sin(x)$$

Take for example a sine wave $w(x)$.

$$w(x, t) = \sin(x - t)$$ $$\class{blue}{\frac{\partial w(x, t)}{\partial t}}$$

For the wave to propagate across a distance, its values have to ripple up and down over time.
The rate of change over time is drawn on top. This is the vertical velocity at every point. Both the wave and its rates of change undergo a complicated numerical dance.

$$w(x, t) = \sin(x - t)$$ $$\class{blue}{\frac{\partial w(x, t)}{\partial t}} \,\, \class{green}{\frac{\partial^2 w(x, t)}{\partial t^2}}$$

But to properly describe this motion, we have to go one level deeper. We have to examine the rate of change of the vertical velocity of the wave. This is its vertical acceleration. We see that green vectors tug on blue vectors as blue vectors tug on the wave.

$$w(x, t) = \sin(x - t)$$ $$\class{green}{\frac{\partial^2 w(x, t)}{\partial t^2}} = \,?$$

It's easier to see what's going on if we center the vectors vertically. The acceleration appears to be equal but opposite to the wave itself.

$$w(x, t) = \sin(x - t) + 1$$ $$\class{green}{\frac{\partial^2 w(x, t)}{\partial t^2}} = \,?$$

But that's just a lucky coincidence. If we shift the wave up by one unit, its opposite shifts down by a unit. Yet its velocity and acceleration are unaltered. So acceleration is not simply the opposite of the wave.

What's actually going on is that the green vectors match the curvature of the wave, positive inside valleys, negative on top of crests. Intuitively, this can be explained by saying that waves tend to bounce towards an average level: this is going to pull the value up out of valleys and down from peaks.

$$w(x, t) = \sin(x - t) + 1$$ $$\class{green}{\frac{\partial^2 w(x, t)}{\partial t^2}} = \class{red}{\frac{\partial^2 w(x, t)}{\partial x^2}}$$

But curvature is the rate of change of the slope, and slope is the rate of change over a distance. So to describe real waves, we need to relate 'second level' change over time and change over distance, each deriving twice. This is Complicated with a capital C.

Let's try this with complex numbers instead. Until now, we had a 2D graph, showing the real value of the wave over real distance. We're going to make the wave's value complex. Mapping a 1D number (distance) to a 2D number (the wave function), means we need a 3D diagram.

The complex plane is mapped into the old Y direction (real) and the new Z direction (imaginary).

$$w(x) = (1 \angle x)$$

To make a complex wave, we do the thing complex numbers are best at: we make them turn, and make a helix. In this case, our wave function is simply the variable number $1 \angle x$ , a constant length with a smoothly changing rotation over distance.

$$w(x, t) = (1 \angle x) \cdot (1 \angle t) = 1 \angle (x + t)$$
$$\class{blue}{\frac{\partial w(x, t)}{\partial t}} = \,?$$

To make the wave move, we can simply twist it in-place. Which we now know is the same as multiplying by an increasing angle $1 \angle t$. If we plot the complex velocity of each point, at first sight this might not look any simpler than the real wave. But in fact, these vectors are not changing in length at all, unlike the real version. As the wave is pulled by the velocity vectors, both undergo a pure rotation.

$$\class{blue}{\frac{\partial w(x, t)}{\partial t}} = i \cdot w(x, t)$$

At all times, the velocity is offset by $90^\circ$ from the wave itself. And that means that described in complex numbers, wave equations are super easy. Instead of involving two derivatives, i.e. the rate of rate of change, we only need one. There is a direct relationship between a value and its rate of change. The necessary rotation by $90^\circ$ can then be written simply as multiplying by $i$.

To recover a real wave from a complex wave, we can simply flatten it back to 2D, discarding the imaginary part. By using complex numbers to describe waves, we give them the power to rotate in place without changing their amplitude, which turns out to be much simpler.

$$\frac{1}{2} (\class{blue}{ 1 \angle (x + t) } + \class{green}{ 1 \angle -(x + t) }) = \cos(x + t)$$

In fact, flattening the wave has a perfectly reasonable complex interpretation: it's what happens when we average out a counter-clockwise wave (positive frequency) with a clockwise wave (negative frequency). By twisting each in opposite directions, the combined wave travels along, locked to the real number line.

$$\frac{1}{2} (\class{blue}{ 1 \angle (x + t) } + \class{green}{ 1 \angle -(\frac{3}{2}x + t) }) = \,?$$

But if we add up two arbitrary complex frequencies, their sum immediately turns into a spirograph pattern that manages to evolve and propagate, even as it just rotates in place. Though the original waves both had a constant amplitude of $1$, the relative differences in angles (i.e. the phase) allows them to cancel out in surprising ways.

Neither curve is actually moving forward: they're just spinning in place, creating motion anyway. This is actually what quantum superposition looks like, where two or more complex probability waves combine and interfere. Where the result cancels out to zero, that's where two separate possible states are cancelling out each other, creating interference. That the underlying numbers are complex doesn't prevent them from describing real physics, indeed, it seems that's how nature actually works.

This serene display hides a whirlwind of phase. We can plot the velocity of the two frequencies, and their combination, scaled down for clarity. Once again you can see the power of describing waves with complex numbers, letting you split up a complicated motion into simple, repetitive rotations… into numbers that like to turn.

## The End Is Just The Beginning

In visualizing complex waves, we've seen functions that map real numbers to complex numbers, and back again. These can be graphed easily in 3D diagrams, from $\mathbb{R}$ to $\mathbb{C}$ or vice-versa. You cross 1 real dimension with the 2 dimensions of the complex plane.

But complex operations in general work from $\mathbb{C}$ to $\mathbb{C}$. To view these, unfortunately you need four-dimensional eyes, which nature has yet to provide. There are ways to project these graphs down to 3D that still somewhat make sense, but it never stops being a challenge to interpret them.

For every mathematical concept that we have a built-in intuition for, there are countless more we can't picture easily. That's the curse of mathematics, yet at the same time, also its charm.

Hence, I tried to stick to the stuff that is (somewhat!) easy to picture. If there's interest, a future post could cover topics like: the nature of $e^{ix}$, Fourier transforms, some actual quantum mechanics, etc.

For now, this story is over. I hope I managed to spark some light bulbs here and there, and that you enjoyed reading it as much as I did making it.