Sage 9.1 Reference Manual: Asymptotic Expansions: Release 9.1
Sage 9.1 Reference Manual: Asymptotic Expansions: Release 9.1
1 Reference Manual:
Asymptotic Expansions
Release 9.1
3 Supplements 5
3.1 Growth Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Term Monoids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Index 149
i
ii
CHAPTER
ONE
The asymptotic ring, as well as its main documentation is contained in the module
• Asymptotic Ring.
1
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
TWO
3
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
THREE
SUPPLEMENTS
Behind the scenes of working with asymptotic expressions a couple of additional classes and tools turn up. For instance
the growth of each summand is managed in growth groups, see below.
3.3 Miscellaneous
5
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
6 Chapter 3. Supplements
CHAPTER
FOUR
This module provides a ring (called AsymptoticRing) for computations with asymptotic expansions.
5𝑧 3 + 4𝑧 2 + 𝑂(𝑧)
as 𝑧 → ∞ or
as 𝑥 and 𝑦 tend to ∞. It is a truncated series (after a finite number of terms), which approximates a function.
The summands of the asymptotic expansions are partially ordered. In this module these summands are the following:
• Exact terms 𝑐 · 𝑔 with a coefficient 𝑐 and an element 𝑔 of a growth group (see below).
• 𝑂-terms 𝑂(𝑔) (see Big O notation; also called Bachmann–Landau notation) for a growth group element 𝑔 (again
see below).
See the Wikipedia article on asymptotic expansions for more details. Further examples of such elements can be found
here.
The elements of a growth group are equipped with a partial order and usually contain a variable. Examples—the order
is described below these examples—are
• elements of the form 𝑧 𝑞 for some integer or rational 𝑞 (growth groups with description strings z^ZZ or z^QQ),
• elements of the form log(𝑧)𝑞 for some integer or rational 𝑞 (growth groups log(z)^ZZ or log(z)^QQ),
• elements of the form 𝑎𝑧 for some rational 𝑎 (growth group QQ^z), or
• more sophisticated constructions like products 𝑥𝑟 · log(𝑥)𝑠 · 𝑎𝑦 · 𝑦 𝑞 (this corresponds to an element of the growth
group x^QQ * log(x)^ZZ * QQ^y * y^QQ).
The order in all these examples is induced by the magnitude of the elements as 𝑥, 𝑦, or 𝑧 (independently) tend to ∞.
For elements only using the variable 𝑧 this means that 𝑔1 ≤ 𝑔2 if
𝑔1
lim ≤ 1.
𝑧→∞ 𝑔2
7
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
Note: Asymptotic rings where the variable tend to some value distinct from ∞ are not yet implemented.
Two Rings
First, we construct the following (very simple) asymptotic ring in the variable 𝑧:
sage: A.an_element()
z^(3/2) + O(z^(1/2))
This element consists of two summands: the exact term with coefficient 1 and growth 𝑧 3/2 and the 𝑂-term 𝑂(𝑧 1/2 ).
Note that the growth of 𝑧 3/2 is larger than the growth of 𝑧 1/2 as 𝑧 → ∞, thus this expansion cannot be simplified
(which would be done automatically, see below).
Elements can be constructed via the generator 𝑧 and the function O(), for example
sage: B.an_element()
1/8*x^(3/2)*log(x)^3*(1/8)^y*y^(3/2) + O(x^(1/2)*log(x)*(1/2)^y*y^(1/2))
Again, elements can be created using the generators 𝑥 and 𝑦, as well as the function O():
Arithmetical Operations
In this section we explain how to perform various arithmetical operations with the elements of the asymptotic rings
constructed above.
In addition to that, special powers—our growth group z^QQ allows the exponents to be out of Q—can also be com-
puted:
sage: (z^(5/2)+z^(1/7)) * z^(-1/5)
z^(23/10) + z^(-2/35)
The central concepts of computations with asymptotic expansions is that the 𝑂-notation can be used. For example, we
have
sage: z^3 + z^2 + z + O(z^2)
z^3 + O(z^2)
Division
The asymptotic expansions support division. For example, we can expand 1/(𝑧 − 1) to a geometric series:
sage: 1 / (z-1)
z^(-1) + z^(-2) + z^(-3) + z^(-4) + ... + z^(-20) + O(z^(-21))
A default precision (parameter default_prec of AsymptoticRing) is predefined. Thus, only the first 20 sum-
mands are calculated. However, if we only want the first 5 exact terms, we cut of the rest by using
sage: (1 / (z-1)).truncate(5)
z^(-1) + z^(-2) + z^(-3) + z^(-4) + z^(-5) + O(z^(-6))
or
sage: 1 / O(z)
Traceback (most recent call last):
...
ZeroDivisionError: Cannot invert O(z).
It works as simple as it can be; just use the usual operators ^, exp and log. For example, we obtain the usual series
expansion of the logarithm
sage: -log(1-1/z)
z^(-1) + 1/2*z^(-2) + 1/3*z^(-3) + ... + O(z^(-21))
as 𝑧 → ∞.
Similarly, we can apply the exponential function of an asymptotic expansion:
sage: exp(1/z)
1 + z^(-1) + 1/2*z^(-2) + 1/6*z^(-3) + 1/24*z^(-4) + ... + O(z^(-20))
Multivariate Arithmetic
sage: B
Asymptotic Ring <x^QQ * log(x)^ZZ * QQ^y * y^QQ> over Rational Field
The AsymptoticRing fully supports coercion. For example, the coefficient ring is automatically extended when
needed:
sage: A
Asymptotic Ring <z^QQ> over Integer Ring
sage: (z + 1/2).parent()
Asymptotic Ring <z^QQ> over Rational Field
Here, the coefficient ring was extended to allow 1/2 as a coefficient. Another example is
Not only the coefficient ring can be extended, but the growth group as well. For example, we can add/multiply elements
of the asymptotic rings A and C to get an expansion of new asymptotic ring:
Data Structures
The summands of an asymptotic expansion are wrapped growth group elements. This wrapping is done by the
term monoid module. However, inside an asymptotic expansion these summands (terms) are stored together
with their growth-relationship, i.e., each summand knows its direct predecessors and successors. As a data structure a
special poset (namely a mutable poset) is used. We can have a look at this:
4.1.5 Various
AUTHORS:
• Benjamin Hackl (2015)
• Daniel Krenn (2015)
• Clemens Heuberger (2016)
ACKNOWLEDGEMENT:
• Benjamin Hackl, Clemens Heuberger and Daniel Krenn are supported by the Austrian Science Fund (FWF): P
24644-N26.
• Benjamin Hackl is supported by the Google Summer of Code 2015.
The usual ring operations, but allowing rational exponents (growth group x^QQ) can be performed:
sage: x^2 + 3*(x - x^(2/5))
x^2 + 3*x - 3*x^(2/5)
sage: (3*x^(1/3) + 2)^3
27*x + 54*x^(2/3) + 36*x^(1/3) + 8
One of the central ideas behind computing with asymptotic expansions is that the 𝑂-notation (see Wikipedia
article Big_O_notation) can be used. For example, we have:
sage: (x+2*x^2+3*x^3+4*x^4) * (O(x)+x^2)
4*x^6 + O(x^5)
In particular, O() can be used to construct the asymptotic expansions. With the help of the summands(), we
can also have a look at the inner structure of an asymptotic expansion:
sage: expr1 = x + 2*x^2 + 3*x^3 + 4*x^4; expr2 = O(x) + x^2
sage: print(expr1.summands.repr_full())
poset(x, 2*x^2, 3*x^3, 4*x^4)
+-- null
| +-- no predecessors
| +-- successors: x
+-- x
| +-- predecessors: null
| +-- successors: 2*x^2
+-- 2*x^2
| +-- predecessors: x
| +-- successors: 3*x^3
+-- 3*x^3
| +-- predecessors: 2*x^2
| +-- successors: 4*x^4
+-- 4*x^4
| +-- predecessors: 3*x^3
| +-- successors: oo
(continues on next page)
In addition to the monomial growth elements from above, we can also compute with logarithmic terms (simply
by constructing the appropriate growth group):
sage: R_log = AsymptoticRing(growth_group='log(x)^QQ', coefficient_ring=QQ)
sage: lx = R_log(log(SR.var('x')))
sage: (O(lx) + lx^3)^4
log(x)^12 + O(log(x)^10)
See also:
(Asymptotic) Growth Groups, (Asymptotic) Term Monoids, mutable_poset.
O()
Convert all terms in this asymptotic expansion to 𝑂-terms.
INPUT:
Nothing.
OUTPUT:
An asymptotic expansion.
EXAMPLES:
sage: AR.<x> = AsymptoticRing(growth_group='x^ZZ', coefficient_ring=ZZ)
sage: O(x)
(continues on next page)
See also:
sage.rings.power_series_ring.PowerSeriesRing(), sage.rings.
laurent_series_ring.LaurentSeriesRing().
compare_with_values(variable, function, values, rescaled=True, ring=Real Interval Field with 53
bits of precision)
Compute the (rescaled) difference between this asymptotic expansion and the given values.
INPUT:
• variable – an asymptotic expansion or a string.
• function – a callable or symbolic expression giving the comparison values.
• values – a list or iterable of values where the comparison shall be carried out.
• rescaled – (default: True) determines whether the difference is divided by the error term of the
asymptotic expansion.
• ring – (default: RIF) the parent into which the difference is converted.
OUTPUT:
A list of pairs containing comparison points and (rescaled) difference values.
EXAMPLES:
See also:
plot_comparison()
exact_part()
Return the expansion consisting of all exact terms of this expansion.
INPUT:
Nothing
OUTPUT:
An asymptotic expansion.
EXAMPLES:
exp(precision=None)
Return the exponential of (i.e., the power of 𝑒 to) this asymptotic expansion.
INPUT:
• precision – the precision used for truncating the expansion. If None (default value) is used, the
default precision of the parent is used.
OUTPUT:
An asymptotic expansion.
Note: The exponential function of this expansion can only be computed exactly if the respective growth
element can be constructed in the underlying growth group.
ALGORITHM:
If the corresponding growth can be constructed, return the exact exponential function. Otherwise, if this
term is 𝑜(1), try to expand the series and truncate according to the given precision.
Todo: As soon as 𝐿-terms are implemented, this implementation has to be adapted as well in order to
yield correct results.
EXAMPLES:
sage: (x^(-1)).exp(precision=7)
1 + x^(-1) + 1/2*x^(-2) + 1/6*x^(-3) + ... + O(x^(-7))
factorial()
Return the factorial of this asymptotic expansion.
OUTPUT:
An asymptotic expansion.
EXAMPLES:
sage: n.factorial()
sqrt(2)*sqrt(pi)*e^(n*log(n))*(e^n)^(-1)*n^(1/2)
+ 1/12*sqrt(2)*sqrt(pi)*e^(n*log(n))*(e^n)^(-1)*n^(-1/2)
+ 1/288*sqrt(2)*sqrt(pi)*e^(n*log(n))*(e^n)^(-1)*n^(-3/2)
+ O(e^(n*log(n))*(e^n)^(-1)*n^(-5/2))
sage: _.parent()
Asymptotic Ring <(e^(n*log(n)))^QQ * (e^n)^QQ * n^QQ * log(n)^QQ>
over Symbolic Constants Subring
1 2𝑛
(︀ )︀
Catalan numbers 𝑛+1 𝑛 :
Note that this method substitutes the asymptotic expansion into Stirling’s formula. This substitution has to
be possible which is not always guaranteed:
sage: log(s).factorial()
Traceback (most recent call last):
...
TypeError: Cannot apply the substitution rules {s: log(s)} on
sqrt(2)*sqrt(pi)*e^(s*log(s))*(e^s)^(-1)*s^(1/2)
+ O(e^(s*log(s))*(e^s)^(-1)*s^(-1/2)) in
Asymptotic Ring <(e^(s*log(s)))^QQ * (e^s)^QQ * s^QQ * log(s)^QQ>
over Symbolic Constants Subring.
...
See also:
Stirling()
has_same_summands(other)
Return whether this asymptotic expansion and other have the same summands.
INPUT:
• other – an asymptotic expansion.
OUTPUT:
A boolean.
Note: While for example O(x) == O(x) yields False, these expansions do have the same summands
and this method returns True.
Moreover, this method uses the coercion model in order to find a common parent for this asymptotic
expansion and other.
EXAMPLES:
sage: R_ZZ.<x_ZZ> = AsymptoticRing('x^ZZ', ZZ)
sage: R_QQ.<x_QQ> = AsymptoticRing('x^ZZ', QQ)
sage: sum(x_ZZ^k for k in range(5)) == sum(x_QQ^k for k in range(5)) #
˓→indirect doctest
True
sage: O(x_ZZ) == O(x_QQ)
False
invert(precision=None)
Return the multiplicative inverse of this element.
INPUT:
• precision – the precision used for truncating the expansion. If None (default value) is used, the
default precision of the parent is used.
OUTPUT:
An asymptotic expansion.
Warning: Due to truncation of infinite expansions, the element returned by this method might not
fulfill el * ~el == 1.
Todo: As soon as 𝐿-terms are implemented, this implementation has to be adapted as well in order to
yield correct results.
EXAMPLES:
sage: R.<x> = AsymptoticRing(growth_group='x^ZZ', coefficient_ring=QQ,
˓→default_prec=4)
sage: ~x
x^(-1)
sage: ~(x^42)
x^(-42)
sage: ex = ~(1 + x); ex
x^(-1) - x^(-2) + x^(-3) - x^(-4) + O(x^(-5))
sage: ex * (1+x)
(continues on next page)
is_exact()
Return whether all terms of this expansion are exact.
OUTPUT:
A boolean.
EXAMPLES:
is_little_o_of_one()
Return whether this expansion is of order 𝑜(1).
INPUT:
Nothing.
OUTPUT:
A boolean.
EXAMPLES:
See also:
limit()
limit()
Compute the limit of this asymptotic expansion.
OUTPUT:
An element of the coefficient ring.
EXAMPLES:
See also:
is_little_o_of_one()
log(base=None, precision=None, locals=None)
The logarithm of this asymptotic expansion.
INPUT:
• base – the base of the logarithm. If None (default value) is used, the natural logarithm is taken.
• precision – the precision used for truncating the expansion. If None (default value) is used, the
default precision of the parent is used.
• locals – a dictionary which may contain the following keys and values:
– 'log' – value: a function. If not used, then the usual log is taken.
OUTPUT:
An asymptotic expansion.
Note: Computing the logarithm of an asymptotic expansion is possible if and only if there is exactly one
maximal summand in the expansion.
ALGORITHM:
If the expansion has more than one summand, the asymptotic expansion for log(1 + 𝑡) as 𝑡 tends to 0 is
used.
Todo: As soon as 𝐿-terms are implemented, this implementation has to be adapted as well in order to
yield correct results.
EXAMPLES:
sage: log(x)
log(x)
sage: log(x^2)
(continues on next page)
sage: (49*x^3-1).log()
3*log(x) + 2*log(7) - 1/49*x^(-3) - 1/4802*x^(-6) ... + O(x^(-12))
sage: _.parent()
Asymptotic Ring <x^ZZ * log(x)^ZZ> over Symbolic Ring
If one wants to avoid this extending to the Symbolic Ring, then the following helps:
A log-function can also be specified to always be used with the asymptotic ring:
sage: log(49*x^3-1)
3*log(x) + 2*log7 - 1/49*x^(-3) - 1/4802*x^(-6) - 1/352947*x^(-9) + O(x^(-12))
map_coefficients(f, new_coefficient_ring=None)
Return the asymptotic expansion obtained by applying f to each coefficient of this asymptotic expansion.
INPUT:
• f – a callable. A coefficient 𝑐 will be mapped to 𝑓 (𝑐).
• new_coefficient_ring – (default: None) a ring.
OUTPUT:
An asymptotic expansion.
EXAMPLES:
monomial_coefficient(monomial)
Return the coefficient in the base ring of the given monomial in this expansion.
INPUT:
• monomial – a monomial element which can be converted into the asymptotic ring of this element
OUTPUT:
An element of the coefficient ring.
EXAMPLES:
sage: R.<m, n> = AsymptoticRing("m^QQ*n^QQ", QQ)
sage: ae = 13 + 42/n + 2/n/m + O(n^-2)
sage: ae.monomial_coefficient(1/n)
42
sage: ae.monomial_coefficient(1/n^3)
0
sage: R.<n> = AsymptoticRing("n^QQ", ZZ)
sage: ae.monomial_coefficient(1/n)
42
sage: ae.monomial_coefficient(1)
13
Note: If rescaled (i.e. divided by the error term), the output should be bounded.
This method is mainly meant to have an easily usable plausability check for asymptotic expansion created
in some way.
EXAMPLES:
We want to check the quality of the asymptotic expansion of the harmonic numbers:
sage: A.<n> = AsymptoticRing('n^ZZ * log(n)^ZZ', SR)
sage: def H(n):
....: return sum(1/k for k in srange(1, n+1))
sage: H_expansion = (log(n) + euler_gamma + 1/(2*n)
....: - 1/(12*n^2) + O(n^-4))
sage: H_expansion.plot_comparison(n, H, srange(1, 30))
Graphics object consisting of 1 graphics primitive
See also:
compare_with_values()
pow(exponent, precision=None)
Calculate the power of this asymptotic expansion to the given exponent.
INPUT:
• exponent – an element.
• precision – the precision used for truncating the expansion. If None (default value) is used, the
default precision of the parent is used.
OUTPUT:
An asymptotic expansion.
EXAMPLES:
sage: (3 + 1/c^2)^c
3^c + 1/3*3^c*c^(-1) + 1/18*3^c*c^(-2) - 4/81*3^c*c^(-3)
- 35/1944*3^c*c^(-4) + O(3^c*c^(-5))
sage: _.parent()
Asymptotic Ring <QQ^c * c^QQ * Signs^c> over Rational Field
sage: (2 + (1/3)^c)^c
2^c + 1/2*(2/3)^c*c + 1/8*(2/9)^c*c^2 - 1/8*(2/9)^c*c
+ 1/48*(2/27)^c*c^3 + O((2/27)^c*c^2)
sage: _.parent()
Asymptotic Ring <QQ^c * c^QQ * Signs^c> over Rational Field
show()
Pretty-print this asymptotic expansion.
OUTPUT:
Nothing, the representation is printed directly on the screen.
EXAMPLES:
sqrt(precision=None)
Return the square root of this asymptotic expansion.
INPUT:
• precision – the precision used for truncating the expansion. If None (default value) is used, the
default precision of the parent is used.
OUTPUT:
An asymptotic expansion.
EXAMPLES:
See also:
pow(), rpow(), exp().
subs(rules=None, domain=None, **kwds)
Substitute the given rules in this asymptotic expansion.
INPUT:
• rules – a dictionary.
• kwds – keyword arguments will be added to the substitution rules.
• domain – (default: None) a parent. The neutral elements 0 and 1 (rules for the keys '_zero_'
and '_one_', see note box below) are taken out of this domain. If None, then this is determined
automatically.
OUTPUT:
An object.
Note: The neutral element of the asymptotic ring is replaced by the value to the key '_zero_'; the
neutral element of the growth group is replaced by the value to the key '_one_'.
EXAMPLES:
See also:
sage.symbolic.expression.Expression.subs()
substitute(rules=None, domain=None, **kwds)
Substitute the given rules in this asymptotic expansion.
INPUT:
• rules – a dictionary.
• kwds – keyword arguments will be added to the substitution rules.
• domain – (default: None) a parent. The neutral elements 0 and 1 (rules for the keys '_zero_'
and '_one_', see note box below) are taken out of this domain. If None, then this is determined
automatically.
OUTPUT:
An object.
Note: The neutral element of the asymptotic ring is replaced by the value to the key '_zero_'; the
neutral element of the growth group is replaced by the value to the key '_one_'.
EXAMPLES:
See also:
sage.symbolic.expression.Expression.subs()
summands
The summands of this asymptotic expansion stored in the underlying data structure (a MutablePoset).
EXAMPLES:
sage: R.<x> = AsymptoticRing(growth_group='x^ZZ', coefficient_ring=ZZ)
sage: expr = 7*x^12 + x^5 + O(x^3)
sage: expr.summands
poset(O(x^3), x^5, 7*x^12)
See also:
sage.data_structures.mutable_poset.MutablePoset
symbolic_expression(R=None)
Return this asymptotic expansion as a symbolic expression.
INPUT:
• R – (a subring of) the symbolic ring or None. The output will be an element of R. If None, then the
symbolic ring is used.
OUTPUT:
A symbolic expression.
EXAMPLES:
sage: A.<x, y, z> = AsymptoticRing(growth_group='x^ZZ * y^QQ * log(y)^QQ *
˓→(QQ_+)^z * z^QQ', coefficient_ring=QQ)
truncate(precision=None)
Truncate this asymptotic expansion.
INPUT:
• precision – a positive integer or None. Number of summands that are kept. If None (default
value) is given, then default_prec from the parent is used.
OUTPUT:
An asymptotic expansion.
Note: For example, truncating an asymptotic expansion with precision=20 does not yield an expan-
sion with exactly 20 summands! Rather than that, it keeps the 20 summands with the largest growth, and
adds appropriate 𝑂-Terms.
EXAMPLES:
variable_names()
Return the names of the variables of this asymptotic expansion.
OUTPUT:
A tuple of strings.
EXAMPLES:
This is equivalent to the following code, which explicitly specifies the underlying growth group:
Of course, the coefficient ring of the asymptotic ring and the base ring of the underlying growth group do not
need to coincide:
Other growth groups are available. See Asymptotic Ring for more examples.
Furthermore, the coercion framework is also involved. Coercion between two asymptotic rings is possible (given
that the underlying growth groups and coefficient rings are chosen appropriately):
sage: R1_x.has_coerce_map_from(R_ZZ_x)
True
Additionally, for the sake of convenience, the coefficient ring also coerces into the asymptotic ring (representing
constant quantities):
sage: R1_x.has_coerce_map_from(QQ)
True
sage: a = A.an_element(); a
1/8*x^3 + O(x)
sage: for t in a.summands.elements_topological(reverse=True):
....: print(t, type(t))
1/8*x^3 <class '__main__.MyExactTermMonoid_with_category.element_class'>
O(x) <class '__main__.MyOTermMonoid_with_category.element_class'>
Element
alias of AsymptoticExpansion
change_parameter(**kwds)
Return an asymptotic ring with a change in one or more of the given parameters.
INPUT:
• growth_group – (default: None) the new growth group.
• coefficient_ring – (default: None) the new coefficient ring.
• category – (default: None) the new category.
• default_prec – (default: None) the new default precision.
OUTPUT:
An asymptotic ring.
EXAMPLES:
coefficient_ring
The coefficient ring of this asymptotic ring.
EXAMPLES:
Todo: Make this method more usable by implementing the processing of symbolic expressions.
EXAMPLES:
Catalan numbers:
Unit fractions:
Harmonic numbers:
Warning: Once singular expansions around points other than infinity are implemented (trac ticket
#20050), the output in the case return_singular_expansions will change to return singular
expansions around the singularities.
In the following example, the result is an exact asymptotic expression for sufficiently large 𝑛 (i.e., there
might be finitely many exceptional values). This is encoded by an 𝑂(0) error term:
In this case, we can manually intervene by adding an an error term that suits us:
construction()
Return the construction of this asymptotic ring.
OUTPUT:
A pair whose first entry is an asymptotic ring construction functor and its second entry
the coefficient ring.
EXAMPLES:
See also:
Asymptotic Ring, AsymptoticRing, AsymptoticRingFunctor.
create_summand(type, data=None, **kwds)
Create a simple asymptotic expansion consisting of a single summand.
INPUT:
• type – ‘O’ or ‘exact’.
• data – the element out of which a summand has to be created.
• growth – an element of the growth_group().
• coefficient – an element of the coefficient_ring().
OUTPUT:
An asymptotic expansion.
Note: This method calls the factory TermMonoid with the appropriate arguments.
EXAMPLES:
default_prec
The default precision of this asymptotic ring.
This is the parameter used to determine how many summands are kept before truncating an infinite series
(which occur when inverting asymptotic expansions).
EXAMPLES:
gen(n=0)
Return the n-th generator of this asymptotic ring.
INPUT:
gens()
Return a tuple with generators of this asymptotic ring.
INPUT:
Nothing.
OUTPUT:
A tuple of asymptotic expansions.
Note: Generators do not necessarily exist. This depends on the underlying growth group. For example,
monomial growth groups have a generator, and exponential growth groups do not.
EXAMPLES:
sage: B.gens()
(y, z)
growth_group
The growth group of this asymptotic ring.
EXAMPLES:
See also:
(Asymptotic) Growth Groups
ngens()
Return the number of generators of this asymptotic ring.
INPUT:
Nothing.
OUTPUT:
An integer.
EXAMPLES:
some_elements()
Return some elements of this term monoid.
See TestSuite for a typical use case.
INPUT:
Nothing.
OUTPUT:
An iterator.
EXAMPLES:
term_monoid(type)
Return the term monoid of this asymptotic ring of specified type.
INPUT:
• type – ‘O’ or ‘exact’, or an instance of an existing term monoid. See TermMonoidFactory for
more details.
OUTPUT:
A term monoid object derived from GenericTermMonoid.
EXAMPLES:
term_monoid_factory
The term monoid factory of this asymptotic ring.
EXAMPLES:
See also:
(Asymptotic) Term Monoids
variable_names()
Return the names of the variables.
OUTPUT:
A tuple of strings.
EXAMPLES:
class sage.rings.asymptotic.asymptotic_ring.AsymptoticRingFunctor(growth_group,
de-
fault_prec=None,
cate-
gory=None,
term_monoid_factory=None,
lo-
cals=None,
cls=None)
Bases: sage.categories.pushout.ConstructionFunctor
A construction functor for asymptotic rings.
INPUT:
• growth_group – a partially ordered group (see AsymptoticRing or (Asymptotic) Growth Groups
for details).
• default_prec – None (default) or an integer.
• category – None (default) or a category.
• cls – AsymptoticRing (default) or a derived class.
EXAMPLES:
See also:
Asymptotic Ring, AsymptoticRing, sage.rings.asymptotic.growth_group.
AbstractGrowthGroupFunctor, sage.rings.asymptotic.growth_group.
ExponentialGrowthGroupFunctor, sage.rings.asymptotic.growth_group.
MonomialGrowthGroupFunctor, sage.categories.pushout.ConstructionFunctor.
merge(other)
Merge this functor with other if possible.
INPUT:
• other – a functor.
OUTPUT:
A functor or None.
EXAMPLES:
exception sage.rings.asymptotic.asymptotic_ring.NoConvergenceError
Bases: RuntimeError
A special RuntimeError which is raised when an algorithm does not converge/stop.
Asymptotic expansions in SageMath can be built through the asymptotic_expansions object. It contains gen-
erators for common asymptotic expressions. For example,
AUTHORS:
• Daniel Krenn (2015)
• Clemens Heuberger (2016)
class sage.rings.asymptotic.asymptotic_expansion_generators.AsymptoticExpansionGenerators
Bases: sage.structure.sage_object.SageObject
A collection of constructors for several common asymptotic expansions.
A list of all asymptotic expansions in this database is available via tab completion. Type
“asymptotic_expansions.” and then hit tab to see which expansions are available.
The asymptotic expansions currently in this class include:
• HarmonicNumber()
• Stirling()
• log_Stirling()
• Binomial_kn_over_n()
• SingularityAnalysis()
• ImplicitExpansion()
• ImplicitExpansionPeriodicPart()
• InverseFunctionAnalysis()
static Binomial_kn_over_n(var, k, precision=None, skip_constant_factor=False)
Return the asymptotic expansion of the binomial coefficient 𝑘𝑛 choose 𝑛.
INPUT:
• var – a string for the variable name.
• k – a number or symbolic constant.
• precision – (default: None) an integer. If None, then the default precision of the asymptotic ring
is used.
• skip_constant_factor
√︀ – (default: False) a boolean. If set, then the constant factor
𝑘/(2𝜋(𝑘 − 1)) is left out. As a consequence, the coefficient ring of the output changes from
Symbolic Constants Subring (if False) to Rational Field (if True).
OUTPUT:
An asymptotic expansion.
EXAMPLES:
Note: In the given case, the radius of convergence of the function of interest is known to be 𝜌 = 𝜏 /Φ(𝜏 ).
Until trac ticket #20050 is implemented, the variable in the returned asymptotic expansion represents a
singular element of the form (1 − 𝑧/𝜌)−1 , for the variable 𝑧 → 𝜌.
EXAMPLES:
We can, for example, determine the singular expansion of the well-known tree function 𝑇 (which satisfies
𝑇 (𝑧) = 𝑧 exp(𝑇 (𝑧))):
sage: asymptotic_expansions.ImplicitExpansion('Z', phi=exp, precision=8)
doctest:warning
...
FutureWarning: This class/method/function is marked as experimental. It, its
˓→functionality or its interface might change without a formal deprecation.
Another classical example in this context is the generating function 𝐵(𝑧) enumerating binary trees with
respect to the number of inner nodes. The√function satisfies 𝐵(𝑧) = 𝑧(1+2𝐵(𝑧)+𝐵(𝑧)2 ), which can also
be solved explicitly, yielding 𝐵(𝑧) = 1− 2𝑧1−4𝑧 − 1. We compare the expansions from both approaches:
sage: def B(z):
....: return (1 - sqrt(1 - 4*z))/(2*z) - 1
sage: A.<Z> = AsymptoticRing('Z^QQ', QQ, default_prec=3)
sage: B((1-1/Z)/4)
1 - 2*Z^(-1/2) + 2*Z^(-1) - 2*Z^(-3/2) + 2*Z^(-2)
- 2*Z^(-5/2) + O(Z^(-3))
sage: asymptotic_expansions.ImplicitExpansion(Z, phi=lambda u: 1 + 2*u + u^2,
˓→precision=7)
Neither 𝜏 nor Φ have to be known explicitly, they can also be passed symbolically:
sage: tau = var('tau')
sage: phi = function('phi')
sage: asymptotic_expansions.ImplicitExpansion('Z', phi=phi, tau=tau,
˓→precision=3) # long time
tau + (-sqrt(2)*sqrt(-tau*phi(tau)^2/(2*tau*diff(phi(tau), tau)^2
- tau*phi(tau)*diff(phi(tau), tau, tau)
- 2*phi(tau)*diff(phi(tau), tau))))*Z^(-1/2) + O(Z^(-1))
Note that we do not check whether a passed 𝜏 actually satisfies the requirements. Only the first of the
following expansions is correct:
sage: asymptotic_expansions.ImplicitExpansion('Z',
....: phi=lambda u: 1 + 2*u + u^2, precision=5) # correct expansion
1 - 2*Z^(-1/2) + 2*Z^(-1) - 2*Z^(-3/2) + O(Z^(-2))
sage: asymptotic_expansions.ImplicitExpansion('Z', phi=lambda u: 1 + 2*u + u^
˓→2, tau=2, precision=5)
See also:
ImplicitExpansionPeriodicPart(), InverseFunctionAnalysis().
static ImplicitExpansionPeriodicPart(var, phi, period, tau=None, precision=None)
Return the singular expansion for the periodic part of a function 𝑦(𝑧) defined implicitly by 𝑦(𝑧) =
𝑧Φ(𝑦(𝑧)).
The function Φ is assumed to be analytic around 0. Furthermore, Φ is not allowed to be an affine-linear
function and we require Φ(0) ̸= 0. For an integer 𝑝, Φ is called 𝑝-periodic if we have Ψ(𝑢𝑝 ) = Φ(𝑢) for a
power series Ψ where 𝑝 is maximal.
Furthermore, it is assumed that there is a unique positive solution 𝜏 of Φ(𝜏 ) − 𝜏 Φ′ (𝜏 ) = 0.
If Φ is 𝑝-periodic, then we have 𝑦(𝑧) = 𝑧𝑔(𝑧 𝑝 ). This method returns the singular expansion of 𝑔(𝑧).
INPUT:
• var – a string for the variable name.
• phi – the function Φ. See the extended description for assumptions on Φ.
• period – the period of the function Φ. See the extended description for details.
• tau – (default: None) the fundamental constant described in the extended description. If None, then
𝜏 is determined automatically if possible.
• precision – (default: None) an integer. If None, then the default precision of the asymptotic ring
is used.
OUTPUT:
An asymptotic expansion.
Note: In the given case, the radius of convergence of the function of interest is known to be 𝜌 = 𝜏 /Φ(𝜏 ).
Until trac ticket #20050 is implemented, the variable in the returned asymptotic expansion represents a
singular element of the form (1 − 𝑧/𝜌)−1 , for the variable 𝑧 → 𝜌.
See also:
ImplicitExpansion(), InverseFunctionAnalysis().
EXAMPLES:
The generating function enumerating binary trees with respect to tree size satisfies 𝐵(𝑧) = 𝑧(1 + 𝐵(𝑧)2 ).
This
√
function can be written as 𝐵(𝑧) = 𝑧𝑔(𝑧 2 ), and as 𝐵(𝑧) can be determined explicitly we have 𝑔(𝑧) =
1− 1−4𝑧
2𝑧 . We compare the corresponding expansions:
sage: asymptotic_expansions.ImplicitExpansionPeriodicPart('Z', phi=lambda u:
˓→1 + u^2,
....: period=2,
˓→precision=7)
doctest:warning
...
FutureWarning: This class/method/function is marked as experimental. It, its
˓→functionality or its interface might change without a formal deprecation.
Note: It is not checked that the passed period actually fits to the passed function Φ.
The resulting asymptotic expansion is only valid for 𝑛 ≡ 1 mod 𝑝, where 𝑝 is the period. All other
coefficients are 0.
EXAMPLES:
There are 𝐶𝑛 (the 𝑛-th Catalan number) different binary trees of size 2𝑛 + 1, and there are no binary trees
with an even number of nodes. The corresponding generating function satisfies 𝐵(𝑧) = 𝑧(1 + 𝐵(𝑧)2 ),
which allows us to compare the asymptotic expansions for the number of binary trees of size 𝑛 obtained
via 𝐶𝑛 and obtained via the analysis of 𝐵(𝑧):
The code in the aperiodic case is more efficient, however. Therefore, it is recommended to use com-
binatorial identities to reduce to the aperiodic case. In the example above, this is well-known: we
now count binary trees with 𝑛 internal nodes. The corresponding generating function satisfies 𝐵(𝑧) =
𝑧(1 + 2𝐵(𝑧) + 𝐵(𝑧)2 ):
sage: catalan_expansion
1/sqrt(pi)*4^n*n^(-3/2) - 9/8/sqrt(pi)*4^n*n^(-5/2)
+ 145/128/sqrt(pi)*4^n*n^(-7/2) + O(4^n*n^(-9/2))
sage: asymptotic_expansions.InverseFunctionAnalysis(n, phi=lambda u: 1 + 2*u
˓→+ u^2,
sage: forget()
See also:
ImplicitExpansion(), ImplicitExpansionPeriodicPart().
static SingularityAnalysis(var, zeta=1, alpha=0, beta=0, delta=0, precision=None, normal-
ized=True)
Return the asymptotic expansion of the coefficients of an power series with specified pole and logarithmic
singularity.
More precisely, this extracts the 𝑛-th coefficient
(︂ )︂𝛼 (︂ )︂𝛽 (︂ (︂ )︂)︂𝛿
𝑛 1 1 1 1 1 1
[𝑧 ] log log log
1 − 𝑧/𝜁 𝑧/𝜁 1 − 𝑧/𝜁 𝑧/𝜁 𝑧/𝜁 1 − 𝑧/𝜁
(if normalized=False).
INPUT:
• var – a string for the variable name.
• zeta – (default: 1) the location of the singularity.
• alpha – (default: 0) the pole order of the singularity.
• beta – (default: 0) the order of the logarithmic singularity.
• delta – (default: 0) the order of the log-log singularity. Not yet implemented for delta != 0.
• precision – (default: None) an integer. If None, then the default precision of the asymptotic ring
is used.
• normalized – (default: True) a boolean, see above.
OUTPUT:
An asymptotic expansion.
EXAMPLES:
sage: S = SR.subring(rejecting_variables=('n',))
sage: asymptotic_expansions.SingularityAnalysis(
....: 'n', alpha=S.var('a'),
....: precision=4).map_coefficients(lambda c: c.factor())
1/gamma(a)*n^(a - 1)
+ (1/2*(a - 1)*a/gamma(a))*n^(a - 2)
+ (1/24*(3*a - 1)*(a - 1)*(a - 2)*a/gamma(a))*n^(a - 3)
+ (1/48*(a - 1)^2*(a - 2)*(a - 3)*a^2/gamma(a))*n^(a - 4)
+ O(n^(a - 5))
sage: _.parent()
Asymptotic Ring <n^(Symbolic Subring rejecting the variable n)>
over Symbolic Subring rejecting the variable n
sage: ae = asymptotic_expansions.SingularityAnalysis('n',
....: alpha=1/2, beta=1, precision=4); ae
1/sqrt(pi)*n^(-1/2)*log(n) + ((euler_gamma + 2*log(2))/sqrt(pi))*n^(-1/2)
- 5/8/sqrt(pi)*n^(-3/2)*log(n) + (1/8*(3*euler_gamma + 6*log(2) - 8)/sqrt(pi)
- (euler_gamma + 2*log(2) - 2)/sqrt(pi))*n^(-3/2) + O(n^(-5/2)*log(n))
sage: n = ae.parent().gen()
sage: ae.subs(n=n-1).map_coefficients(lambda x: x.canonicalize_radical())
1/sqrt(pi)*n^(-1/2)*log(n)
+ ((euler_gamma + 2*log(2))/sqrt(pi))*n^(-1/2)
- 1/8/sqrt(pi)*n^(-3/2)*log(n)
+ (-1/8*(euler_gamma + 2*log(2))/sqrt(pi))*n^(-3/2)
+ O(n^(-5/2)*log(n))
sage: asymptotic_expansions.SingularityAnalysis('n',
....: alpha=1, beta=1/2, precision=4)
log(n)^(1/2) + 1/2*euler_gamma*log(n)^(-1/2)
+ (-1/8*euler_gamma^2 + 1/48*pi^2)*log(n)^(-3/2)
+ (1/16*euler_gamma^3 - 1/32*euler_gamma*pi^2 + 1/8*zeta(3))*log(n)^(-5/2)
+ O(log(n)^(-7/2))
sage: ae = asymptotic_expansions.SingularityAnalysis('n',
....: alpha=0, beta=2, precision=14)
sage: n = ae.parent().gen()
sage: ae.subs(n=n-2)
2*n^(-1)*log(n) + 2*euler_gamma*n^(-1) - n^(-2) - 1/6*n^(-3) + O(n^(-5))
sage: asymptotic_expansions.SingularityAnalysis(
....: 'n', 1, alpha=-1/2, beta=1, precision=2, normalized=False)
-1/2/sqrt(pi)*n^(-3/2)*log(n)
+ (-1/2*(euler_gamma + 2*log(2) - 2)/sqrt(pi))*n^(-3/2)
+ O(n^(-5/2)*log(n))
sage: asymptotic_expansions.SingularityAnalysis(
....: 'n', 1/2, alpha=0, beta=1, precision=3, normalized=False)
2^n*n^(-1) + O(2^n*n^(-2))
ALGORITHM:
See [FS2009].
static Stirling(var, precision=None, skip_constant_factor=False)
Return Stirling’s approximation formula for factorials.
INPUT:
• var – a string for the variable name.
• precision – (default: None) an integer ≥ 3. If None, then the default precision of the asymptotic
ring is used.
√
• skip_constant_factor – (default: False) a boolean. If set, then the constant factor 2𝜋 is
left out. As a consequence, the coefficient ring of the output changes from Symbolic Constants
Subring (if False) to Rational Field (if True).
OUTPUT:
An asymptotic expansion.
EXAMPLES:
See also:
log_Stirling(), factorial().
static log_Stirling(var, precision=None, skip_constant_summand=False)
Return the logarithm of Stirling’s approximation formula for factorials.
INPUT:
• var – a string for the variable name.
• precision – (default: None) an integer. If None, then the default precision of the asymptotic ring
is used.
• skip_constant_summand – (default: False) a boolean. If set, then the constant summand
log(2𝜋)/2 is left out. As a consequence, the coefficient ring of the output changes from Symbolic
Constants Subring (if False) to Rational Field (if True).
OUTPUT:
An asymptotic expansion.
EXAMPLES:
See also:
Stirling(), factorial().
sage.rings.asymptotic.asymptotic_expansion_generators.asymptotic_expansions = <sage.rings.a
A collection of several common asymptotic expansions.
This is an instance of AsymptoticExpansionGenerators whose documentation provides more details.
Many growth groups can be described by a string, which can also be used to create them. For example, the string
'x^QQ * log(x)^ZZ * QQ^y * y^QQ' represents a growth group with the following properties:
• It is a growth group in the two variables 𝑥 and 𝑦.
• Its elements are of the form
𝑥𝑟 · log(𝑥)𝑠 · 𝑎𝑦 · 𝑦 𝑞
for 𝑟 ∈ Q, 𝑠 ∈ Z, 𝑎 ∈ Q and 𝑞 ∈ Q.
• The order is with respect to 𝑥 → ∞ and 𝑦 → ∞ independently of each other.
• To compare such elements, they are split into parts belonging to only one variable. In the example above,
if (𝑟1 , 𝑠1 ) ≤ (𝑟2 , 𝑠2 ) lexicographically. This reflects the fact that elements 𝑥𝑟 are larger than elements log(𝑥)𝑠
as 𝑥 → ∞. The factors belonging to the variable 𝑦 are compared analogously.
The results of these comparisons are then put together using the product order, i.e., ≤ if each component satisfies
≤.
Each description string consists of ordered factors—yes, this means * is noncommutative—of strings describing “el-
ementary” growth groups (see the examples below). As stated in the example above, these factors are split by their
variable; factors with the same variable are grouped. Reading such factors from left to right determines the order:
Comparing elements of two factors (growth groups) 𝐿 and 𝑅, then all elements of 𝐿 are considered to be larger than
each element of 𝑅.
For many purposes the factory GrowthGroup (see GrowthGroupFactory) is the most convenient way to gen-
erate a growth group.
sage: GrowthGroup('z^ZZ')
Growth Group z^ZZ
sage: M = GrowthGroup('z^QQ'); M
Growth Group z^QQ
Each of these two generated groups is a MonomialGrowthGroup, whose elements are powers of a fixed symbol
(above 'z'). For the order of the elements it is assumed that 𝑧 → ∞.
Note: Growth groups where the variable tend to some value distinct from ∞ are not yet implemented.
sage: z = M.gen()
sage: z^(3/5)
z^(3/5)
sage: M('z^7')
z^7
sage: GrowthGroup('log(z)^QQ')
Growth Group log(z)^QQ
sage: E = GrowthGroup('(QQ_+)^z'); E
Growth Group QQ^z
sage: E.an_element()
(1/2)^z
The group 𝐶 itself is a Cartesian product; to be precise a UnivariateProduct. We can see its factors:
sage: C.cartesian_factors()
(Growth Group QQ^z, Growth Group z^QQ, Growth Group log(z)^QQ)
Some Examples
A monomial growth group itself is totally ordered, all elements are comparable. However, this does not hold for
Cartesian products:
sage: e1 = x^2*y; e2 = x*y^2
sage: e1 <= e2 or e2 <= e1
False
The above is True since the order of the factors does not play a role here; they use different variables. But when using
the same variable, it plays a role:
In this case the components are ordered lexicographically, which means that in the second growth group, log(x) is
assumed to grow faster than x (which is nonsense, mathematically). See CartesianProduct for more details or
see above for a more extensive description.
Short notation also allows the construction of more complicated growth groups:
AUTHORS:
• Benjamin Hackl (2015)
• Daniel Krenn (2015)
• Clemens Heuberger (2016)
ACKNOWLEDGEMENT:
• Benjamin Hackl, Clemens Heuberger and Daniel Krenn are supported by the Austrian Science Fund (FWF): P
24644-N26.
• Benjamin Hackl is supported by the Google Summer of Code 2015.
See also:
Asymptotic Ring, ExponentialGrowthGroupFunctor, MonomialGrowthGroupFunctor, sage.
rings.asymptotic.asymptotic_ring.AsymptoticRingFunctor, sage.categories.
pushout.ConstructionFunctor.
merge(other)
Merge this functor with other of possible.
INPUT:
• other – a functor.
OUTPUT:
A functor or None.
EXAMPLES:
class sage.rings.asymptotic.growth_group.ExponentialGrowthElement(parent,
raw_element)
Bases: sage.rings.asymptotic.growth_group.GenericGrowthElement
An implementation of exponential growth elements.
INPUT:
• parent – an ExponentialGrowthGroup.
• raw_element – an element from the base ring of the parent.
This raw_element is the base of the created exponential growth element.
An exponential growth element represents a term of the type basevariable . The multiplication corresponds to the
multiplication of the bases.
EXAMPLES:
base
The base of this exponential growth element.
EXAMPLES:
The elements ExponentialGrowthElement of this group represent exponential functions with bases from
a fixed base ring; the group law is the multiplication.
INPUT:
• base – one of SageMath’s parents, out of which the elements get their data (raw_element).
As exponential expressions are represented by this group, the elements in base are the bases of these
exponentials.
• var – an object.
The string representation of var acts as an exponent of the elements represented by this group.
• category – (default: None) the category of the newly created growth group. It has to be a subcate-
gory of Join of Category of groups and Category of posets. This is also the default
category if None is specified.
EXAMPLES:
See also:
GenericGrowthGroup
DivisionRings
alias of sage.categories.division_rings.DivisionRings
Element
alias of ExponentialGrowthElement
Groups
alias of sage.categories.groups.Groups
Magmas
alias of sage.categories.magmas.Magmas
Posets
alias of sage.categories.posets.Posets
Sets
alias of sage.categories.sets_cat.Sets
construction()
Return the construction of this growth group.
OUTPUT:
A pair whose first entry is an exponential construction functor and its second entry the
base.
EXAMPLES:
INPUT:
• base, var, keywords – use in the initialization of the exponential growth group; see
ExponentialGrowthGroup for details.
• extend_by_non_growth_group – a boolean (default True). If set, then the growth group con-
sists of two parts, one part dealing with the absolute values of the bases and one for their arguments.
• return_factors – a boolean (default: False). If set, then a tuple of the (cartesian) factors of
this growth group is returned.
OUTPUT:
A growth group or tuple of growth groups.
EXAMPLES:
gens()
Return a tuple of all generators of this exponential growth group.
INPUT:
Nothing.
OUTPUT:
An empty tuple.
EXAMPLES:
non_growth_group()
Return a non-growth group (with an argument group, e.g. roots of unity, as base) compatible with this
exponential growth group.
OUTPUT:
A group group.
EXAMPLES:
some_elements()
Return some elements of this exponential growth group.
See TestSuite for a typical use case.
INPUT:
Nothing.
OUTPUT:
An iterator.
EXAMPLES:
class sage.rings.asymptotic.growth_group.ExponentialGrowthGroupFunctor(var)
Bases: sage.rings.asymptotic.growth_group.AbstractGrowthGroupFunctor
A construction functor for exponential growth groups.
INPUT:
• var – a string or list of strings (or anything else Variable accepts).
EXAMPLES:
sage: GrowthGroup('(QQ_+)^z').construction()[0]
ExponentialGrowthGroup[z]
See also:
Asymptotic Ring, AbstractGrowthGroupFunctor, MonomialGrowthGroupFunctor, sage.
rings.asymptotic.asymptotic_ring.AsymptoticRingFunctor, sage.categories.
pushout.ConstructionFunctor.
class sage.rings.asymptotic.growth_group.ExponentialNonGrowthElement(parent,
raw_element)
Bases: sage.rings.asymptotic.growth_group.GenericNonGrowthElement, sage.
rings.asymptotic.growth_group.ExponentialGrowthElement
An element of ExponentialNonGrowthGroup.
class sage.rings.asymptotic.growth_group.ExponentialNonGrowthGroup(base,
*args,
**kwds)
Bases: sage.rings.asymptotic.growth_group.GenericNonGrowthGroup, sage.rings.
asymptotic.growth_group.ExponentialGrowthGroup
A growth group whose base is an argument group.
EXAMPLES:
Element
alias of ExponentialNonGrowthElement
construction()
Return the construction of this growth group.
OUTPUT:
A pair whose first entry is an ExponentialNonGrowthGroupFunctor and its second entry the
base.
EXAMPLES:
class sage.rings.asymptotic.growth_group.ExponentialNonGrowthGroupFunctor(var)
Bases: sage.rings.asymptotic.growth_group.ExponentialGrowthGroupFunctor
A construction functor for ExponentialNonGrowthGroup.
class sage.rings.asymptotic.growth_group.GenericGrowthElement(parent,
raw_element)
Bases: sage.structure.element.MultiplicativeGroupElement
A basic implementation of a generic growth element.
Growth elements form a group by multiplication, and (some of) the elements can be compared to each other,
i.e., all elements form a poset.
INPUT:
• parent – a GenericGrowthGroup.
• raw_element – an element from the base of the parent.
EXAMPLES:
factors()
Return the atomic factors of this growth element. An atomic factor cannot be split further.
INPUT:
Nothing.
OUTPUT:
is_lt_one()
Return whether this element is less than 1.
INPUT:
Nothing.
OUTPUT:
A boolean.
EXAMPLES:
log(base=None)
Return the logarithm of this element.
INPUT:
• base – the base of the logarithm. If None (default value) is used, the natural logarithm is taken.
OUTPUT:
A growth element.
EXAMPLES:
sage: x = GrowthGroup('x^ZZ').an_element()
sage: log(x) # indirect doctest
Traceback (most recent call last):
...
ArithmeticError: Cannot build log(x) since log(x) is not in
Growth Group x^ZZ.
log_factor(base=None, locals=None)
Return the logarithm of the factorization of this element.
INPUT:
• base – the base of the logarithm. If None (default value) is used, the natural logarithm is taken.
• locals – a dictionary which may contain the following keys and values:
– 'log' – value: a function. If not used, then the usual log is taken.
OUTPUT:
A tuple of pairs, where the first entry is a growth element and the second a multiplicative coefficient.
ALGORITHM:
This function factors the given element and calculates the logarithm of each of these factors.
EXAMPLES:
sage: G(1).log_factor()
()
See also:
factors(), log().
rpow(base)
Calculate the power of base to this element.
INPUT:
• base – an element.
OUTPUT:
A growth element.
EXAMPLES:
variable_names()
Return the names of the variables of this growth element.
OUTPUT:
A tuple of strings.
EXAMPLES:
sage: G = GrowthGroup('QQ^m')
sage: G('2^m').variable_names()
('m',)
sage: G('1^m').variable_names()
()
EXAMPLES:
See also:
MonomialGrowthGroup, ExponentialGrowthGroup
AdditiveMagmas
alias of sage.categories.additive_magmas.AdditiveMagmas
Element
alias of GenericGrowthElement
Magmas
alias of sage.categories.magmas.Magmas
Posets
alias of sage.categories.posets.Posets
Sets
alias of sage.categories.sets_cat.Sets
extended_by_non_growth_group()
Extend to a cartesian product of this growth group and a suitable non growth group.
OUTPUT:
A group group.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: GrowthGroup('(QQ_+)^x').extended_by_non_growth_group()
Growth Group QQ^x * Signs^x
sage: GrowthGroup('(RR_+)^x').extended_by_non_growth_group()
Growth Group RR^x * Signs^x
sage: GrowthGroup('(RIF_+)^x').extended_by_non_growth_group()
Growth Group RIF^x * Signs^x
sage: GrowthGroup('(RBF_+)^x').extended_by_non_growth_group()
Growth Group RBF^x * Signs^x
sage: GrowthGroup('(CC_+)^x').extended_by_non_growth_group()
Growth Group CC^x * UU_RR^x
sage: GrowthGroup('(CIF_+)^x').extended_by_non_growth_group()
Growth Group CIF^x * UU_RIF^x
sage: GrowthGroup('(CBF_+)^x').extended_by_non_growth_group()
Growth Group CBF^x * UU_RBF^x
gen(n=0)
Return the 𝑛-th generator (as a group) of this growth group.
INPUT:
• n – default: 0.
OUTPUT:
A MonomialGrowthElement.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: P = GrowthGroup('x^ZZ')
sage: P.gen()
x
sage: P = GrowthGroup('(QQ_+)^x')
sage: P.gen()
Traceback (most recent call last):
...
IndexError: tuple index out of range
gens()
Return a tuple of all generators of this growth group.
INPUT:
Nothing.
OUTPUT:
A tuple whose entries are growth elements.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: P = GrowthGroup('x^ZZ')
sage: P.gens()
(continues on next page)
gens_monomial()
Return a tuple containing monomial generators of this growth group.
INPUT:
Nothing.
OUTPUT:
An empty tuple.
Note: A generator is called monomial generator if the variable of the underlying growth group is a valid
identifier. For example, x^ZZ has x as a monomial generator, while log(x)^ZZ or icecream(x)^ZZ
do not have monomial generators.
is_compatible(other)
Return whether this growth group is compatible with other meaning that both are of the same type and
have the same variables, but maybe a different base.
INPUT:
• other – a growth group
EXAMPLES:
le(left, right)
Return whether the growth of left is at most (less than or equal to) the growth of right.
INPUT:
• left – an element.
• right – an element.
OUTPUT:
A boolean.
Note: This function uses the coercion model to find a common parent for the two operands.
EXAMPLES:
ngens()
Return the number of generators (as a group) of this growth group.
INPUT:
Nothing.
OUTPUT:
A Python integer.
EXAMPLES:
sage: P = GrowthGroup('(QQ_+)^x')
sage: P.ngens()
0
non_growth_group()
Return a non-growth group compatible with this growth group.
OUTPUT:
A group group.
EXAMPLES:
some_elements()
Return some elements of this growth group.
See TestSuite for a typical use case.
INPUT:
Nothing.
OUTPUT:
An iterator.
EXAMPLES:
variable_names()
Return the names of the variables of this growth group.
OUTPUT:
A tuple of strings.
EXAMPLES:
sage: GrowthGroup('(QQ_+)^x').variable_names()
('x',)
sage: GrowthGroup('(QQ_+)^(x*log(x))').variable_names()
('x',)
class sage.rings.asymptotic.growth_group.GenericNonGrowthElement(parent,
raw_element)
Bases: sage.rings.asymptotic.growth_group.GenericGrowthElement
An element of GenericNonGrowthGroup.
class sage.rings.asymptotic.growth_group.GenericNonGrowthGroup(base, var, cate-
gory)
Bases: sage.rings.asymptotic.growth_group.GenericGrowthGroup
A (abstract) growth group whose elements are all of the same growth 1.
See ExponentialNonGrowthGroup for a concrete realization.
sage.rings.asymptotic.growth_group.GrowthGroup = <sage.rings.asymptotic.growth_group.Growth
A factory for growth groups. This is an instance of GrowthGroupFactory whose documentation provides
more details.
class sage.rings.asymptotic.growth_group.GrowthGroupFactor
Bases: tuple
base
Alias for field number 1
cls
Alias for field number 0
extend_by_non_growth_group
Alias for field number 3
var
Alias for field number 2
class sage.rings.asymptotic.growth_group.GrowthGroupFactory
Bases: sage.structure.factory.UniqueFactory
A factory creating asymptotic growth groups.
INPUT:
• specification – a string.
• keyword arguments are passed on to the growth group constructor. If the keyword ignore_variables
is not specified, then ignore_variables=('e',) (to ignore e as a variable name) is used.
OUTPUT:
An asymptotic growth group.
EXAMPLES:
This factory can also be used to construct Cartesian products of growth groups:
sage: GrowthGroup('n^(ZZ)')
Growth Group n^ZZ
sage: GrowthGroup('n^(ZZ[I])')
Growth Group n^ZZ * n^(ZZ*I)
sage: GrowthGroup('n^(I*ZZ)')
Growth Group n^(ZZ*I)
sage: GrowthGroup('n^(ZZ*I)')
Growth Group n^(ZZ*I)
create_key_and_extra_args(specification, **kwds)
Given the arguments and keyword, create a key that uniquely determines this object.
create_object(version, factors, **kwds)
Create an object from the given arguments.
class sage.rings.asymptotic.growth_group.MonomialGrowthElement(parent,
raw_element)
Bases: sage.rings.asymptotic.growth_group.GenericGrowthElement
An implementation of monomial growth elements.
INPUT:
• parent – a MonomialGrowthGroup.
• raw_element – an element from the base ring of the parent.
This raw_element is the exponent of the created monomial growth element.
A monomial growth element represents a term of the type variableexponent . The multiplication corresponds to
the addition of the exponents.
EXAMPLES:
exponent
The exponent of this growth element.
EXAMPLES:
See also:
GenericGrowthGroup
AdditiveMagmas
alias of sage.categories.additive_magmas.AdditiveMagmas
Element
alias of MonomialGrowthElement
Magmas
alias of sage.categories.magmas.Magmas
Posets
alias of sage.categories.posets.Posets
Sets
alias of sage.categories.sets_cat.Sets
construction()
Return the construction of this growth group.
OUTPUT:
A pair whose first entry is a monomial construction functor and its second entry the base.
EXAMPLES:
gens_logarithmic()
Return a tuple containing logarithmic generators of this growth group.
INPUT:
Nothing.
OUTPUT:
A tuple containing elements of this growth group.
Note: A generator is called logarithmic generator if the variable of the underlying growth group is the
logarithm of a valid identifier. For example, x^ZZ has no logarithmic generator, while log(x)^ZZ has
log(x) as logarithmic generator.
gens_monomial()
Return a tuple containing monomial generators of this growth group.
INPUT:
Nothing.
OUTPUT:
A tuple containing elements of this growth group.
Note: A generator is called monomial generator if the variable of the underlying growth group is a valid
identifier. For example, x^ZZ has x as a monomial generator, while log(x)^ZZ or icecream(x)^ZZ
do not have monomial generators.
non_growth_group()
Return a non-growth group (with an imaginary group as base) compatible with this monomial growth
group.
OUTPUT:
A group group.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: GrowthGroup('n^ZZ').non_growth_group()
Growth Group n^(ZZ*I)
class sage.rings.asymptotic.growth_group.MonomialGrowthGroupFunctor(var)
Bases: sage.rings.asymptotic.growth_group.AbstractGrowthGroupFunctor
A construction functor for monomial growth groups.
INPUT:
• var – a string or list of strings (or anything else Variable accepts).
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup,
˓→MonomialGrowthGroupFunctor
sage: GrowthGroup('z^QQ').construction()[0]
MonomialGrowthGroup[z]
See also:
Asymptotic Ring, AbstractGrowthGroupFunctor, ExponentialGrowthGroupFunctor, sage.
rings.asymptotic.asymptotic_ring.AsymptoticRingFunctor, sage.categories.
pushout.ConstructionFunctor.
class sage.rings.asymptotic.growth_group.MonomialNonGrowthElement(parent,
raw_element)
Bases: sage.rings.asymptotic.growth_group.GenericNonGrowthElement, sage.
rings.asymptotic.growth_group.MonomialGrowthElement
An element of MonomialNonGrowthGroup.
class sage.rings.asymptotic.growth_group.MonomialNonGrowthGroup(base, var, cate-
gory)
Bases: sage.rings.asymptotic.growth_group.GenericNonGrowthGroup, sage.rings.
asymptotic.growth_group.MonomialGrowthGroup
A growth group whose base is an imaginary group.
EXAMPLES:
sage: from sage.groups.misc_gps.imaginary_groups import ImaginaryGroup
sage: from sage.rings.asymptotic.growth_group import MonomialNonGrowthGroup
sage: J = MonomialNonGrowthGroup(ImaginaryGroup(ZZ), 'n')
sage: J.an_element()
n^I
Element
alias of MonomialNonGrowthElement
construction()
Return the construction of this growth group.
OUTPUT:
A pair whose first entry is an MonomialNonGrowthGroupFunctor and its second entry the base.
EXAMPLES:
class sage.rings.asymptotic.growth_group.MonomialNonGrowthGroupFunctor(var)
Bases: sage.rings.asymptotic.growth_group.MonomialGrowthGroupFunctor
A construction functor for MonomialNonGrowthGroup.
class sage.rings.asymptotic.growth_group.PartialConversionElement(growth_group,
raw_element)
Bases: sage.structure.sage_object.SageObject
A not converted element of a growth group.
INPUT:
• growth_group – a group group
• raw_element – an object
A PartialConversionElement is an element growth_group(raw_element) which usually ap-
pears in conjunction with PartialConversionValueError. In this case, it was to possible to create
that element, although the conversion went partially well in the sense that a 𝑟𝑎𝑤𝑒 𝑙𝑒𝑚𝑒𝑛𝑡 (e.g. an exponent for
MonomialGrowthElement or a base for ExponentialGrowthElement) could be extracted.
Its main purpose is to carry data used during the creation of elements of cartesian products of
growth groups.
is_compatible(other)
Wrapper to GenericGrowthGroup.is_compatible().
split()
Split the contained raw_element according to the growth group’s GrowthGroup.
_split_raw_element_().
EXAMPLES:
exception sage.rings.asymptotic.growth_group.PartialConversionValueError(element,
*args,
**kwds)
Bases: ValueError
sage: Variable.extract_variable_names('log(77w)')
('w',)
sage: Variable.extract_variable_names('log(x')
Traceback (most recent call last):
...
TypeError: Bad function call: log(x !!!
sage: Variable.extract_variable_names('x)')
Traceback (most recent call last):
...
TypeError: Malformed expression: x) !!!
sage: Variable.extract_variable_names('log)x(')
Traceback (most recent call last):
(continues on next page)
is_monomial()
Return whether this is a monomial variable.
OUTPUT:
A boolean.
EXAMPLES:
variable_names()
Return the names of the variables.
OUTPUT:
A tuple of strings.
EXAMPLES:
class sage.rings.asymptotic.growth_group_cartesian.CartesianProductFactory
Bases: sage.structure.factory.UniqueFactory
Create various types of Cartesian products depending on its input.
INPUT:
• growth_groups – a tuple (or other iterable) of growth groups.
• order – (default: None) if specified, then this order is taken for comparing two Cartesian product ele-
ments. If order is None this is determined automatically.
Note: The Cartesian product of growth groups is again a growth group. In particular, the resulting structure is
partially ordered.
The order on the product is determined as follows:
• Cartesian factors with respect to the same variable are ordered lexicographically. This causes
GrowthGroup('x^ZZ * log(x)^ZZ') and GrowthGroup('log(x)^ZZ * x^ZZ') to pro-
duce two different growth groups.
• Factors over different variables are equipped with the product order (i.e. the comparison is component-
wise).
Also, note that the sets of variables of the Cartesian factors have to be either equal or disjoint.
EXAMPLES:
sage: Px = GrowthGroup('x^QQ')
sage: Lx = GrowthGroup('log(x)^ZZ')
sage: Cx = cartesian_product([Px, Lx], order='lex') # indirect doctest
sage: Py = GrowthGroup('y^QQ')
sage: C = cartesian_product([Cx, Py], order='product'); C # indirect doctest
Growth Group x^QQ * log(x)^ZZ * y^QQ
sage: C.an_element()
x^(1/2)*log(x)*y^(1/2)
See also:
CartesianProduct, CartesianProductPoset.
class Element
Bases: sage.combinat.posets.cartesian_product.CartesianProductPoset.
Element
exp()
The exponential of this element.
INPUT:
Nothing.
OUTPUT:
A growth element.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: G = GrowthGroup('x^ZZ * log(x)^ZZ * log(log(x))^ZZ')
sage: x = G('x')
sage: exp(log(x))
x
sage: exp(log(log(x)))
log(x)
sage: exp(x)
Traceback (most recent call last):
...
ArithmeticError: Cannot construct e^x in
Growth Group x^ZZ * log(x)^ZZ * log(log(x))^ZZ
> *previous* TypeError: unsupported operand parent(s) for *:
'Growth Group x^ZZ * log(x)^ZZ * log(log(x))^ZZ' and
'Growth Group (e^x)^ZZ'
factors()
Return the atomic factors of this growth element. An atomic factor cannot be split further and is not
the identity (1).
INPUT:
Nothing.
OUTPUT:
A tuple of growth elements.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: G = GrowthGroup('x^ZZ * log(x)^ZZ * y^ZZ')
sage: x, y = G.gens_monomial()
sage: x.factors()
(x,)
sage: f = (x * y).factors(); f
(x, y)
sage: tuple(factor.parent() for factor in f)
(Growth Group x^ZZ, Growth Group y^ZZ)
sage: f = (x * log(x)).factors(); f
(continues on next page)
sage: G.one().factors()
()
is_lt_one()
Return whether this element is less than 1.
INPUT:
Nothing.
OUTPUT:
A boolean.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: G = GrowthGroup('x^ZZ'); x = G(x)
sage: (x^42).is_lt_one() # indirect doctest
False
sage: (x^(-42)).is_lt_one() # indirect doctest
True
log(base=None)
Return the logarithm of this element.
INPUT:
• base – the base of the logarithm. If None (default value) is used, the natural logarithm is taken.
OUTPUT:
A growth element.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: G = GrowthGroup('x^ZZ * log(x)^ZZ')
sage: x, = G.gens_monomial()
sage: log(x) # indirect doctest
log(x)
sage: log(x^5) # indirect doctest
Traceback (most recent call last):
...
ArithmeticError: When calculating log(x^5) a factor 5 != 1 appeared,
which is not contained in Growth Group x^ZZ * log(x)^ZZ.
sage: x = GrowthGroup('x^ZZ').an_element()
sage: log(x) # indirect doctest
Traceback (most recent call last):
...
ArithmeticError: Cannot build log(x) since log(x) is not in
Growth Group x^ZZ.
log_factor(base=None, locals=None)
Return the logarithm of the factorization of this element.
INPUT:
• base – the base of the logarithm. If None (default value) is used, the natural logarithm is taken.
• locals – a dictionary which may contain the following keys and values:
– 'log' – value: a function. If not used, then the usual log is taken.
OUTPUT:
A tuple of pairs, where the first entry is a growth element and the second a multiplicative coefficient.
ALGORITHM:
This function factors the given element and calculates the logarithm of each of these factors.
EXAMPLES:
sage: G(1).log_factor()
()
See also:
factors(), log().
rpow(base)
Calculate the power of base to this element.
INPUT:
• base – an element.
OUTPUT:
A growth element.
EXAMPLES:
variable_names()
Return the names of the variables of this growth element.
OUTPUT:
A tuple of strings.
EXAMPLES:
cartesian_injection(factor, element)
Inject the given element into this Cartesian product at the given factor.
INPUT:
• factor – a growth group (a factor of this Cartesian product).
• element – an element of factor.
OUTPUT:
An element of this Cartesian product.
gens_monomial()
Return a tuple containing monomial generators of this growth group.
INPUT:
Nothing.
OUTPUT:
A tuple containing elements of this growth group.
Note: This method calls the gens_monomial() method on the individual factors of this Cartesian
product and concatenates the respective outputs.
EXAMPLES:
some_elements()
Return some elements of this Cartesian product of growth groups.
See TestSuite for a typical use case.
OUTPUT:
An iterator.
EXAMPLES:
variable_names()
Return the names of the variables.
OUTPUT:
A tuple of strings.
EXAMPLES:
class sage.rings.asymptotic.growth_group_cartesian.MultivariateProduct(sets,
cat-
e-
gory,
**kwargs)
Bases: sage.rings.asymptotic.growth_group_cartesian.GenericProduct
A Cartesian product of growth groups with pairwise disjoint (or equal) variable sets.
Note: A multivariate product of growth groups is ordered by means of the product order, i.e. component-wise.
This is motivated by the assumption that different variables are considered to be independent (e.g. x^ZZ *
y^ZZ).
See also:
UnivariateProduct, GenericProduct.
class sage.rings.asymptotic.growth_group_cartesian.UnivariateProduct(sets,
cate-
gory,
**kwargs)
Bases: sage.rings.asymptotic.growth_group_cartesian.GenericProduct
A Cartesian product of growth groups with the same variables.
Note: A univariate product of growth groups is ordered lexicographically. This is motivated by the assumption
that univariate growth groups can be ordered in a chain with respect to the growth they model (e.g. x^ZZ *
log(x)^ZZ: polynomial growth dominates logarithmic growth).
See also:
MultivariateProduct, GenericProduct.
This module implements asymptotic term monoids. The elements of these monoids are used behind the scenes when
performing calculations in an asymptotic ring.
The monoids build upon the (asymptotic) growth groups. While growth elements only model the growth of a function
as it tends towards infinity (or tends towards another fixed point; see (Asymptotic) Growth Groups for more details),
an asymptotic term additionally specifies its “type” and performs the actual arithmetic operations (multiplication and
partial addition/absorption of terms).
Besides an abstract base term GenericTerm, this module implements the following types of terms:
• OTerm – 𝑂-terms at infinity, see Wikipedia article Big_O_notation.
• TermWithCoefficient – abstract base class for asymptotic terms with coefficients.
• ExactTerm – this class represents a growth element multiplied with some non-zero coefficient from a coeffi-
cient ring.
A characteristic property of asymptotic terms is that some terms are able to “absorb” other terms (see absorb()).
For instance, 𝑂(𝑥2 ) is able to absorb 𝑂(𝑥) (with result 𝑂(𝑥2 )), and 3 · 𝑥5 is able to absorb −2 · 𝑥5 (with result 𝑥5 ).
Essentially, absorption can be interpreted as the addition of “compatible” terms (partial addition).
A characteristic property of asymptotic terms is that some terms are able to “absorb” other terms. This is realized with
the method absorb().
For instance, 𝑂(𝑥2 ) is able to absorb 𝑂(𝑥) (with result 𝑂(𝑥2 )). This is because the functions bounded by linear
growth are bounded by quadratic growth as well. Another example would be that 3𝑥5 is able to absorb −2𝑥5 (with
result 𝑥5 ), which simply corresponds to addition.
Essentially, absorption can be interpreted as the addition of “compatible” terms (partial addition).
We want to show step by step which terms can be absorbed by which other terms. We start by defining the necessary
term monoids and some terms:
• Because of the definition of 𝑂-terms (see Wikipedia article Big_O_notation), OTerm are able to absorb all other
asymptotic terms with weaker or equal growth. In our implementation, this means that OTerm is able to absorb
other OTerm, as well as ExactTerm, as long as the growth of the other term is less than or equal to the growth
of this element:
sage: ot1.absorb(ot1)
O(x)
sage: ot2.absorb(ot1)
O(x^2)
sage: ot2.absorb(et1)
O(x^2)
These examples correspond to 𝑂(𝑥) + 𝑂(𝑥) = 𝑂(𝑥), 𝑂(𝑥2 ) + 𝑂(𝑥) = 𝑂(𝑥2 ), and 𝑂(𝑥2 ) + 2𝑥2 = 𝑂(𝑥2 ).
• ExactTerm can only absorb another ExactTerm if the growth coincides with the growth of this element:
When adding two exact terms, they might cancel out. For technical reasons, None is returned in this case:
• The abstract base terms GenericTerm and TermWithCoefficient can neither absorb any other term,
nor be absorbed by any other term.
If absorb is called on a term that cannot be absorbed, an ArithmeticError is raised:
sage: ot1.absorb(ot2)
Traceback (most recent call last):
...
ArithmeticError: O(x) cannot absorb O(x^2)
sage: ot2.absorb(ot1)
O(x^2)
4.5.2 Comparison
4.5.3 Various
Todo:
• Implementation of more term types (e.g. 𝐿 terms, Ω terms, 𝑜 terms, Θ terms).
AUTHORS:
• Benjamin Hackl (2015)
• Daniel Krenn (2015)
• Clemens Heuberger (2016)
ACKNOWLEDGEMENT:
• Benjamin Hackl, Clemens Heuberger and Daniel Krenn are supported by the Austrian Science Fund (FWF): P
24644-N26.
• Benjamin Hackl is supported by the Google Summer of Code 2015.
Asymptotic exact terms may be multiplied (with the usual rules applying):
Note that, as for technical reasons, 0 is not allowed as a coefficient for an asymptotic term with coefficient.
Instead None is returned if two asymptotic exact terms cancel out each other during absorption:
Exact terms can also be created by converting monomials with coefficient from the symbolic ring, or a suitable
polynomial or power series ring:
can_absorb(other)
Check whether this exact term can absorb other.
INPUT:
• other – an asymptotic term.
OUTPUT:
A boolean.
Note: For ExactTerm, absorption corresponds to addition. This means that an exact term can absorb
only other exact terms with the same growth.
EXAMPLES:
is_constant()
Return whether this term is an (exact) constant.
INPUT:
Nothing.
OUTPUT:
A boolean.
EXAMPLES:
is_exact()
Return whether this term is an exact term.
OUTPUT:
A boolean.
EXAMPLES:
is_little_o_of_one()
Return whether this exact term is of order 𝑜(1).
INPUT:
Nothing.
OUTPUT:
A boolean.
EXAMPLES:
log_term(base=None, locals=None)
Determine the logarithm of this exact term.
INPUT:
• base – the base of the logarithm. If None (default value) is used, the natural logarithm is taken.
• locals – a dictionary which may contain the following keys and values:
– 'log' – value: a function. If not used, then the usual log is taken.
OUTPUT:
A tuple of terms.
Note: This method returns a tuple with the summands that come from applying the rule log(𝑥 · 𝑦) =
log(𝑥) + log(𝑦).
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: from sage.rings.asymptotic.term_monoid import TermMonoidFactory
sage: TermMonoid = TermMonoidFactory('__main__.TermMonoid')
sage: T = TermMonoid('exact', GrowthGroup('x^ZZ * log(x)^ZZ'), SR)
sage: T(3*x^2).log_term()
(log(3), 2*log(x))
sage: T(x^1234).log_term()
(1234*log(x),)
sage: T(49*x^7).log_term(base=7)
(2, 7/log(7)*log(x))
See also:
OTerm.log_term().
rpow(base)
Return the power of base to this exact term.
INPUT:
• base – an element or 'e'.
OUTPUT:
A term.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: from sage.rings.asymptotic.term_monoid import TermMonoidFactory
sage: TermMonoid = TermMonoidFactory('__main__.TermMonoid')
sage: T = TermMonoid('exact', GrowthGroup('QQ^x * x^ZZ * log(x)^ZZ'), QQ)
sage: T('x').rpow(2)
2^x
sage: T('log(x)').rpow('e')
x
sage: T('42*log(x)').rpow('e')
x^42
sage: T('3*x').rpow(2)
8^x
sage: T('3*x^2').rpow(2)
Traceback (most recent call last):
...
ArithmeticError: Cannot construct 2^(x^2) in
Growth Group QQ^x * x^ZZ * log(x)^ZZ * Signs^x
(continues on next page)
class sage.rings.asymptotic.term_monoid.ExactTermMonoid(term_monoid_factory,
growth_group, coeffi-
cient_ring, category)
Bases: sage.rings.asymptotic.term_monoid.TermWithCoefficientMonoid
Parent for asymptotic exact terms, implemented in ExactTerm.
INPUT:
• growth_group – a growth group.
• category – The category of the parent can be specified in order to broaden the base structure. It has
to be a subcategory of Join of Category of monoids and Category of posets. This is
also the default category if None is specified.
• coefficient_ring – the ring which contains the coefficients of the elements.
EXAMPLES:
Exact term monoids can also be created using the term factory:
Element
alias of ExactTerm
class sage.rings.asymptotic.term_monoid.GenericTerm(parent, growth)
Bases: sage.structure.element.MultiplicativeGroupElement
Base class for asymptotic terms. Mainly the structure and several properties of asymptotic terms are handled
here.
INPUT:
• parent – the parent of the asymptotic term.
• growth – an asymptotic growth element.
EXAMPLES:
sage: t1.can_absorb(t1)
False
absorb(other, check=True)
Absorb the asymptotic term other and return the resulting asymptotic term.
INPUT:
• other – an asymptotic term.
• check – a boolean. If check is True (default), then can_absorb is called before absorption.
OUTPUT:
An asymptotic term or None if a cancellation occurs. If no absorption can be performed, an ArithmeticEr-
ror is raised.
Note: Setting check to False is meant to be used in cases where the respective comparison is done
externally (in order to avoid duplicate checking).
For a more detailed explanation of the absorption of asymptotic terms see the module description.
EXAMPLES:
We want to demonstrate in which cases an asymptotic term is able to absorb another term, as well as
explain the output of this operation. We start by defining some parents and elements:
𝑂-Terms are able to absorb other 𝑂-terms and exact terms with weaker or equal growth.
sage: ot1.absorb(ot1)
O(x)
sage: ot1.absorb(et1)
O(x)
sage: ot1.absorb(et1) is ot1
True
ExactTerm is able to absorb another ExactTerm if the terms have the same growth. In this case,
absorption is nothing else than an addition of the respective coefficients:
sage: et2.absorb(et3)
3*x^2
sage: et3.absorb(et2)
3*x^2
sage: et3.absorb(et4)
-x^2
Note that, for technical reasons, the coefficient 0 is not allowed, and thus None is returned if two exact
terms cancel each other out:
sage: et2.absorb(et4)
sage: et4.absorb(et2) is None
True
can_absorb(other)
Check whether this asymptotic term is able to absorb the asymptotic term other.
INPUT:
• other – an asymptotic term.
OUTPUT:
A boolean.
EXAMPLES:
sage: G = GenericGrowthGroup(ZZ)
sage: T = GenericTermMonoid(TermMonoid, G, QQ)
(continues on next page)
is_constant()
Return whether this term is an (exact) constant.
INPUT:
Nothing.
OUTPUT:
A boolean.
EXAMPLES:
is_exact()
Return whether this term is an exact term.
OUTPUT:
A boolean.
EXAMPLES:
is_little_o_of_one()
Return whether this generic term is of order 𝑜(1).
INPUT:
Nothing.
OUTPUT:
A boolean.
EXAMPLES:
log_term(base=None, locals=None)
Determine the logarithm of this term.
INPUT:
• base – the base of the logarithm. If None (default value) is used, the natural logarithm is taken.
• locals – a dictionary which may contain the following keys and values:
– 'log' – value: a function. If not used, then the usual log is taken.
OUTPUT:
A tuple of terms.
Note: This abstract method raises a NotImplementedError. See ExactTerm and OTerm for a concrete
implementation.
EXAMPLES:
See also:
ExactTerm.log_term(), OTerm.log_term().
rpow(base)
Return the power of base to this generic term.
INPUT:
• base – an element or 'e'.
OUTPUT:
A term.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: from sage.rings.asymptotic.term_monoid import GenericTermMonoid
sage: from sage.rings.asymptotic.term_monoid import TermMonoidFactory
sage: TermMonoid = TermMonoidFactory('__main__.TermMonoid')
variable_names()
Return the names of the variables of this term.
OUTPUT:
A tuple of strings.
EXAMPLES:
sage: from sage.rings.asymptotic.term_monoid import TermMonoidFactory
sage: TermMonoid = TermMonoidFactory('__main__.TermMonoid')
sage: T = TermMonoid('exact', 'QQ^m * m^QQ * log(n)^ZZ', QQ)
sage: T('4 * 2^m * m^4 * log(n)').variable_names()
('m', 'n')
sage: T('4 * 2^m * m^4').variable_names()
('m',)
(continues on next page)
class sage.rings.asymptotic.term_monoid.GenericTermMonoid(term_monoid_factory,
growth_group, coeffi-
cient_ring, category)
Bases: sage.structure.unique_representation.UniqueRepresentation, sage.
structure.parent.Parent, sage.rings.asymptotic.misc.WithLocals
Parent for generic asymptotic terms.
INPUT:
• growth_group – a growth group (i.e. an instance of GenericGrowthGroup).
• coefficient_ring – a ring which contains the (maybe implicit) coefficients of the elements.
• category – The category of the parent can be specified in order to broaden the base structure. It has
to be a subcategory of Join of Category of Monoids and Category of posets. This is
also the default category if None is specified.
In this class the base structure for asymptotic term monoids will be handled. These monoids are the parents
of asymptotic terms (for example, see GenericTerm or OTerm). Basically, asymptotic terms consist of a
growth (which is an asymptotic growth group element, for example MonomialGrowthElement); addi-
tional structure and properties are added by the classes inherited from GenericTermMonoid.
EXAMPLES:
Element
alias of GenericTerm
change_parameter(growth_group=None, coefficient_ring=None)
Return a term monoid with a change in one or more of the given parameters.
INPUT:
• growth_group – (default: None) the new growth group.
• coefficient_ring – (default: None) the new coefficient ring.
OUTPUT:
A term monoid.
EXAMPLES:
coefficient_ring
The coefficient ring of this term monoid, i.e. the ring where the coefficients are from.
EXAMPLES:
growth_group
The growth group underlying this term monoid.
EXAMPLES:
le(left, right)
Return whether the term left is at most (less than or equal to) the term right.
INPUT:
• left – an element.
• right – an element.
OUTPUT:
A boolean.
EXAMPLES:
some_elements()
Return some elements of this term monoid.
See TestSuite for a typical use case.
INPUT:
Nothing.
OUTPUT:
An iterator.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: from sage.rings.asymptotic.term_monoid import TermMonoidFactory
sage: TermMonoid = TermMonoidFactory('__main__.TermMonoid')
sage: G = GrowthGroup('x^ZZ')
sage: tuple(TermMonoid('O', G, QQ).some_elements())
(O(1), O(x), O(x^(-1)), O(x^2), O(x^(-2)), O(x^3), ...)
term_monoid(type)
Return the term monoid of specified type.
INPUT:
• type – ‘O’ or ‘exact’, or an instance of an existing term monoid. See TermMonoidFactory for
more details.
OUTPUT:
A term monoid object derived from GenericTermMonoid.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: from sage.rings.asymptotic.term_monoid import TermMonoidFactory
sage: TermMonoid = TermMonoidFactory('__main__.TermMonoid')
sage: E = TermMonoid('exact', GrowthGroup('x^ZZ'), ZZ); E
Exact Term Monoid x^ZZ with coefficients in Integer Ring
sage: E.term_monoid('O')
O-Term Monoid x^ZZ with implicit coefficients in Integer Ring
term_monoid_factory
The term monoid factory capable of creating this term monoid.
EXAMPLES:
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: from sage.rings.asymptotic.term_monoid import TermMonoidFactory
sage: TermMonoid = TermMonoidFactory('__main__.TermMonoid')
sage: TermMonoid('exact', GrowthGroup('x^ZZ'), ZZ).term_monoid_factory
Term Monoid Factory '__main__.TermMonoid'
The conversion of growth elements also works for the creation of 𝑂-terms:
can_absorb(other)
Check whether this 𝑂-term can absorb other.
INPUT:
• other – an asymptotic term.
OUTPUT:
A boolean.
Note: An OTerm can absorb any other asymptotic term with weaker or equal growth.
See the module description for a detailed explanation of absorption.
EXAMPLES:
is_little_o_of_one()
Return whether this O-term is of order 𝑜(1).
INPUT:
Nothing.
OUTPUT:
A boolean.
EXAMPLES:
log_term(base=None, locals=None)
Determine the logarithm of this O-term.
INPUT:
• base – the base of the logarithm. If None (default value) is used, the natural logarithm is taken.
• locals – a dictionary which may contain the following keys and values:
– 'log' – value: a function. If not used, then the usual log is taken.
OUTPUT:
A tuple of terms.
Note: This method returns a tuple with the summands that come from applying the rule log(𝑥 · 𝑦) =
log(𝑥) + log(𝑦).
EXAMPLES:
See also:
ExactTerm.log_term().
rpow(base)
Return the power of base to this O-term.
INPUT:
• base – an element or 'e'.
OUTPUT:
A term.
Note: For OTerm, the powers can only be constructed for exponents 𝑂(1) or if base is 1.
EXAMPLES:
sage: T.an_element().rpow(1)
1
sage: T('x^2').rpow(1)
1
sage: T.an_element().rpow('e')
Traceback (most recent call last):
(continues on next page)
class sage.rings.asymptotic.term_monoid.OTermMonoid(term_monoid_factory,
growth_group, coefficient_ring,
category)
Bases: sage.rings.asymptotic.term_monoid.GenericTermMonoid
Parent for asymptotic big 𝑂-terms.
INPUT:
• growth_group – a growth group.
• category – The category of the parent can be specified in order to broaden the base structure. It has
to be a subcategory of Join of Category of monoids and Category of posets. This is
also the default category if None is specified.
EXAMPLES:
Element
alias of OTerm
class sage.rings.asymptotic.term_monoid.TermMonoidFactory(name, ex-
act_term_monoid_class=None,
O_term_monoid_class=None)
Bases: sage.structure.unique_representation.UniqueRepresentation, sage.
structure.factory.UniqueFactory
Factory for asymptotic term monoids. It can generate the following term monoids:
• OTermMonoid,
• ExactTermMonoid.
INPUT:
• term_monoid – the kind of terms held in the new term monoid. Either a string 'exact' or 'O'
(capital letter O), or an existing instance of a term monoid.
• growth_group – a growth group or a string describing a growth group.
• coefficient_ring – a ring.
• asymptotic_ring – if specified, then growth_group and coefficient_ring are taken from
this asymptotic ring.
OUTPUT:
An asymptotic term monoid.
EXAMPLES:
class sage.rings.asymptotic.term_monoid.TermWithCoefficientMonoid(term_monoid_factory,
growth_group,
coeffi-
cient_ring,
category)
Bases: sage.rings.asymptotic.term_monoid.GenericTermMonoid
This class implements the base structure for parents of asymptotic terms possessing a coefficient from some
coefficient ring. In particular, this is also the parent for TermWithCoefficient.
INPUT:
• growth_group – a growth group.
• category – The category of the parent can be specified in order to broaden the base structure. It has
to be a subcategory of Join of Category of monoids and Category of posets. This is
also the default category if None is specified.
• coefficient_ring – the ring which contains the coefficients of the elements.
EXAMPLES:
Element
alias of TermWithCoefficient
some_elements()
Return some elements of this term with coefficient monoid.
See TestSuite for a typical use case.
INPUT:
Nothing.
OUTPUT:
An iterator.
EXAMPLES:
exception sage.rings.asymptotic.term_monoid.ZeroCoefficientError
Bases: ValueError
sage.rings.asymptotic.term_monoid.absorption(left, right)
Let one of the two passed terms absorb the other.
Helper function used by AsymptoticExpansion.
Note: If neither of the terms can absorb the other, an ArithmeticError is raised.
See the module description for a detailed explanation of absorption.
INPUT:
• left – an asymptotic term.
• right – an asymptotic term.
OUTPUT:
An asymptotic term or None.
EXAMPLES:
sage.rings.asymptotic.term_monoid.can_absorb(left, right)
Return whether one of the two input terms is able to absorb the other.
Helper function used by AsymptoticExpansion.
INPUT:
• left – an asymptotic term.
• right – an asymptotic term.
OUTPUT:
A boolean.
EXAMPLES:
AUTHORS:
• Daniel Krenn (2015)
ACKNOWLEDGEMENT:
• Benjamin Hackl, Clemens Heuberger and Daniel Krenn are supported by the Austrian Science Fund (FWF): P
24644-N26.
• Benjamin Hackl is supported by the Google Summer of Code 2015.
class sage.rings.asymptotic.misc.Locals
Bases: dict
A frozen dictionary-like class for storing locals of an AsymptoticRing.
EXAMPLES:
sage: from sage.rings.asymptotic.misc import Locals
sage: locals = Locals({'a': 42})
sage: locals['a']
42
The object contains default values (see default_locals()) for some keys:
sage: locals['log']
<function log at 0x...>
default_locals()
Return the default locals used in the AsymptoticRing.
OUTPUT:
A dictionary.
EXAMPLES:
sage: from sage.rings.asymptotic.misc import Locals
sage: locals = Locals({'a': 2, 'b': 1})
sage: locals
{'a': 2, 'b': 1}
sage: locals.default_locals()
{'log': <function log at 0x...>}
sage: locals['log']
<function log at 0x...>
exception sage.rings.asymptotic.misc.NotImplementedOZero(asymptotic_ring=None,
var=None, ex-
act_part=0)
Bases: NotImplementedError
A special NotImplementedError which is raised when the result is O(0) which means 0 for sufficiently large
values of the variable.
class sage.rings.asymptotic.misc.WithLocals
Bases: sage.structure.sage_object.SageObject
A class extensions for handling local values; see also Locals.
This is used in the AsymptoticRing.
EXAMPLES:
locals(locals=None)
Return the actual Locals object to be used.
INPUT:
• locals – an object
If locals is not None, then a Locals object is created and returned. If locals is None, then
a stored Locals object, if any, is returned. Otherwise, an empty (i.e. no values except the default
values) Locals object is created and returned.
OUTPUT:
A Locals object.
sage.rings.asymptotic.misc.bidirectional_merge_overlapping(A, B, key=None)
Merge the two overlapping tuples/lists.
INPUT:
• A – a list or tuple (type has to coincide with type of B).
• B – a list or tuple (type has to coincide with type of A).
• key – (default: None) a function. If None, then the identity is used. This key-function applied on an
element of the list/tuple is used for comparison. Thus elements with the same key are considered as equal.
OUTPUT:
A pair of lists or tuples (depending on the type of A and B).
Note: Suppose we can decompose the list 𝐴 = 𝑎𝑐 and 𝐵 = 𝑐𝑏 with lists 𝑎, 𝑏, 𝑐, where 𝑐 is nonempty. Then
bidirectional_merge_overlapping() returns the pair (𝑎𝑐𝑏, 𝑎𝑐𝑏).
Suppose a key-function is specified and 𝐴 = 𝑎𝑐𝐴 and 𝐵 = 𝑐𝐵 𝑏, where the list of keys of the elements of 𝑐𝐴
equals the list of keys of the elements of 𝑐𝐵 . Then bidirectional_merge_overlapping() returns the
pair (𝑎𝑐𝐴 𝑏, 𝑎𝑐𝐵 𝑏).
After unsuccessfully merging 𝐴 = 𝑎𝑐 and 𝐵 = 𝑐𝑏, a merge of 𝐴 = 𝑐𝑎 and 𝐵 = 𝑏𝑐 is tried.
sage.rings.asymptotic.misc.bidirectional_merge_sorted(A, B, key=None)
Merge the two tuples/lists, keeping the orders provided by them.
INPUT:
• A – a list or tuple (type has to coincide with type of B).
• B – a list or tuple (type has to coincide with type of A).
• key – (default: None) a function. If None, then the identity is used. This key-function applied on an
element of the list/tuple is used for comparison. Thus elements with the same key are considered as equal.
Note: The two tuples/list need to overlap, i.e. need at least one key in common.
OUTPUT:
A pair of lists containing all elements totally ordered. (The first component uses A as a merge base, the second
component B.)
If merging fails, then a RuntimeError is raised.
sage.rings.asymptotic.misc.combine_exceptions(e, *f )
Helper function which combines the messages of the given exceptions.
INPUT:
• e – an exception.
• *f – exceptions.
OUTPUT:
An exception.
EXAMPLES:
sage.rings.asymptotic.misc.log_string(element, base=None)
Return a representation of the log of the given element to the given base.
INPUT:
• element – an object.
• base – an object or None.
OUTPUT:
A string.
EXAMPLES:
sage.rings.asymptotic.misc.parent_to_repr_short(P)
Helper method which generates a short(er) representation string out of a parent.
INPUT:
• P – a parent.
OUTPUT:
A string.
EXAMPLES:
sage.rings.asymptotic.misc.repr_short_to_parent(s)
Helper method for the growth group factory, which converts a short representation string to a parent.
INPUT:
• s – a string, short representation of a parent.
OUTPUT:
A parent.
The possible short representations are shown in the examples below.
EXAMPLES:
sage.rings.asymptotic.misc.substitute_raise_exception(element, e)
Raise an error describing what went wrong with the substitution.
INPUT:
• element – an element.
• e – an exception which is included in the raised error message.
OUTPUT:
Raise an exception of the same type as e.
sage.rings.asymptotic.misc.transform_category(category, subcategory_mapping, ax-
iom_mapping, initial_category=None)
Transform category to a new category according to the given mappings.
INPUT:
• category – a category.
• subcategory_mapping – a list (or other iterable) of triples (from, to, mandatory), where
– from and to are categories and
– mandatory is a boolean.
• axiom_mapping – a list (or other iterable) of triples (from, to, mandatory), where
– from and to are strings describing axioms and
– mandatory is a boolean.
• initial_category – (default: None) a category. When transforming the given category, this
initial_category is used as a starting point of the result. This means the resulting category will
be a subcategory of initial_category. If initial_category is None, then the category
of objects is used.
OUTPUT:
A category.
EXAMPLES:
sage: transform_category(AdditiveGroups().AdditiveCommutative(), S, A,
....: initial_category=Posets())
Join of Category of commutative groups
and Category of posets
sage: transform_category(ZZ.category(), S, A)
Category of commutative groups
sage: transform_category(QQ.category(), S, A)
Category of commutative groups
sage: transform_category(SR.category(), S, A)
Category of commutative groups
sage: transform_category(Fields(), S, A)
Category of commutative groups
sage: transform_category(ZZ['t'].category(), S, A)
Category of commutative groups
Let 𝐹 (𝑥) = 𝜈∈N𝑑 𝐹𝜈 𝑥𝜈 be a multivariate power series with complex coefficients that converges in a neighborhood
∑︀
of the origin. Assume that 𝐹 = 𝐺/𝐻 for some functions 𝐺 and 𝐻 holomorphic in a neighborhood of the origin.
Assume also that 𝐻 is a polynomial.
This computes asymptotics for the coefficients 𝐹𝑟𝛼 as 𝑟 → ∞ with 𝑟𝛼 ∈ N𝑑 for 𝛼 in a permissible subset of 𝑑-
tuples of positive reals. More specifically, it computes arbitrary terms of the asymptotic expansion for 𝐹𝑟𝛼 when the
asymptotics are controlled by a strictly minimal multiple point of the algebraic variety 𝐻 = 0.
The algorithms and formulas implemented here come from [RW2008] and [RW2012]. For a general reference take a
look in the book [PW2013].
(1/12*sqrt(3)*2^(2/3)*gamma(1/3)/(pi*r^(1/3)),
1,
1/12*sqrt(3)*2^(2/3)*gamma(1/3)/(pi*r^(1/3)))
sage: F.relative_error(asy[0], alpha, [1, 2, 4, 8, 16], asy[1])
[((4, 1), 0.1875000000, [0.1953794675...], [-0.042023826...]),
((8, 2), 0.1523437500, [0.1550727862...], [-0.017913673...]),
((16, 4), 0.1221771240, [0.1230813519...], [-0.0074009592...]),
((32, 8), 0.09739671811, [0.09768973377...], [-0.0030084757...]),
((64, 16), 0.07744253816, [0.07753639308...], [-0.0012119297...])]
4.7.2 Various
AUTHORS:
• Alexander Raichev (2008)
• Daniel Krenn (2014, 2016)
class sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFacto
Bases: sage.structure.element.RingElement
This element represents a fraction with a factored polynomial denominator. See also its parent
FractionWithFactoredDenominatorRing for details.
Represents a fraction with factored polynomial denominator (FFPD) 𝑝/(𝑞1𝑒1 · · · 𝑞𝑛𝑒𝑛 ) by storing the parts 𝑝 and
[(𝑞1 , 𝑒1 ), . . . , (𝑞𝑛 , 𝑒𝑛 )]. Here 𝑞1 , . . . , 𝑞𝑛 are elements of a 0- or multi-variate factorial polynomial ring 𝑅 ,
𝑞1 , . . . , 𝑞𝑛 are distinct irreducible elements of 𝑅 , 𝑒1 , . . . , 𝑒𝑛 are positive integers, and 𝑝 is a function of the
sage: p = 1/x^2
sage: q = 3*x**2*y
sage: qs = q.factor()
sage: f = FFPD(p/qs.unit(), qs)
sage: f
(1/3/x^2, [(y, 1), (x, 2)])
Singular throws a ‘not implemented’ error when trying to factor in a multivariate polynomial ring over an inexact
field:
sage: R.<x,y> = PolynomialRing(CC)
sage: FFPD = FractionWithFactoredDenominatorRing(R)
sage: f = (x + 1)/(x*y*(x*y + 1)^2)
sage: FFPD(f)
Traceback (most recent call last):
...
TypeError: Singular error:
? not implemented
? error occurred in or before STDIN line ...:
`def sage...=factorize(sage...);`
AUTHORS:
• Alexander Raichev (2012-07-26)
• Daniel Krenn (2014-12-01)
algebraic_dependence_certificate()
Return the algebraic dependence certificate of self.
The algebraic dependence certificate is the ideal 𝐽 of annihilating polynomials for the set of polynomials
[q^e for (q, e) in self.denominator_factored()], which could be the zero ideal. The
ideal 𝐽 lies in a polynomial ring over the field self.denominator_ring.base_ring() that has
m = len(self.denominator_factored()) indeterminates.
OUTPUT:
An ideal.
EXAMPLES:
sage: from sage.rings.asymptotic.asymptotics_multivariate_generating_
˓→functions import FractionWithFactoredDenominatorRing
algebraic_dependence_decomposition(whole_and_parts=True)
Return an algebraic dependence decomposition of self.
Let 𝑓 = 𝑝/𝑞 where 𝑞 lies in a 𝑑-variate polynomial ring 𝐾[𝑋] for some field 𝐾. Let 𝑞1𝑒1 · · · 𝑞𝑛𝑒𝑛 be the
unique factorization of 𝑞 in 𝐾[𝑋] into irreducible factors and let 𝑉𝑖 be the algebraic variety {𝑥 ∈ 𝐿𝑑 |
𝑞𝑖 (𝑥) = 0} of 𝑞𝑖 over the algebraic closure 𝐿 of 𝐾. By [Rai2012], 𝑓 can be written as
∑︁ 𝑝𝐴
(*) ∏︀ 𝑏𝑖
,
𝐴 𝑖∈𝐴 𝑞𝑖
where the 𝑏𝑖 are positive integers, each 𝑝𝐴 is a products of 𝑝 and an element in 𝐾[𝑋], and the sum is taken
over all subsets 𝐴 ⊆ {1, . . . , 𝑚} such that |𝐴| ≤ 𝑑 and {𝑞𝑖 | 𝑖 ∈ 𝐴} is algebraically independent.
We call (*) an algebraic dependence decomposition of 𝑓 . Algebraic dependence decompositions are not
unique.
The algorithm used comes from [Rai2012].
OUTPUT:
An instance of FractionWithFactoredDenominatorSum.
EXAMPLES:
asymptotic_decomposition(alpha, asy_var=None)
Return the asymptotic decomposition of self.
The asymptotic decomposition of 𝐹 is a sum that has the same asymptotic expansion as 𝑓 in the direction
alpha but each summand has a denominator factorization of the form [(𝑞1 , 1), . . . , (𝑞𝑛 , 1)], where 𝑛 is at
most the dimension() of 𝐹 .
INPUT:
• alpha – a 𝑑-tuple of positive integers or symbolic variables
• asy_var – (default: None) a symbolic variable with respect to which to compute asymptotics; if
None is given, we set asy_var = var('r')
OUTPUT:
An instance of FractionWithFactoredDenominatorSum.
The output results from a Leinartas decomposition followed by a cohomology decomposition.
EXAMPLES:
sage: from sage.rings.asymptotic.asymptotics_multivariate_generating_
˓→functions import FractionWithFactoredDenominatorRing
• N – a positive integer
• asy_var – (optional; default: None) a symbolic variable; the variable of the asymptotic expansion,
if none is given, var('r') will be assigned
• coordinate – (optional; default: None) an integer in {0, . . . , 𝑑 − 1} indicating a convenient coor-
dinate to base the asymptotic calculations on; if None is assigned, then choose coordinate=d-1
• numerical – (optional; default: 0) a natural number; if numerical is greater than 0, then return
a numerical approximation of the Maclaurin ray coefficients of self with numerical digits of
precision; otherwise return exact values
• verbose – (default: False) print the current state of the algorithm
OUTPUT:
The asymptotic expansion.
EXAMPLES:
sage: from sage.rings.asymptotic.asymptotics_multivariate_generating_
˓→functions import FractionWithFactoredDenominatorRing
sage: q = 1/2
sage: qq = q.denominator()
sage: H = 1 - q*x + q*x*y - x^2*y
sage: Hfac = H.factor()
sage: G = (1 - q*x)/Hfac.unit()
sage: F = FFPD(G, Hfac)
sage: alpha = list(qq*vector([2, 1 - q]))
sage: alpha
(continues on next page)
cohomology_decomposition()
Return the cohomology decomposition of self.
Let 𝑝/(𝑞1𝑒1 · · · 𝑞𝑛𝑒𝑛 ) be the fraction represented by self and let 𝐾[𝑥1 , . . . , 𝑥𝑑 ] be the polynomial ring
in which the 𝑞𝑖 lie. Assume that 𝑛 ≤ 𝑑 and that the gradients of the 𝑞𝑖 are linearly independent at all
points in the intersection 𝑉1 ∩ . . . ∩ 𝑉𝑛 of the algebraic varieties 𝑉𝑖 = {𝑥 ∈ 𝐿𝑑 | 𝑞𝑖 (𝑥) = 0}, where
𝐿 is the algebraic closure of the field 𝐾. Return a FractionWithFactoredDenominatorSum
𝑓 such that the differential form 𝑓 𝑑𝑥1 ∧ · · · ∧ 𝑑𝑥𝑑 is de Rham cohomologous to the differential form
𝑝/(𝑞1𝑒1 · · · 𝑞𝑛𝑒𝑛 )𝑑𝑥1 ∧ · · · ∧ 𝑑𝑥𝑑 and such that the denominator of each summand of 𝑓 contains no repeated
irreducible factors.
The algorithm used here comes from the proof of Theorem 17.4 of [AY1983].
OUTPUT:
An instance of FractionWithFactoredDenominatorSum.
EXAMPLES:
sage: p = 1
sage: qs = [(x*y - 1, 1), (x**2 + y**2 - 1, 2)]
sage: f = FFPD(p, qs)
sage: f.cohomology_decomposition()
(0, []) + (-4/3*x*y, [(x^2 + y^2 - 1, 1)]) +
(1/3, [(x*y - 1, 1), (x^2 + y^2 - 1, 1)])
critical_cone(p, coordinate=None)
Return the critical cone of the convenient multiple point p.
INPUT:
• p – a dictionary with keys that can be coerced to equal self.denominator_ring.gens() and
values in a field
• coordinate – (optional; default: None) a natural number
OUTPUT:
A list of vectors.
This list of vectors generate the critical cone of p and the cone itself, which is None if the values of p
don’t lie in Q. Divide logarithmic gradients by their component coordinate entries. If coordinate
= None, then search from 𝑑 − 1 down to 0 for the first index j such that for all i we have self.
log_grads()[i][j] != 0 and set coordinate = j.
EXAMPLES:
denominator()
Return the denominator of self.
OUTPUT:
The denominator (i.e., the product of the factored denominator).
EXAMPLES:
denominator_factored()
Return the factorization in self.denominator_ring of the denominator of self but without the
unit part.
OUTPUT:
The factored denominator as a list of tuple (f, m), where 𝑓 is a factor and 𝑚 its multiplicity.
EXAMPLES:
denominator_ring
Return the ring of the denominator.
OUTPUT:
A ring.
EXAMPLES:
dimension()
Return the number of indeterminates of self.denominator_ring.
OUTPUT:
An integer.
EXAMPLES:
grads(p)
Return a list of the gradients of the polynomials [q for (q, e) in self.
denominator_factored()] evaluated at p.
INPUT:
• p – (optional; default: None) a dictionary whose keys are the generators of self.
denominator_ring
OUTPUT:
A list.
EXAMPLES:
is_convenient_multiple_point(p)
Tests if p is a convenient multiple point of self.
In case p is a convenient multiple point, verdict = True and comment is a string stating which
variables it’s convenient to use. In case p is not, verdict = False and comment is a string explaining
why p fails to be a convenient multiple point.
See [RW2012] for more details.
INPUT:
• p – a dictionary with keys that can be coerced to equal self.denominator_ring.gens()
OUTPUT:
A pair (verdict, comment).
EXAMPLES:
leinartas_decomposition()
Return a Leinartas decomposition of self.
Let 𝑓 = 𝑝/𝑞 where 𝑞 lies in a 𝑑 -variate polynomial ring 𝐾[𝑋] for some field 𝐾. Let 𝑞1𝑒1 · · · 𝑞𝑛𝑒𝑛 be the
unique factorization of 𝑞 in 𝐾[𝑋] into irreducible factors and let 𝑉𝑖 be the algebraic variety {𝑥 ∈ 𝐿𝑑 |
𝑞𝑖 (𝑥) = 0} of 𝑞𝑖 over the algebraic closure 𝐿 of 𝐾. By [Rai2012], 𝑓 can be written as
∑︁ 𝑝𝐴
(*) ∏︀ 𝑏𝑖
,
𝐴 𝑖∈𝐴 𝑞𝑖
where the 𝑏𝑖 are positive integers, each 𝑝𝐴 is a product of 𝑝 and an element of 𝐾[𝑋], and the sum is taken
over all subsets 𝐴 ⊆ {1, . . . , 𝑚} such that
1. |𝐴| ≤ 𝑑,
⋂︀
2. 𝑖∈𝐴 𝑇𝑖 ̸= ∅, and
3. {𝑞𝑖 | 𝑖 ∈ 𝐴} is algebraically independent.
In particular, any rational expression in 𝑑 variables can be represented as a sum of rational expressions
whose denominators each contain at most 𝑑 distinct irreducible factors.
We call (*) a Leinartas decomposition of 𝑓 . Leinartas decompositions are not unique.
The algorithm used comes from [Rai2012].
OUTPUT:
An instance of FractionWithFactoredDenominatorSum.
EXAMPLES:
log_grads(p)
Return a list of the logarithmic gradients of the polynomials [q for (q, e) in self.
denominator_factored()] evaluated at p.
The logarithmic gradient of a function 𝑓 at point 𝑝 is the vector (𝑥1 𝜕1 𝑓 (𝑥), . . . , 𝑥𝑑 𝜕𝑑 𝑓 (𝑥)) evaluated at 𝑝.
INPUT:
• p – (optional; default: None) a dictionary whose keys are the generators of self.
denominator_ring
OUTPUT:
A list.
EXAMPLES:
sage: from sage.rings.asymptotic.asymptotics_multivariate_generating_
˓→functions import FractionWithFactoredDenominatorRing
maclaurin_coefficients(multi_indices, numerical=0)
Return the Maclaurin coefficients of self with given multi_indices.
INPUT:
• multi_indices – a list of tuples of positive integers, where each tuple has length self.
dimension()
• numerical – (optional; default: 0) a natural number; if positive, return numerical approximations
of coefficients with numerical digits of accuracy
OUTPUT:
A dictionary whose value of the key nu are the Maclaurin coefficient of index nu of self.
EXAMPLES:
nullstellensatz_certificate()
Return a Nullstellensatz certificate of self if it exists.
Let [(𝑞1 , 𝑒1 ), . . . , (𝑞𝑛 , 𝑒𝑛 )] be the denominator factorization of self. The Nullstellensatz certificate is a
list of polynomials ℎ1 , . . . , ℎ𝑚 in self.denominator_ring that satisfies ℎ1 𝑞1 + · · · + ℎ𝑚 𝑞𝑛 = 1 if
it exists.
OUTPUT:
A list of polynomials or None if no Nullstellensatz certificate exists.
EXAMPLES:
sage: f = 1/(x*y)
sage: L = FFPD(f).nullstellensatz_certificate()
sage: L is None
True
nullstellensatz_decomposition()
Return a Nullstellensatz decomposition of self.
Let 𝑓 = 𝑝/𝑞 where 𝑞 lies in a 𝑑 -variate polynomial ring 𝐾[𝑋] for some field 𝐾 and 𝑑 ≥ 1. Let
𝑞1𝑒1 · · · 𝑞𝑛𝑒𝑛 be the unique factorization of 𝑞 in 𝐾[𝑋] into irreducible factors and let 𝑉𝑖 be the algebraic
variety {𝑥 ∈ 𝐿𝑑 | 𝑞𝑖 (𝑥) = 0} of 𝑞𝑖 over the algebraic closure 𝐿 of 𝐾. By [Rai2012], 𝑓 can be written as
∑︁ 𝑝𝐴
(*) ∏︀ 𝑒𝑖 ,
𝐴 𝑖∈𝐴 𝑞𝑖
𝑝𝐴 are products of 𝑝 and elements in 𝐾[𝑋] and the sum is taken over all subsets 𝐴 ⊆ {1, . . . , 𝑚}
where the⋂︀
such that 𝑖∈𝐴 𝑇𝑖 ̸= ∅.
We call (*) a Nullstellensatz decomposition of 𝑓 . Nullstellensatz decompositions are not unique.
The algorithm used comes from [Rai2012].
OUTPUT:
An instance of FractionWithFactoredDenominatorSum.
EXAMPLES:
numerator()
Return the numerator of self.
OUTPUT:
The numerator.
EXAMPLES:
numerator_ring
Return the ring of the numerator.
OUTPUT:
A ring.
EXAMPLES:
quotient()
Convert self into a quotient.
OUTPUT:
An element.
EXAMPLES:
divided by exp_scale**m; err_r is the list of relative errors (a_r - f)/a_r for f in b_r. All
outputs are decimal approximations.
EXAMPLES:
singular_ideal()
Return the singular ideal of self.
Let 𝑅 be the ring of self and 𝐻 its denominator. Let 𝐻𝑟𝑒𝑑 be the reduction (square-free part) of 𝐻. Re-
turn the ideal in 𝑅 generated by 𝐻𝑟𝑒𝑑 and its partial derivatives. If the coefficient field of 𝑅 is algebraically
closed, then the output is the ideal of the singular locus (which is a variety) of the variety of 𝐻.
OUTPUT:
An ideal.
EXAMPLES:
smooth_critical_ideal(alpha)
Return the smooth critical ideal of self.
Let 𝑅 be the ring of self and 𝐻 its denominator. Return the ideal in 𝑅 of smooth critical points of the
variety of 𝐻 for the direction alpha. If the variety 𝑉 of 𝐻 has no smooth points, then return the ideal in
𝑅 of 𝑉 .
See [RW2012] for more details.
INPUT:
• alpha – a tuple of positive integers and/or symbolic entries of length self.
denominator_ring.ngens()
OUTPUT:
An ideal.
EXAMPLES:
sage: H = (1-x-y-x*y)^2
sage: Hfac = H.factor()
sage: G = 1/Hfac.unit()
sage: F = FFPD(G, Hfac)
sage: alpha = [7/3, var('a')]
sage: F.smooth_critical_ideal(alpha)
Ideal (y^2 + 14/3/a*y - 1, x + (-3/7*a)*y + 3/7*a - 1) of Multivariate
˓→Polynomial Ring in x, y over Fraction Field of Univariate Polynomial Ring
univariate_decomposition()
Return the usual univariate partial fraction decomposition of self.
Assume that the numerator of self lies in the same univariate factorial polynomial ring as the factors of
the denominator.
Let 𝑓 = 𝑝/𝑞 be a rational expression where 𝑝 and 𝑞 lie in a univariate factorial polynomial ring 𝑅. Let
𝑞1𝑒1 · · · 𝑞𝑛𝑒𝑛 be the unique factorization of 𝑞 in 𝑅 into irreducible factors. Then 𝑓 can be written uniquely
as:
𝑚
∑︁ 𝑝𝑖
(*) 𝑝0 + ,
𝑞 𝑒𝑖
𝑖=1 𝑖
OUTPUT:
An instance of FractionWithFactoredDenominatorSum.
EXAMPLES:
One variable:
sage: R.<x> = PolynomialRing(QQ)
sage: FFPD = FractionWithFactoredDenominatorRing(R)
sage: f = 5*x^3 + 1/x + 1/(x-1) + 1/(3*x^2 + 1)
sage: f
(5*x^7 - 5*x^6 + 5/3*x^5 - 5/3*x^4 + 2*x^3 - 2/3*x^2 + 1/3*x - 1/3)/(x^4 - x^
˓→3 + 1/3*x^2 - 1/3*x)
˓→0.333333333333333*x)
AUTHORS:
• Robert Bradshaw (2007-05-31)
• Alexander Raichev (2012-06-25)
• Daniel Krenn (2014-12-01)
class sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFacto
AUTHORS:
• Daniel Krenn (2014-12-01)
Element
alias of FractionWithFactoredDenominator
base_ring()
Returns the base ring.
OUTPUT:
A ring.
EXAMPLES:
class sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFacto
Bases: list
A list representing the sum of FractionWithFactoredDenominator objects with distinct denominator
factorizations.
AUTHORS:
• Alexander Raichev (2012-06-25)
• Daniel Krenn (2014-12-01)
denominator_ring
Return the polynomial ring of the denominators of self.
OUTPUT:
A ring or None if the list is empty.
EXAMPLES:
˓→FractionWithFactoredDenominatorSum
sum()
Return the sum of the elements in self.
OUTPUT:
An instance of FractionWithFactoredDenominator.
EXAMPLES:
˓→FractionWithFactoredDenominatorSum
whole_and_parts()
Rewrite self as a sum of a (possibly zero) polynomial followed by reduced rational expressions.
OUTPUT:
An instance of FractionWithFactoredDenominatorSum.
Only useful for multivariate decompositions.
EXAMPLES:
sage: from sage.rings.asymptotic.asymptotics_multivariate_generating_
˓→functions import FractionWithFactoredDenominatorRing,
˓→FractionWithFactoredDenominatorSum
sage.rings.asymptotic.asymptotics_multivariate_generating_functions.coerce_point(R,
p)
Coerce the keys of the dictionary p into the ring R.
EXAMPLES:
sage.rings.asymptotic.asymptotics_multivariate_generating_functions.diff_all(f,
V,
n,
end-
ing=[],
sub=None,
sub_final=None,
zero_order=0,
rekey=None)
Return a dictionary of representative mixed partial derivatives of 𝑓 from order 1 up to order 𝑛 with respect to
the variables in 𝑉 .
The default is to key the dictionary by all nondecreasing sequences in 𝑉 of length 1 up to length 𝑛.
INPUT:
• f – an individual or list of 𝒞 𝑛+1 functions
• V – a list of variables occurring in 𝑓
• n – a natural number
• ending – a list of variables in 𝑉
• sub – an individual or list of dictionaries
• sub_final – an individual or list of dictionaries
• rekey – a callable symbolic function in 𝑉 or list thereof
• zero_order – a natural number
OUTPUT:
The dictionary {s_1:deriv_1, ..., sr:deriv_r}.
Here s_1, ..., s_r is a listing of all nondecreasing sequences of length 1 up to length 𝑛 over the alpha-
bet 𝑉 , where 𝑤 > 𝑣 in 𝑋 if and only if str(w) > str(v), and deriv_j is the derivative of 𝑓 with
respect to the derivative sequence s_j and simplified with respect to the substitutions in sub and evaluated at
sub_final. Moreover, all derivatives with respect to sequences of length less than zero_order (derivatives
of order less than zero_order ) will be made zero.
If rekey is nonempty, then s_1, ..., s_r will be replaced by the symbolic derivatives of the functions in
rekey.
If ending is nonempty, then every derivative sequence s_j will be suffixed by ending.
EXAMPLES:
sage: f = function('f')(x)
sage: dd = diff_all(f, [x], 3)
sage: dd[(x, x, x)]
diff(f(x), x, x, x)
sage: a = {x:1}
sage: dd = diff_all(f, [x], 3, sub=d1, rekey=f, sub_final=a)
sage: dd[diff(f, x, 3)]
24
sage: g = function('g')(*X)
sage: dd = diff_all([f, g], X, 2)
sage: dd[(0, y, z)]
diff(f(x, y, z), y, z)
sage: f = exp(x*y*z)
sage: ff = function('ff')(*X)
sage: dd = diff_all(f, X, 2, rekey=ff)
sage: dd[diff(ff, x, z)]
x*y^2*z*e^(x*y*z) + y*e^(x*y*z)
sage.rings.asymptotic.asymptotics_multivariate_generating_functions.diff_op(A,
B,
AB_derivs,
V,
M,
r,
N)
Return the derivatives 𝐷𝐷(𝑙+𝑘) (𝐴[𝑗]𝐵 𝑙 ) evaluated at a point 𝑝 for various natural numbers 𝑗, 𝑘, 𝑙 which depend
on 𝑟 and 𝑁 .
Here 𝐷𝐷 is a specific second-order linear differential operator that depends on 𝑀 , 𝐴 is a list of symbolic
functions, 𝐵 is symbolic function, and AB_derivs contains all the derivatives of 𝐴 and 𝐵 evaluated at 𝑝 that
are necessary for the computation.
INPUT:
EXAMPLES:
sage.rings.asymptotic.asymptotics_multivariate_generating_functions.diff_op_simple(A,
B,
AB_derivs,
x,
v,
a,
N)
Return 𝐷𝐷( 𝑒𝑘 + 𝑣𝑙)(𝐴𝐵 𝑙 ) evaluated at a point 𝑝 for various natural numbers 𝑒, 𝑘, 𝑙 that depend on 𝑣 and 𝑁 .
Here 𝐷𝐷 is a specific linear differential operator that depends on 𝑎 and 𝑣 , 𝐴 and 𝐵 are symbolic functions, and
𝐴𝐵𝑑 𝑒𝑟𝑖𝑣𝑠 contains all the derivatives of 𝐴 and 𝐵 evaluated at 𝑝 that are necessary for the computation.
INPUT:
• A, B – Symbolic functions in the variable x
• AB_derivs - a dictionary whose keys are the (symbolic) derivatives of A up to order 2 * N if v is even
or N if v is odd and the (symbolic) derivatives of B up to order 2 * N + v if v is even or N + v if v is
odd; the values of the dictionary are complex numbers that are the keys evaluated at a common point 𝑝
• x – a symbolic variable
• a – a complex number
• v, N – natural numbers
OUTPUT:
A dictionary.
The output is a dictionary whose keys are natural number pairs of the form (𝑘, 𝑙), where 𝑘 < 𝑁 and 𝑙 ≤ 2𝑘 and
whose values are 𝐷𝐷( 𝑒𝑘 + 𝑣𝑙)(𝐴𝐵 𝑙 ) evaluated at a point 𝑝. Here 𝑒 = 2 if 𝑣 is even, 𝑒 = 1 if 𝑣 is odd, and 𝐷𝐷
is the linear differential operator (𝑎−1/𝑣 𝑑/𝑑𝑡) if 𝑣 is even and (|𝑎|−1/𝑣 𝑖sgn(𝑎)𝑑/𝑑𝑡) if 𝑣 is odd.
EXAMPLES:
sage: A = function('A')(x)
sage: B = function('B')(x)
sage: AB_derivs = {}
sage: sorted(diff_op_simple(A, B, AB_derivs, x, 3, 2, 2).items())
[((0, 0), A(x)),
((1, 0), 1/2*I*2^(2/3)*diff(A(x), x)),
((1, 1),
1/4*2^(2/3)*(B(x)*diff(A(x), x, x, x, x) + 4*diff(A(x), x, x, x)*diff(B(x), x)
˓→+ 6*diff(A(x), x, x)*diff(B(x), x, x) + 4*diff(A(x), x)*diff(B(x), x, x, x) +
˓→A(x)*diff(B(x), x, x, x, x)))]
sage.rings.asymptotic.asymptotics_multivariate_generating_functions.diff_prod(f_derivs,
u,
g,
X,
in-
ter-
val,
end,
ud-
erivs,
atc)
Take various derivatives of the equation 𝑓 = 𝑢𝑔, evaluate them at a point 𝑐, and solve for the derivatives of 𝑢.
INPUT:
• f_derivs – a dictionary whose keys are all tuples of the form s + end, where s is a sequence of
variables from X whose length lies in interval, and whose values are the derivatives of a function 𝑓
evaluated at 𝑐
• u – a callable symbolic function
• g – an expression or callable symbolic function
• X – a list of symbolic variables
• interval – a list of positive integers Call the first and last values 𝑛 and 𝑛𝑛, respectively
• end – a possibly empty list of repetitions of the variable z, where z is the last element of X
• uderivs – a dictionary whose keys are the symbolic derivatives of order 0 to order 𝑛 − 1 of u evaluated
at 𝑐 and whose values are the corresponding derivatives evaluated at 𝑐
• atc – a dictionary whose keys are the keys of 𝑐 and all the symbolic derivatives of order 0 to order 𝑛𝑛 of
g evaluated 𝑐 and whose values are the corresponding derivatives evaluated at 𝑐
OUTPUT:
A dictionary whose keys are the derivatives of u up to order 𝑛𝑛 and whose values are those derivatives evaluated
at 𝑐.
This function works by differentiating the equation 𝑓 = 𝑢𝑔 with respect to the variable sequence s + end, for
all tuples s of X of lengths in interval, evaluating at the point 𝑐 , and solving for the remaining derivatives
of u. This function assumes that u never appears in the differentiations of 𝑓 = 𝑢𝑔 after evaluating at 𝑐.
EXAMPLES:
sage: u = function('u')(x)
sage: g = function('g')(x)
sage: fd = {(x,):1,(x, x):1}
sage: ud = {u(x=2): 1}
sage: atc = {x: 2, g(x=2): 3, diff(g, x)(x=2): 5}
sage: atc[diff(g, x, x)(x=2)] = 7
sage: dd = diff_prod(fd, u, g, [x], [1, 2], [], ud, atc)
sage: dd[diff(u, x, 2)(x=2)]
22/9
sage.rings.asymptotic.asymptotics_multivariate_generating_functions.diff_seq(V,
s)
Given a list s of tuples of natural numbers, return the list of elements of V with indices the elements of the
elements of s.
INPUT:
• V – a list
• s – a list of tuples of natural numbers in the interval range(len(V))
OUTPUT:
The tuple tuple([V[tt] for tt in sorted(t)]), where t is the list of elements of the elements of
s.
EXAMPLES:
sage.rings.asymptotic.asymptotics_multivariate_generating_functions.direction(v,
co-
or-
di-
nate=None)
Return [vv/v[coordinate] for vv in v] where coordinate is the last index of v if not specified
otherwise.
INPUT:
• v – a vector
• coordinate – (optional; default: None) an index for v
EXAMPLES:
sage.rings.asymptotic.asymptotics_multivariate_generating_functions.permutation_sign(s,
u)
This function returns the sign of the permutation on 1, ..., len(u) that is induced by the sublist s of u.
Note: This function was intended for internal use and is deprecated now (trac ticket #29465).
INPUT:
• s – a sublist of u
• u – a list
OUTPUT:
The sign of the permutation obtained by taking indices within u of the list s + sc, where sc is u with the
elements of s removed.
EXAMPLES:
sage.rings.asymptotic.asymptotics_multivariate_generating_functions.subs_all(f,
sub,
sim-
plify=False)
Return the items of 𝑓 substituted by the dictionaries of sub in order of their appearance in sub.
INPUT:
• f – an individual or list of symbolic expressions or dictionaries
• sub – an individual or list of dictionaries
• simplify – (default: False) boolean; set to True to simplify the result
OUTPUT:
The items of f substituted by the dictionaries of sub in order of their appearance in sub. The subs()
command is used. If simplify is True, then simplify() is used after substitution.
EXAMPLES:
FIVE
• Index
• Module Index
• Search Page
145
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
r
sage.rings.asymptotic.asymptotic_expansion_generators, 37
sage.rings.asymptotic.asymptotic_ring, 7
sage.rings.asymptotic.asymptotics_multivariate_generating_functions, 110
sage.rings.asymptotic.growth_group, 46
sage.rings.asymptotic.growth_group_cartesian, 71
sage.rings.asymptotic.misc, 103
sage.rings.asymptotic.term_monoid, 79
147
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
A
absorb() (sage.rings.asymptotic.term_monoid.GenericTerm method), 87
absorption() (in module sage.rings.asymptotic.term_monoid), 101
AbstractGrowthGroupFunctor (class in sage.rings.asymptotic.growth_group), 49
AdditiveMagmas (sage.rings.asymptotic.growth_group.GenericGrowthGroup attribute), 58
AdditiveMagmas (sage.rings.asymptotic.growth_group.MonomialGrowthGroup attribute), 65
algebraic_dependence_certificate() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWith
method), 114
algebraic_dependence_decomposition() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionW
method), 115
asymptotic_decomposition() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDe
method), 116
asymptotic_expansions (in module sage.rings.asymptotic.asymptotic_expansion_generators), 46
AsymptoticExpansion (class in sage.rings.asymptotic.asymptotic_ring), 12
AsymptoticExpansionGenerators (class in sage.rings.asymptotic.asymptotic_expansion_generators), 38
AsymptoticRing (class in sage.rings.asymptotic.asymptotic_ring), 28
AsymptoticRingFunctor (class in sage.rings.asymptotic.asymptotic_ring), 36
asymptotics() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominator
method), 117
asymptotics_multiple() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenomin
method), 119
asymptotics_smooth() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominato
method), 120
B
base (sage.rings.asymptotic.growth_group.ExponentialGrowthElement attribute), 50
base (sage.rings.asymptotic.growth_group.GrowthGroupFactor attribute), 63
base_ring() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominatorRing
method), 135
bidirectional_merge_overlapping() (in module sage.rings.asymptotic.misc), 104
bidirectional_merge_sorted() (in module sage.rings.asymptotic.misc), 104
Binomial_kn_over_n() (sage.rings.asymptotic.asymptotic_expansion_generators.AsymptoticExpansionGenerators
static method), 38
C
can_absorb() (in module sage.rings.asymptotic.term_monoid), 102
can_absorb() (sage.rings.asymptotic.term_monoid.ExactTerm method), 82
149
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
D
default_locals() (sage.rings.asymptotic.misc.Locals method), 103
default_prec (sage.rings.asymptotic.asymptotic_ring.AsymptoticRing attribute), 33
DefaultTermMonoidFactory (in module sage.rings.asymptotic.term_monoid), 81
denominator() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominator
method), 123
denominator_factored() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenomin
method), 123
denominator_ring (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominator
attribute), 124
denominator_ring (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominatorSum
attribute), 136
diff_all() (in module sage.rings.asymptotic.asymptotics_multivariate_generating_functions), 138
diff_op() (in module sage.rings.asymptotic.asymptotics_multivariate_generating_functions), 139
diff_op_simple() (in module sage.rings.asymptotic.asymptotics_multivariate_generating_functions), 140
diff_prod() (in module sage.rings.asymptotic.asymptotics_multivariate_generating_functions), 141
diff_seq() (in module sage.rings.asymptotic.asymptotics_multivariate_generating_functions), 142
dimension() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominator
method), 124
150 Index
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
E
Element (sage.rings.asymptotic.asymptotic_ring.AsymptoticRing attribute), 30
Element (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominatorRing
attribute), 135
Element (sage.rings.asymptotic.growth_group.ExponentialGrowthGroup attribute), 51
Element (sage.rings.asymptotic.growth_group.ExponentialNonGrowthGroup attribute), 54
Element (sage.rings.asymptotic.growth_group.GenericGrowthGroup attribute), 58
Element (sage.rings.asymptotic.growth_group.MonomialGrowthGroup attribute), 65
Element (sage.rings.asymptotic.growth_group.MonomialNonGrowthGroup attribute), 67
Element (sage.rings.asymptotic.term_monoid.ExactTermMonoid attribute), 86
Element (sage.rings.asymptotic.term_monoid.GenericTermMonoid attribute), 92
Element (sage.rings.asymptotic.term_monoid.OTermMonoid attribute), 98
Element (sage.rings.asymptotic.term_monoid.TermWithCoefficientMonoid attribute), 101
exact_part() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 16
ExactTerm (class in sage.rings.asymptotic.term_monoid), 81
ExactTermMonoid (class in sage.rings.asymptotic.term_monoid), 86
exp() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 16
exp() (sage.rings.asymptotic.growth_group_cartesian.GenericProduct.Element method), 73
exponent (sage.rings.asymptotic.growth_group.MonomialGrowthElement attribute), 64
ExponentialGrowthElement (class in sage.rings.asymptotic.growth_group), 50
ExponentialGrowthGroup (class in sage.rings.asymptotic.growth_group), 50
ExponentialGrowthGroupFunctor (class in sage.rings.asymptotic.growth_group), 53
ExponentialNonGrowthElement (class in sage.rings.asymptotic.growth_group), 53
ExponentialNonGrowthGroup (class in sage.rings.asymptotic.growth_group), 53
ExponentialNonGrowthGroupFunctor (class in sage.rings.asymptotic.growth_group), 54
extend_by_non_growth_group (sage.rings.asymptotic.growth_group.GrowthGroupFactor attribute), 63
extended_by_non_growth_group() (sage.rings.asymptotic.growth_group.GenericGrowthGroup method),
58
extract_variable_names() (sage.rings.asymptotic.growth_group.Variable static method), 69
F
factorial() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 17
factors() (sage.rings.asymptotic.growth_group.GenericGrowthElement method), 54
factors() (sage.rings.asymptotic.growth_group_cartesian.GenericProduct.Element method), 73
factory() (sage.rings.asymptotic.growth_group.ExponentialGrowthGroup class method), 51
factory() (sage.rings.asymptotic.growth_group.MonomialGrowthGroup class method), 66
FractionWithFactoredDenominator (class in sage.rings.asymptotic.asymptotics_multivariate_generating_functions),
112
FractionWithFactoredDenominatorRing (class in sage.rings.asymptotic.asymptotics_multivariate_generating_functions),
135
FractionWithFactoredDenominatorSum (class in sage.rings.asymptotic.asymptotics_multivariate_generating_functions),
136
G
gen() (sage.rings.asymptotic.asymptotic_ring.AsymptoticRing method), 33
gen() (sage.rings.asymptotic.growth_group.GenericGrowthGroup method), 59
GenericGrowthElement (class in sage.rings.asymptotic.growth_group), 54
Index 151
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
H
HarmonicNumber() (sage.rings.asymptotic.asymptotic_expansion_generators.AsymptoticExpansionGenerators
static method), 39
has_same_summands() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 17
I
ImplicitExpansion() (sage.rings.asymptotic.asymptotic_expansion_generators.AsymptoticExpansionGenerators
static method), 39
ImplicitExpansionPeriodicPart() (sage.rings.asymptotic.asymptotic_expansion_generators.AsymptoticExpansionGenerato
static method), 41
InverseFunctionAnalysis() (sage.rings.asymptotic.asymptotic_expansion_generators.AsymptoticExpansionGenerators
static method), 42
invert() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 18
is_compatible() (sage.rings.asymptotic.growth_group.GenericGrowthGroup method), 60
is_compatible() (sage.rings.asymptotic.growth_group.PartialConversionElement method), 68
is_constant() (sage.rings.asymptotic.term_monoid.ExactTerm method), 83
is_constant() (sage.rings.asymptotic.term_monoid.GenericTerm method), 89
is_convenient_multiple_point() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFacto
method), 125
is_exact() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 19
is_exact() (sage.rings.asymptotic.term_monoid.ExactTerm method), 83
is_exact() (sage.rings.asymptotic.term_monoid.GenericTerm method), 89
is_little_o_of_one() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 19
is_little_o_of_one() (sage.rings.asymptotic.term_monoid.ExactTerm method), 84
is_little_o_of_one() (sage.rings.asymptotic.term_monoid.GenericTerm method), 89
is_little_o_of_one() (sage.rings.asymptotic.term_monoid.OTerm method), 96
is_lt_one() (sage.rings.asymptotic.growth_group.GenericGrowthElement method), 55
152 Index
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
L
le() (sage.rings.asymptotic.growth_group.GenericGrowthGroup method), 60
le() (sage.rings.asymptotic.term_monoid.GenericTermMonoid method), 93
leinartas_decomposition() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDen
method), 126
limit() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 19
Locals (class in sage.rings.asymptotic.misc), 103
locals() (sage.rings.asymptotic.misc.WithLocals method), 104
log() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 20
log() (sage.rings.asymptotic.growth_group.GenericGrowthElement method), 55
log() (sage.rings.asymptotic.growth_group_cartesian.GenericProduct.Element method), 74
log_factor() (sage.rings.asymptotic.growth_group.GenericGrowthElement method), 56
log_factor() (sage.rings.asymptotic.growth_group_cartesian.GenericProduct.Element method), 75
log_grads() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominator
method), 127
log_Stirling() (sage.rings.asymptotic.asymptotic_expansion_generators.AsymptoticExpansionGenerators
static method), 45
log_string() (in module sage.rings.asymptotic.misc), 105
log_term() (sage.rings.asymptotic.term_monoid.ExactTerm method), 84
log_term() (sage.rings.asymptotic.term_monoid.GenericTerm method), 90
log_term() (sage.rings.asymptotic.term_monoid.OTerm method), 96
M
maclaurin_coefficients() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenom
method), 128
Magmas (sage.rings.asymptotic.growth_group.ExponentialGrowthGroup attribute), 51
Magmas (sage.rings.asymptotic.growth_group.GenericGrowthGroup attribute), 58
Magmas (sage.rings.asymptotic.growth_group.MonomialGrowthGroup attribute), 65
map_coefficients() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 21
merge() (sage.rings.asymptotic.asymptotic_ring.AsymptoticRingFunctor method), 36
merge() (sage.rings.asymptotic.growth_group.AbstractGrowthGroupFunctor method), 49
monomial_coefficient() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 21
MonomialGrowthElement (class in sage.rings.asymptotic.growth_group), 64
MonomialGrowthGroup (class in sage.rings.asymptotic.growth_group), 65
MonomialGrowthGroupFunctor (class in sage.rings.asymptotic.growth_group), 67
MonomialNonGrowthElement (class in sage.rings.asymptotic.growth_group), 67
MonomialNonGrowthGroup (class in sage.rings.asymptotic.growth_group), 67
MonomialNonGrowthGroupFunctor (class in sage.rings.asymptotic.growth_group), 68
MultivariateProduct (class in sage.rings.asymptotic.growth_group_cartesian), 78
N
ngens() (sage.rings.asymptotic.asymptotic_ring.AsymptoticRing method), 34
ngens() (sage.rings.asymptotic.growth_group.GenericGrowthGroup method), 61
NoConvergenceError, 37
non_growth_group() (sage.rings.asymptotic.growth_group.ExponentialGrowthGroup method), 52
non_growth_group() (sage.rings.asymptotic.growth_group.GenericGrowthGroup method), 61
non_growth_group() (sage.rings.asymptotic.growth_group.MonomialGrowthGroup method), 67
Index 153
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
NotImplementedOZero, 103
nullstellensatz_certificate() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactore
method), 129
nullstellensatz_decomposition() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFact
method), 129
numerator() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominator
method), 130
numerator_ring (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominator
attribute), 130
O
O() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 14
OTerm (class in sage.rings.asymptotic.term_monoid), 94
OTermMonoid (class in sage.rings.asymptotic.term_monoid), 98
P
parent_to_repr_short() (in module sage.rings.asymptotic.misc), 106
PartialConversionElement (class in sage.rings.asymptotic.growth_group), 68
PartialConversionValueError, 68
permutation_sign() (in module sage.rings.asymptotic.asymptotics_multivariate_generating_functions), 143
plot_comparison() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 22
Posets (sage.rings.asymptotic.growth_group.ExponentialGrowthGroup attribute), 51
Posets (sage.rings.asymptotic.growth_group.GenericGrowthGroup attribute), 58
Posets (sage.rings.asymptotic.growth_group.MonomialGrowthGroup attribute), 65
pow() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 23
Q
quotient() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominator
method), 131
R
relative_error() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominator
method), 131
repr_op() (in module sage.rings.asymptotic.misc), 106
repr_short_to_parent() (in module sage.rings.asymptotic.misc), 107
rpow() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 24
rpow() (sage.rings.asymptotic.growth_group.GenericGrowthElement method), 57
rpow() (sage.rings.asymptotic.growth_group_cartesian.GenericProduct.Element method), 76
rpow() (sage.rings.asymptotic.term_monoid.ExactTerm method), 85
rpow() (sage.rings.asymptotic.term_monoid.GenericTerm method), 91
rpow() (sage.rings.asymptotic.term_monoid.OTerm method), 97
S
sage.rings.asymptotic.asymptotic_expansion_generators (module), 37
sage.rings.asymptotic.asymptotic_ring (module), 7
sage.rings.asymptotic.asymptotics_multivariate_generating_functions (module), 110
sage.rings.asymptotic.growth_group (module), 46
sage.rings.asymptotic.growth_group_cartesian (module), 71
sage.rings.asymptotic.misc (module), 103
sage.rings.asymptotic.term_monoid (module), 79
154 Index
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
T
term_monoid() (sage.rings.asymptotic.asymptotic_ring.AsymptoticRing method), 35
term_monoid() (sage.rings.asymptotic.term_monoid.GenericTermMonoid method), 94
term_monoid_factory (sage.rings.asymptotic.asymptotic_ring.AsymptoticRing attribute), 35
term_monoid_factory (sage.rings.asymptotic.term_monoid.GenericTermMonoid attribute), 94
TermMonoidFactory (class in sage.rings.asymptotic.term_monoid), 98
TermWithCoefficient (class in sage.rings.asymptotic.term_monoid), 100
TermWithCoefficientMonoid (class in sage.rings.asymptotic.term_monoid), 100
transform_category() (in module sage.rings.asymptotic.misc), 108
truncate() (sage.rings.asymptotic.asymptotic_ring.AsymptoticExpansion method), 28
U
univariate_decomposition() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDe
method), 133
UnivariateProduct (class in sage.rings.asymptotic.growth_group_cartesian), 78
V
var (sage.rings.asymptotic.growth_group.GrowthGroupFactor attribute), 63
Variable (class in sage.rings.asymptotic.growth_group), 69
Index 155
Sage 9.1 Reference Manual: Asymptotic Expansions, Release 9.1
W
whole_and_parts() (sage.rings.asymptotic.asymptotics_multivariate_generating_functions.FractionWithFactoredDenominatorSum
method), 137
WithLocals (class in sage.rings.asymptotic.misc), 104
Z
ZeroCoefficientError, 101
156 Index