This general question is possibly easier to answer. Let's call the operator gop
and let be it linear. Then
gop[H[y] G[l, x]] = D[H[y] (l G[l + 1, x] + (l + 1) G[l - 1, x]), y]
= l D[H[y] G[l + 1, x], y] + (l + 1) D[H[y] G[l - 1, x], y]
= l D[H[y], y] G[l + 1, x] + (l + 1) D[H[y], y] G[l - 1, x]
gop[gop[H[y] G[l, x]]] = l gop[D[H[y], y] G[l + 1, x]] + (l + 1) gop[D[H[y], y] G[l - 1, x]]
= l ((l + 1) D[H[y], {y, 2}] G[l + 2, x] + (l + 2) D[H[y], {y, 2}] G[
l, x]) + (l + 1) ((l - 1) D[H[y], {y, 2}] G[l, x] +
l D[H[y], {y, 2}] G[l - 2, x])
In fact gop
operates on it's index function G
and then does a differentiation. Because the differentiation is also linear, one should make the index function as well as the differentiation variable explicit:
Clear[gop, singleQ]
singleQ[G_, f_] := Length[Select[Level[f, {1}], Head[#] == G &]] == 1 /; Head[f] === Times
singleQ[G_, f_] := And @@ (singleQ[G, #] & /@ (List @@ f)) /; Head[f] === Plus
singleQ[G_, f_] := False /; Head[f] =!= Times && Head[f] =!= Plus
gop[G_, y_, f_] := D[f /. G[l_, x__] -> l G[l + 1, x] + (l + 1) G[l - 1, x], y] /; ! FreeQ[f, G] &&
FreeQ[Denominator[Together[f]], G] && singleQ[G, Expand[f]] && FreeQ[D[f, y], Derivative[__][G]]
Things one isn't able to pin down are excluded. So one tries to implement the In-doubt-never-Rule. Check against the above double application of gop
:
In[302]:= gop[G, y, gop[G, y, H[y] G[l, x]]]
Out[302]= ((1 + l) (l G[-2 + l, x] + (-1 + l) G[l, x]) +
l ((2 + l) G[l, x] + (1 + l) G[2 + l, x])) (H^\[Prime]\[Prime])[y]
In[309]:= %302 - (l ((l + 1) D[H[y], {y, 2}] G[l + 2, x] + (l + 2) D[
H[y], {y, 2}] G[l, x]) + (l +
1) ((l - 1) D[H[y], {y, 2}] G[l, x] +
l D[H[y], {y, 2}] G[l - 2, x])) // Simplify
Out[309]= 0
Well, some more test cases:
In[289]:= gop[G, z, gop[G, y, H[y] Q[y] G[l, x]]]
Out[289]= 0
In[304]:= gop[G, x, gop[G, y, H[y] Q[y] G[l, x]]]
Out[304]= gop[G, x, ((1 + l) G[-1 + l, x] + l G[1 + l, x]) Q[
y] Derivative[1][H][y] + ((1 + l) G[-1 + l, x] + l G[1 + l, x]) H[
y] Derivative[1][Q][y]]
In[305]:= gop[G, x, gop[G, x, gop[G, y, H[y] Q[y] G[l, x]]]]
Out[305]= gop[G, x,
gop[G, x, ((1 + l) G[-1 + l, x] + l G[1 + l, x]) Q[y] Derivative[1][
H][y] + ((1 + l) G[-1 + l, x] + l G[1 + l, x]) H[y] Derivative[
1][Q][y]]]
In[307]:= gop[G, y,
gop[G, y, gop[G, y, H[y] G[l, x] + Q[y] P[y] G[l, x]]]]
Out[307]=
3 ((1 + l) (l ((-1 + l) G[-3 + l, x] + (-2 + l) G[-1 + l, x]) + (-1 +
l) ((1 + l) G[-1 + l, x] + l G[1 + l, x])) +
l ((2 + l) ((1 + l) G[-1 + l, x] + l G[1 + l, x]) + (1 +
l) ((3 + l) G[1 + l, x] + (2 + l) G[3 + l, x]))) Derivative[
1][Q][y] (P^\[Prime]\[Prime])[y] +
3 ((1 + l) (l ((-1 + l) G[-3 + l, x] + (-2 + l) G[-1 + l, x]) + (-1 +
l) ((1 + l) G[-1 + l, x] + l G[1 + l, x])) +
l ((2 + l) ((1 + l) G[-1 + l, x] + l G[1 + l, x]) + (1 +
l) ((3 + l) G[1 + l, x] + (2 + l) G[3 + l, x]))) Derivative[
1][P][y] (Q^\[Prime]\[Prime])[
y] + ((1 +
l) (l ((-1 + l) G[-3 + l, x] + (-2 + l) G[-1 + l, x]) + (-1 +
l) ((1 + l) G[-1 + l, x] + l G[1 + l, x])) +
l ((2 + l) ((1 + l) G[-1 + l, x] + l G[1 + l, x]) + (1 +
l) ((3 + l) G[1 + l, x] + (2 + l) G[3 + l, x])))
\!\(\*SuperscriptBox[\(H\),
TagBox[
RowBox[{"(", "3", ")"}],
Derivative],
MultilineFunction->None]\)[
y] + ((1 +
l) (l ((-1 + l) G[-3 + l, x] + (-2 + l) G[-1 + l, x]) + (-1 +
l) ((1 + l) G[-1 + l, x] + l G[1 + l, x])) +
l ((2 + l) ((1 + l) G[-1 + l, x] + l G[1 + l, x]) + (1 +
l) ((3 + l) G[1 + l, x] + (2 + l) G[3 + l, x]))) Q[y]
\!\(\*SuperscriptBox[\(P\),
TagBox[
RowBox[{"(", "3", ")"}],
Derivative],
MultilineFunction->None]\)[
y] + ((1 +
l) (l ((-1 + l) G[-3 + l, x] + (-2 + l) G[-1 + l, x]) + (-1 +
l) ((1 + l) G[-1 + l, x] + l G[1 + l, x])) +
l ((2 + l) ((1 + l) G[-1 + l, x] + l G[1 + l, x]) + (1 +
l) ((3 + l) G[1 + l, x] + (2 + l) G[3 + l, x]))) P[y]
\!\(\*SuperscriptBox[\(Q\),
TagBox[
RowBox[{"(", "3", ")"}],
Derivative],
MultilineFunction->None]\)[y]
Despite the restriction to linear expressions in the index function G
and despite the inability to detect the index function as well as the differentiation variable automatically the definitions might be useful. Please check for errors before usage.
Mix the index function a bit:
In[310]:= gop[G, y, gop[G, y, H[y] G[l, x] + Q[y] P[y] G[l, a, b, c]]]
Out[310]=
2 ((1 + l) (l G[-2 + l, a, b, c] + (-1 + l) G[l, a, b, c]) +
l ((2 + l) G[l, a, b, c] + (1 + l) G[2 + l, a, b, c])) Derivative[
1][P][y] Derivative[1][Q][
y] + ((1 + l) (l G[-2 + l, x] + (-1 + l) G[l, x]) +
l ((2 + l) G[l, x] + (1 + l) G[2 + l, x])) (H^\[Prime]\[Prime])[
y] + ((1 + l) (l G[-2 + l, a, b, c] + (-1 + l) G[l, a, b, c]) +
l ((2 + l) G[l, a, b, c] + (1 + l) G[2 + l, a, b, c])) Q[y] (
P^\[Prime]\[Prime])[
y] + ((1 + l) (l G[-2 + l, a, b, c] + (-1 + l) G[l, a, b, c]) +
l ((2 + l) G[l, a, b, c] + (1 + l) G[2 + l, a, b, c])) P[y] (
Q^\[Prime]\[Prime])[y]