I expect that the following is a standard problem from analytic number theory, but I don't know where exactly to look for an answer.
Let f: ℤr→ H be a surjective homomorphism into a finite group. Let
$S(N)= \frac{1}{N^r}\#\{(x_1,\dots,x_r)\in \ker f\colon 0\leq x_i <N\}$.
One expects that S(N) is roughly |H|-1. My question is:
What is the best known estimate of the error term S(N)-|H|-1 in terms of N and the structure of H? I am especially interested in the case, when H=(ℤ/pnℤ)d, for some d<r.
To give some idea of what kind of results I am looking for, I will give the estimate, that I managed to find myself. If "e" is the exponent of the group H, and "h" is its size, then by estimating character sums one gets
$S(N) - h^{-1} \ll h^{-1}(\log \min\{h,N\})^r \max\{eN^{-1},e^rN^{-r}\}$,
where the implicit constant depends only on r. I think, that this can be improved at least when N is small with respect to e.