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

subs into inequality involving RootOf raises GeneratorsNeeded #10092

Closed
smichr opened this Issue Nov 1, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@smichr
Copy link
Member

smichr commented Nov 1, 2015

If x is real then the following generates and error

>>> from sympy import *
>>> var('x', real=True)
x
>>> eq=RootOf(x**3 - 17*x**2 + 81*x - 118, 0)
>>> (x<eq).subs(x,eq)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympy\core\basic.py", line 895, in subs
    rv = rv._subs(old, new, **kwargs)
  File "sympy\core\cache.py", line 93, in wrapper
    retval = cfunc(*args, **kwargs)
  File "sympy\core\compatibility.py", line 880, in wrapper
    result = user_function(*args, **kwds)
  File "sympy\core\basic.py", line 1009, in _subs
    rv = fallback(self, old, new)
  File "sympy\core\basic.py", line 981, in fallback
    arg = arg._subs(old, new, **hints)
  File "sympy\core\cache.py", line 93, in wrapper
    retval = cfunc(*args, **kwargs)
  File "sympy\core\compatibility.py", line 880, in wrapper
    result = user_function(*args, **kwds)
  File "sympy\core\basic.py", line 1009, in _subs
    rv = fallback(self, old, new)
  File "sympy\core\basic.py", line 986, in fallback
    rv = self.func(*args)
  File "sympy\polys\rootoftools.py", line 68, in __new__
    poly = PurePoly(f, x, greedy=False, expand=expand)
  File "sympy\polys\polytools.py", line 89, in __new__
    return cls._from_expr(rep, opt)
  File "sympy\polys\polytools.py", line 199, in _from_expr
    rep, opt = _dict_from_expr(rep, opt)
  File "sympy\polys\polyutils.py", line 366, in _dict_from_expr
    rep, gens = _dict_from_expr_no_gens(expr, opt)
  File "sympy\polys\polyutils.py", line 311, in _dict_from_expr_no_gens
    (poly,), gens = _parallel_dict_from_expr_no_gens((expr,), opt)
  File "sympy\polys\polyutils.py", line 272, in _parallel_dict_from_expr_no_gens

    raise GeneratorsNeeded("specify generators to give %s a meaning" % arg)
sympy.polys.polyerrors.GeneratorsNeeded: specify generators to give -17*RootOf(x
**3 - 17*x**2 + 81*x - 118, 0)**2 - 118 + RootOf(x**3 - 17*x**2 + 81*x - 118, 0)
**3 + 81*RootOf(x**3 - 17*x**2 + 81*x - 118, 0) a meaning

But a vanilla x does not raise:

>>> var('x')
x
>>> eq=RootOf(x**3 - 17*x**2 + 81*x - 118, 0)
>>> (x<eq).subs(x,eq)
False
@tyagi-prashant

This comment has been minimized.

Copy link
Contributor

tyagi-prashant commented Nov 3, 2015

@smichr it should return a error,right??

@smichr

This comment has been minimized.

Copy link
Member

smichr commented Nov 4, 2015

PR #10097 just makes subs pass over RootOf -- RootOf is kind of like an atom as I think I discussed in the commit message there. In general, if a subs shouldn't target something it just passes over that object; the behavior is governed by _eval_subs.

Please feel free to make comments on the PR.

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 16, 2016

sympy/sympy#10092: do not allow subs to target args of RootOf
// edited by skirpichev

Signed-off-by: Sergey B Kirpichev <skirpichev@gmail.com>

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 17, 2016

Do not allow subs to target args of RootOf
Closes sympy/sympy#10092

// edited by skirpichev

Signed-off-by: Sergey B Kirpichev <skirpichev@gmail.com>

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 17, 2016

Do not allow subs to target args of RootOf
Closes sympy/sympy#10092

// edited by skirpichev

Signed-off-by: Sergey B Kirpichev <skirpichev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment