# What's the Mathematica command for $\frac{\partial^a}{\partial n^a}\binom{n}{k}$?

What's the Mathematica command for

$$f(a,n,k)=\frac{\partial^a}{\partial n^a}\binom{n}{k}$$

I tried

f[a_,n_,k_]:=D[Binomial[n,k], {n,a}]


but didn't work. To make it work, I had to use

f[a_]:=D[Binomial[n,k], {n,a}]


then I picked a value for $$a$$ (f[2] for example) to get a function in terms of $$n$$ and $$k$$ then I selected values for $$n$$ and $$k$$.

Is there one-line command for this? Thank you.

The problem you face is, that you must evaluate the derivative relative to n before n is replaced by an argument. One way to achieve this is by using an additional variable: n1. E.g.:

f[a_, n_, k_] := D[Binomial[n1, k],{n1,a}] /. n1 -> n


with this:

f[1, 5, 3]
(* 47/6*)

• Thanks Dan thats what I'm looking for (+1). Apr 11, 2022 at 16:51
• I think you meant D[Binomial[n1, k], {n1, a}] Apr 11, 2022 at 18:05
• Yes that's right. Thank you. Apr 11, 2022 at 20:28

Try

Derivative[a, 0][Function[{nn, kk}, Binomial[nn, kk]]][n, k]


or

Derivative[a, 0][Binomial][n, k] (Thanks @CarlWoll )


$$\frac{1}{2} \left( \begin{array}{cc} \{ & \begin{array}{cc} a! \left( \begin{array}{cc} \{ & \begin{array}{cc} 1 & a=2 \\ 2 n-1 & a=1 \\ \end{array} \\ \end{array} \right) & a\geq 1 \\ (n-1) n & \text{True} \\ \end{array} \\ \end{array} \right)$$

• Simpler is Derivative[a, 0][Binomial][n, k] Apr 11, 2022 at 18:04
• Got it. I also see @bmf's code is simple as well. thank you guys Apr 12, 2022 at 9:29

Another way to do it: use Set rather than SetDelayed

g[a_, n_, k_] = D[Binomial[n, k], {n, a}];


The first derivative

g[1, 5, 3]


The second

g[2, 5, 3]


• (+1) This is a typical example, why it is better to use Set, whereever you can, instead of SetDelayed as a standard. I often said. Jul 19, 2022 at 11:33