# Forcing Mathematica to use certain simplification rule

I'm trying to force Mathematica to use following transformation function

tf[e_] :=
e /. {BarnesG[1 + 2 x_] :>
2^(x (2 x - 1)) Pi^(-x - 1/2) (
BarnesG[3/2 + x] BarnesG[1/2 + x] BarnesG[1 + x]^2)/
BarnesG[1/2]^2};


After evaluation of the previous line simplification

Simplify[BarnesG[1 + 2 x],
TransformationFunctions -> {Automatic, tf}]


does not yield desirable result but instead returns original

BarnesG[1 + 2 x]


What am I doing wrong?

Any help is appreciated, thank you!

I guess Simplify does not use your rule, because the result would be more complex (LeafCount) than the original input.

The following is really a hack which seems only to work because of internal behavior of Simplify.

ClearAll[tf, rule];
tf[BarnesG[1 + 2 x_]] := rule;
Simplify[BarnesG[1 + 2 x], TransformationFunctions -> {Automatic, tf}];
rule = 2^(x (2 x - 1)) Pi^(-x -
1/2) (BarnesG[3/2 + x] BarnesG[1/2 + x] BarnesG[1 + x]^2)/
BarnesG[1/2]^2;


Now you can call Simplify as you did

Simplify[BarnesG[1 + 2 x], TransformationFunctions -> {Automatic, tf}] ### Possible (!) explanation

I assume the following happens: When you call this the first time, without rule having any value

tf[BarnesG[1 + 2 x_]] := rule;
Simplify[BarnesG[1 + 2 x], TransformationFunctions -> {Automatic, tf}];


then Simplify seems to cache that the simplification to rule is better, because it has a lower LeafCount. Once this is done, the rule is applied, even if rule is now set to an expression which is more complex than the original one.

• I am using v9.0.1 and this does not work for me. It returns unevaluated. – RunnyKine Sep 29 '13 at 21:17
• @RunnyKine Indeed, when I tried it, it worked. Let me investigate. – halirutan Sep 29 '13 at 21:27
• @RunnyKine Can you try again. It seems I accidentally revealed some cashing issue, which enables this hack. – halirutan Sep 29 '13 at 22:03
• I get @halirutan's result (V9.0.1, Mac). – Michael E2 Sep 30 '13 at 0:04
• So this works now. I wonder why it only works if you use Simplify twice as in your code. – RunnyKine Sep 30 '13 at 5:19