I want to replace all occurences of the symbol x
with x[a]
, as long as it is not in the form x[a]
.
In other words, I am looking for magicReplacementRule
in
x[a] + x /. magicReplacementRule
--> x[a] + x[a]
I tried
x[a] + x /. Except[x[a], x] -> x[a]
but the result was x[a][a] + x[a]
.
Replace[x[a] + x, x -> y, {1}]
? $\endgroup$x[a] + x /. {x -> y, z : _[_] :> z}
? $\endgroup$x[a] + x /. {x[a] -> x[a], x -> x[a]}
$\endgroup${x[a] -> x, x -> x[a]}
, which was nonsense.) $\endgroup$