# Partial derivatives as operators

I have a function which is a function of some scalar variables called :$$x,y,t,\rho$$ I want to calculate its derivative in the form of : $$(\partial_{t}-\partial_{z})^m (\partial_{x} -\partial_{y})^n$$ where $$m$$ and $$n$$ could be 1,2,3,4 each time.How I can get this derivative correctly?To say the whole thing once: $$(\partial_{t}-\partial_{z})^m (\partial_{x} -\partial_{y})^n f(x,y,t,\rho)$$,Could anybody help me?

• I assume that the partial with respect to z is intended to be with respect to ρ then der[m_, n_] = ((D[#, t] - D[#, ρ])^m*(D[#, x] - D[#, y])^n) &@f[x, y, t, ρ]; Apr 20 at 5:25
• Apr 20 at 5:31
• @Bob Hanlon, It works. Thank you
– Ali
Apr 20 at 6:12
• @BobHanlon I think the OP wants the power of an operator, eg (d/dx)^n f(x)=f^{n} (x) giving the n-th derivative, but the code above just gives the power, eg (f'(x))^n. Maybe something with Fold would work. Apr 20 at 13:49
• @HansOlo - Thanks for explaining the notation used. I have posted an answer using a nested Nest Apr 20 at 15:15

In a comment, Hans Olo stated that the powers used in the notation are intended to indicate the number of times the differential operators are applied. I would then also assume that the product shown is intended to reflect concatenation of the operators. If that is the case, a nested Nest is needed

Clear["Global*"]

dOp[func_, m_, n_] :=

Nest[(D[#, x] - D[#, y]) &, Nest[(D[#, t] - D[#, ρ]) &, func, m], n]


For example,

dOp[f[x, y, t, ρ], 0, 0]

(* f[x, y, t, ρ] *)

dOp[f[x, y, t, ρ], 0, 1]


dOp[f[x, y, t, ρ], 1, 0]


dOp[f[x, y, t, ρ], 2, 2]
`