Question: Differentiating in a sum with arguments from a list

Hi, my problem is that I have a set of variables stored in a list, then when I try to sum with differentiation inside the sum, Maple immediately tries to differentiate before summing, thus returning zero.

 

So I define a list coords := [t, r, theta, varphi], then call sum(diff(r^2, coords[k]), k = 1 .. 4), however Maple does the differentiation first, so it becomes 0 instead of 8r.

 

I attached the maple worksheet with what I did, on the first line I define the list with variables, on the second line I show that maple evaluates diff(r^2, coords[k]) to zero before doing the sum, where k is what is being summed over, on the third line I show that it copes fine if a specific element of the list is called, on the fourth line I show that summation over elements of the list is fine, and the last two lines show an example of the kind of thing I would like to do

 

Is there a way to make this work?

Please Wait...