Consider N variables, x_1, x_2, ... , x_N. Given i < N and j < N, it holds dx_i/dx_j=delta_i,j, i.e. the derivative is 1 when i=j and 0 otherwise.
While diff(x[i],x[i]) returns 1, unfortunately diff(x[i],x[j]) returns 0 rather than delta_i,j and sum(diff(x[i],x[j]),j=1..N) returns 0 rather than 1.
Is there a way of getting the correct derivative without specifying the value of N? I.e. a way that can be used for calculations that hold for any N.