methods in polynomial module

25 views
Skip to first unread message

Yash Aggarwal

unread,
Dec 4, 2016, 2:52:51 PM12/4/16
to sympy
A polynomial should not include division and poly() function seems to raise an error when such an argument is given to it. But several other functions like degree() gives buggy result instead of raising an error. Shouldn't they too raise an error?

>>> a=(x+1)**5/(x-3)
>>> poly(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/sympy-1.0.1.dev0-py3.5.egg/sympy/polys/polytools.py", line 6889, in poly
    return _poly(expr, opt)
  File "/usr/local/lib/python3.5/dist-packages/sympy-1.0.1.dev0-py3.5.egg/sympy/polys/polytools.py", line 6839, in _poly
    _poly(factor.base, opt).pow(factor.exp))
  File "/usr/local/lib/python3.5/dist-packages/sympy-1.0.1.dev0-py3.5.egg/sympy/polys/polytools.py", line 1404, in pow
    result = f.rep.pow(n)
  File "/usr/local/lib/python3.5/dist-packages/sympy-1.0.1.dev0-py3.5.egg/sympy/polys/polyclasses.py", line 446, in pow
    return f.per(dmp_pow(f.rep, n, f.lev, f.dom))
  File "/usr/local/lib/python3.5/dist-packages/sympy-1.0.1.dev0-py3.5.egg/sympy/polys/densearith.py", line 978, in dmp_pow
    return dup_pow(f, n, K)
  File "/usr/local/lib/python3.5/dist-packages/sympy-1.0.1.dev0-py3.5.egg/sympy/polys/densearith.py", line 943, in dup_pow
    raise ValueError("can't raise polynomial to a negative power")
ValueError: can't raise polynomial to a negative power
>>> degree(a)
5
>>> LT(a)
x**5/(x - 3)



Reply all
Reply to author
Forward
0 new messages