If I have a generic expression such as
8 + 48*(Subscript[e,1])^2
+ 64*(Subscript[e,1])^3
+ 12*(Subscript[e,3])^6
+ ...
+ n*Subscript[e,j]^k + ...
I like to replace terms of the form n*(Subscript[e,j])^k
with n
if Mod[k,2]==0
, otherwise with n*(Subscript[e,j])
.
How can this be achieved?
EDIT:
If i have
Subscript[e, 5]*Subscript[e, 7]*Subscript[e, 4]*Subscript[e, 3]*Subscript[e, 4]*Subscript[e, k]*Subscript[e, j]
I would like to return Subscript[e, U]
if k != j
compared all products, the return value will Subscript[e, l]
, any idea? Thx
k
be1
or0
? $\endgroup$expr /. n_. (t : Subscript[e, _])^k_. :> If[Mod[k, 2] == 0, n, n t]
... Look up_.
$\endgroup$k
? $\endgroup$