# Show Factorial instead of Gamma in the result of Integrate

Clear["Global*"];

f[x_] := (Cos[x]^(2 n))

int=Assuming[Element[n,PositiveIntegers], Integrate[f[x], {x, 0, 2*Pi}]]

(*(2 Sqrt[\[Pi]] Gamma[1/2 + n])/Gamma[1 + n]*)


I tried:

DeveloperGammaSimplify@int

(*(2 Sqrt[\[Pi]] Gamma[1/2 + n])/Gamma[1 + n]*)

SimplifySimplifyGamma@int

(*(2 Sqrt[\[Pi]] Gamma[1/2 + n])/Gamma[1 + n]*)


I want to get Factorial instead of Gamma. As commented by @Michael E2, it should be a double factorial, Factorial2:

$$\frac{2 \pi(2 n-1) ! !}{(2 n) ! !}$$

I think the key point is that I cannot expand Gamma[1/2+n] into Factorial using the MMA function or code.

Related:

Show Factorial instead of Gamma in the result of RSolve

How can I get the simplest result of this sum?

• If $n$ is a positive integer, then you could use the rule Gamma[n_ + 1/2] -> 2^-n Sqrt[\[Pi]] (-1 + 2 n)!!.
– JimB
Commented Aug 27, 2023 at 15:25
• If you merely want to get only factorials, use the rule Gamma[z_] :> (z - 1)! Commented Aug 27, 2023 at 16:05
• You call it Factorial but you show a double factorial ($(2n)!!$ = Factorial2[2n]). Which do you mean? Commented Aug 27, 2023 at 19:46
• Great. Thank you all! Commented Aug 27, 2023 at 23:23
• @Michael E2 You're right. Thank you for telling me that there is a Factorial2 function. Commented Aug 27, 2023 at 23:26

int = (2 Sqrt[π] Gamma[1/2 + n])/Gamma[1 + n];

Assuming[n >= 0 && Element[n, Integers],
int /. Gamma[t_] -> 2^(1-t) (π/2)^((1-Cos[2π(t-1)])/4) (2(t-1))!! //FullSimplify]

(*    (2 π (-1 + 2 n)!!)/(2 n)!!    *)


How did I get this formula? Just invert this output:

u!! // FunctionExpand
(*    2^(u/2 + 1/4 (1 - Cos[π u])) π^(1/4 (-1 + Cos[π u])) Gamma[1 + u/2]    *)


## update

For a bit more automated judging of simplifications, we can define custom transformation functions for FullSimplify:

fac[z_] := z /. Gamma[t_] :> (t - 1)!
fac2[z_] := z /. Gamma[t_] :> FullSimplify[2^(1-t)*(π/2)^((1-Cos[2π(t-1)])/4)] (2(t-1))!!

Assuming[n >= 0 && Element[n, Integers],
FullSimplify[int, TransformationFunctions -> {Automatic, fac, fac2}]]

(*    (2 π (-1 + 2 n)!!)/(2 n)!!    *)

• A great answer. Especially, update solves the problem of converting Gamma to Factorial (Factorial2). Thank you! Commented Aug 27, 2023 at 23:48
FullSimplify[(2 Sqrt[\[Pi]] Gamma[1/2 + n])/
Gamma[1 + n], {n \[Element] Integers, n > 0}]

(*  (2 Sqrt[\[Pi]] Gamma[1/2 + n])/n!  *)


??

• ?? There is still a Gamma` function in your result. Commented Aug 27, 2023 at 15:20
• Well, better than nothing. Commented Aug 27, 2023 at 17:05