# Derivative of function with large number of arguments

I have a function which depends on more than 30 parameters and I want to symbolically compute the derivatives with respect to the individual parameters.

From the documentation of the D operator I got the impression that I have to explicitly mention all parameters in the function definition. Is there a way around it? That is, is it possible to take the derivative of a function which is an expression of another symbol, which doesn't appear in the function signature?

If not, is there a way to write the function parameter list on multiple lines, for example like this:

Foo[(* These parameters describe... *)
x11, y12, z13,
(* And these parameters describe.... *)
x21, y22, y23,
(* Many more parameters... *)] := (* Function implementation... *)

• Have you looked at the Dt[] function? – Somos Oct 31 '19 at 19:19

## 1 Answer

Clear["Global*"]


Define the variables using an indexed variable

n = 3; (* change as desired *)

var = Array[x, n];


Define the function

Evaluate[f @@ var] = Sqrt[Total@var^2]

(* Sqrt[(x[1] + x[2] + x[3])^2] *)


Taking the partial derivatives

D[f @@ var, Sequence @@ var]

(* (3 (x[1] + x[2] + x[3])^3)/((x[1] + x[2] + x[3])^2)^(5/2) - (
3 (x[1] + x[2] + x[3]))/((x[1] + x[2] + x[3])^2)^(3/2) *)


or for a vector derivative

D[f @@ var, {var}]

(* {(x[1] + x[2] + x[3])/Sqrt[(x[1] + x[2] + x[3])^2], (
x[1] + x[2] + x[3])/Sqrt[(x[1] + x[2] + x[3])^2], (
x[1] + x[2] + x[3])/Sqrt[(x[1] + x[2] + x[3])^2]} *)
`