#12745: Coercion problem with Algebraic Real Field
-----------------------------+----------------------------------------------
Reporter: davidloeffler | Owner: AlexGhitza
Type: defect | Status: new
Priority: major | Milestone: sage-5.0
Component: algebra | Keywords:
Work issues: | Report Upstream: N/A
Reviewers: | Authors:
Merged in: | Dependencies:
Stopgaps: |
-----------------------------+----------------------------------------------
The following algebraic number is clearly real, but the AA class seems to
have trouble digesting it:
{{{
----------------------------------------------------------------------
| Sage Version 5.0.beta10, Release Date: 2012-03-23 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
**********************************************************************
* *
* Warning: this is a prerelease version, and it may be unstable. *
* *
**********************************************************************
sage: x = exp(2*I*pi/7) + exp(-2*I*pi/7)
sage: QQbar(x) in AA
True
sage: AA(x)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (1327, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (4541, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (1327, 0))
---------------------------------------------------------------------------
ValueError Traceback (most recent call
last)
/storage/masiao/sage-5.0.beta10/devel/sage-main/<ipython console> in
<module>()
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/structure/parent.so in sage.structure.parent.Parent.__call__
(sage/structure/parent.c:7940)()
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/structure/coerce_maps.so in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_
(sage/structure/coerce_maps.c:3344)()
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/structure/coerce_maps.so in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_
(sage/structure/coerce_maps.c:3247)()
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/rings/qqbar.pyc in _element_constructor_(self, x)
689 raise ValueError("Cannot coerce algebraic number
with non-zero imaginary part to algebraic real")
690 elif hasattr(x, '_algebraic_'):
--> 691 return x._algebraic_(AA)
692 return AlgebraicReal(x)
693
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/symbolic/expression.so in
sage.symbolic.expression.Expression._algebraic_
(sage/symbolic/expression.cpp:6286)()
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/symbolic/expression_conversions.pyc in algebraic(ex, field)
830 0
831 """
--> 832 return AlgebraicConverter(field)(ex)
833
834 ##############
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
212 div = self.get_fake_div(ex)
213 return self.arithmetic(div, div.operator())
--> 214 return self.arithmetic(ex, operator)
215 elif operator in relation_operators:
216 return self.relation(ex, operator)
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex,
operator)
717 return self.field(base**expt)
718 else:
--> 719 return reduce(operator, map(self, ex.operands()))
720 except TypeError:
721 if operator is _operator.pow:
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
218 return self.derivative(ex, operator)
219 else:
--> 220 return self.composition(ex, operator)
221
222 def get_fake_div(self, ex):
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/symbolic/expression_conversions.pyc in composition(self, ex,
operator)
787 if cmp(res, ex) == 0:
788 raise TypeError, "unable to convert %s to %s"%(ex,
self.field)
--> 789 return self.field(res)
790
791 def algebraic(ex, field):
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/structure/parent.so in sage.structure.parent.Parent.__call__
(sage/structure/parent.c:7940)()
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/structure/coerce_maps.so in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_
(sage/structure/coerce_maps.c:3344)()
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/structure/coerce_maps.so in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_
(sage/structure/coerce_maps.c:3247)()
/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-
packages/sage/rings/qqbar.pyc in _element_constructor_(self, x)
687 return x.real()
688 else:
--> 689 raise ValueError("Cannot coerce algebraic number
with non-zero imaginary part to algebraic real")
690 elif hasattr(x, '_algebraic_'):
691 return x._algebraic_(AA)
ValueError: Cannot coerce algebraic number with non-zero imaginary part to
algebraic real
}}}
This does not seem to be related to #12665 or to #12727 -- applying the
patches at those tickets does not fix the problem.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12745>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.