# Product of different differential operators

I need to define a multivariable differential equation of the type

$$\mathcal{D}=\Theta_1^2-z_1(-\Theta_1+\Theta_2+\Theta_3+\Theta_4)(1+\Theta_1+\Theta_2+\Theta_3+\Theta_4)\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;-z_1(z_2+z_3+z_4)(1+\Theta_1+\Theta_2+\Theta_3+\Theta_4)(2+\Theta_1+\Theta_2+\Theta_3+\Theta_4)$$ where $$\Theta_k=z_k\partial_{z_k}$$.
I have tried to define each paranthesis as their own operator and compose all the operators with one another:

Θ[f_, k_] := k*D[f, k]
d1[k_, z1_, z2_, z3_, z4_] := (k # + Θ[#, z1] + Θ[#, z2] + Θ[#, z3] + Θ[#, z4]) &
d2[k_, z1_, z2_, z3_, z4_] := (Θ[#, z1] + Θ[#, z2] + Θ[#, z3] + Θ[#, z4] - 2 Θ[#, k]) &
D1[z1_, z2_, z3_, z4_] := (Θ[Θ[#, z1], z1]-z1 d2[z1, z1, z2, z3, z4]@d1[1, z1, z2, z3, z4]-z1 d1[1, z1, z2, z3, z4]@d1[2, z1, z2, z3, z4]) &
D1[z1, z2, z3, z4]@f[z]


Which produces the undesired output

(-z1)*((-z1)*(Derivative[0, 1][Θ][#1, z1] & ) + z2*(Derivative[0, 1][Θ][#1, z2] & ) + z3*(Derivative[0, 1][Θ][#1, z3] & ) +
z4*(Derivative[0, 1][Θ][#1, z4] & )) - z1*((2*#1 + Θ[#1, z1] + Θ[#1, z2] + Θ[#1, z3] + Θ[#1, z4] & ) +
z1*(Derivative[0, 1][Θ][#1, z1] & ) + z2*(Derivative[0, 1][Θ][#1, z2] & ) + z3*(Derivative[0, 1][Θ][#1, z3] & ) +
z4*(Derivative[0, 1][Θ][#1, z4] & )) + z1*(Derivative[1, 0, 0, 0][f][z1, z2, z3, z4] + z1*Derivative[2, 0, 0, 0][f][z1, z2, z3, z4])


How can one define a differential operator that is the product of two or more (generally) different differential operators?

• See section "Some noncommutative algebraic manipulation" here. It is important that one avoid explicit Times for other than scalars since for example x and d/dx (as D[#,x]&) do not commute as operators. May 27 at 15:23

## 2 Answers

I too wish there was a nicer way to manipulate operators. For now, this will have to do:

opRules = Prepend[Join[Function[{Θk, zk}, (c_. Θk^j_.)[f][args__] /;
FreeQ[c, Θ1 | Θ2 | Θ3 | Θ4] :> c Nest[zk D[#, zk] &, f[args], j]] @@@
Transpose[{{Θ1, Θ2, Θ3, Θ4}, {z1, z2, z3, z4}}],
Function[{Θp, zp, id}, (c_. Θp)[f][args__] /;
FreeQ[c, Θ1 | Θ2 | Θ3 | Θ4] :>
c zp Apply[Derivative, UnitVector[4, id[[1]]] +
UnitVector[4, id[[2]]]][f][args]] @@@
Transpose[{Times @@@ Subsets[{Θ1, Θ2, Θ3, Θ4}, {2}],
Times @@@ Subsets[{z1, z2, z3, z4}, {2}],
Subsets[Range[4], {2}]}]],
(c_ /; FreeQ[c, Θ1 | Θ2 | Θ3 | Θ4])[f][args__] :> c f[args]];

Through[Operate[Composition[Through,
Expand[Θ1^2 - z1 (-Θ1 + Θ2 + Θ3 + Θ4) (1 + Θ1 + Θ2 + Θ3 + Θ4) -
z1 (z2 + z3 + z4) (1 + Θ1 + Θ2 + Θ3 + Θ4) (2 + Θ1 + Θ2 + Θ3 + Θ4)]],
f[z1, z2, z3, z4]]] /. opRules // Simplify


You have to take care that the derivative operator is not evaluated too soon. For this you may use another name and rename it in the end. E.g. we may use DD instead of D.

We first define a helper function: t to ease the writing of Θk:

t[i_] := Symbol["z" <> ToString[i]] DD[#, sym[i]];


Then we write the operator with "DD":

op = t[1]^2 -
z1 (-t[1] + t[2] + t[3] + t[4]) (1 + t[1] + t[2] + t[3] + t[4]) -
z2 (z2 + z3 + z4) (1 + t[1] + t[2] + t[3] + t[4]) (2 + t[1] + t[2] +
t[3] + t[4])


Finally we change "DD" to "D" and define a function:

op = Evaluate[op] & /. DD -> D


We may try our operator on a function f[z1, z2, z3, z4]:

op[f[z1, z2, z3, z4]]