TITLE: Finite dimensional spaces
QUESTION [7 upvotes]: What are the finite-dimensional spaces $W$ of differentiable functions with this property: If $f$ is in $W$, then $\frac{df}{dx}$ is in $W$.

REPLY [10 votes]: Exactly the ones generated by $x^k e^{cx}$ for various $c\in \mathbb{C}$.  (Over $\mathbb{R}$, we should use sines and cosines as well as exponentials)
Finite-dimensionality is the key.  We have an operator $D: W\to W$, so $W$ decomposes into generalized eigenspaces.  The possible eigenvectors of this operator are exactly $e^{cx}$ for various $c\in\mathbb{C}$, and you can check the generalized eigenspaces are spanned by elements from $\{x^k e^{cx} \mid c\in\mathbb{C}, k=0,1,2,\ldots\}$.
By the way, if you write down the characteristic equation for $D$, you get an ordinary linear differential equation whose solution set is precisely $W$ (this follows from counting dimension).  Of course, this is the opposite of how it's usually done in a first differential equations course, where we are given the equation and asked to construct $W$.
To give an example of that last paragraph: if $W$ has basis $\{1, x, e^x\}$, then we can represent $D$ (with respect to this basis) by the matrix $A=\begin{pmatrix}0 & 1 & 0 \\0 & 0 & 0 \\0 & 0  & 1 \end{pmatrix}$.  The characteristic polynomial is: $$\det(XI - A) = \det{\begin{pmatrix}X & -1 & 0 \\0 & X & 0 \\0 & 0  & X-1 \end{pmatrix}} = X^2(X-1)$$
By Cayley-Hamilton, $D$ satisfies its own characteristic polynomial, so $D^3 - D^2 = 0$ as operators on $W$.  That is, every $f\in W$ satisfies $(\frac{d^3}{dx^3} - \frac{d^2}{dx^2})f = 0$.  But this is exactly the linear differential equation $f''' = f''$, and, by standard methods, its solution set is spanned by $\{1,x,e^x\}$—that is, every solution to this equation already lies in $W$.  So what we've really done here is described a dictionary between finite-dimensional vector spaces of functions, closed under differentiation, and linear differential equations.