Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
n=4;L=3;
p0[n_Integer]:=
Product[
Sum[Subscript[r, k][l, l], {l, L - 1}], {k, n}] // 
Expand;

How to ignore terms containing three or more multiplications of [2, 2] in this sum. Example, I want to ignore this term...

Subscript[r, 1][1, 1] Subscript[r, 2][2, 
2] Subscript[r, 3][2, 2] Subscript[r, 4][2, 2]
share|improve this question

1 Answer 1

up vote 1 down vote accepted
eq = p0[4] // Expand;

FullForm[eq] reveals how the terms that should be remove are defined:

(* Times[Subscript[r, 1][2, 2], Subscript[r, 2][2, 2], 
         Subscript[r, 3][2, 2], Subscript[r, 4][2, 2]] *)

Then, we can find those and replace them with zeros (here I generalized the pattern to allow having three or more multiplications of the [2,2] terms):

eq /. Times[Subscript[r, a_][2, 2], 
            Subscript[r, b_][2, 2], 
            Subscript[r, c_][2, 2], ___] :> 0
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.