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

Symbolic substitution infinite recursion (was "NumberField infinite recursion") #1566

Closed
sagetrac-phatsphere mannequin opened this issue Dec 19, 2007 · 5 comments
Closed

Comments

@sagetrac-phatsphere
Copy link
Mannequin

sagetrac-phatsphere mannequin commented Dec 19, 2007

I think the input is wrong, but it should not loop forever and throw an error.

K3.<a>=NumberField([x^2+1,sqrt(x^3)+1])

gives

Exception (click to the left for traceback):
...
RuntimeError: maximum recursion depth exceeded in cmp

here the infinite traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/server4/sage_notebook/worksheets/phatsphere/0/code/123.py", line 4, in <module>
    exec compile(ur'K3=NumberField([x**Integer(2)+Integer(1),sqrt(x**Integer(3))+Integer(1)],names=(\u0027a\u0027,)); (a,) = K3._first_ngens(Integer(1))' + '\n', '', 'single')
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sympy/plotting/", line 1, in <module>
    
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py", line 245, in NumberField
    return NumberFieldTower(polynomial, name)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py", line 389, in NumberFieldTower
    w = NumberFieldTower(v[1:], names=names[1:])
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py", line 387, in NumberFieldTower
    return NumberField(v[0], names=names)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py", line 251, in NumberField
    polynomial = polynomial.polynomial(QQ)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 1344, in polynomial
    dict([(var(V[i]),G[i]) for i in range(len(G))]), ring=R)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 2825, in substitute_over_ring
    return X._recursive_sub_over_ring(kwds, ring)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 3763, in _recursive_sub_over_ring
    new_ops = [op._recursive_sub_over_ring(kwds, ring=ring) for op in ops]
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 4842, in _recursive_sub_over_ring
    return ring(ops[0](ops[1]._recursive_sub_over_ring(kwds, ring=ring)))
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/rings/polynomial/polynomial_ring.py", line 218, in __call__
    return x._polynomial_(self)        
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 1409, in _polynomial_
    return self.substitute_over_ring(dict(sub), ring=R)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 2825, in substitute_over_ring
    return X._recursive_sub_over_ring(kwds, ring)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 4842, in _recursive_sub_over_ring
    return ring(ops[0](ops[1]._recursive_sub_over_ring(kwds, ring=ring)))
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/rings/polynomial/polynomial_ring.py", line 218, in __call__
    return x._polynomial_(self)        
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 1409, in _polynomial_
    return self.substitute_over_ring(dict(sub), ring=R)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 2825, in substitute_over_ring
    return X._recursive_sub_over_ring(kwds, ring)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 4842, in _recursive_sub_over_ring
    return ring(ops[0](ops[1]._recursive_sub_over_ring(kwds, ring=ring)))
.
.
.
 File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 1409, in _polynomial_
    return self.substitute_over_ring(dict(sub), ring=R)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 2825, in substitute_over_ring
    return X._recursive_sub_over_ring(kwds, ring)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 4842, in _recursive_sub_over_ring
    return ring(ops[0](ops[1]._recursive_sub_over_ring(kwds, ring=ring)))
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/rings/polynomial/polynomial_ring.py", line 218, in __call__
    return x._polynomial_(self)        
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 1387, in _polynomial_
    vars = self.variables()
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 3524, in variables
    return self.simplify().variables(vars)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 2555, in simplify
    S = evaled_symbolic_expression_from_maxima_string(self._maxima_init_())
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 6466, in evaled_symbolic_expression_from_maxima_string
    return symbolic_expression_from_maxima_string(maxima.eval(x))
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/interfaces/expect.py", line 707, in eval
    return '\n'.join([self._eval_line(L, **kwds) for L in code.split('\n') if L != ''])
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/interfaces/maxima.py", line 540, in _eval_line
    self._synchronize()
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/interfaces/maxima.py", line 600, in _synchronize
    self._expect_expr(timeout=0.5)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/sage/interfaces/maxima.py", line 453, in _expect_expr
    i = self._expect.expect(expr,timeout=timeout)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/pexpect.py", line 911, in expect
    compiled_pattern_list = self.compile_pattern_list(pattern)
  File "/usr/local/sage-2.6/local/lib/python2.5/site-packages/pexpect.py", line 843, in compile_pattern_list
    compiled_pattern_list.append(re.compile(p, re.DOTALL))
  File "/usr/local/sage-2.6/local/lib/python2.5/re.py", line 180, in compile
    return _compile(pattern, flags)
  File "/usr/local/sage-2.6/local/lib/python2.5/re.py", line 222, in _compile
    p = _cache.get(cachekey)
RuntimeError: maximum recursion depth exceeded in cmp

Component: calculus

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

@sagetrac-dmharvey
Copy link
Mannequin

sagetrac-dmharvey mannequin commented Dec 20, 2007

comment:2

I'm taking a look a this....

here is a simpler example that causes the same problem:

sage: K3.<a> = NumberField(sqrt(x))

@sagetrac-dmharvey
Copy link
Mannequin

sagetrac-dmharvey mannequin commented Dec 21, 2007

comment:3

aha it has nothing to do with number fields:

sage: f = sqrt(x)
sage: g = f.polynomial(QQ)
[boom]

@sagetrac-dmharvey
Copy link
Mannequin

sagetrac-dmharvey mannequin commented Dec 21, 2007

comment:4

ok it's some nastiness to do with recursive substitution in symbolic expressions. The same thing happens with cos(x).polynomial(QQ) etc. I will leave this voodoo to someone else who understands the symbolic calculus package.

@sagetrac-dmharvey sagetrac-dmharvey mannequin changed the title NumberField infinite recursion Symbolic substitution infinite recursion (was "NumberField infinite recursion") Dec 21, 2007
@mwhansen mwhansen assigned mwhansen and unassigned williamstein Dec 22, 2007
@mwhansen
Copy link
Contributor

comment:7

Attachment: 1566.patch.gz

@rlmill
Copy link
Mannequin

rlmill mannequin commented Dec 22, 2007

comment:8

merged in 2.9.1 rc0

@rlmill rlmill mannequin closed this as completed Dec 22, 2007
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

2 participants