subs with non-commutative symbols

14 views
Skip to first unread message

Julien Rioux

unread,
Feb 14, 2011, 4:06:25 PM2/14/11
to sy...@googlegroups.com
Dear list,

I found some more problems when using non-commutative symbols and subs
and I wonder if I should reopen issue 2022 or open a new issue?

In [1]: import sympy

In [2]: print sympy.__version__
0.6.7-git

In [3]: sympy.var('a b c')
Out[3]: (a, b, c)

In [4]: A=sympy.Symbol('A', commutative=False)

In [5]: B=sympy.Symbol('B', commutative=False)

In [6]: (a*A).subs(a*a*A,B)
Out[6]: a*B

In [7]: (A*A).subs(A*A*A,c)
Out[7]: c**(2/3)

In [8]: (A*A*A).subs(A*A,c)
Out[8]: c**(3/2)

In [6] and [7] no substitution should occur, in [8] c*A should be the result.

[7] and [8] are related to issue 2026, but it's different in that with
non-commutative symbols, it is simply wrong to do algebraic
substitution.

--
Julien

Aaron S. Meurer

unread,
Feb 14, 2011, 4:10:41 PM2/14/11
to sy...@googlegroups.com
I guess you could reopen 2022. I would mark it blocked on 2026 if you think that issue will solve [7] and [8].

Aaron Meurer

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

Aaron S. Meurer

unread,
Feb 14, 2011, 4:12:18 PM2/14/11
to Aaron S. Meurer, sy...@googlegroups.com
By the way, I have just (hopefully) given you the permissions to do these things on the Google Code issue tracker.

Aaron Meurer

Chris Smith

unread,
Feb 14, 2011, 9:28:07 PM2/14/11
to sy...@googlegroups.com
Julien Rioux wrote:
>> Dear list,
>>
>> I found some more problems when using non-commutative symbols and
>> subs and I wonder if I should reopen issue 2022 or open a new issue?
>>

Before the changes of 2039 you would get:

h[2] >>> (a*A).subs(a*a*A,B)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sympy\core\basic.py", line 705, in subs
return self._subs_old_new(old, new)
File "sympy\core\cache.py", line 85, in wrapper
func_cache_it_cache[k] = r = func(*args, **kw_args)
File "sympy\core\basic.py", line 714, in _subs_old_new
return self._eval_subs(old, new)
File "sympy\core\mul.py", line 897, in _eval_subs
comms_final.remove(ele)
ValueError: list.remove(x): x not in list

Now you get the wrong result. I'll look into this.

/c

smichr

unread,
Feb 15, 2011, 2:25:50 AM2/15/11
to sympy
The fix is ready for review [ https://github.com/sympy/sympy/pull/113 ]
Reply all
Reply to author
Forward
0 new messages