I'd like to exploit Stirling's approximation during the symbolic manipulation of an expression. Essentially, I want replace Factorial[n]
with n^n E^-n Sqrt[2 \Pi n]
everywhere in a large expression.
How is it possible to achieve that?
As an example, I'd like to approximate a sum like this
$$ \frac{n!}{(n+m_1)! (n-m_1)!} + \frac{n!}{(n+m_2)! (n-m_2)!} + \frac{n!}{ (n+m_3)! (n-m_3)!} $$ to $$ \frac{F(n)}{F(n + m_1)Fun(n - m_1)} + \frac{F(n)}{F(n + m_2) F(n - m_2)} + \frac{F(n)}{F(n + m_3) F(n - m_3)}, $$ where $$ F(n) := \sqrt{2 \pi n} \, e^{-n} n^n $$ is the Stirling approximation of $n!$.
N
is a built-in symbol, so better usen
instead. UsingReplaceAll
with the ruleFactorial[n] -> n^n E^-n Sqrt[2 \[Pi] n]
should do, no? $\endgroup$/. Factorial[x_] -> x^x E^-x Sqrt[2 \[Pi] x]
? $\endgroup$Gamma[]
(usingFunctionExpand[]
if necessary) and then use a replacement rule for Stirling. That way, you can handleBeta[]
,Binomial[]
,FactorialPower[]
,Pochhammer[]
... $\endgroup$