Rational approximation to the exponential in a complex region
Approximation of the exponential function has many applications, some of which are described in other Chebfun examples. Here we consider approximating via a rational function in a region in the complex plane, in the context of computing the matrix exponential via the scaling and squaring method, the most commonly used method for this purpose, cf. chapter 10 of [2]. Constructions of rational approximations to on a real interval are described in [3].
In brief, the scaling and squaring method is based on a type rational approximation to the exponential in a region in the complex plane that contains the eigenvalues of , where and are suitably chosen integer parameters. It first computes by first choosing an integer such that has norm of order $1$, then taking a rational (normally type Pade) approximation to where is chosen so that . Then we compute via repeated squaring of the matrix.
(Note that the letter e in the name Pade should have an accent aigu, but we dispense with this in a Chebfun Example to avoid trouble in some web browsers.)
Suppose is diagonalizable and . Then this method approximates
by
and the error satisfies
where is a region in the complex plane that contains the eigenvalues of , and is the 2-norm condition number of the eigenvectors. The term represents the exact error if is a normal matrix: the term can have nontrivial effects on the method for nonnormal , but this is outside the scope of this example. Below we investigate the error where takes points in the complex plane. If this is small in the whole region , then is a good approximation to .
The type Pade approximant of the exponential is explicitly known to be , where
Alternatively (and in particular for general functions for which Pade approximants are not explicitly known), Pade approximants can be obtained simply and robustly via the Chebfun command padeapprox, see [1].
Here is a contour plot of the logarithm of for the case and :
s = 2; m = 8;
f = [1 , 1./cumprod(1:50)]; % or f = @(z)exp(z);
[r,a,b] = padeapprox(f,m,m,0);
xgrid = linspace(-100,100,140);
[x,y] = meshgrid(xgrid,xgrid);
z = x + 1i*y;
contourf(x,y,log10(abs(exp(z) - r(z/(2^s)).^(2^s))+eps),[-16:2:0])
colorbar
Since we are using a Pade approximation centered at the origin, the error is zero at the origin and is expected to grow with . However, notice that the plot is highly nonsymmetric about the imaginary axis: the error is large for large and small for . In particular, the region in which the error is stretches much farther into the left complex plane than the right, reaching . This is perhaps not surprising because (literally) grows exponentially with , so for we have and the error is essentially just , which is itself small for moderately large provided that .
The relative error , on the other hand, looks completely different:
contourf(x,y,log10(abs(exp(z) - r(z/(2^s)).^(2^s))./abs(exp(z))),[-16:2:16])
colorbar
The graph shows that has no digits of relative accuracy except in the blue region.
The two plots illustrate for example that around the point , the relative accuracy is terrible but the absolute accuracy is of order unit roundoff. Hence is a good approximant near if we are concerned with absolute accuracy instead of relative accuracy.
In the context of the matrix exponential, the forward error is measured by the quantity , which for normal reduces to
Since the denominator is constant (when varies in ), this means the absolute error is indeed the appropriate metric of error in the context. The implication is that is well-approximated by if the eigenvalues of lie inside the dark-blue region in the first plot.
References
- P. Gonnet, S. Guettel, and L. N. Trefethen: Robust Pade approximation via SVD. SIAM Review, 55 (2013), 101-117.
- N. J. Higham. Functions of Matrices: Theory and Computation. SIAM, Philadelphia, 2008.
- L. N. Trefethen, J. A. C. Weideman, and T. Schmelzer: Talbot quadratures and rational approximations. BIT Numerical Mathematics, 46 (2006), pp. 653-670.