2
$\begingroup$

Suppose I define differential operators $d=x\frac{\partial}{\partial x}$ and $L=g(x)d^4$ (so that $L(f)=g(x)(x\frac{\partial}{\partial x})^4f$ ) and I want to expand the differential operator $L=a_0+a_1 \frac{\partial}{\partial x}+ a_2 \frac{\partial^2}{\partial x^2} + \cdots$. I tried doing the following but it doesn't work.

d[f_] := x D[f,x]
g[x_] := 2 x
L[f_] := g[x] Nest[d,f,4]
Expand[L[g[x]]]
$\endgroup$
5
  • $\begingroup$ Maybe a starting point: d[f_] := # Derivative[1][f][#] &. $\endgroup$ Feb 4, 2020 at 13:28
  • $\begingroup$ Fourth Derivative is D[f[x],{x,4}] $\endgroup$ Feb 4, 2020 at 14:05
  • 1
    $\begingroup$ It seems that everything is correct. L[g[x]] == L[2 x] == 4 x^2, because g[x] is defined to be 2x. Expand[L[h[x]] looks like what you expected. $\endgroup$
    – aooiiii
    Feb 4, 2020 at 14:42
  • $\begingroup$ Section "Some noncommutative algebraic manipulation" here might have usable approaches. $\endgroup$ Feb 4, 2020 at 14:59
  • $\begingroup$ Related: mathematica.stackexchange.com/questions/71643/… $\endgroup$
    – Michael E2
    Feb 4, 2021 at 18:50

1 Answer 1

2
$\begingroup$

Here's what I think you want:

ClearAll[d, g, L];
d[f_] := x D[f, x]
g[x_] := 2 x
L[f_] := g[x] Nest[d, f, 4]
exL = Evaluate[Expand[L[#[x]]]] & /.
  Derivative[k_][#][x] :> D[#, {x, k}]

The replacement Derivative[k_][#][x] :> D[#, {x, k}] changes the argument # from representing a pure function to representing an expression. This seemed unavoidable because if we had used L[#], then D[#, x] would be zero; but in L[#[x]], D[#[x], x] would be correct.

If you want the coefficients:

Block[{D = $f^#2[[2]] &},
 CoefficientList[First@exL, $f]
 ]
{0, 2 x^2, 14 x^3, 12 x^4, 2 x^5}

Compare applications:

L[Exp[a x]] // Expand
exL[Exp[a x]]

Here's a refactoring with the parameters as arguments:

ClearAll[d, g, L];
d[x_][f_] := x D[f, x]
L[f_, g_, x_] := g Nest[d[x], f, 4]
exL = Evaluate@Expand[L[#[x], g[x], x]] & /. 
  Derivative[k_][#][x] :> D[#, {x, k}]
$\endgroup$

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.