# Derivative of a factorial

What is ${\partial\over \partial x_i}(x_i !)$ where $x_i$ is a discrete variable?

Do e consider $(x_i!)=(x_i)(x_i-1)...1$ and do product rule on each term, or something else? THanks.

-
What do you mean by the 'derivative'? Since you're working with discrete things, do you want the forward difference or something like that? –  Antonio Vargas Feb 11 '13 at 20:37
Writing an expression with a variable number of terms/factors and treating it as if it were fixed formulas is a very bad idea in doing differentation. You will find examples under the tag (fake-proofs) on this site. –  Marc van Leeuwen Aug 27 '13 at 8:55

The derivative of a function of a discrete variable doesn't really make sense in the typical calculus setting. However, there is a continuous variant of the factorial function called the Gamma function, for which you can take derivatives and evaluate the derivative at integer values.

In particular, since $n!=\Gamma(n+1)$, there is a nice formula for $\Gamma^\prime$ at integer values: $$\Gamma^\prime(n+1)=n!\left(-\gamma+\sum_{k=1}^n\frac{1}{k}\right)$$ where $\gamma$ is the Euler-Mascheroni constant.

-
THank you, icurays1! –  Grizzly Feb 11 '13 at 20:25
It might be good to observe that ther are other differentiable (and even analytic) functions that restrict to the factorial functions on the natural numbers, and that they have different derivatives; the question, even with a liberal interpretation of what it is asking, really has no definite answer. –  Marc van Leeuwen Aug 27 '13 at 8:50

As has been mentioned, the Gamma function $\Gamma(x)$ is the way to go.

Integration by parts yields \begin{align} \Gamma(x) &=\int_0^\infty e^{-t}t^{x-1}\,\mathrm{d}t\\ &=(x-1)\int_0^\infty e^{-t}t^{x-2}\,\mathrm{d}t\\ &=(x-1)\Gamma(x-1) \end{align} Taking the derivative of the logarithm of $\Gamma(x)$ gives $$\frac{\Gamma'(x)}{\Gamma(x)}=\frac1{x-1}+\frac{\Gamma'(x-1)}{\Gamma(x-1)}$$ Because $\Gamma(x)$ is log-connvex and $$\lim_{x\to\infty}\frac{\Gamma'(x)}{\Gamma(x)}-\log(x)=0$$ we get that $$\frac{\Gamma'(x)}{\Gamma(x)}=-\gamma+\sum_{k=1}^\infty\left(\frac1k-\frac1{k+x-1}\right)$$ For integer $n$, $n!=\Gamma(n+1)$, so the derivative is \begin{align} \Gamma'(n+1) &=\Gamma(n+1)\left(-\gamma+\sum_{k=1}^\infty\frac{n}{k(k+n)}\right)\\ &=n!(-\gamma+H_n) \end{align} where $H_n$ is the $n^\text{th}$ Harmonic Number (with the convention that $H_0=0$).

-
Thank you, robjohn! –  Grizzly Feb 12 '13 at 2:33

$x!$ is usually defined only for nonnegative integer $x$. However, there is an extension to non-integers, given by the Gamma function: $x! = \Gamma(x+1)$, and the derivative of this is $\Psi(x+1) \Gamma(x+1)$ where $\Psi$ is the Digamma function. The values of this derivative at $x=0,1,\ldots,10$ are $-\gamma,1-\gamma,3-2\,\gamma,11-6\,\gamma,50-24\,\gamma,274-120\, \gamma,1764-720\,\gamma,13068-5040\,\gamma,109584-40320\,\gamma, 1026576-362880\,\gamma,10628640-3628800\,\gamma$ where $\gamma$ is Euler's constant.

-
Thank you, Robert! –  Grizzly Feb 11 '13 at 20:29

It's probably best to use an analytic continuation of the factorial function, rather than the factorial itself. Consider the gamma function:

$\Gamma(x) = \int_{0}^{\infty}x^{t}e^{-t}dt$

Obviously, $\Gamma(0) = 1$, and we also have:

\begin{align} \Gamma(x+1) &= \int_{0}^{\infty}x^{t+1}e^{-x}dt\\ &=[t^{x+1}e^{-t}]_{0}^{\infty} + (x+1)\int^{\infty}_{0}t^{x}e^{-t}dt\\ &=(x+1)\Gamma(x) \end{align}

So, $\Gamma(x) = (x-1)!$. So, just freely take derivatives now.

-
Thank you, Jerry! –  Grizzly Feb 11 '13 at 20:30
There is no such thing as an analytic continuation of the factorial funcion on$~\Bbb N$. The function $x\mapsto\Gamma(x+1)$ is an analytic extension (or maybe interpolation or extrapolation is a better term), but it is not the only one that exists. Other extensions have different derivatives of course. –  Marc van Leeuwen Aug 27 '13 at 8:46