Status: New
Owner: ness...@googlemail.com
CC: matt...@gmail.com
Labels: Type-Defect Priority-Medium Polynomial
New issue 2384 by ness...@googlemail.com: Polynomial evaluation bug
http://code.google.com/p/sympy/issues/detail?id=2384
In [2]: _x = Dummy('x')
In [3]: _A= Dummy('A')
In [4]: Poly((-3.52090351936158 + 8.88983362580487*I)*_A**4 +
(11.8741294994128 - 8.32264165441408*I)*_A**3 + (-9.18362999273934 -
2.71296684982264*I)*_A**2 + (0.68784378477558 + 2.31591615695851*I)*_A +
0.14256022791254 - 0.170141278526651*I, _A, domain='EX').eval(_A,
_x/(1.55404728225593 + 0.822882244808321*I) + 1)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/home/ness/src/sympy/<ipython console> in <module>()
/home/ness/src/sympy/sympy/polys/polytools.pyc in eval(f, x, a, auto)
1964
1965 try:
-> 1966 result = f.rep.eval(a, j)
1967 except CoercionFailed:
1968 if not auto:
/home/ness/src/sympy/sympy/polys/polyclasses.pyc in eval(f, a, j)
506
507 return f.per(dmp_eval_in(f.rep,
--> 508 f.dom.convert(a), j, f.lev, f.dom), kill=True)
509
510 def half_gcdex(f, g):
/home/ness/src/sympy/sympy/polys/densetools.pyc in dmp_eval_in(f, a, j, u,
K)
358 raise IndexError("-%s <= j < %s expected, got %s" % (u, u,
j))
359
--> 360 return _rec_eval_in(f, a, u, 0, j, K)
361
362 @cythonized("i,u")
/home/ness/src/sympy/sympy/polys/densetools.pyc in _rec_eval_in(g, a, v, i,
j, K)
331 """Recursive helper for :func:`dmp_eval_in`."""
332 if i == j:
--> 333 return dmp_eval(g, a, v, K)
334
335 v, i = v-1, i+1
/home/ness/src/sympy/sympy/polys/densetools.pyc in dmp_eval(f, a, u, K)
314 """
315 if not u:
--> 316 return dup_eval(f, a, K)
317
318 if not a:
/home/ness/src/sympy/sympy/polys/densetools.pyc in dup_eval(f, a, K)
293 for c in f:
294 result *= a
--> 295 result += c
296
297 return result
/home/ness/src/sympy/sympy/polys/domains/expressiondomain.pyc in __add__(f,
g)
52
53 def __add__(f, g):
---> 54 return f.simplify(f.ex+f.__class__(g).ex)
55
56 def __radd__(f, g):
/home/ness/src/sympy/sympy/polys/domains/expressiondomain.pyc in
simplify(f, ex)
43
44 def simplify(f, ex):
---> 45 return f.__class__(ex.cancel())
46
47 def __abs__(f):
/home/ness/src/sympy/sympy/core/expr.pyc in cancel(self, *gens, **args)
1783 """See the cancel function in sympy.polys"""
1784 from sympy.polys import cancel
-> 1785 return cancel(self, *gens, **args)
1786
1787 def invert(self, g):
/home/ness/src/sympy/sympy/polys/polytools.pyc in cancel(f, *gens, **args)
4943 return S.One, p, q
4944
-> 4945 c, P, Q = F.cancel(G)
4946
4947 if type(f) is not tuple:
/home/ness/src/sympy/sympy/polys/polytools.pyc in cancel(f, g)
2837
2838 if hasattr(F, 'cancel'):
-> 2839 cp, cq, p, q = F.cancel(G, multout=False)
2840 else: # pragma: no cover
2841 raise OperationNotSupported(f, 'cancel')
/home/ness/src/sympy/sympy/polys/polyclasses.pyc in cancel(f, g, multout)
582 F, G = dmp_cancel(F, G, lev, dom, multout=True)
583 else:
--> 584 cF, cG, F, G = dmp_cancel(F, G, lev, dom, multout=False)
585
586 F, G = per(F), per(G)
/home/ness/src/sympy/sympy/polys/euclidtools.pyc in dmp_cancel(f, g, u, K,
multout)
1844 cp, cq = K.one, K.one
1845
-> 1846 _, p, q = dmp_inner_gcd(f, g, u, K)
1847
1848 if K0 is not None:
/home/ness/src/sympy/sympy/polys/euclidtools.pyc in dmp_inner_gcd(f, g, u,
K)
1554
1555 J, (f, g) = dmp_multi_deflate((f, g), u, K)
-> 1556 h, cff, cfg = _dmp_inner_gcd(f, g, u, K)
1557
1558 return (dmp_inflate(h, J, u, K),
/home/ness/src/sympy/sympy/polys/euclidtools.pyc in _dmp_inner_gcd(f, g, u,
K)
1520 pass
1521
-> 1522 return dmp_ff_prs_gcd(f, g, u, K)
1523 else:
1524 if K.is_ZZ and query('USE_HEU_GCD'):
/home/ness/src/sympy/sympy/polys/euclidtools.pyc in dmp_ff_prs_gcd(f, g, u,
K)
1118 gc, g = dmp_primitive(g, u, K)
1119
-> 1120 h = dmp_subresultants(f, g, u, K)[-1]
1121 c, _, _ = dmp_ff_prs_gcd(fc, gc, u-1, K)
1122
/home/ness/src/sympy/sympy/polys/euclidtools.pyc in dmp_subresultants(f, g,
u, K)
543
544 """
--> 545 return dmp_inner_subresultants(f, g, u, K)[0]
546
547 @cythonized("u,v,s,i,d,du,dv,dw")
/home/ness/src/sympy/sympy/polys/euclidtools.pyc in
dmp_inner_subresultants(f, g, u, K)
518 D.append(d)
519
--> 520 h = dmp_prem(f, g, u, K)
521 h = [ dmp_exquo(ch, b, v, K) for ch in h ]
522
/home/ness/src/sympy/sympy/polys/densearith.pyc in dmp_prem(f, g, u, K)
1279 r = dmp_sub(R, G, u, K)
1280
-> 1281 c = dmp_pow(lc_g, N, u-1, K)
1282
1283 return dmp_mul_term(r, c, 0, u, K)
/home/ness/src/sympy/sympy/polys/densearith.pyc in dmp_pow(f, n, u, K)
998 """
999 if not u:
-> 1000 return dup_pow(f, n, K)
1001
1002 if not n:
/home/ness/src/sympy/sympy/polys/densearith.pyc in dup_pow(f, n, K)
962 return [K.one]
963 if n < 0:
--> 964 raise ValueError("can't raise polynomial to a negative
power")
965 if n == 1 or not f or f == [K.one]:
966 return f
ValueError: can't raise polynomial to a negative power
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.