Exp Will Solve All Your Problems
October 24, 2024
Towards the end of my previous article, I made the wild claim that , or in prose, that the exponential of the derivative operator is the shift operator. If you're interested in knowing why that's the case, I recommend giving it a read. But in short:
The differential equation , which says "at position , move in the direction ", has the solution . So tells us "starting at , move in the direction for one second", thus landing us at .
More generally, we have that , where shifts a function over by units. All of this can be verified using Taylor series, as demonstrated here, although I personally don't find such an algebraic proof convincing. Instead, I think both you and I would prefer to see the applications of this identity. And surprisingly, they're quite plentiful. In this article, we'll explore applications in
- Dynamical systems
- Fourier analysis
- Partial differential equations
which, hopefully, you'll find convincing enough!
1. Dynamical Systems
Any dynamical systems course will cover linear dynamical systems, which come in two flavors: continuous and discrete. Continuous linear systems have the form
for and a square matrix , whereas discrete linear systems have the form
for a similar vector and matrix . It would seem that these two types of systems have something in common, but it's hard to say exactly how they're related. But if we turn to the exponential, all becomes clear. In the continuous case, our system is telling us that and do the same thing to , so it stands to reason that and would also do the same thing to , that is,
But we already know what does: it's the shift operator! So we can rewrite the above equation as
and if we let , we get the exact form of a discrete system. Like magic, the exponential has turned a continuous object into a discrete one.
But there's more! After introducing linear dynamical systems, stability conditions are usually discussed. For continuous linear systems, a system is stable only if the eigenvalues of all have a negative real part. For discrete linear systems, they're only stable if the eigenvalues have a magnitude less than .
It's common for students to be frustrated by these seemingly unrelated conditions, but our exponential analysis reveals the connection: if a complex number has a negative real part, then the magnitude of is less than one. In other words, the exponential of the left half-plane is the unit disc. When we used the exponential to go from continuous to discrete, we brought the eigenvalues along with us!
More generally, brings us from the continuous world to the discrete world. tells us how to move "a little bit", while tells us how to move a discrete amount of time. It's a lot like integration in that respect.
2. Fourier Analysis
The Fourier Transform
The Fourier transform of a function , defined as
says how to represent a function as a sum/integral of complex exponentials. More specifically, indicates how strongly the frequency contributes to . The inverse relationship is
which says that is an infinite linear combination of exponentials, weighted by .
These exponentials are "eigenfunctions" of differentiation, that is, they simply get scaled when you differentiate them.
so it's no surprise that the Fourier transform, as a linear combination of exponentials, acts like an eigenfunction as well.
This property has many names, but we'll call it the differentiation property of the Fourier transform. The differentiation property is so easy to prove that it's rarely called a theorem, instead just a basic fact about the transform. But there's another slightly more subtle result called the shift theorem:
which says that the Fourier transform a function shifted by units is the same as multiplying by . If you're comfortable with Fourier analysis, this should be intuitive, since represents a phase shift by at frequency . But of course, there's another way to view this; let's take another look at the differentiation property. Essentially, it tells us that, at a given frequency , differentiating is the same as multiplying by . So, like last time, it stands to reason that , i.e. . With respect to the Fourier transform, the shift and the exponential are exactly the same operation.
3. Partial Differential Equations
But maybe even the previous material isn't applied enough for you. You want to see some numerical, scientific computing done with . In that case, you're probably familiar with the discrete derivative matrix, but let's review it anyway!
Suppose you have a function sampled at (we write to ease notation), and we want to approximate the derivative at . Is there a "best" way to do this? As it turns out, yes! gives us the best answer for the derivative at . Try it on a line and see what you get. If we instead have a vector of samples
we can compress our so-called "discrete derivative" into a matrix
so that, as we hope, gives us our estimated values for
We should expect that the derivative can be encapsulated by a matrix, since it's a linear operator and all finite-dimensional linear operators can be represented by matrices.
Now, onto the PDEs! The first PDE you study in depth is typically the 1D heat equation
where equals the temperature at position at time . When we're solving this computationally, we usually have a starting vector of temperatures, and we use the heat equation to advance it in time. At this point in the article, you're probably already thinking what I'm thinking: if we view the equation as
then we transform it into a first order linear ODE, which has the exact solution
And we've done it again, we've exponentiated the derivative operator! Except now that we've discretized it, we can get numerical results. Here's what the evolution looks like, starting with randomly initialized data.[1]
The code for the above simulation is available here. Heat simulations exist already, but what's fascinating here is that this exponential method gives a formula for seeing any point in the future. Most simulations require you to slowly advance time to the point you're interested in. With this method, if we want to know how the simulation looks in exactly 85 seconds, we can see it with one computation.
We can easily do the same thing with the wave equation, which has the form
Since the time derivative is second-order, we'll need to transform this into a first-order equation, which is pretty straightforward. Simply let , so we have
Note that we've replaced with like last time. This gives us the explicit solution
Here's a visualization:
The code for the above simulation is available here. This method also has the advantage of being completely timestep invariant. Most simulations lose accuracy if you advance time too quickly, but this one remains perfectly accurate. It's exciting what exponentials can do for us!
- This simulation has periodic boundary conditions, which is captured by the fact that the entries of wrap around at the edges. You can use the forward- and backward-difference formulas if you want different boundary conditions. ↩