Opened 3 years ago

Last modified 3 years ago

#21665 new defect

AsymptoticRing.substitute fails with exponents in QQbar

Reported by: cheuberg Owned by:
Priority: major Milestone: sage-7.4
Component: asymptotic expansions Keywords:
Cc: behackl, dkrenn Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #22120 Stopgaps:

Description

Presence of a redundant exponential growth group lets substitution fail.

sage: A.<T> = AsymptoticRing('T^QQbar', SR)
sage: B.<n> = AsymptoticRing('QQbar^n*n^QQbar', SR)
sage: C.<p> = AsymptoticRing('n^QQbar', SR)
sage: e1 = T^QQbar(sqrt(2))
sage: e1.subs(T=p)
n^(1.414213562373095?)
sage: e1.subs(T=n)
Traceback (most recent call last):
...
TypeError: Cannot apply the substitution rules {T: n} on T^(1.414213562373095?) in Asymptotic Ring <T^(Algebraic Field)> over Symbolic Ring.
> *previous* ValueError: Cannot substitute in T^(1.414213562373095?) in Asymptotic Ring <T^(Algebraic Field)> over Symbolic Ring.
>> *previous* ValueError: Cannot substitute in T^(1.414213562373095?) in Exact Term Monoid T^(Algebraic Field) with coefficients in Symbolic Ring.
>>> *previous* ValueError: Cannot substitute in T^(1.414213562373095?) in Growth Group T^(Algebraic Field).
>>>> *previous* ValueError: Cannot take n to the exponent 1.414213562373095?.
>>>>> *previous* TypeError: no canonical coercion from Algebraic Field to Rational Field

Change History (3)

comment:1 follow-up: Changed 3 years ago by cheuberg

The problem boils down to the following:

sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: G = GrowthGroup('m^QQbar')
sage: H = GrowthGroup('QQbar^n * n^QQbar')
sage: K = GrowthGroup('QQbar^p')
sage: m = G('m')
sage: n = H('n')
sage: alpha = QQbar(sqrt(2))
sage: m^alpha
m^(1.414213562373095?)
sage: n^alpha
Traceback (most recent call last):
...
/local/sage/sage-7.4.beta6/local/lib/python2.7/site-packages/sage/rings/qqbar.pyc in __pow__(self, e)
   3878             1.000000000000000? + 0.?e-18*I
   3879         """
-> 3880         e = QQ._coerce_(e)
   3881         n = e.numerator()
   3882         d = e.denominator()
...
TypeError: no canonical coercion from Algebraic Field to Rational Field
sage: K('1')^alpha
Traceback (most recent call last):
...
/local/sage/sage-7.4.beta6/local/lib/python2.7/site-packages/sage/rings/qqbar.pyc in __pow__(self, e)
   3878             1.000000000000000? + 0.?e-18*I
   3879         """
-> 3880         e = QQ._coerce_(e)
   3881         n = e.numerator()
   3882         d = e.denominator()
...
TypeError: no canonical coercion from Algebraic Field to Rational Field

So the problem is that we cannot compute QQbar(1)^alpha.

I see the following options:

  1. Fix QQbar so that QQbar(1)^everything == QQbar(1).
  2. Fix ExponentialGrowthElement.__pow__ such that base == 1 leads to result 1, irrespective of exponent.
  3. Fix GenericProduct.Element.__pow__ such that trivial factors are ignored.

comment:2 Changed 3 years ago by cheuberg

Another related problem:

sage: R.<n> = AsymptoticRing('QQbar^n*n^QQbar', SR)
sage: alpha = QQbar(sqrt(2))
sage: n.rpow(alpha)
Traceback (most recent call last):
...
ValueError: Cannot construct the power of 1.414213562373095? to the exponent n in Asymptotic Ring <(Algebraic Field)^n * n^(Algebraic Field)> over Symbolic Ring.
> *previous* ValueError: Cannot take 1.414213562373095?^n to the exponent 1.
>> *previous* TypeError: no canonical coercion from Symbolic Ring to Rational Field

​ So basically, in order to have alpha^n*n^alpha, it is currently necessary to use the following work-around:

sage: R1 = AsymptoticRing('QQbar^n', SR)
sage: R2.<n> = AsymptoticRing('n^QQbar', SR)
sage: R = AsymptoticRing('QQbar^n*n^QQbar', SR)
sage: alpha = QQbar(sqrt(2))
sage: t1 = R1(R1.growth_group(raw_element=alpha)); t1
sage: t2 = n^alpha
sage: R(t1)*t2

comment:3 in reply to: ↑ 1 Changed 3 years ago by dkrenn

  • Dependencies set to #22120

Replying to cheuberg:

I see the following options:

  1. Fix QQbar so that QQbar(1)^everything == QQbar(1).

This is now #22120.

Note: See TracTickets for help on using tickets.