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

PolynomialError with minpoly() #5934

Closed
asmeurer opened this Issue Nov 10, 2011 · 5 comments

Comments

Projects
None yet
6 participants
@asmeurer
Member

asmeurer commented Nov 10, 2011

I found this from the expression from issue 5933 :

In [50]: [minpoly(i) for i in x.as_numer_denom()]
---------------------------------------------------------------------------
PolynomialError                           Traceback (most recent call last)
/Users/aaronmeurer/Documents/python/sympy/sympy/<ipython-input-50-ffbba6cffd4e> in <module>()
----> 1 [minpoly(i) for i in x.as_numer_denom()]

/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/numberfields.pyc in minimal_polynomial(ex, x, **args)
    130     else:
    131         F = [x - bottom_up_scan(ex)] + mapping.values()
--> 132         G = groebner(F, symbols.values() + [x], order='lex')
    133 
    134         _, factors = factor_list(G[-1])

/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/polytools.pyc in groebner(F, *gens, **args)
   5458 
   5459     """
-> 5460     return GroebnerBasis(F, *gens, **args)
   5461 
   5462 def is_zero_dimensional(F, *gens, **args):

/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/polytools.pyc in __new__(cls, F, *gens, **args)
   5485 
   5486         try:
-> 5487             polys, opt = parallel_poly_from_expr(F, *gens, **args)
   5488         except PolificationFailed, exc:
   5489             raise ComputationFailed('groebner', len(F), exc)

/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/polytools.pyc in parallel_poly_from_expr(exprs, *gens, **args)
   3670     """Construct polynomials from expressions. """
   3671     opt = options.build_options(gens, args)
-> 3672     return _parallel_poly_from_expr(exprs, opt)
   3673 
   3674 def _parallel_poly_from_expr(exprs, opt):

/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/polytools.pyc in _parallel_poly_from_expr(exprs, opt)
   3721 
   3722     try:
-> 3723         reps, opt = _parallel_dict_from_expr(exprs, opt)
   3724     except GeneratorsNeeded:
   3725         raise PolificationFailed(opt, origs, exprs, True)

/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/polyutils.pyc in _parallel_dict_from_expr(exprs, opt)
    276 
    277     if opt.gens:
--> 278         reps, gens = _parallel_dict_from_expr_if_gens(exprs, opt)
    279     else:
    280         reps, gens = _parallel_dict_from_expr_no_gens(exprs, opt)

/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/polyutils.pyc in _parallel_dict_from_expr_if_gens(exprs, opt)
    161                             coeff.append(factor)
    162                         else:
--> 163                             raise PolynomialError("%s contains an element of the generators set" % factor)
    164 
    165             monom = tuple(monom)

PolynomialError: sqrt(_a4) contains an element of the generators set

In [83]: print x
(-240*sqrt(2)*sqrt(sqrt(5) + 5)*sqrt(8*sqrt(5) + 40) - 360*sqrt(2)*sqrt(-8*sqrt(5) + 40)*sqrt(-sqrt(5) + 5) - 120*sqrt(10)*sqrt(-8*sqrt(5) + 40)*sqrt(-sqrt(5) + 5) + 120*sqrt(2)*sqrt(-8*sqrt(5) + 40)*sqrt(sqrt(5) + 5) + 120*sqrt(2)*sqrt(-sqrt(5) + 5)*sqrt(8*sqrt(5) + 40) + 120*sqrt(10)*sqrt(-8*sqrt(5) + 40)*sqrt(sqrt(5) + 5) + 120*sqrt(10)*sqrt(-sqrt(5) + 5)*sqrt(8*sqrt(5) + 40))/(-36000 - 7200*sqrt(5) + (12*sqrt(10)*sqrt(sqrt(5) + 5) + 24*sqrt(10)*sqrt(-sqrt(5) + 5))**2)

The error also occurs if you just call minpoly(x).

Original issue for #5934: http://code.google.com/p/sympy/issues/detail?id=2835
Original author: https://code.google.com/u/asmeurer@gmail.com/
Referenced issues: #5933

@asmeurer

This comment has been minimized.

Member

asmeurer commented Mar 20, 2012

@smichr

This comment has been minimized.

Member

smichr commented Apr 19, 2013

If the expression is expanded first ( issue 5986 ) minpoly hangs but if the expression were checked as being equal to zero before the minpoly algorithm was attempted, the trivial result could have been returned.

Suggestion:

before the test that ex is algebraic, see if nsimplify(ex) is zero and verify it. In this case this is a precisionless zero after evaluation, but equals is able to verify that this is a zero:


>>> eq.n()
0.e-12
>>> nsimplify(eq)
0
>>> eq.equals(0)
True

**Labels:** EasyToFix  

Referenced issues: #5986
Original comment: http://code.google.com/p/sympy/issues/detail?id=2835#c2
Original author: https://code.google.com/u/117933771799683895267/

@smichr

This comment has been minimized.

Member

smichr commented Apr 23, 2013

Perhaps the check could be whether the expression is a Number (not only zero).

Original comment: http://code.google.com/p/sympy/issues/detail?id=2835#c3
Original author: https://code.google.com/u/117933771799683895267/

@pernici

This comment has been minimized.

Contributor

pernici commented May 3, 2013

In PR 2038 ``minpoly`` raises an exception if it finds a division by
zero, as in the case of ``minpoly(x)`` with ``x`` of the first comment.

Original comment: http://code.google.com/p/sympy/issues/detail?id=2835#c4
Original author: https://code.google.com/u/107755593449647463741/

@mayukuse24

This comment has been minimized.

mayukuse24 commented Dec 16, 2015

I am new to sympy and open source development and i would like to take up this task.
Can someone explain what the problem is and where to get started

skirpichev added a commit to skirpichev/diofant that referenced this issue Sep 18, 2018

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