  In boundary integral methods it is often necessary to evaluate layer
potentials on or close to the boundary, where the underlying integral is
difficult to evaluate numerically. Quadrature by expansion (QBX) is a new
method for dealing with such integrals, and it is based on forming a local
expansion of the layer potential close to the boundary. In doing so, one
introduces a new quadrature error due to nearly singular integration in the
evaluation of expansion coefficients. Using a method based on contour
integration and calculus of residues, the quadrature error of nearly singular
integrals can be accurately estimated. This makes it possible to derive
accurate estimates for the quadrature errors related to QBX, when applied to
layer potentials in two and three dimensions. As examples we derive estimates
for the Laplace and Helmholtz single layer potentials. These results can be
used for parameter selection in practical applications.
