It is well-known that for any positive integer $n$ the equality $\Gamma(n+\frac12)=\sqrt\pi\,(2n-1)!!/2^n$ holds, where $!!$ stands for the double factorial. I am using FullSimplify[expr,Assumptions -> n \[Element] Integers] on certain expression expr, and the output contains $\Gamma(-\frac12+n)/\sqrt\pi$.

My question is: how can I instruct Mathematica to perform the simplification "$\Gamma(n+\frac12)=\sqrt\pi\,(2n-1)!!/2^n$ whenever $n$ is a positive integer" ? Of course, I want an answer no limited to this specific situation.

Edit: What I want is to "add" the simplification rule above to the list of simplifications included in FullSimplify, not merely "replace" the "string" $\Gamma(\cdots)$ by $\cdots !!/\cdots$.

  • $\begingroup$ you can simply do expr/.Gamma[n+1/2]-> Sqrt[Pi](2 n-1)!!/2^n and check! $\endgroup$ Aug 12, 2013 at 18:12

2 Answers 2


You could use a function to do this expansion for you:

gammaExpand[e_] := e /. (Gamma[n_ + 1/2 /; FullSimplify[n ∈ Integers && n > 0]] :> 
                         Sqrt[π] (2 n - 1)!!/2^n)

The FullSimplify in the definition takes care of picking up any assumptions placed in surrounding Assumptions blocks or assignments to $Assumptions.

expr = Sin[Log[Gamma[1/2 + n]]];

This doesn't expand (as it should):


Sin[Log[Gamma[1/2 + n]]]

This does:

Assuming[n ∈ Integers && n > 0, gammaExpand@expr]

Sin[Log[2^-n Sqrt[π] (-1 + 2 n)!!]]

It would be nice if you could build this rule into FullSimplify itself. It has the option TransformationFunctions for that. However, there is a reason that this doesn't work:

            Assumptions -> n ∈ Integers && n > 0, 
            TransformationFunctions -> {Automatic, gammaExpand}

Sin[Log[Gamma[1/2 + n]]]

The reason is that the resulting expression is simply more complex than the original, so FullSimplify doesn't have an incentive to perform this step. In fact, whenever it sees anything like the expanded form it will try to reduce it:

FullSimplify[2^-n Sqrt[π] (-1 + 2 n)!!,
             Assumptions -> n ∈ Integers && n > 0]

Gamma[1/2 + n]

You could try to come up with a modified version of the default ComplexityFunction but that would probably be too much hassle for this simple goal. Easier would be to forbid the reducing transformation using ExcludedForms:

Assuming[n ∈ Integers && n > 0, 
   FullSimplify[expr // gammaExpand, 
                ExcludedForms -> {Sqrt[π] (2 n_ - 1)!!/2^n_}

Sin[Log[2^-n Sqrt[π] (-1 + 2 n)!!]]

  • $\begingroup$ FWIW, ComplexityFunction -> (LeafCount[#] + 100 Count[#, _Gamma, Infinity] &) is suitable setting. Also the pattern Gamma[n_] /; FullSimplify[n - 1/2 \[Element] Integers && n > 1/2] seems to work more generally. $\endgroup$
    – Michael E2
    Aug 13, 2013 at 1:16
  • $\begingroup$ @MichaelE2 I know, had been experimenting with that but noted that in Nasser's follow up question this was already provided, so didn't care to add that here. One big disadvantage would be that it would prevent any simplification with Gamma unrelated to the double factorial that is the issue here. $\endgroup$ Aug 13, 2013 at 5:33
  • $\begingroup$ There's your +1. I guess I should read comments before answering. $\endgroup$
    – Mr.Wizard
    Aug 14, 2013 at 15:59

If you try to define

Gamma[n_ + 1/2] := theExpression /; FullSimplify[ Element[ n, Integers ] && n > 0]

you will get

enter image description here

That is, you cannot "add the simplification rule above to the list of simplifications included in FullSimplify" without unprotecting Gamma first. The following code should do what you ask.

Gamma[n_ + 1/2] := theExpression /; FullSimplify[Element[n, Integers] && n > 0];
Assuming[Element[s, Integers] && s > 0, Gamma[1/2 + s]]

Nevertheless, exercise caution when unprotecting Mathematica definitions.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.