By default, Mathematica simplifies
Power[f[x],2]. In most cases it's fine, but I happen to have a code where this rule is particularly annoying.
Is it possible to modify the behavior of Times so that this rule is not applied for a particular type of argument (let's call it g) i.e.
Times[g[x],g[x]] is kept unchanged, but
a is a Symbol (or anything except
Thank you for your help.
Edit : Sorry if I was unclear. I would like this behavior to be applied automatically everywhere in the session. For example, I can modify
Times by doing :
Unprotect[Times] Times[a_g,a_g]:=Defer[Times[a,a]] Protect[Times]
This work fine, because
Times[g[x],g[x]] does not change. But with this trick, I'm stuck with the ugly FullForm
Defer[Times[g[x],g[x]]], which will mess up my pattern matchings. What I'd really like to do is remove a rule from
Times, instead of adding one.