TITLE: Counting isomorphism classes of elliptic curves with specific torsion
QUESTION [9 upvotes]: Generally speaking, I am interested in counting the number of $\mathbb{F}_p$- isomorphism classes of elliptic curves containing a specific torsion subgroup, and I was wondering if there were any simple formulas for particular torsion subgroups.  Any information on this topic is appreciated.
More specifically, I would like to count the number of $\mathbb{F_p}$-isomorphism classes  of elliptic curves whose torsion subgroup contains $\mathbb{Z}/N \times \mathbb{Z}/N$, where $N$ is a small fixed integer, for instance one for which the modular curve $X(N)$ has genus 0.  
I know that if you fix a prime $p$, and fix an isogeny class of such curves over $\mathbb{F}_p$, then Schoof  (in "Nonsingular plane cubic curves over finite fields") has formulas which express the number of isomorphism classes of these curves in the given isogeny class in terms of class numbers of certain quadratic extensions of the rationals.  So, for example, summing these expressions over all possible isogeny classes is an answer to the question. However, I don't know of any easy way to compute this sum of class numbers, and it seems that such a sum could potentially be expressed more simply.
Also, Schoof's result holds for all $N$, and I thought it might be possible for smaller $N>1$'s that things simplified a bit.
Thanks for the help!

REPLY [8 votes]: To add to Aşağı Güzdək's nice answer, there is something you can do also when the genus is greater than zero which is also in some sense an exact formula. Namely, if $\Gamma$ is one of $\Gamma_0(N), \Gamma_1(N)$ or $\Gamma(N)$ [or probably some other congruence subgroups as well, but I am not familiar with this story], and $Y_\Gamma$ (resp. $X_\Gamma$) is the corresponding open (resp. compact) modular curve, then one has 
$$ |Y_\Gamma(\mathbf{F}_p)| = p+1-\mathrm{Tr}(\mathrm{Frob}_p|E_2(\Gamma))-\mathrm{Tr}(\mathrm{Frob}_p|S_2(\Gamma)),$$
where $E_k(\Gamma)$ (resp. $S_k(\Gamma)$) is the Galois representation attached to Eisenstein series (resp. cusp forms) of weight $k$ for $\Gamma$. The Galois representation $E_2(\Gamma)$ is given by the $\ell$-adic cohomology of $X^\infty_\Gamma = X_\Gamma \setminus Y_\Gamma$, hence the appearance of the number of cusps in the previous answer. In general one can for a given $\Gamma$ and p figure out which of the cusps are defined over what fields by looking explicitly at the modular interpretation of $X_\Gamma^\infty$ described in the paper by Deligne & Rapoport.
The trace of Frobenius on the space of cusp forms is the really interesting one. In many cases this can be computed for a given $\Gamma$ and $p$ by looking in tables like the Modular Forms Database of William Stein, or asking SAGE to spit them out for you (see e.g. http://www.sagemath.org/doc/reference/sage/modular/modform/cuspidal_submodule.html) -- for a prime p, the trace of $\mathrm{Frob_p}$ coincides with the trace of the Hecke operator $T_p$, which can be read off from the pth Fourier coefficients of a basis of normalized eigenforms for the space of cusp forms you are looking at. 
It seems the only built-in functionality in SAGE is for the groups $\Gamma_0(N)$ and $\Gamma_1(N)$. But perhaps one can still do something for small N, e.g. using that conjugation by the matrix with entries $(0,-1;N,0)$ takes $\Gamma(N)$ to $\Gamma_0(N^2) \cap \Gamma_1(N)$ -- this tells you how to get cusp forms for $\Gamma(N)$ both from $\Gamma_0(N^2)$ and $\Gamma_1(N)$, and by the genus formula for $\Gamma(N)$ you can tell if this has produced all of them.