# Why doesn't Simplify use my own TransformationFunction?

I define a simple TransformationFunctions via:

tfTest[e_] := e /. {x^2 -> Hold[x*x]}


and try to use it with Simplify like this:

Simplify[x^2, TransformationFunctions -> {Automatic, tfTest}]


x^2 (output)

The output is of course the input without tfTest applied to it. Interestingly a TransformationFunction like

tfTest[e_] := e /. {x^2 -> 2}


is working.

I tried monitoring the output via using a ComplexityFunction

cf = (Print[#]; LeafCount[#] + Count[#, _Symbol, {0, -1}]) &;
ClearSystemCache[]
FullSimplify[x^2, TransformationFunctions -> {Automatic, tfTest},
ComplexityFunction -> cf]


but I could not make sense of the output being an alternating sequence of the answer I would want and the unchanged input.

Any ideas how to fix that?

• Hint: Simplify tries to minimize ComplexityFunction. – Michael E2 Oct 13 '15 at 13:59
• Makes sense that it tries to minimize ComplexityFunction. For some reason I was naive enough to think that manually supplied TransformationFunctions have absolute priority. – Wizard Oct 19 '15 at 11:25

tfTest[e_] := e /. {x^2 -> Hold[x*x]}