8

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.

Kuba
  • 136,707
  • 13
  • 279
  • 740
Jack
  • 135
  • 5

1 Answers1

5

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]};
  Expand[r]]

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

ubpdqn
  • 60,617
  • 3
  • 59
  • 148