I want to be able to define an operator

$(a(x) d/dx + b(x))^n$

where $d/dx$ is the derivative operator and $a(x)$ and $b(x)$ are known functions and $n$ is a positive integer.

Related Query: How about defining

$ \prod_{i=1,...,n} (a_i(x) d/dx + b_i(x) ) $

where $a_i(x)$ and $b_i(x)$ are known functions and $n$ is a positive integer ?

  • $\begingroup$ I believe the result I was looking for was abderiv[n_] = Function[f, Nest[(a[x] D[#, x] + b[x] #) &, f, n]]; $\endgroup$ – Quasar Supernova Sep 13 '16 at 12:41
  • $\begingroup$ ...and the answer to the related query is most easily accomplished by a recursive procedure: abderg[0, x_] := f[x] and abderg[n_, x_] := (a[x, n] D[abderg[n - 1, x], x] + b[x, n] abderg[n - 1, x]) $\endgroup$ – Quasar Supernova Sep 14 '16 at 1:02

This can be done with Nest:

abderiv[n_] = 
  Function[f, Nest[(a[x] D[#, x] + b[x]) &, f, n]];


(* ==> f[x] *)


(* ==> b[x] + a[x] Derivative[1][f][x] *)


==> b[x] + 
 a[x] (Derivative[1][b][x] + Derivative[1][a][x] Derivative[1][f][x] +
     a[x] (f^\[Prime]\[Prime])[x])

Here the order n is provided as the argument to a function that is itself a function acting on an arbitrary expression f. The assumption in the question seems to be that the differentiation variable is always x, so I don't specify this variable as an additional argument.

  • $\begingroup$ Thanks so much. I want to trouble you with a rejoinder. $\endgroup$ – Quasar Supernova Aug 20 '16 at 4:35
  • $\begingroup$ More generally, If I define a function of three variables F(X,Y,Z) [which can be anything my whim decides] I want it to be meaningful when a) X,Y,Z are (complex) numbers b) X,Y are square matrices and Z is a complex number (say) c) X = d/dx, Y = \int dx, Z = x $\endgroup$ – Quasar Supernova Aug 20 '16 at 4:36
  • $\begingroup$ Maybe have a look at this question and adapt it to your whims. To give more specific advice, it would be best if you show what code you've already written so that the parameters of the question are less hazy. $\endgroup$ – Jens Aug 20 '16 at 5:10
  • $\begingroup$ Sorry again. While the above question was just for kicks, I really need the answer to this now as I am working on something. It is a stupid question I admit but I am getting errors all over the place. $\endgroup$ – Quasar Supernova Aug 20 '16 at 5:49
  • 3
    $\begingroup$ @QuasarSupernova You really ought to mark this as accepted and post a followup question. It's not good form to ask a question, get an answer, and then go "just kidding, that wasn't my question". $\endgroup$ – QuantumDot Aug 20 '16 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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