Gruntz algorithm
The Gruntz algorithm computes limits of exp-log functions at infinity[1]. Limits at a finite point reduce to this case by substituting or , and many special functions can be handled by rewriting them in exp-log form. Earlier limit procedures expanded the function in powers of , which fails whenever an exponentially small term decides the answer. Gruntz's method, from his 1996 thesis at ETH Zürich[1], instead expands in the most rapidly varying subexpression, using the comparability classes of Hardy's orders of infinity[2]. The recursion terminates because each step moves to a strictly lower class. It is used by SymPy's limit and was developed for Maple; related methods based on multiseries and transseries give full asymptotic expansions[3][4][5].
Example
The bracket is the difference of two numbers that agree to about decimal digits, multiplied by a number that large. Evaluating it in floating point loses all accuracy once is a few tens, and expanding in powers of gives zero at every order. The answer depends only on , which is smaller than every power of .
The function evaluated directly and after rewriting it in w = e^(−x).
Running it.
x direct in terms of w1 -2.27434683020919 -2.274346830209195 -1.21729711102195 -1.2172971110219410 -1.10514583111641 -1.1051458311142720 -1.05127117037794 -1.0512710952926130 -1.03457307555225 -1.0338951135135336 -0.957285705619525 -1.0281671774377140 0 -1.02531512052443100 0 -1.01005016708417700 0 -1.00142959232282
Comparability classes
Functions tending to 0 or are compared through their logarithms[1][2]. is more rapidly varying than , written , when
and they are in the same comparability class, , when the limit is finite and nonzero. A function tending to a finite nonzero constant is in the lowest class, below all others. So : every power of is in one class, , and are in the class above it, and is above both. Exp-log functions form a Hardy field, in which any two functions are eventually comparable, so these limits always exist in [2].
The MRV set is the set of subexpressions of in the highest comparability class present. It is computed recursively: for or , compare the classes of and and keep the higher, or their union if they are equal; for with , compare with . Each comparison is itself a limit of a smaller expression, computed by the same algorithm[1].
Algorithm
For [1]:
1. Compute . If , substitute , which moves every class up one level without changing the limit, and start again.
2. Choose in the class of with , of the form . Every element of can then be written with and in a strictly lower class.
3. Substitute these into and expand as a power series in , treating the lower-class expressions as constants:
4. If the limit is 0; if it is , with the sign of ; if it is , computed recursively. The coefficient lies in a lower class than , so the recursion terminates.
Worked examples
For the example above, the MRV set is . Take , so , and , which tends to 1, is in a lower class. Expanding,
The leading exponent is 0, so the limit is that of , which is . The rewritten form is also what the demo evaluates in its second column, and it is accurate for every .
For , the MRV set is , so the algorithm substitutes and obtains . Now and
with leading exponent 0 and , so the limit is 1.
Why powers of 1/x are not enough
An expansion in powers of cannot find the first limit. Since is smaller than every power of , the bracket expands to zero at every order in , and the factor that makes the product finite is invisible. Older limit procedures based on such expansions, or on heuristics like repeated l'Hôpital's rule, either failed or returned wrong answers on such inputs[1]. The series has to be taken in the most rapidly varying quantity, which is what the MRV set provides; more generally, asymptotic expansions of exp-log functions are multiseries in several scales, or transseries[3][5].
Zero equivalence
The algorithm has to decide whether the leading coefficient is identically zero, and whether constants such as the in step 2 are zero. If a zero coefficient is mistaken for a nonzero one, the answer is wrong. For exp-log expressions over this reduces to deciding whether exp-log constants are zero, which is not known to be decidable; Richardson showed that related problems for richer classes of functions are undecidable[6]. Gruntz's algorithm is therefore complete relative to a zero-equivalence oracle, the same limitation as the Risch algorithm. In practice systems use normal forms and numerical tests.
History
Hardy introduced the orders of infinity and the comparability of functions in 1910[2]. Algorithms for asymptotic expansions of exp-log functions were developed in the late 1980s and 1990s by Shackell, Salvy, Richardson and van der Hoeven, using nested expansions and multiseries[3][4][7]. Gruntz's 1996 thesis gave the MRV method, simpler to implement because it needs only ordinary power series in one variable at each step, and implemented it in Maple[1]. SymPy's limit function is based on it. Van der Hoeven's theory of transseries gives the general framework in which such expansions live[5].
see also
- Risch algorithmThe Risch algorithm is a decision procedure for integration in finite terms: given an elementary function, it either finds an elementary antiderivative or proves that none exists. It rests on Liouville's theorem, which says that an elementary antiderivative, if one exists, is a function of the same field plus constant multiples of logarithms. The algorithm writes the integrand in a tower of logarithmic, exponential and algebraic extensions of the rational functions and works down it, using Hermite reduction, the Rothstein–Trager resultant and the Risch differential equation y′ + fy = g. Its transcendental case is completely algorithmic; its algebraic case is much harder; and both are decision procedures only relative to deciding whether a constant is zero.
- Canonical formIn computer algebra, a canonical form is a representation in which mathematically equal expressions are written identically, so that equality becomes a syntactic comparison and zero-testing a look at the representation. A normal form is the weaker requirement that expressions equal to zero are represented by 0. Expanded polynomials with sorted terms, reduced rational functions and remainders modulo a Gröbner basis are canonical; for expressions with exponentials, logarithms and absolute values, Richardson proved in 1968 that zero-equivalence is undecidable, so no canonical form can exist. Where no canonical form is practical, randomized evaluation, justified by the Schwartz–Zippel lemma, tests identities with high confidence.
- Hermite reductionHermite reduction is the step of symbolic integration that splits the integral of a rational function A/D into a rational function and an integral whose denominator is square-free, using only gcds and the extended Euclidean algorithm, with no factorization of D. The rational part of the antiderivative comes entirely from the repeated factors of D, and each reduction step lowers their multiplicity by one. What remains integrates to a sum of logarithms, whose coefficients are the roots of the Rothstein–Trager resultant. Together the two steps integrate any rational function over a field of characteristic zero exactly, introducing algebraic numbers only where the answer needs them.
further reading
- [1]D. Gruntz, On Computing Limits in a Symbolic Manipulation System, PhD thesis, ETH Zürich (1996).
- [2]G. H. Hardy, Orders of Infinity, Cambridge Tracts in Mathematics 12 (1910).
- [3]D. Richardson, B. Salvy, J. Shackell, J. van der Hoeven, “Asymptotic expansions of exp-log functions”, ISSAC (1996).
- [4]J. R. Shackell, Symbolic Asymptotics, Algorithms and Computation in Mathematics 12, Springer (2004).
- [5]J. van der Hoeven, Transseries and Real Differential Algebra, Lecture Notes in Mathematics 1888, Springer (2006).
- [6]D. Richardson, “Some undecidable problems involving elementary functions of a real variable”, Journal of Symbolic Logic 33 (1968).
- [7]B. Salvy, J. Shackell, “Symbolic asymptotics: multiseries of inverse functions”, Journal of Symbolic Computation 27 (1999).
last updated