TITLE: In generatingfunctionology, for a polynomial $P$ and a differential operator $D$, what does $P(xD)$ mean?
QUESTION [11 upvotes]: I'm working through some of the exercises in generatingfunctionology. One of the questions is to find the generating function where the $n$th term $a_n=P(n)$ for $P$ a polynomial. The answer is $P(xD)(1/(1-x))$. I thought it meant something like if $P(n)=3n+n^2$, then $P(xD)=3xD+x^2D^2$, and then you would apply that to $1/(1-x)$. However, I know the generating function for $a_n=n^2$ is $$\frac{x(x+1)}{(1-x)^3}$$
which is not the same as $x^2D^2(1/(1-x))$. So what does it mean? Thanks.

REPLY [16 votes]: The problem is that you've mistakenly assumed commutativity. Here $\rm\:x\:$ and $\rm\:D\:$ do not commute. Indeed $\rm\,\color{#c00}{D\:\!x = x\:\!D + 1}\,$ since $\rm\,(D\:\!x)\:\!f\:\!=\:\!D\:\!(x\:\!f)\:\!=\:\!x\:\!f\:\!'+f\:\!=\:\!(x\:\!D + 1)\:\!f.\,$ So it's not true that $\rm\:\!(x\:\!D)^2 =\:\!x^2\:\!D^2.\,$ Instead $\rm\,x\:\!\color{#c00}{D\:\!x}\:\!D\:\!=\:\!x\:\!(\color{#c00}{x\:\!D + 1})\:\!D\:\!=\:\!x^2\:\!D^2 + x\:\!D.\,$ Generally
$$\rm (x\:\!D)^n\:\!=\:\!\sum_{k\:\!=\:\!0}^n\:\!S(n,k)\:\!x^k\:\!D^k $$
where $\rm\:\!S(n,k)\:\!$ are the Stirling numbers of the second kind.
Beware $\, $ Since this operator algebra is noncommutative so many familiar polynomial identities do not hold true. For example, consider the proof of the difference of squares identity
$$\rm\:\!(x-y)\:\!(x+y)\:\!=\:\!x^2 + \color{#0a0}{x\:\!y - y\:\!x} - y^2\:\!=\:\!x^2 - y^2$$
Notice how commutativity is assumed to cancel the $\rm\color{#0a0}{middle}$ terms. Thus the identity needn't remain true if we substitute elements from some noncommutative ring, e.g. we cannot substitute $\rm\,D\,$ for $\rm\,y.\,$ Said slightly more technically, the polynomial evaluation map is a ring homomorphism iff coefficients and indeterminates commute. See this post for further remarks on this topic.