Consider the smallest Weyl algebra $A_1=\{q,p; qppq=1\}$. It is known that there exist pairs of commuting elements, say $L$ and $M$, that obey various polynomial relations, e.g. elliptic curves. I wonder how big the commutative subalgebra of the Weyl algebra can be? (of course, I mean how big the generating set of commuting elements can be since any product of commuting things trivially commutes with the generating set)

4$\begingroup$ Dumb comment: You'll want to restrict yourself to maximal subalgebras in order to say anything. Otherwise, for any positive integer $n$, $k[p^{n+1}, p^{n+2}, \cdots, p^{2n}]$ is a commutative subalgebra which can't be generated by fewer than $n$ elements. $\endgroup$– David E SpeyerAug 19, 2013 at 22:44

1$\begingroup$ This seems like a bad notion of bigness. I think you want something like Krull dimension instead. $\endgroup$– Qiaochu YuanAug 20, 2013 at 5:00

3$\begingroup$ @QiaochuYuan The Krull dimension is $\leq 1$. Let $f$ be any nonscalar element of $A_1$ and let $C(f)$ be the set of $g \in A_1$ that commute $f$. Then $C(f)$ is a finitely generated $k[f]$ module. Since a nontrivial commutative subalgebra must be contained in some $C(f)$, this shows that commutative subalgebras are finite over one dimensional polynomial rings, and hence are Krull dimension one and finitely generated. In fact, more is true: $C(f)$ is, itself, a commutative subalgebra of $A_1$. See Amitsur ams.org/mathscinetgetitem?mr=95305 . $\endgroup$– David E SpeyerAug 20, 2013 at 15:33

$\begingroup$ Totally agree that the notion of being big was not made precise enough. Actually, I still have no idea what is the best definition of the size. I mentioned pairs of commuting operators that obey elliptic curve type relations to emphasize that the subalgebra should be more rich/nontrivial than $p^n, p^{n+1},...$ in the example above. @David, thank you for a nice reference! $\endgroup$– Eugene StarlingAug 20, 2013 at 15:51
2 Answers
The key papers on this seem to be by Krichever: I skimmed "Commutative rings of ordinary linear differential operators" and "Integration of nonlinear equations by the methods of algebraic geometry". I am not certain that I understood them correctly; I hope an expert will show up to correct any errors.
Let $f$ be any nonscalar element of $A_1$ and let $C(f)$ be the set of $g\in A_1$ that commute with $f$. Then $C(f)$ is a finitely generated $k[f]$module. In particular, if $R$ is a commutative ring containing $f$, then $R$ is a finitely generated $k[f]$ module. This result is originally due to Flanders; see Amitsur for an elementary proof.
Let $R$ be a commutative subalgebra of $A_1$. We have just showed that $R$ is a $\mathbb{C}$algebra which is finite over $\mathbb{C}[f]$ for any nonscalar $f$ in $R$. Let $\tilde{R}$ be the normalization of $R$. Then this shows that $\mathrm{Spec}(\tilde{R})$ is a curve with one puncture. (If there were more than one puncture, we could find $f$ in $R$ which blew up at one of the punctures and not another, and then $R$ wouldn't be finite over $\mathbb{C}[f]$.)
It seems like papers in this field describe the size of subalgebras of $A_1$ using two parameters: The genus of $\mathrm{Spec}(\tilde{R})$ and something called the "rank". I didn't understand the more sophisticated description of rank, but it seems to have the following elementary description: Let $\phi \in R \subset A_1$ be a nonscalar. Considered as an element of $\tilde{R}$, let $\phi$ have a pole of order $d$ at the puncture. Considered as an element of $A_1$, let $\phi$ be a polynomial in $p$ and $q$ of degree $e$. Then $e/d$ is an integer independent of $\phi$, called the rank. WARNING: I inferred this from context; no one explicitly said it.
See Mokhov for constructions of commutative subalgebras of arbitrary genus and rank.
You asked about number of generators. In other words, you would like the ring $R$ to have many generators. This is not what most papers focus on and I agree with Qiaochu that it isn't the best notion of size, but I'll try to think about it. If $R = \tilde{R}$, then $R$ can be generated by $3$ elements because any smooth affine curve embeds into $\mathbb{C}^3$. (Take a generic projection of a high dimensional embedding.) I found papers that stated that $R$ need not equal to $\tilde{R}$, but I didn't find explicit examples. The papers of Krichever linked above are supposed to be answering the inverse problem: Given $R$, build the ring of differential operators, but I couldn't extract an explicit statement from them of whether this is always possible.

$\begingroup$ Do the papers state that $R$ need not be equal to $\tilde{R}$ even if $R$ is maximal? $\endgroup$ Aug 20, 2013 at 19:55

$\begingroup$ @WillSawin Yup. Some explicit examples appear on page 412 of link.springer.com/content/pdf/10.1007%2F0817644784.pdf : MakarLimanov gives several examples, due to other people, of $h$ in $\mathrm{Frac}(A_1)$ such that $h^2$ and $h^3$ are in $A_1$ but $h$ is not. ($A_1$ is an Ore domain, which means it has a good notion of a field of fractions.) $\endgroup$ Aug 20, 2013 at 20:20
A maximal commutative subalgebra of the Weyl algebra can have arbitrarily many generators. (Though, as explained in my other answer, it must be finitely generated.) Let the Weyl algebra as $k\langle x,y \rangle / yxxy1$ (where $k$ is a field of characteristic zero) and define $z = xy$. Let $a$ be a rational noninteger. Set $$\theta = \frac{\prod_{i=1}^{n} (za+i)(zai)}{(za)^n} x,$$ I will discuss below how to make sense of the division. Then I claim that $$k[\theta] \cap A_1 = k[\theta^{n+1}, \theta^{n+2}, \theta^{n+3}, \ldots],$$ and that this is a maximal commutative subalgebra of $A_1$. This ring cannot be generated by fewer then $n+1$ generators. This example (slightly modified) for $n=1$ appears in MikarLimanov's paper, where he credits it to "someone in Moscow, Russia about 1968".
Thanks for making me finally figure out why this example works!
We begin with the equations $$zx = x(z+1) \quad zy=y(z1)$$ which may be checked directly. These maybe seen to imply $$f(z) x = x f(z+1) \quad f(z) y = y f(z1)$$ for any polynomial $f$. Let $B$ be the ring generated by $k(z)$, $x$ and $y$, with relations $$f(z) x = x f(z+1) \quad f(z) y = y f(z1) \quad xy=z \quad yx= z+1$$ for any rational function $f(z) \in k(z)$. So the Weyl algebra $A$ maps to $B$ and, using that $A$ is a domain, this can be seen to be an embedding. Note that, in $B$, we have $x^{1} = (z+1)^{1} y$ or, equivalently, $y = (z+1) x^{1}$. So we can equally well describe $B$ as the ring generated by $k(z)$ and $x^{\pm 1}$, subject to the relation $zx=x(z+1)$.
Every element of the ring $B$ can be uniquely written as $$\sum_{n=\infty}^{\infty} f_n(z) x^n$$ with the $f_n(z)$ in $k(z)$ and all but finitely many $f_n$ equal to zero. Multiplication is given by $$\left( \sum_m f_m(z) x^m \right) \left( \sum_n g_n(z) x^n \right) = \sum_{m,n} f_m(z) g_n(zm) x^{m+n}$$
Define $$ f^{(n)}(z) = \begin{cases} f(z) f(z1) f(z2) \cdots f(zn+1) & n > 0 \\ 1 & n=1 \\ \frac{1}{f(z+1)f(z+2) \cdots f(z+(n))} & n < 0 \\ \end{cases}$$
An easy induction establishes $$\left( f(z) x \right)^n = f^{(n)}(z) x^n$$
Lemma Let $\theta = f(z) x$ for some nonzero rational function $f(z)$. Then $\sum a_n(z) x^n$ commutes with $\theta$ if and only if $a_n$ is a scalar multiple of $f^{(n)}$ for all $n$. In other words, the elements of $B$ which commute with $\theta$ are all of the form $\sum c_n \theta^n$ for $c_n \in k$.
Proof Write $a_n(z)$. Comparing the coefficient of $x^{n+1}$ on both sides of $ \left( \sum a_n(z) x^n \right) \theta = \theta \left( \sum a_n(z) x^n \right)$ gives $$a_n(z) f(zn) = f(z) a_n(z1).$$ Writing $a_n(z) = f^{(n)}(z) b_n(z)$, we deduce that $$b_n(z) = b_n(z1).$$ The only periodic rational functions are the constants. $\square$.
Set $f(z) = \prod_{i=1}^n (za+i)(zai)/(za)^n$. I leave the following to you:
Lemma For $m>n$, the rational function $f^{(m)}(z)$ is in $k[z]$. For $m$ nonzero and $\leq n$, the rational function $f^{(m)}(z)$ has a pole at a noninteger.
Corollary The elements of $A_1$ which commute with $\theta$ are of the form $c_0 + \sum_{m >n } c_m \theta^m$.
The only detail to keep track of is the conversion from $x^{m}$ to $\frac{1}{(z+1)(z+2) \cdots (z+m) } y^m$; this is why I made $a$ a noninteger.
Having checked all this, I claim that $R=k[\theta^{n+1} , \theta^{n+2}, \cdots, ]$ is a maximal commutative subring of $A_1$. We showed above that it is contained in $A_1$. And, if $\alpha$ commutes with $\theta^{n+1}$ and $\theta^{n+2}$, then $\alpha$ commutes with $\theta$. So any element of $A_1$ which commutes with $R$ is itself in $R$. This shows that $R$ is maximal.