  Objective: The subtraction approach is known for being a
theoretically-rigorous and accurate technique for solving the forward problem
in electroencephalography by means of the finite element method. One key aspect
of this approach consists of computing integrals of singular kernels over the
discretised domain, usually referred to as potential integrals. Several
techniques have been proposed for dealing with such integrals, all of them
approximating the results at the expense of reducing the accuracy of the
solution. In this paper, we derive analytic formulas for the potential
integrals, reducing approximation errors to a minimum.
  Approach: Based on volume coordinates and Gauss theorems, we obtained
parametric expressions for all the element matrices needed in the formulation
assuming first order basis functions defined on a tetrahedral mesh. This
included solving potential integrals over triangles and tetrahedra, for which
we found compact and efficient formulas.
  Main results: Comparison with numerical quadrature schemes allowed to test
the advantages of the methodology proposed, which were found of great relevance
for highly-eccentric sources, as those found in the somatosensory and visual
cortices. Moreover, the availability of compact formulas allowed an efficient
implementation of the technique, which resulted in similar computational cost
than the simplest numerical scheme.
  Significance: The analytical subtraction approach is the optimal
subtraction-based methodology with regard to accuracy. The computational cost
is similar to that obtained with the lowest order numerical integration scheme,
making it a competitive option in the field. The technique is highly relevant
for improving electromagnetic source imaging results utilising individualised
head models and anisotropic electric conductivity fields without imposing
impractical mesh requirements.
