4
$\begingroup$

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]}}
$\endgroup$
10
$\begingroup$
args = Array[x, 20];
D[f @@ args, {args, 1}]
D[f @@ args, {args, 2}]
$\endgroup$
  • 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
0
$\begingroup$

first ,let's creat a funtion

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

then you just need this

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

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.