TITLE: how to visualize the class number of an imaginary quadratic field?
QUESTION [20 upvotes]: Let me detail the title of the question. I'm trying to give students an intuition of what the class number is.
Let $K=\mathbb{Q}(\sqrt{-d})$, with $d>0$ a square-free integer, be a quadratic imaginary field. Let $\mathcal{O}_K$ be its ring of integers. It is of the form $\mathbb{Z}[\tau]$ with $\tau=\sqrt{-d}$ or $\tau=\frac{1+\sqrt{-d}}{2}$ depending on the value of $d$ mod $4$. 
So let us think of $\mathcal{O}_K$ as the lattice of $\mathbb{C}$ generated by $1$ and $\tau$. Then ideals should correspond to sublattices of $\mathcal{O}_K$ and two of them should define the same class in the class group if one can pass from one to another by multiplying by an element of $\alpha$, isn't it? 
Could anybody help me to make this analogy precise? For instance, how can one see that $\mathbb{Q}(i)$ has class number 1 but $\mathbb{Q}(\sqrt{-5})$ doesn't just by looking at the corresponding lattices? The (non-equivalent) decompositions
$2.3=(1+\sqrt{5}i)(1-\sqrt{5}i)$ 
suggest to consider the lattices $\mathbb{Z}\cdot 2+\mathbb{Z}\cdot(1+\sqrt{5}i)$ and $\mathbb{Z}\cdot 3+\mathbb{Z}\cdot(1-\sqrt{5}i).$ Is that what I have to do?
Thanks!

REPLY [10 votes]: I think that showing the lattices $(1, \sqrt{-5})$ and $(2, 1+\sqrt{-5})$ is a good idea. As Felipe Voloch says, not all lattices are ideals, but the fact that these lattices are ideals can be shown visually: You just need to check that $\sqrt{-5} I \subset I$ and, of course, multiplication by $\sqrt{-5}$ means multiplication by $\sqrt{5}$ and rotation by $\pi/2$. And it is geometrically obvious that $(2, 1+\sqrt{-5})$ is not principal -- it does not have a rectangular fundamental domain. (You could contrast this with $(2, 1+\sqrt{-1})$, which is principal.)
Beyond that, if you are going to talk about reduced forms, you could plot the roots of $a z^2+bz+c=0$ for all reduced forms of some discriminant and show how they lie in the fundamental domain. For example, here are the $23$ reduced forms of discriminant $-647$ (with real and imaginary axes transposed to fit nicely on the page).

If you want to play with this example, here are the coefficients in $(a,b,c)$ form
{{12, 5, 14}, {12, -5, 14}, {13, 9, 14}, {13, -9, 14}, {12, 11, 16}, {12, -11, 16}, {9, 1, 18}, {9, -1, 18}, {8, 5, 21}, {8, -5, 21}, {7, 5, 24}, {7, -5, 24}, {6, 1, 27}, {6, -1, 27}, {6, 5, 28}, {6, -5, 28}, {4, 3, 41}, {4, -3, 41}, {3, 1, 54}, {3, -1, 54}, {2, 1, 81}, {2, -1, 81}, {1, 1, 162}}