We give the bounds for an alphabet of size , including the binary case . Let be a length- code with codewords and minimum Hamming distance at least , where . Write for the maximum code size at a given distance and
for the number of words in a Hamming ball of radius . The th term chooses the changed coordinates and the alternative symbols in each.
For the Hamming bound, put . Balls of radius around distinct codewords are disjoint: a common point would, by the triangle inequality, make their distance at most . Counting those balls inside the ambient words proves
No linearity is needed. For a linear code of dimension over , replace by .
For the Gilbert–Varshamov bound, construct a code greedily, adding any word at distance at least from all previously selected words, until none remains. The process terminates because the space is finite. Its maximality implies that the radius- balls around its codewords cover the whole space: an uncovered word could have been added. These balls may overlap, but the size of their union is at most the sum of their sizes. Hence the constructed code has , proving the existence bound
One may take the ceiling on the right because code size is integral.
For completeness, the sharper linear version is the Varshamov bound for linear codes. When is a prime power and , an linear code exists provided
Set and choose columns of an parity-check matrix in order. When choosing column , exclude all combinations of at most earlier columns, including the zero combination. There are at most forbidden vectors, smaller than by the assumed inequality. A column can therefore be chosen. Inductively every set of at most chosen columns is independent: a relation involving the newest one would express it as a combination of at most earlier columns. The kernel has dimension at least and minimum Hamming distance at least , since a low-weight kernel vector would be such a column relation. If its dimension is larger than , take a -dimensional subspace. This proves the stated linear existence claim; it does not assume the greedy nonlinear code was linear.
To derive the asymptotic bounds, define the q-ary entropy
with the continuous endpoint conventions. Its derivative is , so it is increasing on and has maximum one at . Stirling's formula gives, uniformly for integer ,
The sum defining is between its largest summand and times that summand. For radius fractions tending to , monotonicity of makes the largest exponent tend to . Consequently the Hamming ball volume exponent is
For , the exponent is one: use a radius fraction just below for a lower bound and for an upper bound.
Set and define the asymptotic rate-distance function by
The code rate is and the relative minimum distance is . A limsup suffices; no unproved existence of a limit for optimal code sizes is required. The packing radii have fraction tending to , so the finite Hamming bound and the volume exponent give the asymptotic Hamming bound
The covering radii have fraction tending to , giving the asymptotic Gilbert–Varshamov bound
For larger , this covering argument gives only the trivial lower bound zero, not the expression obtained by extending the decreasing information entropy function beyond its maximum.
The asymptotic lower bound is also achievable by linear codes over a finite field. For and sufficiently large , take redundancy , so . The linear existence condition produces dimension at least ; its rate has liminf at least . At , use the whole space, of rate one. In particular, for binary codes the bounds reduce to
where is the binary entropy function.