>>> l1 = Wild('l1')
>>> l2 = Wild('l2')
>>> testexpr = p1[MM]*p2[NN] + p1[XX]*p2[MM] + p1[XX]**2
>>> t = testexpr.replace(p1[l1]*p2[l2], FF1[l1]*FF2[l2])
>>> t = t.replace(p1[l1]**2, 0)
>>> t
FF1[MM]*FF2[NN] + FF1[XX]*FF2[MM]
--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/DXfsFNYbjW0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/74c91bfa-9c28-4c5b-871b-f77afb75b493%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
>>> w = Wild('w')
>>> x = Wild('x')
>>> y = Wild('y')
>>> z = wild('z')
>>> expr = a[1]*b[2]*c[3]*d[4] + a[1]**2*b[3]*c[1]*d[4] + a[1]*b[2]**2*c[3] + b[2]*c[3]
>>> p = expr.replace(w*b[x]*c[y]*d[z], 0) # p has the terms which are not needed
>>> sol = expr - p
>>> sol
a[1]**2*b[3]*c[1]*d[4] + a[1]*b[2]*c[3]*d[4]
>>> p