Opened 8 years ago

Closed 8 years ago

Last modified 4 months ago

#11728 closed defect (duplicate)

Multiplication(?) buggy in AA

Reported by: spice Owned by: AlexGhitza
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: algebra Keywords: algebra, AA, QQbar, sd32
Cc: was Merged in:
Authors: Reviewers: William Stein
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

Something is rotten in the state of AlgebraicReal?. Multiplying some elements of AA seems to be broken in strange and interesting ways.

sage: a = QQbar((-1)^(1/4)); a
0.7071067811865475? + 0.7071067811865475?*I
sage: b = AA(a^3-a); b
-1.414213562373095?
sage: b*1
-1.414213562373095?
sage: b.as_number_field_element()
(Cyclotomic Field of order 8 and degree 4, zeta8^3 - zeta8, Ring morphism:
  From: Cyclotomic Field of order 8 and degree 4
  To:   Algebraic Field
  Defn: zeta8 |--> 0.7071067811865475? + 0.7071067811865475?*I)
sage: b*1
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/sage/sage-4.7.2.alpha2/devel/sage-dev/sage/<ipython console> in <module>()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/IPython/Prompts.pyc in __call__(self, arg)
    549 
    550             # and now call a possibly user-defined print mechanism
--> 551             manipulated_val = self.display(arg)
    552             
    553             # user display hooks can change the variable to be stored in

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/IPython/Prompts.pyc in _display(self, arg)
    575             return IPython.generics.result_display(arg)
    576         except TryNext:            
--> 577             return self.shell.hooks.result_display(arg)
    578 
    579     # Assign the default display method:

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/IPython/hooks.pyc in __call__(self, *args, **kw)
    139             #print "prio",prio,"cmd",cmd #dbg
    140             try:
--> 141                 ret = cmd(*args, **kw)
    142                 return ret
    143             except ipapi.TryNext, exc:

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/misc/displayhook.pyc in result_display(ip_self, obj)
    148     # IPython's default result_display() uses the IPython.genutils.Term.cout stream.
    149     # See also local/lib/python2.6/site-packages/IPython/hooks.py.
--> 150     print_obj(IPython.genutils.Term.cout, obj)
    151 
    152 def displayhook(obj):

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/misc/displayhook.pyc in print_obj(out_stream, obj)
    140             if _check_tall_list_and_print(out_stream, obj):
    141                 return
--> 142     print >>out_stream, `obj`
    143 
    144 def result_display(ip_self, obj):

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1463)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/qqbar.pyc in _repr_(self)
   2214             return repr(CIF(self._value))
   2215         else:
-> 2216             return repr(RIF(self._value))
   2217 
   2218     def _sage_input_(self, sib, coerce):

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/real_mpfi.so in sage.rings.real_mpfi.RealIntervalField_class.__call__ (sage/rings/real_mpfi.c:4285)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/real_mpfi.so in sage.rings.real_mpfi.RealIntervalFieldElement.__init__ (sage/rings/real_mpfi.c:7725)()

TypeError: Unable to convert number to real interval.

As far as I can tell, problems arise if the representation of the AlgebraicReal? element is in term of non-real elements in QQbar.

This also seems to be the root cause of the following (from patch #10981):

sage: P = AA[x](1+x^4); P
x^4 + 1
sage: a1,a2 = P.factor()[0][0],P.factor()[1][0]; a1,a2
(x^2 - 1.414213562373095?*x + 1.000000000000000?, x^2 + 1.414213562373095?*x + 1.000000000000000?)
sage: a1*a2
x^4 + 1.000000000000000?
sage: a1,a2
(x^2 - 1.414213562373095?*x + 1, x^2 + 1.414213562373095?*x + 1)
sage: a1*a2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/sage/sage-4.7.2.alpha2/devel/sage-dev/sage/<ipython console> in <module>()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.RingElement.__mul__ (sage/structure/element.c:12051)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial._mul_ (sage/rings/polynomial/polynomial_element.c:10928)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial._mul_karatsuba (sage/rings/polynomial/polynomial_element.c:16309)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.do_karatsuba (sage/rings/polynomial/polynomial_element.c:36878)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.do_karatsuba (sage/rings/polynomial/polynomial_element.c:36759)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.RingElement.__mul__ (sage/structure/element.c:12051)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.RingElement._mul_ (sage/structure/element.c:12195)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/qqbar.pyc in _mul_(self, other)
   2277         sdk = sd.kind()
   2278         odk = od.kind()
-> 2279         return type(self)(_mul_algo[sdk, odk](self, other, False))
   2280 
   2281     def _div_(self, other):

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/qqbar.pyc in __init__(self, x)
   3384 class AlgebraicReal(AlgebraicNumber_base):
   3385     def __init__(self, x):
-> 3386         AlgebraicNumber_base.__init__(self, AA, x)
   3387 
   3388     def __reduce__(self):

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/qqbar.pyc in __init__(self, parent, x)
   2186             raise TypeError, "Illegal initializer for algebraic number"
   2187 
-> 2188         self._value = self._descr._interval_fast(64)
   2189         
   2190     def _repr_(self):

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/qqbar.pyc in _interval_fast(self, prec)
   5660         op = self._op
   5661 
-> 5662         lv = self._left._interval_fast(prec)
   5663         rv = self._right._interval_fast(prec)
   5664 

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/qqbar.pyc in _interval_fast(self, prec)
   3638 
   3639     def _interval_fast(self, prec):
-> 3640         return self.interval_fast(RealIntervalField(prec))
   3641 
   3642     def interval_exact(self, field):

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/qqbar.pyc in interval_fast(self, field)
   2794         """
   2795         if field.prec() == self._value.prec():
-> 2796             return field(self._value)
   2797         elif field.prec() > self._value.prec():
   2798             self._more_precision()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/real_mpfi.so in sage.rings.real_mpfi.RealIntervalField_class.__call__ (sage/rings/real_mpfi.c:4285)()

/Users/sage/sage-4.7.2.alpha2/local/lib/python2.6/site-packages/sage/rings/real_mpfi.so in sage.rings.real_mpfi.RealIntervalFieldElement.__init__ (sage/rings/real_mpfi.c:7725)()

TypeError: Unable to convert number to real interval.
sage: 

Change History (4)

comment:1 Changed 8 years ago by was

  • Resolution set to duplicate
  • Status changed from new to closed

I'm closing this, since the fix for #10981 also fixes this. It should be one ticket.

Last edited 4 months ago by slelievre (previous) (diff)

comment:2 Changed 8 years ago by was

  • Keywords sd32 added

comment:3 Changed 8 years ago by mvngu

  • Milestone changed from sage-4.7.2 to sage-duplicate/invalid/wontfix

comment:4 Changed 8 years ago by leif

  • Reviewers set to William Stein
Note: See TracTickets for help on using tickets.