Thursday, June 03, 2010

Approximations to an Exponential

Summarizing, we have the exponential function taking a complex argument
F = exp(Z)
If we write Z explicitly in terms of its real and imaginary parts,
Z = X + 1j*Y
then
F = exp(X) * exp(1j*Y)
But each of these pieces is simple:
FX(Z) == exp(X) is the exponential function on a real argument, very small for negative X, very large for positive X, and always positive for any X
FY(Z) == exp(1j*Y) is a rotating phasor. FY always has magnitude 1 and phase Y radians.
Now let us consider approximating exp(Z) with a finite polynomial. The page referred to above describes that a little more in detail, most of you will not need to check that to see what is going on. Let us write the approximation of exp(Z) to an Nth order polynomial as
expN(Z) = FXN(X)*FYN(Y)
Let us look at graphs of some of these functions. First the exponential.
Here we show the argument of the exponential. We see it depends only on the imaginary part of Z, not on the real part of Z at all. And we see it "rolls," as the phasor exp(1j*Y) rolls.
Now lets look at the magnitude of the exponential. The log of the magnitude of the exponential is what we show, we label it Real(log(exp(Z))) because this is equivalent to log(abs(exp(Z)). Now exp(X) gets extremely large (close to infinity) and extremely small (close to zero) so we take the log of exp(Z) to get that magnitude down. When we do that we see the magnitude depends only on Real(Z), as we would expect from the equations above.
Now what might we expect from approximations to the exponential? Lets put up the results for a 51 term polynomial approximation to exp(Z).
Here is the argument, the phase, of the approximation. We see inside a 'C' shape, it is a pretty good match for what we had with the complete exponential. Outside the 'C', it is quite different.
What defines the 'C' shape? The 'x' marks on the plot show the roots of the 51 term polynomial which we are using to approximate the exponential. There are 51 roots. They lie on the 'C' shape. Apparently, the approximation to the exponential is pretty good as long as we are inside the rough shape defined by the roots of the approximating polynomial, and are wildly bad if we are outside that shape.
We notice a similar result for the magnitude of the approximation. We have plotted the magnitude of the approximation using the same scales as we plotted the original exponential. Inside the 'C' shape defined by the roots, you can see rather good agreement: the colors match. Outside the 'C' shape, things are much worse. Indeed, Red corresponds to very large values, outside the 'C' shape the magnitude of the approximation rises to very large values, it only manages to stay very close to zero inside the 'C' shape.
We have shown the result for a 51 term polynomial. How does this result change as the order of the polynomial changes?
The figure shows an estimate of the radius of the 'C' of roots as the order of the polynomial increases from 0 to 99. The 'C' wraps around the point Z=0. The estimate above is made by measuring the distance from Z=0 to the top of the 'C'.
From this one learns that the radius of the 'C' is growing linearly with the order of the polynomia. Indeed, for larger N, the radius is essentially 0.42*N.
What this shows is how the exponential function, with no zeros (no roots), arises from increasingly accurate polynomial approximation. Even though each higher order polynomial has more roots, the roots are moving away from the origin, being pushed out towards the edge of the complex plane.
In some sense, one might say, in the limit the exponential function has an infinite number of roots but that they are all at infinity. Now many real mathematicians might hate that statement. But I suspect the intuitivists might like it. The intuitivists believe it is not the limit at infinity that tells you what is happening, but the journey to get there.

Note added: from comments a great page about this very same problem: http://www.mai.liu.se/~halun/complex/taylor/