Consider the following object: function[x,a,b]. It is a symbol carrying one "coordinate" x and two indices a,b.
I would like to make the rule Der
D[function[x,a,b],function[x,c,f]] -> KroneckerDelta[a, c]KroneckerDelta[b,f] in order to apply it to an arbitrary object obj containing function and its powers (a scalar expression, a matrix, etc.), Der[obj,function[x,c,f]]. Say, an example of the object is
obj=function[x,a,b]*function[x,a,c]*coefficient[b,c] +function[x,a,c]^2 For which the result of applying the rule should be
Der[obj,function[x,c,f]] = KroneckerDelta[a,c]KroneckerDelta[b,f]function[x,a,c]coefficient[b,c] + KroneckerDelta[a,c]KroneckerDelta[c,f]function[x,a,b]coefficient[b,c]+2function[x,a,c]*KroneckerDelta[a,c]KroneckerDelta[c,f] Could you please tell me how to do this?
My attempt is to use UpSetDelayed:
D[function[x_, a_, b_], function[x_, c_, f_]] ^:= KroneckerDelta[a, c] KroneckerDelta[b, f] It works if derivating just function[x, a, b], but fails if there is any difference from the pattern. Say, if function[x, a, b] is a summand in some scalar expression, or it is inside a matrix (please see also this question).
UpSetDelayedand notTagSetDelayed$\endgroup$