How big can a commutative subalgebra of Weyl algebra be? Consider the smallest Weyl algebra $A_1=\{q,p; qp-pq=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)
 A: 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.
A: 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 / yx-xy-1$ (where $k$ is a field of characteristic zero) and define $z = xy$. Let $a$ be a rational non-integer. Set
$$\theta = \frac{\prod_{i=1}^{n} (z-a+i)(z-a-i)}{(z-a)^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 Mikar-Limanov'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(z-1)$$
which may be checked directly. These maybe seen to imply
$$f(z) x = x f(z+1) \quad f(z) y = y f(z-1)$$
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(z-1) \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(z-m) x^{m+n}$$
Define 
$$ f^{(n)}(z) =
\begin{cases} f(z) f(z-1) f(z-2) \cdots f(z-n+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(z-n) = f(z) a_n(z-1).$$
Writing $a_n(z) = f^{(n)}(z) b_n(z)$, we deduce that
$$b_n(z) = b_n(z-1).$$
The only periodic rational functions are the constants. $\square$.
Set $f(z) = \prod_{i=1}^n (z-a+i)(z-a-i)/(z-a)^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.
