0
$\begingroup$

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?

$\endgroup$

1 Answer 1

1
$\begingroup$

If you want n! terms, this is the thing:

expr[n_] := Sum[c[[i, 2]] Derivative[Sequence @@ Table[c[[i, 1, j]], {j, n}]][f][##], {i, n!}] & @@ ToExpression["z" <> ToString[#] & /@ Range[n]] 

I'm not sure, but with 24 for n=4, I'm kinda convinced, even though you have 3 terms for n=2.

$\endgroup$
1
  • $\begingroup$ That works perfectly, thank you very much! And yeah it is supposed to be n!, I have a typo in the n=2 example in the OP. $\endgroup$ Commented Feb 28, 2014 at 17:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.