2
$\begingroup$

Well, there is an integral that has quite a lot to do with $n!$, and that is the following :

$f(n)$ = Integrate[x^(n - 1)/E^x, {x, 0, Infinity}] =$\int_0^{\infty } \frac{x^{n-1}}{e^x} \, dx$ (1)

Integrate by parts the above gives

parts[u_, v_] := (#1*Integrate[#2, x] - Integrate[D[#1, x]*Integrate[#2, x], x] & )[u, v]

parts[x^(n - 1), E^(-x)] = $-e^{-x} x^{n-1}-(n-1) \Gamma (n-1,x)$

How to get this result ? ( see (1) too )

enter image description here

$\endgroup$
1
  • $\begingroup$ To see the outcome of the integration in parts done in MMA in the form as noted in the box That's the goal. It is the factorial $\endgroup$
    – janhardo
    Mar 30, 2022 at 20:39

2 Answers 2

5
$\begingroup$

Using RuleDelayed


Assuming[n > 0, 
 Integrate[x^(n - 1)/E^x, {x, 0, ∞}] /. 
  Gamma[x_] :> Factorial[x - 1]]

(-1 + n)!


Using ComplexityFunction


gammatofac[x_, xx_] := 
  FullSimplify[x, xx ∈ Integers && xx > 0, 
   ComplexityFunction -> ((LeafCount@# + 
        10 Count[#, _Gamma | _Pochhammer, {0, ∞}]) &)];

and run the integration

gammatofac[Integrate[x^(n - 1)/E^x, {x, 0, ∞}], n]

(-1 + n)!

$\endgroup$
8
  • $\begingroup$ bmf, Yes, that is the correct outcome, cleverly done! Have seen this example as study text and the derivation is done manually. Your elaboration shows that this does involve specialized MMA knowledge which I as a regular user do not have. $\endgroup$
    – janhardo
    Mar 30, 2022 at 20:45
  • $\begingroup$ bmf, Starting with the outcome of the partial integration. Can anything be derived from this? $\endgroup$
    – janhardo
    Mar 30, 2022 at 20:49
  • $\begingroup$ @janhardo - "specialized MMA knowledge which I as a regular user do not have" ... You do if you use the readily available documentation. $\endgroup$
    – Bob Hanlon
    Mar 30, 2022 at 20:49
  • $\begingroup$ @janhardo you could try for example FullSimplify[(n - 1) Gamma[n - 1], Element[n, Integers] && n > 0] but this gives back only Gamma[n]. $\endgroup$
    – bmf
    Mar 30, 2022 at 20:51
  • $\begingroup$ @janhardo you could also try a simple replacement rule -see update. $\endgroup$
    – bmf
    Mar 30, 2022 at 20:54
5
$\begingroup$
Clear["Global`*"]

Your definition of parts does not consider the interval of integration. Change the definition to

parts[u_, dv_, interval_List] :=
 Module[{v = Integrate[dv, x]},
  Limit[u*v, x -> interval[[-1]]] -
   Limit[u*v, x -> interval[[-2]]] - 
   Integrate[D[u, x]*v, interval]]

Assuming[n > 1, parts[x^(n - 1), E^-x, {x, 0, Infinity}]]

(* Gamma[n] *)

% /. Gamma[z_] :> (z - 1)! // TraditionalForm

(* (n-1)! *)
$\endgroup$
1
  • $\begingroup$ Bob Hanlon- thanks ,I overlooked that the integration intervals when I used the code for the integration in parts. You did tackle it thoroughly by using this with module programming. $\endgroup$
    – janhardo
    Mar 30, 2022 at 21:56

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.