I was trying to answer this question but having hard time with the correct way to write the transformation rule.
Trying to write a rule to transform Gamma[1/2 + n] to Sqrt[Pi] (Factorial2[2 *(n - 1/2) - 1])/2^(n - 1/2). Will worry about the conditions when this transformation is valid later on. I now can't even make Simplify use this rule.
The rule is being invoked (I add a Print and see it there), but the final result returned by the transformation function is not being used or returned)
I looked at this answer and tried what is there, but still no success. These are my attempts. The result of the Simplify command should return Sqrt[Pi] (Factorial2[2 *(n - 1/2) - 1])/2^(n - 1/2) in this example.
I am not sure if it is scoping issue. Can one use an If or Cases in the transformationFunction or must it be based only on the syntax of /. :>?
I wish help has more examples. Only 3 basic examples are shown and that is it.
When an expression being used inside the tranformation function (like in this case, Gamma[1/2 + n] then n here is taken as global symbol, right? I mean it will not have a $$n or it? That what seems to be the case. So I do not see why any of these are not working.
ClearAll[n, f, e];
f = # /. Gamma[1/2 + n] :> Sqrt[Pi] (Factorial2[2*(n - 1/2) - 1])/2^(n - 1/2) &
Simplify[Gamma[1/2 + n], TransformationFunctions -> {Automatic, f}]

ClearAll[n, f, e];
f[e_] := If[MatchQ[e, Gamma[1/2 + n]], Sqrt[Pi] (Factorial2[2 *(n - 1/2) - 1])/2^(n - 1/2), e]
Simplify[Gamma[1/2 + n], TransformationFunctions -> {Automatic, f}]

http://reference.wolfram.com/mathematica/ref/TransformationFunctions.html


ComplexityFunctiondoesn't value the new transformed expression as less complex than the original, it won't transform anything. Could this be it? – Rojo Aug 12 '13 at 20:23ComplexityFunctionin addition somehow? Will look into it. – Nasser Aug 12 '13 at 20:26Simplifyand friends' objective is to "more or less" minimize theComplexityFunction, and you can help out by allowing additional transformations to be tried on parts or subparts. If you don't specify a ComplexityFunction for which the expression you aim to get is simpler, then you are not really trying to simplify. – Rojo Aug 12 '13 at 20:31Gamma, such asComplexityFunction -> Function[exp, Count[exp, Gamma, Infinity, Heads -> True] 1000 + LeafCount@exp]– Rojo Aug 12 '13 at 20:32nand 2) it doesn't take the constraints onn(positive integer) into account. See my answer for that. – Sjoerd C. de Vries Aug 12 '13 at 21:30Will worry about the conditions when this transformation is valid later onmy question here was on why the transformation was not being taken into account. a separate issue. – Nasser Aug 12 '13 at 21:42