I have a differential equation defined as the product of operators which I want to expand out into a polynomial in powers of $z\frac{d}{dz}$

$\qquad \prod_{n=1}^p(z\frac{d}{dz}+a_n)$

However when I try to code this using the D[#,x]& function it doesn't multiply out as I would wish it to. Instead each derivative just acts on the z rather that than $z\frac{d}{dz}$ and the whole thing just reduces to a number.

Do I need to define some special properties of an operator $z\frac{d}{dz}$?

I have considered trying to nest the operator but I am quite inexperienced and don't fully grasp how to do this whilst preserving the integrity of the operator.

  • 1
    $\begingroup$ You can mark $z \frac{d}{dz}$ as $x$ and expand it as a regular polynomial since powers of $x$ commute with each other. However it will be interestion to find the general solution. $\endgroup$
    – ybeltukov
    Jan 13, 2015 at 16:33
  • 3
    $\begingroup$ You should use Derivative instead of D and when defining that operator use SetDelayed (:=) rather than Set. Examine e.g. this answer Using D to find a symbolic derivative. $\endgroup$
    – Artes
    Jan 13, 2015 at 16:36
  • 5
    $\begingroup$ There is a section in the notebook located here that discusses ways to work with products of differential operators. $\endgroup$ Jan 13, 2015 at 16:51

1 Answer 1


You could use Fold, e.g.

q[f_, x_, a_] := Expand@Fold[ x D[#1, x] + #2 #1 &, f, a];

Or rule replacement of polynomial as suggested in comment:

fun[f_, x_] := x D[f, x]
op[n_, f_, x_] := Nest[Expand@fun[#, x] &, f, n]
w[f_, x_, a_] := Module[{v, pol, r},
  pol = Expand[Times @@ (v + # & /@ a)];
  r = pol /. {Times @@ a -> (Times @@ a) f, v -> x D[f, x], 
     v^(s_) :> op[s, f, x]};

For example:

ar = Array[a, 4];
Grid[Table[{q[h[x], x, ar[[1 ;; j]]], w[h[x], x, ar[[1 ;; j]]]}, {j, 
   2, 4}], Frame -> All]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.