  Zagier proved that the traces of singular moduli, i.e., the sums of the
values of the classical j-invariant over quadratic irrationalities, are the
Fourier coefficients of a modular form of weight 3/2 with poles at the cusps.
Using the theta correspondence, we generalize this result to traces of CM
values of (weakly holomorphic) modular functions on modular curves of arbitrary
genus. We also study the theta lift for the weight 0 Eisenstein series for
SL(2,Z) and realize a certain generating series of arithmetic intersection
numbers as the derivative of Zagier's Eisenstein series of weight 3/2. This
recovers a result of Kudla, Rapoport and Yang.
