ES01E10: Numerical Electric Field Maps and Independent Checks
computer calculations are valuable in electrostatics, but they are reliable only when they
implement the same geometry and signs as the analytic derivation. This lesson develops a small
field evaluator, applies it to a point charge map, reconstructs E from potential with a centered
difference, and checks numerical convergence. A runnable Python program is supplied at the
article’s top level.
1 1. The basic field evaluator
The field evaluation function implements the vector Coulomb sum at an observation point
r:
For an ideal point charge the field is singular at the source location. A singularity mask means
deliberately excluding those positions or representing their field as undefined, rather than replacing
an infinite value by zero. The code checks that the input arrays have matching lengths and that no
evaluation point coincides with a source.
2 2. Worked example 1: a sampled point charge map
Take a positive charge Q at the origin. At (a, 0), (a,a), and (2a, 0), the analytically scaled fields in
units of E0 = keQ∕a2 are
A correct program must reproduce these values to floating point precision. Figure 1 shows an
example map with all arrows at a common scale. When a plotting routine automatically normalizes
vectors, the figure displays direction only and must not be used to infer the inverse square
magnitude law.
Figure 1. Sample vector field about a positive point charge, with the singular source excluded. All
arrows are scaled consistently within the diagram.
3 3. Worked example 2: use potential as an independent computation
For a point charge at the origin, V (x, 0) = keQ∕x for x > 0. The exact field at x > 0 is
Ex = keQ∕x2. A finite difference gradient approximates the derivative using nearby potential
values:
For x = 1 m, substitute V = keQ∕x and simplify algebraically:
The exact value is Ex = keQ. Thus the relative error is
For h = 0.200, 0.100, and 0.0500 m the relative errors are approximately 4.17%, 1.01%, and
0.251%, respectively. This is a controlled calculation because V is known analytically; it is not a
measurement of the accuracy of an arbitrary laboratory voltmeter.
4 4. Worked example 3: measure convergence
A convergence test repeats the calculation as the numerical step is refined. Equation (5)
predicts an O(h2) error for sufficiently small h. Halving h should reduce the error by a factor
approaching four. The exact ratios at finite h are slightly different because of the denominator
1 − h2.
Figure 2. Schematic convergence trend when numerical resolution increases. The number of
sample points and the step size are inversely related; the actual error must be measured against
an independent result.
A single grid result cannot prove convergence. For a general field map, compare successive grid
resolutions away from singular sources and verify at least one symmetry or analytic limit.
Refinement near a singularity requires special care, because the underlying field diverges
there.
5 5. Worked example 4: two charges and cancellation checks
Place two identical charges +q at (−a, 0) and (a, 0). At the midpoint the code should return
E(0, 0) = 0 within numerical roundoff, because the two contributions are equal and opposite. At
(0,z) with z > 0, it should return the purely vertical result
These checks exercise both sign conventions and symmetry. Far from a neutral pair with opposite
charges, the direct summation subtracts nearly equal terms and can suffer cancellation error in
finite precision. Compare that result with the analytically derived dipole far field, and report the
observation distance relative to the source size.
6 6. Running the accompanying program
The bundled file ES01E10_field_checks.py uses Python 3 and NumPy. Running
python ES01E10_field_checks.py
prints the main analytic comparisons and numerical errors, checks two source symmetry with
assertions, and saves a CSV of finite difference results. It neither accesses the network nor treats a
generated field as experimental data. Read the source and change the charges to experiment with
new geometries.
File downloads: ES01E10˙field˙checks.py ES01E10˙finite˙difference.csv
7 7. Exercises
- Derive the general centered difference field for V (x) = keQ∕x at any x > h > 0, and
calculate its relative error.
- Explain why a field evaluator must not return 0 at a point source location.
- If a centered difference has an O(h2) truncation error, what error ratio should occur
after halving h sufficiently far from singularities?
- A symmetric two-charge problem returns a small nonzero Ex of order 10−13 times the
magnitude of each contribution. What independent information decides whether this
is a physics effect or floating point roundoff?
8 8. Solutions
- The finite difference expression simplifies to Ex,h = keQ∕(x2 −h2). Divide by the exact
keQ∕x2 to obtain (E
x,h − Ex)∕Ex = h2∕(x2 − h2).
- The ideal point charge field diverges at the source and is not a finite vector there.
Returning zero would falsely suggest a physical cancellation or equilibrium.
- The error should approach one quarter of its previous value, for smooth data and
sufficiently small h. Measurement noise or rounding can eventually spoil this trend.
- Verify the analytic reflection symmetry, compare individual component magnitudes
with the residual, change numeric precision or source order, and test the result under
coordinate reflection. A residual near machine precision is usually roundoff, not a new
physical field.
9 9. Numerical quality checklist
State the sources, coordinate units, and observation grid; mask singularities; preserve the sign of
every source charge; use physical vector scales; compare with a known solution and
convergence study; and label simulated curves as calculations rather than experimental
readings.
References
References
[1] P. Dourmashkin and collaborators, Electricity and Magnetism, MIT 8.02 course notes,
chapters on Coulomb’s law and electric fields.
[2] D. J. Griffiths, Introduction to Electrodynamics, 4th ed., Cambridge University Press,
2017, electrostatics chapters.
[3] E. M. Purcell and D. J. Morin, Electricity and Magnetism, 3rd ed., Cambridge
University Press, 2013.
[4] PhysicsLibrary, ES01/EM05 articles and the earlier single example entries for the
corresponding ES01E identifiers.