1
$\begingroup$

I'm having trouble with a simple replacement-rule. It seems my understanding of Blanks is wrong. I have an expression containing the following multiple times:

e[a1,a2] e[b1,b2] e[c1,c2]

I want to replace this expression with zero, whenever a2=b2=c2. The following replacement-rule however does nothing to the expression:

e[a1,1] e[b1,1] e[c1,1]/.e[_,a_] e[_,a_] e[_,a_]->0,

whereas the following works:

e[a1,1] e[b1,1] e[c1,1]/.e[_,a_] e[d_,a_] e[f_,a_]->0

I don't really understand why. I know that d_has the Head Pattern, which is why it is colored green in the rule, whereas _ has the Head Blank and is left in black. But that doesn't really help me.

Any help is appreciated!

$\endgroup$
  • 2
    $\begingroup$ Take a look at what e[_, a_] e[_, a_] e[_, a_] -> 0 evaluates to. Then use HoldPattern[e[_, a_] e[_, a_] e[_, a_]] -> 0 to prevent that evaluation. $\endgroup$ – jjc385 Nov 30 '17 at 19:25
  • $\begingroup$ Or, e[a1, 1] e[b1, 1] e[c1, 1] /. Repeated[e[_, a_]] e[_, a_] -> 0 $\endgroup$ – march Nov 30 '17 at 22:04
  • $\begingroup$ @jjc385 Thank you! I didn't consider that $\endgroup$ – AstanVizu Nov 30 '17 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.