I want to do replacement of products (because I am dealing with abstract projectors), but Mathematica seems to fail understanding this toy example replacement :
x y y /. {x y -> 1}
x y^2
because it doesn't understand that there is $xy$ in $xy^2$. Is there an easy way to deal with this kind of issues ?
Thanks!
x x
? If so, consider something likeInactivate[x x, Times]
, or even consider make your own (I admit it's a bit advanced):SetAttributes[times, {Orderless, Flat, OneIdentity}]; expr = times[x, times[y, x]]; expr /. times[x, y] -> aaa
$\endgroup$Hold[x y y] /. x y -> 1 // ReleaseHold
(givingy
as output)? $\endgroup$