Suppose we have the following expression
A[j_] := Subscript[A, j]
EXPR=A[1]^2*A[2] + A[1]^4*A[3] + A[2]^2
As stated in the title, I am struggling to retain some summands in EXPR
, in particular the ones for which the sum of the product of the subscript and the power in each term is equal to some integer c
. For instance, how to get all those terms that satisfy this rule with $c=4$? The correct answer is
A[1]^2*A[2] + A[2]^2
as in the first term we have $1\cdot 2+2\cdot 1=4$, whereas in the second one $2\cdot 2=4$