1

I have a very simple question.

If I have a polynomial in x say, $f(x)$, how to construct the differential operator $f(\frac{d}{dx})$?

Failed Attempt:

In[739]:= f[x] = a0 + a1*x + a2*x^2 + a3*x^3;

f[x] /. {x -> Function@D[#, x], x^n_ -> Function@D[#, {x, n}]}

Out[740]= a0 + a1 (\!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]#1\) &) + a2 (\!\(
\*SubscriptBox[\(\[PartialD]\), \({x, 2}\)]#1\) &) + a3 (\!\(
\*SubscriptBox[\(\[PartialD]\), \({x, 3}\)]#1\) &)
Subho
  • 1,534
  • 1
  • 8
  • 18

2 Answers2

3
f[x] = a0 + a1*x + a2*x^2 + a3*x^3;
f1[x_] = (f[x] /. {x -> D[#, x], x^n_ -> D[#, {x, n}]}) &;
f1[x][Exp[m x]]

a0 + a1 E^(m x) m + a2 E^(m x) m^2 + a3 E^(m x) m^3

Sumit
  • 15,912
  • 2
  • 31
  • 73
2

Rules can be shortened using the _. pattern. A function can be defined as

g[y_] := f[x] /. {x^n_. -> D[y, {x, n}]}

For example, g[x^4] gives

a0 + 4*a1*x^3 + 12*a2*x^2 + 24*a3*x

Andrew
  • 2,513
  • 17
  • 15