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


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]}}
args = Array[x, 20];
D[f @@ args, {args, 1}]
D[f @@ args, {args, 2}]
  • 1
    $\begingroup$ +1 More generally, for any non-negative integer m: D[f @@ args, {args, m}] == Nest[D[#, {args}] &, f @@ args, m] $\endgroup$ – Bob Hanlon Dec 11 '19 at 15:56

first ,let's creat a funtion

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

then you just need this

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.