  Chebyshev was the first to observe a bias in the distribution of primes in
residue classes. The general phenomenon is that if $a$ is a nonsquare\mod q and
$b$ is a square\mod q, then there tend to be more primes congruent to $a\mod q$
than $b\mod q$ in initial intervals of the positive integers; more succinctly,
there is a tendency for $\pi(x;q,a)$ to exceed $\pi(x;q,b)$. Rubinstein and
Sarnak defined $\delta(q;a,b)$ to be the logarithmic density of the set of
positive real numbers $x$ for which this inequality holds; intuitively,
$\delta(q;a,b)$ is the "probability" that $\pi(x;q,a) > \pi(x;q,b)$ when $x$ is
"chosen randomly". In this paper, we establish an asymptotic series for
$\delta(q;a,b)$ that can be instantiated with an error term smaller than any
negative power of $q$. This asymptotic formula is written in terms of a
variance $V(q;a,b)$ that is originally defined as an infinite sum over all
nontrivial zeros of Dirichlet $L$-functions corresponding to characters\mod q;
we show how $V(q;a,b)$ can be evaluated exactly as a finite expression. In
addition to providing the exact rate at which $\delta(q;a,b)$ converges to
$\frac12$ as $q$ grows, these evaluations allow us to compare the various
density values $\delta(q;a,b)$ as $a$ and $b$ vary modulo $q$; by analyzing the
resulting formulas, we can explain and predict which of these densities will be
larger or smaller, based on arithmetic properties of the residue classes $a$
and $b\mod q$. For example, we show that if $a$ is a prime power and $a'$ is
not, then $\delta(q;a,1) < \delta(q;a',1)$ for all but finitely many moduli $q$
for which both $a$ and $a'$ are nonsquares. Finally, we establish rigorous
numerical bounds for these densities $\delta(q;a,b)$ and report on extensive
calculations of them.
