# Product of n different operators [duplicate]

I have a sequence of differential operators given by

$H_n = x \frac{d}{dx} + n$

where $n=1,2,...$ and I would like to construct the operator

$\hat{O}(n) = \frac{1}{n!}H_nH_{n-1}...H_2H_1$

as a function of the integer $n$. I know how to compose operators, and in particular how to compose the same operator $n$ times using, say, the Nest function, e.g. for $nH_1$ n-times I'd write

h[x_, n_] := x D[#, x] + n # &

ohat1[n_] := 1/n! Nest[h[x, 1], #, n] &


which would give me $\hat{O}_1(n) = (H_1)^n/n!$, but I haven't been able to generalise this to the case I'm interested in.

Aside: if this is even possible would mathematica then be able to deal with the case $n=\infty$ when acting on a specific function?

• Welcome to mathematica.SE, please post what relevant code you have in your question, and format it with the {} button (or indentation of every line of code with four spaces). – Feyre Sep 1 '16 at 8:28
• EDIT: Instead of "e.g. for n=1" it should read "e.g. for H_1 n-times I'd write" (when i tried to edit I got the message that the changes are not substantive enough to warrant a change...) – Dionigi Benincasa Sep 1 '16 at 8:43
• You just want Product don't you? Try 1/n! Product[h[x, i], {i, 1, n}] – Quantum_Oli Sep 1 '16 at 8:56

ohat1[n_] :=
Function[expr, 1/n! Fold[x D[#1, x] + #2 #1 &, expr, Range[n]]]
ohat1[2][f[x]]
(*1/2 (2 (f[x]+x f'[x])+x (2 f'[x]+x f''[x]))*)

• this is nice. However, I believe the function should be x D[#1, x] + #2 #1 &]. – ubpdqn Sep 1 '16 at 9:24
• Thanks. I agree with @ubpdqn. Can you edit your answer or should I do it myself? – Dionigi Benincasa Sep 1 '16 at 9:30
• Oh I'm sorry for that misunderstanding, it has been edited. – wuyingddg Sep 1 '16 at 12:36

Perhaps a start (factorial absorbed):

h[x_, n_] := x D[#, x]/n + # &
o[n_] := Composition @@ Table[h[x, j], {j, n}]
ol[n_][f_] := ComposeList[Table[h[x, j], {j, n}], f]


e.g.

Grid[{#, o[3][#], ol[3][#]} & /@ {x, x^2, x^3, x + 1}]


Comparing with a modification of wuyongddg's answer (I like the approach

ohat[n_] :=
Function[expr, 1/n! Fold[x D[#1, x] + #2 #1 &, expr, Range[n]]];


So, Expand[ohat[2][g[x]]] and o[2][g[x]] both yield:

g[x] + 2 x Derivative[1][g][x] + 1/2 x^2 (g^′′)[x]

• Nice thanks. Is it possible to have it compute o[n][g[x]] for $n$ an unspecified positive integer? – Dionigi Benincasa Sep 1 '16 at 9:44
• @DionigiBenincasa if you are searching for general form you should look at the various Find_. ,e.g. FindSequenceFunction and apply to first few 'values'. – ubpdqn Sep 1 '16 at 9:56