A post about the exponential function being a miracle did the rounds recently, and the Hacker News comment thread brought up some debate about the miracle of Euler’s famous identity:
A while back I used to make a living teaching this stuff to high school students and university undergrads. Let me give my personal take on what’s so special about Euler’s identity.
Complex numbers are already a miracle
Let’s start with complex numbers.
The first introduction to complex numbers is usually something like, “We don’t know what is, so let’s try calling it .” As it turns out, it works. It works unreasonably well. To see what I mean, imagine we tried to do the same thing with . We’ll let’s just make up a value for it called, say, . Now consider this old teaser:
(If you’re not sure about the factorisation, try expanding it.) Obviously , so where does this “proof” go wrong? At the point it assumes dividing by the factor obeys the normal rules of algebra — it doesn’t because . We can’t just quietly add to our number system and expect any of our existing maths to work with it. On the other hand, it turns out we can (for example) write quadratic equations using and treat them just like quadratic equations using real numbers (even solving them with the same old quadratic formula).
It gets better. As anyone who’s studied complex numbers knows, after we take the plunge and say , we don’t need to invent new numbers for, e.g., (it’s ). In fact, instead of going “turtles all the way down” naming new numbers, we discover that complex numbers actually fill more gaps in the real number system. In many ways, complex numbers work better than real numbers.
isn’t just a made up thing
I’ve met a few engineers who think that and its generalisation are just notation made up by mathematicians for conveniently modelling things like rotations. I think that’s a shame because Euler’s formula is a lot more surprising than just notation.
Let’s look at some ways to calculate for real numbers. With a bit of calculus, you can figure out this Taylor series expansion around zero (also known as a Maclaurin series):
A neat thing about this series is that it’s easy to compare with the series for sin and cos. If you assume they work just as well for complex numbers as real numbers, it only takes simple algebra to show , so it’s the classic textbook proof.
Unfortunately, if you try evaluating the series on a computer, you hit numerical stability problems. Here’s another way to calculate :
Or, translated naïvely into a stupid approximation algorithm in computer code 1:
Try plugging some numbers into this function, and you’ll see it calculates approximate values for (though you might need
n in the thousands to get good results).
Now for a little leap of faith: That function only uses addition, division and multiplication, which can all
be defined and implemented for complex numbers without assuming Euler’s formula. So what if you replace
double with a complex number type, assume
everything’s okay mathematically, and try plugging in some numbers like ? Try it for yourself. Somehow everything starts cancelling out as gets bigger and gets closer to , and you get something closer and closer to .
and are miracles, too
Because mathematicians prefer to write these constants symbolically, it’s easy to forget what they really are. Imagine the real number line stretching from minus infinity to infinity. There’s one notch slightly below 3, and another notch just above 3, and for deeper reasons, these two notches are special and keep turning up in seemingly unrelated places in maths.
For example, take the series sum . It doesn’t converge, but the sum to terms (called the Harmonic function, or ) approximates . If you square the terms, the series converges, but this time appears instead of : .
Here’s some more context for why the ubiquity of and is special. “The ratio of a circle’s circumference to its diameter” and “the square root of 2” are both numbers that can’t be written down as exact decimals, but at least we can describe them well enough to define them exactly. Imagine some immortal creature tried listing all the numbers that can be mathematically defined. The list could start with all numbers that can be defined in under 10 characters, then all the numbers that can be defined in 10-20 characters, and so on. Obviously, that list never ends, but every definable number will appear on it somewhere, at some finite position. That’s what Georg Cantor called countably infinite, and he went on to prove (using a simple diagonalisation argument) that the set of real numbers is somehow infinitely bigger than that. That means most real numbers aren’t even definable.
In other words, you could say maths with numbers is based on a sea of literally indescribable chaos. Thinking of it that way, it’s amazing that the five constants in Euler’s formula get us as far as they do.
Yes, the exponential function is a miracle
I hinted that we can’t just assume that the Taylor series expansion for works for complex numbers. Here are some examples that show what I mean. First, take the series expansion of , the shape of the bell curve famous in statistics:
Of course, we can’t calculate the whole infinite sum, but we can approximate it by taking the first terms. Here’s a plot of approximations taking successively more terms. We can see the bell shape after a few dozen terms, and the more terms we add, the better it gets:
Okay, that’s a Taylor series doing what it’s supposed to. How about we try the same thing with another hump-shaped curve, ?
This time it’s like there’s an invisible brick wall at . By adding more terms, we can get as close to perfect an approximation as we like, until hits , then the approximation stops converging. The series just won’t work beyond that. But if Taylor expansion doesn’t always work for the whole real number line, can we take it for granted that the series for , and work for complex numbers?
To get some more insight, we can colour in the places in the complex plane where the Taylor series for converges. It turns out we get a perfect circle of radius 1 centred at 0:
There are two special points on the plane: and . At these points, turns into a singularity, and the series expansion simply can’t work. It’s as if the convergence region expands out from 0 until it hits these singularity points and gets stuck. The funny thing is, these singularities in the complex plane limit how far the Taylor series can work, even when if we derive it using nothing but real analysis.
It turns out that , and don’t have any problematic points in the complex plane, and that’s why we can easily use Taylor series to explore them beyond real numbers.
This is yet another example of things making more sense when analysed with complex numbers, which only makes “real” numbers look like the odd ones out. Which raises another question: if complex numbers are apparently fundamental to explaining the universe2, why do we only experience real values? Obviously, the world would be a very different place if we could eat slices of pizza, or if the flow of time had real and imaginary parts. But why the heck not?
Provably true things can still be surprising
Of course, philosophy about the physical world aside, none of this is just luck. Maths is maths and there’s no alternative universe where things work differently. That’s because there are logical reasons why all this is true.
But I don’t think that makes it less special. Arthur C. Clarke famously said that any sufficiently advanced technology is indistinguishable from magic, and I don’t think it should lose all magic as soon as someone, somewhere is smart enough to figure out how to make it work. Likewise, I don’t think mathematical theory becomes less special just because someone figures out a proof. On the contrary, it’s thanks to people wondering about these miraculous patterns that we have the calculus and complex analysis needed to understand how it all works.