A Byte of PhysicsLogo

Maxwell’s equations symbolically

Maxwell’s equations connect electric charge, current, electric field, and magnetic field. Symbolic notation is not decoration beside a solver: each equation specifies a relationship that a discretized field state should satisfy within a measured tolerance. A grid can draw a convincing travelling wave while violating a source constraint, so every relation needs a named residual.

Think like a programmer

Give each equation a diagnostic function and units-aware inputs. Keep chargeDensity, currentDensity, electricField, magneticField, divergence, and curl distinct in the API. Record both the maximum and norm of each residual, the grid spacing, boundary policy, and whether the run is source-free. A field update that changes these names or signs silently is a physics bug, not merely a rendering bug.

Model checklist

Inputs
Charge density ρ, current density J, E and B field arrays, permittivity ε₀, permeability μ₀, discrete curl/divergence operators, and boundaries.
State
Electric and magnetic field samples plus source samples and constraint residual histories.
Rule
Advance curl-coupled fields and evaluate both divergence constraints against sources.
Output
Updated fields, wave propagation, source residuals, and energy/flux diagnostics.
Check
Source-free fields give near-zero divergence residuals; a known static symmetry case agrees with its analytic divergence or curl.

In SI vacuum notation, the four equations are

\[\nabla\cdot\mathbf E=\frac{\rho}{\varepsilon_0},\qquad \nabla\cdot\mathbf B=0,\qquad \nabla\times\mathbf E=-\frac{\partial\mathbf B}{\partial t},\qquad \nabla\times\mathbf B=\mu_0\mathbf J+\mu_0\varepsilon_0\frac{\partial\mathbf E}{\partial t}\]

The first two are divergence constraints. The latter two give coupled curl dynamics. For a grid, write the first constraint as a residual rather than pretending finite differences are exact:

\[R_E=\nabla_h\cdot\mathbf E-\frac{\rho}{\varepsilon_0}\]

Here ∇h means the particular discrete operator on your mesh. Similar residuals apply to magnetic divergence and the two curl equations. Report their units and norm; do not compare an unscaled residual from one grid resolution with another without considering cell size and source scaling.

const electricGaussResidual = divergence(electricField, cell) - chargeDensity[cell] / vacuumPermittivity;
const magneticGaussResidual = divergence(magneticField, cell);

Start with fixtures the solver should not struggle to explain. With ρ = 0 and uniform fields, both divergence residuals should be approximately zero. For a source-free analytic plane wave, E and B remain transverse while the curl updates propagate phase. For a symmetric static point-charge approximation, exclude the singular source cell and compare sampled divergence with the deposited charge policy rather than with a continuum delta function you did not represent.

Try this experiment

Prediction: A source-free plane-wave fixture can pass its propagation check while a bad discrete operator still produces a magnetic-divergence residual.

List the four residuals you would log for a wave run. Predict which two should be near zero without sources, then explain why a visual animation cannot substitute for those numbers.

Where this model breaks

The equations and residuals here assume a chosen continuum model and SI vacuum constants. Real materials add constitutive relations, dispersion, polarization, magnetization, conductivity, and nonlinear response. A finite grid adds boundary error, numerical dispersion, source deposition choices, divergence cleaning or constrained transport, and roundoff; no one residual proves all of them are controlled.

Summary

Treat Maxwell’s equations as executable specifications. Name the fields and sources clearly, advance the curl rules, log each divergence and curl residual, and compare source-free and analytic fixtures before trusting a rendered electromagnetic field.

Glossary

Self-check

  1. Which Maxwell constraint should be zero in a source-free magnetic field?
  2. Why should a discrete Gauss-law check be called a residual?
  3. What metadata makes residuals comparable across two runs?

Sources

Model contract

Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.

\[\text{observable output} = f(\text{inputs},\,\text{state})\]
Inputs
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.

Implement the idea as a model

For Maxwell’s Equations Symbolically, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Maxwell’s Equations and EM Waves, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.

Guided experiment

Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.

Where this model breaks

This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.

Summary

Treat Maxwell’s Equations Symbolically as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.

Glossary

  • Input: a measured value or chosen parameter supplied to a model.
  • State: the smallest set of values needed to continue or reproduce a model.
  • Validation: comparing an output with a known result, limit, invariant, or measurement.

Self-check

  1. Which values are inputs, and which values must remain state?
  2. What observable result would tell you the model is behaving as expected?
  3. Which assumption would you test first before applying the model to a real system?

Model review: turn Maxwell’s Equations Symbolically into a test

Use Maxwell constraints as named residuals and test oracles for field-array solvers.

  1. Name the inputs and units that the maxwell’s equations and em waves model needs.
  2. Separate the state you must keep from values you can calculate when needed.
  3. Write one rule that maps the current state and inputs to an observable result.
  4. Choose a limiting case, unit check, invariant, or known result before trusting an output.
  5. State one assumption you would change before using this simplified model for a real decision.

Share to: