On 10-09-18 09:30 PM, smichr wrote:
But that only groups together one variety of M**(n+1). If you want
them all together you have to give them a common coefficient that can
be used for collection:
u = Dummy('u')
These are the quantities that may have the n+1 power
expr2.atoms(IndexedElement)
set([M(1, 2), M(1, 1), M(2, 1)])
So we replace them with u*M**(n+1) and colelct on u
collect(expr2.subs([(a**(n+1), u*a**(n+1)) for a in _]), u)
_u*(B*M(2, 1)**(1 + n) - D*M(1, 1)**(1 + n) - E*M(2, 1)**(1 + n)) +
A*M(1, 1)**n - C*M(1, 2)**n
Then split the expression into u-independent and u-dependent pieces
with as_independent and feed that back to Eq with the *prefix and
remove the u by replacing with 1.
Eq(*_.as_independent(u)).subs(u, 1)
A*M(1, 1)**n - C*M(1, 2)**n == B*M(2, 1)**(1 + n) - D*M(1, 1)**(1 + n)
- E*M(2, 1)**(1 + n)
All the n+1 powers are on the right now.
That's exactly what I wanted; thank you very much smichr!
Nicholas
--
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+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.