Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop from converting to QQbar #24440

Closed
rwst opened this issue Dec 28, 2017 · 10 comments
Closed

Infinite loop from converting to QQbar #24440

rwst opened this issue Dec 28, 2017 · 10 comments

Comments

@rwst
Copy link

rwst commented Dec 28, 2017

sage: QQbar(tanh(pi + 0.1))

/home/ralf/sage/src/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9406)()
    915         if mor is not None:
    916             if no_extra_args:
--> 917                 return mor._call_(x)
    918             else:
    919                 return mor._call_with_args(x, args, kwds)

/home/ralf/sage/src/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4972)()
    153                 print(type(C), C)
    154                 print(type(C._element_constructor), C._element_constructor)
--> 155             raise
    156 
    157     cpdef Element _call_with_args(self, x, args=(), kwds={}):

/home/ralf/sage/src/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4840)()
    148         cdef Parent C = self._codomain
    149         try:
--> 150             return C._element_constructor(x)
    151         except Exception:
    152             if print_warnings:

/home/ralf/sage/local/lib/python2.7/site-packages/sage/rings/qqbar.pyc in _element_constructor_(self, x)
   1138             return AlgebraicNumber(x._descr)
   1139         elif hasattr(x, '_algebraic_'):
-> 1140             return x._algebraic_(QQbar)
   1141         return AlgebraicNumber(x)
   1142 

/home/ralf/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._algebraic_ (build/cythonized/sage/symbolic/expression.cpp:12139)()
   1477         """
   1478         from sage.symbolic.expression_conversions import algebraic
-> 1479         return algebraic(self, field)
   1480 
   1481     def __hash__(self):

/home/ralf/sage/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in algebraic(ex, field)
   1046         0
   1047     """
-> 1048     return AlgebraicConverter(field)(ex)
   1049 
   1050 ##############

/home/ralf/sage/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
    224             return self.tuple(ex)
    225         else:
--> 226             return self.composition(ex, operator)
    227 
    228     def get_fake_div(self, ex):

/home/ralf/sage/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in composition(self, ex, operator)
    987                 res = -QQbar.zeta(4)*(exp_ia - ~exp_ia)/(exp_ia + ~exp_ia)
    988         elif func_name in ['sinh', 'cosh', 'tanh']:
--> 989             exp_a = exp(operand)._algebraic_(QQbar)
    990             if func_name == 'sinh':
    991                 res = (exp_a - ~exp_a)/2

/home/ralf/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._algebraic_ (build/cythonized/sage/symbolic/expression.cpp:12139)()
   1477         """
   1478         from sage.symbolic.expression_conversions import algebraic
-> 1479         return algebraic(self, field)
   1480 
   1481     def __hash__(self):

/home/ralf/sage/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in algebraic(ex, field)
   1046         0
   1047     """
-> 1048     return AlgebraicConverter(field)(ex)
   1049 
   1050 ##############

... last 6 frames repeated, from the frame below ...

/home/ralf/sage/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
    216                 div = self.get_fake_div(ex)
    217                 return self.arithmetic(div, div.operator())
--> 218             return self.arithmetic(ex, operator)
    219         elif operator in relation_operators:
    220             return self.relation(ex, operator)

RuntimeError: maximum recursion depth exceeded in __instancecheck__

It seems that only pi as constant will trigger it.

Component: basic arithmetic

Author: Ralf Stephan

Branch/Commit: 39bfd96

Reviewer: Sébastien Labbé

Issue created by migration from https://trac.sagemath.org/ticket/24440

@rwst rwst added this to the sage-8.2 milestone Dec 28, 2017
@rwst

This comment has been minimized.

@rwst rwst changed the title Infinite loop from proving an expression Infinite loop from converting to QQbar Feb 2, 2018
@rwst

This comment has been minimized.

@rwst
Copy link
Author

rwst commented Feb 9, 2018

comment:4

Also QQbar(sin(I*pi/7)) crashes (with or without hold=True) but differently. Finally,

sage: QQbar(sinh(I*pi/7.,hold=True))
...
/home/ralf/sage/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in composition(self, ex, operator)
    976             # Coerce (not convert, see #22571) arg to a rational
    977             arg = operand.imag()/(2*ex.parent().pi())
--> 978             rat_arg = QQ.coerce(arg.pyobject())
    979             res = QQbar.zeta(rat_arg.denom())**rat_arg.numer()
    980         elif func_name in ['sin', 'cos', 'tan']:
...
TypeError: no canonical coercion from Real Field with 53 bits of precision to Rational Field

@rwst
Copy link
Author

rwst commented Feb 9, 2018

@rwst
Copy link
Author

rwst commented Feb 9, 2018

Author: Ralf Stephan

@rwst
Copy link
Author

rwst commented Feb 9, 2018

New commits:

39bfd9624440: Infinite loop from converting to QQbar

@rwst
Copy link
Author

rwst commented Feb 9, 2018

Commit: 39bfd96

@seblabbe
Copy link
Contributor

Reviewer: Sébastien Labbé

@rwst
Copy link
Author

rwst commented Apr 29, 2018

comment:8

Thanks.

@vbraun
Copy link
Member

vbraun commented May 8, 2018

Changed branch from u/rws/infinite_loop_from_converting_to_qqbar to 39bfd96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants