Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #19423: Merge #19946 to fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
cheuberg committed Feb 4, 2016
2 parents 2a76cd7 + 1259201 commit 1a526b7
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 4 deletions.
50 changes: 50 additions & 0 deletions src/sage/rings/asymptotic/asymptotic_ring.py
Expand Up @@ -283,6 +283,36 @@
sage: (1 + 1/z + O(1/z^5))^(1 + 1/z)
1 + z^(-1) + z^(-2) + 1/2*z^(-3) + 1/3*z^(-4) + O(z^(-5))
.. NOTE::
In the asymptotic ring
::
sage: M.<n> = AsymptoticRing(growth_group='QQ^n * n^QQ', coefficient_ring=ZZ)
the operation
::
sage: (1/2)^n
Traceback (most recent call last):
...
ValueError: 1/2 is not in Exact Term Monoid QQ^n * n^QQ
with coefficients in Integer Ring. ...
fails, since the rational `1/2` is not contained in `M`. You can use
::
sage: n.rpow(1/2)
(1/2)^n
instead. (See also the examples in
:meth:`ExactTerm.rpow() <sage.rings.asymptotic.term_monoid.ExactTerm.rpow>`
for a detailed explanation.)
Another way is to use a larger coefficent ring::
sage: M_QQ.<n> = AsymptoticRing(growth_group='QQ^n * n^QQ', coefficient_ring=QQ)
sage: (1/2)^n
(1/2)^n
Multivariate Arithmetic
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -1391,6 +1421,18 @@ def __pow__(self, exponent, precision=None):
ValueError: Cannot take s + t to the exponent s.
> *previous* ValueError: Cannot determine main term of s + t
since there are several maximal elements s, t.
Check that :trac:`19946` is fixed::
sage: A.<n> = AsymptoticRing('QQ^n * n^QQ', SR)
sage: e = 2^n; e
2^n
sage: e.parent()
Asymptotic Ring <SR^n * n^SR> over Symbolic Ring
sage: e = A(e); e
2^n
sage: e.parent()
Asymptotic Ring <QQ^n * n^QQ> over Symbolic Ring
"""
if not self.summands:
if exponent == 0:
Expand Down Expand Up @@ -1632,6 +1674,14 @@ def rpow(self, base, precision=None):
ArithmeticError: Cannot construct y^x in Growth Group x^ZZ
> *previous* TypeError: unsupported operand parent(s) for '*':
'Growth Group x^ZZ' and 'Growth Group SR^x'
Check that :trac:`19946` is fixed::
sage: A.<n> = AsymptoticRing('QQ^n * n^QQ', SR)
sage: n.rpow(2)
2^n
sage: _.parent()
Asymptotic Ring <QQ^n * n^SR> over Symbolic Ring
"""
if isinstance(base, AsymptoticExpansion):
return base.__pow__(self, precision=precision)
Expand Down
8 changes: 8 additions & 0 deletions src/sage/rings/asymptotic/growth_group.py
Expand Up @@ -873,6 +873,14 @@ def _rpow_(self, base):
sage: x = G('x')
sage: (x * log(x)).rpow(2) # indirect doctest
2^(x*log(x))
::
sage: n = GrowthGroup('QQ^n * n^QQ')('n')
sage: n.rpow(2)
2^n
sage: _.parent()
Growth Group QQ^n * n^QQ
"""
if base == 0:
raise ValueError('%s is not an allowed base for calculating the '
Expand Down
14 changes: 10 additions & 4 deletions src/sage/rings/asymptotic/growth_group_cartesian.py
Expand Up @@ -692,11 +692,17 @@ def _pushout_(self, other):
Growth Group QQ^x * x^QQ
sage: cm.common_parent(GrowthGroup('QQ^x * x^ZZ'), GrowthGroup('ZZ^x * x^QQ'))
Growth Group QQ^x * x^QQ
::
sage: pushout(GrowthGroup('QQ^n * n^QQ'), GrowthGroup('SR^n'))
Growth Group SR^n * n^QQ
"""
from growth_group import GenericGrowthGroup, AbstractGrowthGroupFunctor
from misc import merge_overlapping
from misc import underlying_class

Sfactors = self.cartesian_factors()
if isinstance(other, GenericProduct):
Ofactors = other.cartesian_factors()
elif isinstance(other, GenericGrowthGroup):
Expand Down Expand Up @@ -759,7 +765,7 @@ def next(self):
self.factors = tuple()

from itertools import groupby
S = it(groupby(self.cartesian_factors(), key=lambda k: k.variable_names()))
S = it(groupby(Sfactors, key=lambda k: k.variable_names()))
O = it(groupby(Ofactors, key=lambda k: k.variable_names()))

newS = []
Expand All @@ -786,9 +792,9 @@ def next(self):

assert(len(newS) == len(newO))

if (len(self.cartesian_factors()) == len(newS) and
len(other.cartesian_factors()) == len(newO)):
# We had already all factors in each of the self and
if (len(Sfactors) == len(newS) and
len(Ofactors) == len(newO)):
# We had already all factors in each of self and
# other, thus splitting it in subproblems (one for
# each factor) is the strategy to use. If a pushout is
# possible :func:`sage.categories.pushout.pushout`
Expand Down
26 changes: 26 additions & 0 deletions src/sage/rings/asymptotic/term_monoid.py
Expand Up @@ -3308,6 +3308,32 @@ def rpow(self, base):
Growth Group QQ^x * x^ZZ * log(x)^ZZ
> *previous* TypeError: unsupported operand parent(s) for '*':
'Growth Group QQ^x * x^ZZ * log(x)^ZZ' and 'Growth Group ZZ^(x^2)'
::
sage: T = TermMonoid('exact', GrowthGroup('QQ^n * n^QQ'), SR)
sage: n = T('n')
sage: n.rpow(2)
2^n
sage: _.parent()
Exact Term Monoid QQ^n * n^SR with coefficients in Symbolic Ring
Above, we get ``QQ^n * n^SR``. The reason is the following:
Since $n = 1_{SR} \cdot (1_{\QQ})^n \cdot n^{1_{\QQ}}$, we have
.. MATH::
2^n = (2_{\QQ})^{1_{SR} \cdot (1_{\QQ})^n \cdot n^{1_{\QQ}}}
= \left( (2_{\QQ})^n \cdot n^{0_{\QQ}} \right)^{1_{SR}}
= \left((2_{\QQ})^{1_{SR}}\right)^n \cdot n^{0_{\QQ} 1_{SR}}
= (2_{\QQ})^n \cdot n^{0_{SR}}
where ::
sage: (QQ(2)^SR(1)).parent(), (QQ(0)*SR(1)).parent()
(Rational Field, Symbolic Ring)
was used.
"""
P = self.parent()

Expand Down

0 comments on commit 1a526b7

Please sign in to comment.