I'd like to make a formula for a sum containing Derivative
where the number of arguments in the latter depends on an input parameter n. Also involved is a list c
calculated before and a function f
that has n inputs. Here's the version for n=2
c[[1,2]]*Derivative[c[[1,1,1],c[[1,1,2]]]][f][z1,z2]+
c[[2,2]]*Derivative[c[[2,1,1],c[[2,1,2]]]][f][z1,z2]+
c[[3,2]]*Derivative[c[[3,1,1],c[[3,1,2]]]][f][z1,z2];
And here for n=3:
c[[1,2]]*Derivative[c[[1,1,1],c[[1,1,2],c[[1,1,3]]]][f][z1,z2,z3]+
c[[2,2]]*Derivative[c[[2,1,1],c[[2,1,2],c[[2,1,3]]]][f][z1,z2,z3]+
c[[3,2]]*Derivative[c[[3,1,1],c[[3,1,2],c[[3,1,3]]]][f][z1,z2,z3]+
c[[4,2]]*Derivative[c[[4,1,1],c[[4,1,2],c[[4,1,3]]]][f][z1,z2,z3]+
c[[5,2]]*Derivative[c[[5,1,1],c[[1,1,2],c[[5,1,3]]]][f][z1,z2,z3]+
c[[6,2]]*Derivative[c[[6,1,1],c[[6,1,2],c[[6,1,3]]]][f][z1,z2,z3];
And so on. I was thinking about how I can make this more general and I think I can almost get it working using sum
, doing something like (for n=4)
Sum[c[[i,2]]]*Derivative[Table[c[[i,1,j]],{j,1,4}]][f][z1,z2,z3,z4],{i,1,24}];
The problem with this is that Table
outputs a list with curly brackets, and this won't work with Derivative
, as seen from e.g. running
f[x_,y_]=x^2+5*x*y;
Derivative[1,1][f][x,y]
Derivative[{1,1}][f][x,y]
The first way works but not the second. Trying to get rid of the brackets I've tried Flatten
with different inputs but that seems to only remove brackets inside brackets; I can't get rid of the outermost ones.
Does anyone know a way to get rid of the brackets from a Table
, or use Derivative
with a list in curly brackets? Or maybe a better way to do the whole thing?