# 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? Oct 31, 2019 at 19:19

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 + x + x)^2] *)


Taking the partial derivatives D[f @@ var, Sequence @@ var]

(* (3 (x + x + x)^3)/((x + x + x)^2)^(5/2) - (
3 (x + x + x))/((x + x + x)^2)^(3/2) *)


or for a vector derivative D[f @@ var, {var}]

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