Sideband #70: The exp Function

Converging…

Back in October I published two posts involving the ubiquitous exponential function. [see: Circular Math and Fourier Geometry] The posts were primarily about Fourier transforms, but the exponential function is a key aspect of how they work.

We write it as ex or as exp(x) — those are equivalent forms. The latter has a formal definition that allows for the complex numbers necessary in physics. That definition is of a series that converges on an answer of increasing accuracy.

As a sidebar, I thought I’d illustrate that convergence. There’s an interesting non-linear aspect to it.

Because e is a transcendental number, calculations that use it usually are approximations to an acceptable precision. [There are some notable exceptions: e0=1 (by definition). Other examples include: e=-1 (which is Euler’s Identity) and ei=+1, both for reasons explained in those previous two posts. Most answers aren’t as precise, though.]

The formal definition of the exp(x) function reflects this transcendental nature. In principle, it’s an infinite series of terms. In reality, we use enough terms to give us the precision we need for a given task.

Here’s the formal definition:

The infinity symbol over the big Sigma (Σ) indicates the series continues infinitely (the n below the Sigma is the index variable; here it’s assumed to begin at zero and increase by one for each term).

The above expands to and is calculated as:

For however many terms one chooses for n.

Note that this definition makes it easy for x to be a complex number (or a quaternion… or any type that supports multiplication and division). This definition is what gives e-to-the-power-of-something so much utility, and therefore presence, in mathematics and physics.

Note that the first term is always 1 because x0=1 and 0!=1.

Likewise, the second term is always x because x1=x and 1!=1.

That’s why the definition is sometimes written as:

So the answer is always 1 if we calculate only a single term. Calculating only two isn’t much better, it just adds 1 to the input, x. It’s the later terms that start to converge on the computed value — the more terms added, the more accurate the value.

The precision of the answer and the number of terms are correlated. This correlation is not linear. Convergence is quick “near zero,” but takes longer and longer with larger values. I’ll show you what I mean by that.

§

Figure 1. exp(i2π×0.375)

The image at the top of the post (and shown again to the right here) illustrates a simple calculation for a point on the complex unit circle. Each red dot represents one more term added to the sum.

We’re calculating: ei2πa, where a=3/8 (or 0.375).

That’s a point on the complex unit circle 3/8’s of the way around (an angle of 135°). In the image, we see the black lines and red dots converging on that point. Each dot represents a calculation of n terms (beginning at one).

The first dot, on the far right of the circle, represents calculating just one term — which, of course, is just 1 (which, as a complex number, is [1+0i]).

The second dot (two terms), is 1+(i×0.375), which is the complex number [1+(~2.36)i]. That’s the second red dot in the upper right of the image.

In this case, further calculations quickly converge on approximately the right point, and calculations after that refine the value with increasing precision.

Notice that by eight terms, we’re fairly close to the correct point. By 12 terms we’re even closer, and with 20 terms we’d have a very useful answer.

§

Circles are circular, so we can calculate the same point, but after going fully around the circle (360°+135°=495°). To calculate that, we add 1.0 (one full revolution) to a, to give us a=1.375 (whereas before it was 0.375).

Going around once takes us “further from zero” (135° vs 495°), and this means we don’t converge as quickly. Here’s an illustration:

Figure 2. exp(i2p×1.375)

The four panels show different zoom levels and an increasing number of terms in the calculation.

The upper-left, which is zoomed out to -50 to +50 (horizontally and vertically) isn’t zoomed out enough to show all the points. Note the tiny blue unit circle in the center. This calculation involves 20 terms. The first two terms are the same as above, but then it diverges hugely before returning to the general location of the unit circle.

The upper-right uses 24 terms. The first term is the red dot on the right; the 20th term is the red dot on the far left — that’s where the previous panel left off.

The lower-left adds two more terms (26 total), and now the point is generally in the right location.

The lower-right adds yet two more terms (28 total) for a reasonably precise answer. We could round up to make it 30 for a good answer here whereas the same point only took 20 when we were “closer to zero.”

§

It isn’t necessary to go fully around the circle to need more terms. Even points “later” in the circle need more precision (“later” meaning getting closer to all the way around).

Here’s a peek at what happens with a point 7/8’s around the circle (at the angle of 315°):

Figure 3: exp(i2p×0.875)

In this case the points don’t jump quite as far afield. In the left panel, which shows 12 terms, I only had to zoom out to -30 by +30 to capture them all. Notice that those 12 terms don’t even get us in the right quadrant.

The right panel (16 terms) converges on a better answer; 20 terms would probably provide a sufficiently precise one. (The red dot in the lower left of the right image is where the left image left off.)

However, in reality, in all cases, we’d probably do at least 100 terms, and that would give us very good precision for cases generally “close to zero.” But because of chaos, cases far from zero blow up eventually, even with 100 terms.

§

Note that e0=1, which is ultimately close to zero, is also what we get using a single term for any input — at zero, that first term is accurate. For an extremely small angle, two terms would be fairly close.

We can see the effect of increasing angle if we try to draw a circle. That is, if we try to draw a number of points on the complex unit circle:

Figure 4. Calculating 32 points around the unit circle.

The 16 panels, left-to-right and top-to-bottom, represent that calculation using 1 to 16 terms. As you see, increasing the number of terms wraps more and more of the points around the circle.

In the upper-left, N=1, so all the points are at [1,0i]. In the second panel, N=2, so the points are just 1+x, which stacks them in a vertical line.

By N=3, the points are starting to wrap around the circle. As N increases, more points wrap around. However, even by N=16, they points don’t quite form a circle.

Note how some number of initial points are reasonably close, but further ones diverge wildly — they run off towards infinity. At the end, it’s only the last points that are seriously off.

Of course, if we calculated more points — ones representing a second time around the circle — we’d continue to see severe divergence. It would be even worse on a third time around the circle.

The larger the angle, the more terms necessary for even a reasonable answer.

§ §

The reason calculations diverge “further from zero” has to do with the calculus of what’s really happening in an infinite series like the one that defines the exp(x) function.

It has to do with derivatives and the increasing powers in the series. As usual, Grant Sanderson, of 3Blue1Brown, has a really great video that explains:

Once again, I have to commend the channel to anyone with an interest in math. There aren’t any better, and few that come close.

Stay exponential, my friends! Go forth and spread beauty and light.


About Wyrd Smythe

The canonical fool on the hill watching the sunset and the rotation of the planet and thinking what he imagines are large thoughts. View all posts by Wyrd Smythe

8 responses to “Sideband #70: The exp Function

  • Wyrd Smythe

    As an illustration of how far the series diverges before it converges, below is a listing of the points generated for the full revolution plus 3/8’s example (Figure 2).

    1. (+1.000000, +0.000000i)
    2. (+1.000000, +8.639380i)
    3. (-36.319442, +8.639380i)
    4. (-36.319442, -98.832897i)
    5. (+195.804012, -98.832897i)
    6. (+195.804012, +302.247639i)
    7. (-381.710501, +302.247639i)
    8. (-381.710501, -410.519106i)
    9. (+388.022327, -410.519106i)
    10. (+388.022327, +328.371365i)
    11. (-250.333214, +328.371365i)
    12. (-250.333214, -172.991905i)
    13. (+110.622428, -172.991905i)
    14. (+110.622428, +66.887548i)
    15. (-37.406836, +66.887548i)
    16. (-37.406836, -18.371188i)
    17. (+8.629576, -18.371188i)
    18. (+8.629576, +5.024462i)
    19. (-2.599530, +5.024462i)
    20. (-2.599530, -0.081459i)
    21. (-0.393930, -0.081459i)
    22. (-0.393930, +0.825922i)
    23. (-0.750258, +0.825922i)
    24. (-0.750258, +0.692076i)
    25. (-0.702077, +0.692076i)
    26. (-0.702077, +0.708727i)
    27. (-0.707609, +0.708727i)
    28. (-0.707609, +0.706956i)
    29. (-0.707063, +0.706956i)
    30. (-0.707063, +0.707119i)

    As you see, some values got very large, which is why zooming out even to ±50 wasn’t enough to show all the points.

  • SelfAwarePatterns

    Is it wrong to think of a series as a for loop? Because I do.

  • Wyrd Smythe

    I’ve been enjoying this guy’s lectures:

  • Wyrd Smythe

    Here’s a new guy I just discovered. This is a good intro to the wave-function (not the Schrödinger equation — that uses a wave-function; this is about the wave-function itself):

And what do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

<span>%d</span> bloggers like this: