# sympy/sympy

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.

# Polynomial solve with GoldenRatio causes Traceback #11553

Open
opened this Issue Aug 29, 2016 · 2 comments

Projects
None yet
3 participants
Contributor

### 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 "", line 1, in File "sympy\solvers\solvers.py", line 1053, in solve solution = _solve_system(f, symbols, **flags) File "sympy\solvers\solvers.py", line 1660, in _solve_system poly = g.as_poly(*symbols, extension=True) File "sympy\core\basic.py", line 699, in as_poly poly = Poly(self, *gens, **args) File "sympy\polys\polytools.py", line 89, in __new__ return cls._from_expr(rep, opt) File "sympy\polys\polytools.py", line 200, in _from_expr return cls._from_dict(rep, opt) File "sympy\polys\polytools.py", line 144, in _from_dict domain, rep = construct_domain(rep, opt=opt) File "sympy\polys\constructor.py", line 238, in construct_domain result = _construct_simple(coeffs, opt) File "sympy\polys\constructor.py", line 45, in _construct_simple domain, result = _construct_algebraic(coeffs, opt) File "sympy\polys\constructor.py", line 93, in _construct_algebraic g, span, H = primitive_element(exts, ex=True, polys=True) File "sympy\polys\numberfields.py", line 857, in primitive_element f = minpoly(ext, y) File "sympy\polys\numberfields.py", line 657, in minimal_polynomial result = _minpoly_compose(ex, x, dom) File "sympy\polys\numberfields.py", 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 ``````
Member

### 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

``` Add special case for GoldenRatio in _minpoly_compose ```
`Fixes sympy/sympy#11553`
``` f414ac1 ```

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

``` Add special case for GoldenRatio in _minpoly_compose ```
`Fixes sympy/sympy#11553`
``` f50c998 ```
Member

### 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.
to join this conversation on GitHub. Already have an account? Sign in to comment