# Do not evaluate function inside of another function for simplification

Consider the simple example :

ff[x_] := x^2

gg[x_] := (ff[x] - ff[-x])^2


Let's assume I would like to expand g[x_] as a polynome of ff[x] and ff[-x], but I don't want mathematica to replace ff[x] by their value x^2 (even if it is defined in my code).

How can I do it ?

Said differently : I would like to Expand[gg[x]] such that I would have a polynome in ff[x], ff[-x] where they are not evaluated.

I want to do it to check consistancy in some functions I defined in a more complicated code (if mathematica replaces me all the function by their values it will be hard for me to check this).

• perhaps defining gg as ClearAll[gg]; gg[x_] :=Inactivate[ (ff[x] - ff[-x])^2,ff]? – kglr Jun 27 '19 at 10:11
• ... or as gg[x_] := (HoldForm[ff][x] -HoldForm[ ff][-x])^2? – kglr Jun 27 '19 at 10:17
• @kglr and is there a way from the "outside" to do it ? Because it would ask me to redefine my function g. Like is there a way to do "Expand[NotEvaluateInside[gg[x]]" ? It could be more clean for my notebook to not redefine my functions if I just want to check their expression – StarBucK Jun 27 '19 at 11:27
• how about ClearAll[gg];gg[x_] := (ff[x] - ff[-x])^2; Block[{ff=Inactive[ff]}, Expand[gg[x]]]? – kglr Jun 27 '19 at 11:34