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

Polynomial solve with GoldenRatio causes Traceback #11553

ctefer opened this Issue Aug 29, 2016 · 2 comments


None yet
3 participants
Copy link

ctefer commented Aug 29, 2016

Found during issue 11538 investigation. The GoldenRatio::NumberSymbol is the only NumberSymbol currently treated as an algebraic expression. However when solve is called on the GoldenRatio a Traceback occurs where GoldenRatio is not being treated algebraically.

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sympy
>>> x,y=sympy.symbols('x y')
>>> e1=x+y+1
>>> e2=x+sympy.GoldenRatio
>>> sympy.solve([e1,e2],x,y)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympy\solvers\", line 1053, in solve
    solution = _solve_system(f, symbols, **flags)
  File "sympy\solvers\", line 1660, in _solve_system
    poly = g.as_poly(*symbols, extension=True)
  File "sympy\core\", line 699, in as_poly
    poly = Poly(self, *gens, **args)
  File "sympy\polys\", line 89, in __new__
    return cls._from_expr(rep, opt)
  File "sympy\polys\", line 200, in _from_expr
    return cls._from_dict(rep, opt)
  File "sympy\polys\", line 144, in _from_dict
    domain, rep = construct_domain(rep, opt=opt)
  File "sympy\polys\", line 238, in construct_domain
    result = _construct_simple(coeffs, opt)
  File "sympy\polys\", line 45, in _construct_simple
    domain, result = _construct_algebraic(coeffs, opt)
  File "sympy\polys\", line 93, in _construct_algebraic
    g, span, H = primitive_element(exts, ex=True, polys=True)
  File "sympy\polys\", line 857, in primitive_element
    f = minpoly(ext, y)
  File "sympy\polys\", line 657, in minimal_polynomial
    result = _minpoly_compose(ex, x, dom)
  File "sympy\polys\", line 578, in _minpoly_compose
    raise NotAlgebraic("%s doesn't seem to be an algebraic element" % ex)
sympy.polys.polyerrors.NotAlgebraic: GoldenRatio doesn't seem to be an algebraic element

This comment has been minimized.

Copy link

jksuom commented Aug 29, 2016

It seems that GoldenRatio should be treated in the same way as I in _minpoly_compse. So, the following should be added:

    if ex is GoldenRatio:
        return x**2 - x - 1

skirpichev added a commit to skirpichev/diofant that referenced this issue Aug 30, 2016

skirpichev added a commit to skirpichev/diofant that referenced this issue Sep 12, 2016


This comment has been minimized.

Copy link

asmeurer commented Jul 11, 2017

I think in general it shouldn't assume that is_algebraic means that it can find its minimal polynomial. It should check more directly for the types of expressions it can work with, rather than blacklisting.

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