Exact forms for electric potentials can be found by integrating over the charge distribution of the source. A very useful representation is an expansion of the potential, expressed in terms of spherical harmonics, specifically of the form
. Each of the monopole, dipole, quadrupole and octupole charge densities belongs to a
-dimensional representation of the 3-dimensional rotational group, with their characteristic symmetries. As an approximation to the exact solutions, a multipole expansion can be computed using numerical integration.
This Demonstration computes an electric flux through the surface of a sphere centered at the origin, multiplying a sample density constant by a sum of radial components of the electric field (multiplied by
) over a subset of all vectors with norm equal to
, the radius of the surface of integration. When the subset of vectors is chosen from a distribution such that the sample can be described by one density as a function of solid angle, the computed quantity can equal the electric flux in Gauss's law. However, the uniform density in this Demonstration is chosen according to the isotropic spherical harmonic
, leading to a computed value of approximately
for a point charge. Using this quantity as a coefficient for
gives an expansion for the monopole electric field:
in units of
. Likewise, expansion coefficients for the radial component of electric fields, corresponding to higher-order multipole charge densities, can be computed by summing over a subset of vectors related to the spherical harmonics,
When an expansion includes a term
, it will also include
because the real (or imaginary) part of
can be expressed as a multiple of the real (or imaginary) part of
. Therefore, coefficients for the
have been divided by two so that the expansion does not duplicate the contributions to the radial component of the electric field. For example, in this Demonstration, the expansion of dipole has two significant terms, and the computed coefficient for each of these terms should be made to approach the limit
 D. J. Griffiths, Introduction to Electrodynamics
, 3rd ed., Upper Saddle River, NJ: Prentice Hall, 1999.
 J. D. Jackson, Classical Electrodynamics
, New York: Wiley, 1975.