# Derivatives of function with 20 variables with respect to each variable

I want to find the derivative of a function with 20 variables and arrange it in a 20 by 1 vector.

Si[a,b,c,d,.....20 variables] is a function. Is there a simple command to find the first derivative of each variable and arrange it in a 20 by 1 vector as follows

{D[Si,a],D[Si,b],....D[si,t]}

Similarly, I want to find the second derivative and arrange it in a 20 by 20 matrix as follows

{{D[D[Si, a], a], D[D[Si, a], b], ... .. D[D[Si, a], t]}, {D[D[Si, b], a],D[D[Si, b], b], ... .. D[D[Si, b], t]}, ... ... ...., {D[D[Si, t], D[D[Si, t], b], ....D[D[Si, t], t]}}

– jcp
Dec 11, 2019 at 14:51
• If this is really an acegen-related question, I would suggest looking for the description of SMSD in the documentation. Dec 11, 2019 at 15:05

args = Array[x, 20];
D[f @@ args, {args, 1}]
D[f @@ args, {args, 2}]

• +1 More generally, for any non-negative integer m: D[f @@ args, {args, m}] == Nest[D[#, {args}] &, f @@ args, m] Dec 11, 2019 at 15:56

first ,let's creat a funtion

si = Si @@ (ToExpression /@ Alphabet[])


then you just need this

Defer@D[si, #] & /@ (ToExpression /@ Alphabet[])