3
$\begingroup$

I know there is functionality in Mathematica to perform replacements like:

x[a] d[a,b]/.y_[z_] d[z_,p_]->y[p]

Which naturally gives x[b] as a result. Now, I was wondering if there is a stronger generalization, such that:

x[a]Subscript[q,a]Superscript[m,a]d[a,b]/. y_ d[z_,p_]->(set all occurrences of z to p in y)

was done automatically and the result would be x[b]Subscript[q,b]Superscript[m,b]? What syntax should I use to achieve that? thanks for any suggestion!

$\endgroup$

1 Answer 1

4
$\begingroup$

Not that I'm aware of but perhaps this can work for you:

x[a] Subscript[q, a] Superscript[m, a] d[a, b] /. 
 y_ d[z_, p_] :> (y /. z -> p) d[z, p]
$\endgroup$
1
  • $\begingroup$ Wow! It actually does work. I did not know you could stack those operators. Great, exactly what I needed. $\endgroup$
    – Kagaratsch
    Commented Oct 21, 2014 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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