On Apr 19, 8:44 am, smichr <[email protected]> wrote:
> In trying to rebuild an expression piece by piece, I have generated
> the following expression:
>
>
>
> >>> Add(*[Pow(*[y,2],evaluate=True),Mul(*[-1,Pow(*[y,2],evaluate=True)],evaluate=True)],evaluate=True)
> y**2 - y**2
>
> What do I need to do at this point to get it to go to zero?

I think you just hit an obscure bug. Simplifying your testcase gives
this:

In [11]: Add(Pow(y, 2, evaluate=True), Mul(-1, Pow(y, 2)))
Out[11]:
 2    2
y  - y

In [12]: Add(Pow(y, 2, evaluate=False), Mul(-1, Pow(y, 2)))
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call
last)

/home/one/src/sympy/<ipython console> in <module>()

/home/one/src/sympy/sympy/core/cache.pyc in wrapper(*args, **kw_args)
     83         except KeyError:
     84             pass
---> 85         func_cache_it_cache[k] = r = func(*args, **kw_args)
     86         return r
     87

/home/one/src/sympy/sympy/core/operations.pyc in __new__(cls, *args,
**assumptions)
     29         if len(args)==1:
     30             return _sympify(args[0])
---> 31         c_part, nc_part, order_symbols =
cls.flatten(map(_sympify, args))
     32         if len(c_part) + len(nc_part) <= 1:
     33             if c_part: obj = c_part[0]

/home/one/src/sympy/sympy/core/add.pyc in flatten(cls, seq)
    108                     newseq.append(Mul(c,s))
    109
--> 110             noncommutative = noncommutative or not
s.is_commutative
    111
    112         # nan


AttributeError: is_commutative

In [13]: Add(Pow(y, 2), Mul(-1, Pow(y, 2)))
Out[13]: 0

The first two results are wrong. I opened an issue for this:

http://code.google.com/p/sympy/issues/detail?id=1907

Vinzent

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to