  Let $f: {\Bbb R}^n \longrightarrow {\Bbb R}$ be a positive definite quadratic
form and let $y \in {\Bbb R}^n$ be a point. We present a fully polynomial
randomized approximation scheme (FPRAS) for computing $\sum_{x \in {\Bbb Z}^n}
e^{-f(x)}$, provided the eigenvalues of $f$ lie in the interval roughly between
$s$ and $e^{s}$ and for computing $\sum_{x \in {\Bbb Z}^n} e^{-f(x-y)}$,
provided the eigenvalues of $f$ lie in the interval roughly between $e^{-s}$
and $s^{-1}$ for some $s \geq 3$. To compute the first sum, we represent it as
the integral of an explicit log-concave function on ${\Bbb R}^n$, and to
compute the second sum, we use the reciprocity relation for theta functions. We
then apply our results to test the existence of many short integer vectors in a
given subspace $L \subset {\Bbb R}^n$, to estimate the distance from a given
point to a lattice, and to sample a random lattice point from the discrete
Gaussian distribution.
