Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2452 by peterjef...@gmail.com: Problem with function evaluation
http://code.google.com/p/sympy/issues/detail?id=2452

Please forgive any poor technique in reporting issues, I'm new to this process (if you know of any resources with bug reporting/due diligence guidelines I'm always happy to read)
sympy VERSION 0.6.7

It looks to me like there is a problem evaluating the function for storage a more organized form. The answer given by the following 2 entries should be:
        2 ⎛     2⎞
(-1 + x) ⋅⎝1 + x ⎠
...but instead the negative one is not carried with the constant and factored out of the variable x.

In [2]: ((x - 1)**2 * (x**2 + 1))
Out[2]:
       2 ⎛     2⎞
(1 - x) ⋅⎝1 + x ⎠

In [9]: ((-1+x)**2 * (x**2 + 1))
Out[9]:
       2 ⎛     2⎞
(1 - x) ⋅⎝1 + x ⎠


I came on this error trying to use apart to find partial fractions, the exception raised displays a term that should not be in the polynomial I was asking it to expand => (1 + 2*x**2 + x**4)**2, but it should (1 - 2*x**2 + x**4). I thought the might be related because of the mishandling of the negative. Im not at all sure why the power of 2 gets added, I imagined it might be used in the decomposition technique, but I have not yet learned to use a debugging tools to see if that might be true:
In [3]: f = (x**2 - 4*x -1)/((x - 1)**2 * (x**2 + 1))

In [4]: f
Out[4]:
  ⎛           2⎞
 -⎝1 + 4⋅x - x ⎠
─────────────────
⎛     2⎞        2
⎝1 + x ⎠⋅(1 - x)

In [5]:

In [6]: apart(f, x)
---------------------------------------------------------------------------
PolynomialError                           Traceback (most recent call last)

/home/mightymouse/<ipython console> in <module>()

/usr/lib/pymodules/python2.6/sympy/utilities/decorator.pyc in threaded_decorator(expr, *args, **kwargs) 54 return Add(*[ func(f, *args, **kwargs) for f in expr.args ])
     55                 else:
---> 56                     return func(expr, *args, **kwargs)
     57
     58         threaded_decorator.__doc__  = func.__doc__

/usr/lib/pymodules/python2.6/sympy/simplify/rewrite.pyc in apart(f, z, **flags)
    278             Q = Q.subs(*subs[0])
    279
--> 280             P, Q = Poly(P, z), Poly(Q, z)
    281
    282             G = poly_gcd(P, d)

/usr/lib/pymodules/python2.6/sympy/polys/polynomial.pyc in __new__(cls, poly, *symbols, **flags)
    452                         terms = Poly._permute(poly, *symbols)
    453         else:
--> 454             terms = Poly._decompose(poly, *symbols)
    455
    456         if terms:

/usr/lib/pymodules/python2.6/sympy/polys/polynomial.pyc in _decompose(poly, *symbols)
    596                             continue
    597
--> 598 raise PolynomialError("Can't decompose %s" % factor)
    599                     else:
    600                         coeff *= factor

PolynomialError: Can't decompose (1 + 2*x**2 + x**4)**2


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

Reply via email to