Chapter 27
25 min read
Section 233 of 353

Applications: Electromagnetic Waves

The Wave Equation

Learning Objectives

By the end of this section, you will be able to:

  1. Recognize the same wave equation utt=c2uxxu_{tt} = c^{2}\,u_{xx} hiding inside Maxwell's four equations.
  2. Derive the wave equation for the electric and magnetic fields in vacuum starting from Faraday's and Ampère–Maxwell's laws.
  3. Predict the speed of light from two laboratory constants μ0\mu_0 and ε0\varepsilon_0.
  4. Write down a plane-wave solution and check that EBk^E\perp B\perp \hat{k} and E/B=c|E|/|B|=c.
  5. Distinguish linear, circular and elliptical polarization and explain each as a phase relation between two orthogonal components.
  6. Compute the energy density and Poynting vector of a plane wave.
  7. Connect the universal wave equation to radio, fibre-optic communication, medical imaging, and wireless power.

The Big Picture: From Strings to Light

“The agreement of the results seems to show that light and magnetism are affections of the same substance, and that light is an electromagnetic disturbance propagated through the field according to electromagnetic laws.” — James Clerk Maxwell, 1864

For six chapters we have been studying one equation written in many disguises:

2ut2  =  c22ux2\displaystyle \frac{\partial^{2} u}{\partial t^{2}} \;=\; c^{2}\,\frac{\partial^{2} u}{\partial x^{2}}

On a guitar string, uu was the vertical displacement and cc was the wave speed T/ρ\sqrt{T/\rho}. On a drumhead uu was the height of the membrane. In a sound wave it was air pressure. In each case the same shape — a travelling sinusoid — emerged because the second time-derivative of uu balanced a restoring force proportional to the second space-derivative.

In 1864 James Clerk Maxwell discovered that light itself obeys exactly this equation. The displacement uu is replaced by an electric field E\mathbf{E}, the “tension” by the magnetic constant μ0\mu_0, the “density” by the electric constant ε0\varepsilon_0, and the wave speed by

c  =  1μ0ε0    2.998×108m/s.\displaystyle c \;=\; \frac{1}{\sqrt{\mu_0 \varepsilon_0}} \;\approx\; 2.998 \times 10^{8}\,\text{m/s}.
Why this is breathtaking. Nobody put light into Maxwell's theory. The two constants μ0\mu_0 and ε0\varepsilon_0 were measured years earlier in electrostatic and magnetic experiments that had nothing to do with optics — coils, capacitors, currents. Yet plugging them into the wave equation that falls out of the field laws gives, to four digits, the speed that astronomers had measured for light. The universe quietly admitted: “You have just understood what light is.”

Historical Context: Maxwell's Synthesis

Three giants laid the groundwork. Carl Friedrich Gauss formulated the divergence laws relating field flux to enclosed sources. Michael Faraday showed by experiment that a time-varying magnetic field induces an electric field. And André-Marie Ampère related currents to circulating magnetic fields. Each of these laws was beautiful, but they sat beside each other like separate puzzle pieces.

In 1861 Maxwell noticed something subtle: Ampère's law as it stood violated charge conservation when applied to a charging capacitor. To fix it he added a term proportional to the time derivative of the electric field — the famous displacement current. That single correction made the equations internally consistent and, completely unexpectedly, produced a wave equation. The speed of that wave matched Fizeau and Foucault's 1850s measurement of the speed of light. Maxwell wrote, “We can scarcely avoid the inference that light consists in the transverse undulations of the same medium which is the cause of electric and magnetic phenomena.”

Twenty-three years later, in 1887, Heinrich Hertz generated and detected radio waves in his laboratory — the first artificial electromagnetic waves — using a spark gap to launch them and a wire loop to receive them. Within a decade Marconi was sending radio across oceans. The wave equation had become a technology.


The Question That Launched a Revolution

Here is the question we want to answer in this section, framed as concretely as possible:

We already know the wave equation describes vibrations on strings and drums. Does it also describe the propagation of electric and magnetic disturbances through empty space?

The answer is yes, and the proof is almost suspicious in its elegance: the wave equation simply falls out when you take the curl of Faraday's law and substitute the Ampère–Maxwell law into it. There is no force balance, no continuum-mechanics derivation. The mathematics of fields alone is enough.


Maxwell's Equations in Empty Space

Strip away charges and currents (we will study a region of vacuum far from any source). Maxwell's four equations become:

Gauss for E
E  =  0\nabla\cdot\mathbf{E} \;=\; 0

No electric charges to act as sources in vacuum.

Gauss for B
B  =  0\nabla\cdot\mathbf{B} \;=\; 0

No magnetic monopoles — ever, in vacuum or otherwise.

Faraday
×E  =  Bt\nabla\times\mathbf{E} \;=\; -\dfrac{\partial \mathbf{B}}{\partial t}

A changing magnetic field swirls up an electric field.

Ampère–Maxwell
×B  =  μ0ε0Et\nabla\times\mathbf{B} \;=\; \mu_0\varepsilon_0\,\dfrac{\partial \mathbf{E}}{\partial t}

A changing electric field swirls up a magnetic field. Maxwell's displacement-current addition.

Intuition. The last two equations couple E\mathbf{E} and B\mathbf{B} dynamically. A wiggling E creates a B, which then wiggles, which creates an E, which wiggles… This bootstrap is the wave. It travels because each field, in creating the other, hands the disturbance forward in space.

Deriving the Wave Equation for E and B

We can squeeze the wave equation out of Maxwell's equations in about five lines. Take the curl of Faraday's law:

×(×E)  =  t(×B).\displaystyle \nabla\times(\nabla\times\mathbf{E}) \;=\; -\frac{\partial}{\partial t}\bigl(\nabla\times\mathbf{B}\bigr).

Use the vector identity ×(×E)=(E)2E\nabla\times(\nabla\times\mathbf{E}) = \nabla(\nabla\cdot\mathbf{E}) - \nabla^{2}\mathbf{E} on the left, and substitute Ampère–Maxwell on the right:

(E)2E  =  μ0ε02Et2.\displaystyle \nabla(\nabla\cdot\mathbf{E}) - \nabla^{2}\mathbf{E} \;=\; -\mu_0\varepsilon_0\,\frac{\partial^{2}\mathbf{E}}{\partial t^{2}}.

In vacuum E=0\nabla\cdot\mathbf{E}=0, so the first term on the left vanishes. Rearrange:

  2E  =  μ0ε02Et2  \displaystyle \boxed{\;\nabla^{2}\mathbf{E} \;=\; \mu_0\varepsilon_0\,\frac{\partial^{2}\mathbf{E}}{\partial t^{2}}\;}

This is the wave equation, component by component. Each cartesian component of E\mathbf{E} obeys utt=c22uu_{tt} = c^{2}\,\nabla^{2}u with c2=1/(μ0ε0)c^{2} = 1/(\mu_0\varepsilon_0). The same manipulation starting from the curl of Ampère–Maxwell gives the identical equation for B\mathbf{B}.

What we just proved. Maxwell's equations in vacuum force every component of E\mathbf{E} and B\mathbf{B} to satisfy the same wave equation that describes a vibrating string — the only difference is that the wave speed is c=1/μ0ε0c = 1/\sqrt{\mu_0\varepsilon_0} instead of T/ρ\sqrt{T/\rho}.

The Speed Emerges: c = 1/√(μ₀ε₀)

Let's actually compute the number. The two constants were already known in the lab decades before Maxwell:

ConstantValueWhat measured it
μ₀ (permeability)4π × 10⁻⁷ H/mForce between two parallel current-carrying wires (Ampère)
ε₀ (permittivity)8.854 × 10⁻¹² F/mCapacitance of a parallel-plate capacitor (Cavendish, Kohlrausch–Weber)

Compute:

c  =  1(4π×107)(8.854×1012)  =  2.998×108  m/s.\displaystyle c \;=\; \frac{1}{\sqrt{(4\pi\times10^{-7})(8.854\times10^{-12})}} \;=\; 2.998\times 10^{8}\;\text{m/s}.

That number — to four digits — is the speed of light measured by Fizeau in 1849 with a rotating toothed wheel: 3.13 × 10⁸ m/s. Use the slider below to see how the speed changes when you replace vacuum by a material with different relative permittivity and permeability.

Loading speed-of-light calculator…
The refractive index n. For most transparent materials μr1\mu_r \approx 1 so cmedium=c/εrc_\text{medium} = c/\sqrt{\varepsilon_r}. The ratio n=μrεrn = \sqrt{\mu_r\varepsilon_r} is called the refractive index — exactly the number Snell's law uses for refraction. Water has εr1.77\varepsilon_r \approx 1.77 for visible light, giving n1.33n \approx 1.33. Diamond has n2.4n \approx 2.4, which is why it sparkles — light slows so dramatically inside it that total internal reflection is easy.

Plane Waves: The Simplest Solution

D'Alembert taught us that any function of xctx - ct solves the 1D wave equation. The simplest interesting choice is a sinusoid:

E(x,t)=E0y^cos(kxωt),B(x,t)=E0cz^cos(kxωt).\displaystyle \mathbf{E}(x,t) = E_0\,\hat{\mathbf{y}}\,\cos(kx - \omega t),\qquad \mathbf{B}(x,t) = \tfrac{E_0}{c}\,\hat{\mathbf{z}}\,\cos(kx - \omega t).

Substitute into Ett=c2ExxE_{tt} = c^{2} E_{xx}:

ω2cos()  =  c2k2cos()ω=ck.\displaystyle -\omega^{2}\cos(\cdot) \;=\; -c^{2} k^{2}\cos(\cdot) \quad\Longrightarrow\quad \omega = c\,k.

The wave equation enforces a relationship between frequency and wave number — the dispersion relation. In vacuum every plane wave moves at the same speed cc, regardless of wavelength. (In a medium with frequency-dependent ε\varepsilon — like glass — different colors travel at different speeds. That is what splits white light into a rainbow.)

Three relations always hold for a vacuum plane wave:

  • Phase speed: vp=ω/k=cv_p = \omega/k = c.
  • Field amplitudes: E/B=c|\mathbf{E}|/|\mathbf{B}| = c.
  • Geometry: E\mathbf{E}, B\mathbf{B}, and the propagation direction k^\hat{\mathbf{k}} form a right-handed triad — k^=E^×B^\hat{\mathbf{k}} = \hat{\mathbf{E}}\times\hat{\mathbf{B}}.

Visualizing the Coupled E–B Wave

Slide the wavelength and amplitude controls below. Notice that the crests of E\mathbf{E} (orange) line up perfectly with the crests of B\mathbf{B} (cyan) — they are in phase, not 90° apart as you might guess from inductor/capacitor intuition. They oscillate at right angles to each other and both perpendicular to the direction of travel: a textbook transverse wave.

Loading EM wave visualization…
Why in phase, not out of phase? Take Ey=E0cos(kxωt)E_y = E_0\cos(kx-\omega t). Faraday says xEy=tBz\partial_x E_y = -\partial_t B_z, so kE0sin()=(ω)B0sin()-kE_0\sin(\cdot) = -(-\omega)B_0\sin(\cdot), giving B0=(k/ω)E0=E0/cB_0 = (k/\omega)E_0 = E_0/c and the same phase. Energy is sloshing back and forth between the electric and magnetic forms only spatially — at each point it is 50/50.

Polarization: The Tip of E Draws a Curve

Because E\mathbf{E} is perpendicular to the propagation direction, it has two independent components in the transverse plane — say EyE_y and EzE_z. The full electric field of a plane wave is:

E=Aycos(kxωt)y^  +  Azcos(kxωt+δ)z^.\displaystyle \mathbf{E} = A_y\cos(kx-\omega t)\hat{\mathbf{y}} \;+\; A_z\cos(kx-\omega t + \delta)\hat{\mathbf{z}}.

The two amplitudes Ay,AzA_y, A_z and the relative phase δ\delta are three free numbers. They decide the polarization state — the curve the tip of E\mathbf{E} traces when you look along the propagation direction.

PolarizationA_yA_zδTip trace
Linear (vertical)10Vertical line
Linear (horizontal)01Horizontal line
Linear (45°)110Diagonal line
Right circular11+90°Circle (clockwise from source)
Left circular11−90°Circle (counter-clockwise)
EllipticalanyanyanyEllipse

Use the explorer to feel the relationship. Pick a preset, then drag the amplitudes and phase to interpolate between states.

Loading polarization explorer…
Why polarization matters. Polaroid sunglasses block the horizontal component of glare. Liquid-crystal displays twist the polarization angle electrically to make pixels go bright or dark. Radio telescopes measure the polarization of light from magnetized cosmic plasmas to reconstruct interstellar magnetic fields. And 3D cinemas project the two stereoscopic images with opposite circular polarizations — your glasses filter one image to each eye.

Energy and the Poynting Vector

An EM wave carries energy. The instantaneous energy density (in J/m³) is the sum of an electric and a magnetic contribution:

u  =  12ε0E2+12μ0B2.\displaystyle u \;=\; \tfrac{1}{2}\varepsilon_0 |\mathbf{E}|^{2} + \tfrac{1}{2\mu_0}|\mathbf{B}|^{2}.

For a plane wave with B=E/c|\mathbf{B}| = |\mathbf{E}|/c, the two terms are equal — the wave splits energy 50/50 between electric and magnetic forms.

Energy flows in the direction of propagation at speed cc. The flow per unit area is the Poynting vector:

S  =  1μ0E×B[W/m2].\displaystyle \mathbf{S} \;=\; \tfrac{1}{\mu_0}\,\mathbf{E}\times\mathbf{B} \qquad \text{[W/m}^{2}\text{]}.

The right-hand rule on E×B\mathbf{E}\times\mathbf{B} always points along k^\hat{\mathbf{k}} — the direction the wave is going. Time-averaging over one cycle for a sinusoidal plane wave gives the convenient form S=12ε0cE02\langle S\rangle = \tfrac{1}{2}\varepsilon_0 c\,E_0^{2}. The sun delivers about 1361 W/m21361~\text{W/m}^{2} of S\langle S\rangle at the top of Earth's atmosphere — the “solar constant”.


The Electromagnetic Spectrum

The wave equation has no preferred frequency — only the dispersion relation ω=ck\omega = ck. So solutions exist at every wavelength, from kilometres-long radio waves to femtometre-short gamma rays. They are all the same kind of object; the labels (“radio”, “visible”, “X-ray”) only reflect how we generate, detect, and use them.

Loading EM spectrum…

Worked Example: Plane Wave at 1 GHz

Work this through with pen and paper before you peek at the solution. It pulls together every formula in the section.

A 1 GHz plane wave with E₀ = 10 V/m propagates in vacuum. Compute λ, B₀, the time period T, the wavenumber k, the intensity ⟨S⟩, and the photon energy at that frequency. Click to expand the solution.

Step 1 — wavelength. Using c=fλc = f\lambda:

λ  =  cf  =  2.998×1081×109  =  0.2998  m    30  cm.\lambda \;=\; \frac{c}{f} \;=\; \frac{2.998\times 10^{8}}{1\times 10^{9}} \;=\; 0.2998\;\text{m}\;\approx\;30\;\text{cm}.

(That is why cell-phone antennas are a few centimetres long — they are tuned to a fraction of this wavelength.)

Step 2 — magnetic amplitude. B0=E0/cB_0 = E_0/c:

B0  =  102.998×108    3.34×108  T.B_0 \;=\; \frac{10}{2.998\times 10^{8}} \;\approx\; 3.34\times 10^{-8}\;\text{T}.

Compare to Earth's magnetic field (≈ 5 × 10⁻⁵ T). The EM wave's magnetic component is a thousand times weaker — yet this is the field your phone's antenna detects.

Step 3 — period and wavenumber.

T  =  1/f  =  1  ns,k  =  2π/λ    20.96  rad/m.T \;=\; 1/f \;=\; 1\;\text{ns},\qquad k \;=\; 2\pi/\lambda \;\approx\; 20.96\;\text{rad/m}.

Step 4 — time-averaged intensity.

S  =  12ε0cE02  =  12(8.854×1012)(2.998×108)(10)2    0.133  W/m2.\langle S\rangle \;=\; \tfrac{1}{2}\varepsilon_0 c\,E_0^{2} \;=\; \tfrac{1}{2}(8.854\times 10^{-12})(2.998\times 10^{8})(10)^{2} \;\approx\; 0.133\;\text{W/m}^{2}.

One-tenth of a watt per square metre — about 0.01% of the solar constant. That is roughly the field strength close to a high-power Wi-Fi router.

Step 5 — photon energy. Quantum mechanics says each photon carries Eγ=hfE_{\gamma} = hf with h=6.626×1034J\cdotpsh = 6.626\times 10^{-34}\,\text{J·s}:

Eγ  =  (6.626×1034)(1×109)    6.6×1025  J    4.1  μeV.E_{\gamma} \;=\; (6.626\times 10^{-34})(1\times 10^{9}) \;\approx\; 6.6\times 10^{-25}\;\text{J} \;\approx\; 4.1\;\mu\text{eV}.

For comparison: a visible-light photon carries about 22 eV — five hundred million times more. That is why visible light can kick electrons out of atoms (photoelectric effect) while radio waves cannot.

Sanity check. Multiply fλ=(109)(0.2998)=2.998×108=cf \cdot \lambda = (10^{9})(0.2998) = 2.998\times 10^{8} = c. Every column passes the consistency test.


Python Implementation

Now let's confirm the entire chain numerically. We will construct a plane wave by hand, plot E and B side by side, and use finite differences to check that 2E/t2\partial^{2}E/\partial t^{2} really equals c22E/x2c^{2}\,\partial^{2}E/\partial x^{2} at every grid point.

Plane wave verification: from μ₀, ε₀ to c
🐍em_plane_wave.py
4Vacuum permeability μ₀

μ₀ = 4π × 10⁻⁷ H/m is the magnetic constant of free space. Historically it was a defined constant of the SI system (until 2019). It quantifies how much magnetic flux a current generates in vacuum and appears in Ampère–Maxwell's law.

EXECUTION STATE
mu0 = 1.2566 × 10⁻⁶ H/m
5Vacuum permittivity ε₀

ε₀ ≈ 8.854 × 10⁻¹² F/m is the electric constant. It controls the strength of the Coulomb force in vacuum (F = q₁q₂/(4πε₀r²)) and appears in Gauss's law for E.

EXECUTION STATE
eps0 = 8.854 × 10⁻¹² F/m
6The speed of light pops out

The wave equation forces c² = 1/(μ₀ε₀). Plug the two constants in and you get exactly the measured speed of light. Maxwell computed this in 1862 and remarked: 'we can scarcely avoid the inference that light consists in the transverse undulations of the same medium which is the cause of electric and magnetic phenomena.'

EXECUTION STATE
c = 2.998 × 10⁸ m/s
15Amplitude E₀

E₀ is the peak electric-field strength of the wave. Real-world values range from microvolts/meter (faint radio) to GV/m (intense laser focal spots). We use 1 V/m as a normalized reference.

16Wavelength λ

λ = 0.6 m is in the radio band — comparable to a FM antenna. Visible light has λ ≈ 5 × 10⁻⁷ m (about a million times shorter). The wave equation does not care which: every wavelength travels at the same c.

17Wave number k

k = 2π/λ tells you how many radians of phase fit into one meter of space. For λ = 0.6 m, k ≈ 10.47 rad/m. It is the spatial analogue of angular frequency ω.

EXECUTION STATE
k = ≈ 10.47 rad/m
18Dispersion relation ω = ck

Substituting cos(kx − ωt) into u_tt = c² u_xx gives −ω² = −c²k², i.e. ω/k = c. This is the dispersion relation of light in vacuum: every plane wave moves at speed c regardless of its frequency. (In a medium with μ or ε different from vacuum, ω/k = c/n where n = √(μᵣεᵣ) is the refractive index, and now different colors can move at different speeds — that is how a prism makes rainbows.)

EXECUTION STATE
omega = ≈ 3.14 × 10⁹ rad/s
freq = ≈ 500 MHz
22Discrete spatial grid

We cover two full wavelengths with 400 points so each wavelength gets 200 samples — comfortably above the Nyquist limit. dx ≈ 3 × 10⁻³ m.

24CFL-safe time step

For numerical stability of any explicit wave-equation solver we need dt ≤ dx/c (the Courant condition you met in §27.5). We use dt = 0.5 · dx/c — well inside the stable region.

30E along y, B along z

We pick a convention: the wave propagates along x, E oscillates along y, B oscillates along z. Faraday's law forces (E, B, k̂) to be a right-handed triple, and the wave equation forces them in phase.

31Magnetic amplitude B₀ = E₀ / c

From Faraday's law applied to a plane wave you get |E| = c |B|. So if E₀ = 1 V/m then B₀ = 1/c ≈ 3.34 × 10⁻⁹ T — tiny in everyday units but completely sufficient to carry the wave.

EXECUTION STATE
B0 = 3.336 × 10⁻⁹ T
35Central-difference second derivative

We approximate ∂²u/∂x² with the classical three-point stencil (u(x+dx) − 2u(x) + u(x−dx))/dx² — accurate to O(dx²). The endpoints are left at zero because they require a stencil that reaches beyond the grid.

40u(x, t₀ − dt) and u(x, t₀ + dt)

We sample the analytic solution at three adjacent times so we can build a central-difference estimate of ∂²u/∂t² and compare it against c² · ∂²u/∂x². If our plane wave really satisfies the wave equation, the two should match to machine epsilon plus a small truncation error.

44The residual

If E(x, t) = E₀ cos(kx − ωt) is genuinely a solution, residual = u_tt − c² u_xx should be near zero everywhere except at the boundaries (where the stencil is undefined). For our parameters the residual is < 10⁻⁵ relative — that is a numerical proof that the plane wave satisfies Maxwell's equations.

50Top plot: E and c·B coincide

We overlay E_y and c·B_z. They sit exactly on top of each other — visible proof that |E|/|B| = c and that the two fields are in phase, not out of phase. A node in E is a node in B, and the same goes for crests.

56Bottom plot: ∂²E/∂t² and c²·∂²E/∂x²

The wave-equation check. Two curves are drawn — the time second derivative and the scaled space second derivative — and they overlap perfectly. This is the modern equivalent of Maxwell's pen-and-paper derivation, computed with finite differences instead of algebra.

61 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
3
4# Fundamental constants
5mu0  = 4 * np.pi * 1e-7        # vacuum permeability  [H/m]
6eps0 = 8.854187817e-12         # vacuum permittivity  [F/m]
7c    = 1.0 / np.sqrt(mu0 * eps0)   # predicted speed of light [m/s]
8
9print(f"c (from Maxwell) = {c:.6e} m/s")
10print(f"c (measured)     = 2.997924e+08 m/s")
11
12# A plane wave traveling in +x with E along y
13#   E_y(x, t) = E0 * cos(k x - omega t)
14#   B_z(x, t) = (E0 / c) * cos(k x - omega t)
15
16E0     = 1.0                    # amplitude of E [V/m]
17lam    = 0.6                    # wavelength [m]   -> radio range
18k      = 2 * np.pi / lam        # wave number  [rad/m]
19omega  = c * k                  # dispersion relation: omega/k = c
20freq   = omega / (2 * np.pi)    # ordinary frequency [Hz]
21
22# Discrete grid
23x  = np.linspace(0.0, 2.0 * lam, 400)
24dx = x[1] - x[0]
25dt = 0.5 * dx / c               # well inside the CFL limit (dt < dx/c)
26t_grid = np.arange(0.0, 5e-9, dt)   # 5 nanoseconds total
27
28# Snapshot the wave at a single time
29t0  = 1e-9                      # 1 ns
30Ey  = E0 * np.cos(k * x - omega * t0)
31Bz  = (E0 / c) * np.cos(k * x - omega * t0)
32
33# ── Verify the wave equation numerically: u_tt = c^2 u_xx ──────────
34def second_derivative_x(u, dx):
35    """Central difference for d^2 u / dx^2 on a 1D grid."""
36    d2u = np.zeros_like(u)
37    d2u[1:-1] = (u[2:] - 2 * u[1:-1] + u[:-2]) / dx**2
38    return d2u
39
40# Take a tiny time step to estimate u_tt by finite differences
41Ey_minus = E0 * np.cos(k * x - omega * (t0 - dt))
42Ey_plus  = E0 * np.cos(k * x - omega * (t0 + dt))
43
44u_tt = (Ey_plus - 2 * Ey + Ey_minus) / dt**2
45u_xx = second_derivative_x(Ey, dx)
46
47residual = u_tt - c**2 * u_xx
48print(f"max |u_tt - c^2 u_xx| = {np.max(np.abs(residual[2:-2])):.3e}")
49
50# Side-by-side plots
51fig, axes = plt.subplots(2, 1, figsize=(10, 6), sharex=True)
52
53axes[0].plot(x, Ey, color="#f97316", linewidth=2, label="E_y(x, t)")
54axes[0].plot(x, Bz * c, color="#06b6d4", linewidth=2,
55             linestyle="--", label="c · B_z(x, t)")
56axes[0].axhline(0, color="#94a3b8", linewidth=0.5)
57axes[0].set_ylabel("Field amplitude")
58axes[0].set_title(f"Plane wave at t = {t0*1e9:.1f} ns, λ = {lam} m")
59axes[0].legend(loc="upper right")
60axes[0].grid(True, alpha=0.3)
61
62axes[1].plot(x, c**2 * u_xx, color="#22c55e", linewidth=2,
63             label="c² ∂²E/∂x²")
64axes[1].plot(x, u_tt, color="#a855f7", linewidth=2, linestyle="--",
65             label="∂²E/∂t²")
66axes[1].set_xlabel("position x [m]")
67axes[1].set_ylabel("second derivative")
68axes[1].set_title("Wave equation check (curves should coincide)")
69axes[1].legend(loc="upper right")
70axes[1].grid(True, alpha=0.3)
71
72plt.tight_layout()
73plt.show()
74
75# Print frequency and time period
76print(f"\nλ = {lam} m,  f = {freq/1e6:.3f} MHz,  T = {1/freq*1e9:.3f} ns")
77print(f"E0 / B0 = c = {E0 / (E0/c):.6e} m/s  (ratio always = c)")
What just happened. We never told the computer anything about light. We told it the values of two laboratory constants and the form E0cos(kxωt)E_0\cos(kx-\omega t). The wave equation check came out clean — proof in code of Maxwell's 1864 result.

PyTorch Implementation

Finite differences are nice, but they leak truncation error. Let's use automatic differentiation to compute the second derivatives exactly. PyTorch's autograd treats every operation as a node in a graph, applies the chain rule symbolically, and gives us results down to machine epsilon.

Autograd verification of the EM wave equation
🐍em_autograd_check.py
5Constants — same as Python version

We re-import the same μ₀, ε₀, c so the PyTorch trace is directly comparable to the NumPy one above. Notice the dispersion relation ω = ck is hard-coded — the only way a cos(kx − ωt) plane wave satisfies the wave equation.

13E(x, t) as a pure torch function

Wrapping the plane wave in a function with PyTorch tensors as inputs makes it differentiable. Every operation on x and t — multiplication, subtraction, cos — is tracked in the autograd graph so we can ask the framework for ∂E/∂x and ∂E/∂t exactly, with no finite differences at all.

17x and t need requires_grad=True

PyTorch only differentiates with respect to tensors that explicitly opt in. We pick a single spacetime sample (x = 0.2 m, t = 1 ns) and mark both axes as variables we want gradients for.

EXECUTION STATE
x = 0.2 (requires_grad)
t = 1.0e-9 (requires_grad)
20u = E(x, t) — forward pass

Evaluating the wave at that point. The result depends on x and t through a chain of differentiable operations, so the autograd graph captures the dependency.

23torch.autograd.grad with create_graph=True

We ask for ∂u/∂x and ∂u/∂t in one call. create_graph=True keeps the graph alive so we can differentiate those gradients again — that is what lets us go to second order. Without it the next grad call would crash.

29Second derivatives

Each second derivative is one more autograd.grad call on the corresponding first derivative. The result is exact — no finite-difference truncation error — because PyTorch knows the analytic chain rule for cos, multiplication, and subtraction.

EXECUTION STATE
d2u_dx2 = -k² · cos(kx − ωt)
d2u_dt2 = -ω² · cos(kx − ωt)
33The residual u_tt − c²·u_xx

Algebraically this is (−ω² + c²k²) · cos(kx − ωt). Because ω = ck this collapses to zero exactly. PyTorch confirms this to machine epsilon — typically ~10⁻²² in float64. This is autograd doing Maxwell's derivation for us.

40Recovering c from the ratio

If the wave satisfies u_tt = c² u_xx, then dividing the two derivatives gives c². Taking the square root recovers c itself — extracted from autograd output alone. It is the same number we plugged in for the dispersion relation, closing the loop.

37 lines without explanation
1import torch
2import math
3
4# Constants
5mu0  = 4 * math.pi * 1e-7
6eps0 = 8.854187817e-12
7c    = 1.0 / math.sqrt(mu0 * eps0)
8
9# Plane-wave parameters
10lam   = 0.6                         # wavelength [m]
11k     = 2 * math.pi / lam           # wave number
12omega = c * k                       # dispersion relation
13
14def E(x, t):
15    """Plane-wave E component: E_y(x, t) = cos(k x - omega t)."""
16    return torch.cos(k * x - omega * t)
17
18# Pick a point in spacetime where we will check the wave equation
19x = torch.tensor(0.2, requires_grad=True)
20t = torch.tensor(1e-9, requires_grad=True)
21
22u = E(x, t)
23
24# First derivatives (held in the graph for further differentiation)
25du_dx, du_dt = torch.autograd.grad(
26    outputs=u, inputs=(x, t),
27    create_graph=True,
28)
29
30# Second derivatives
31d2u_dx2 = torch.autograd.grad(du_dx, x, create_graph=True)[0]
32d2u_dt2 = torch.autograd.grad(du_dt, t, create_graph=True)[0]
33
34# Wave-equation residual:  u_tt - c^2 u_xx  should be 0
35residual = d2u_dt2 - c**2 * d2u_dx2
36
37print(f"u            = {u.item():.6e}")
38print(f"u_xx         = {d2u_dx2.item():.6e}")
39print(f"u_tt         = {d2u_dt2.item():.6e}")
40print(f"c^2 u_xx     = {(c**2 * d2u_dx2).item():.6e}")
41print(f"residual     = {residual.item():.3e}    (≈ 0 means the wave eq. holds)")
42
43# ── Symbolic identity: u_tt + c^2 u_xx = 0 for cos(kx-omega t) iff omega = c k
44ratio = (-d2u_dt2 / d2u_dx2).sqrt()
45print(f"sqrt(-u_tt / u_xx) = {ratio.item():.6e}  =  c = {c:.6e}")
This is a microcosm of physics-informed neural networks (PINNs). PINNs use exactly this trick — autograd second derivatives on a neural network uθ(x,t)u_{\theta}(x,t) — to enforce that the network satisfies a PDE like Maxwell's. You have just written a one-line PINN residual.

Applications

Radio & Wireless

AM/FM radio, television, Wi-Fi, 5G, GPS, Bluetooth all use the same wave equation — only the frequency changes. Antenna length is tuned to roughly λ/4\lambda/4 to maximize radiation efficiency.

Fibre-Optic Internet

Light pulses bounce down silica fibres by total internal reflection. Modern fibres carry terabits per second across oceans — every byte you read travels as an EM wave guided by Snell's law, which itself follows from c/nc/n.

Medical Imaging

X-rays (high-frequency EM waves) for radiography, MRI (RF EM pulses driving nuclear-spin Larmor precession), optical coherence tomography (near-infrared interferometry of tissue).

Astronomy

Every photon from a distant galaxy is a plane wave segment that travelled billions of years through vacuum at exactly cc. Spectroscopy, redshift, the cosmic microwave background — all read from the EM wave equation.

Wireless Power

Inductive charging pads, RFID tags, and proposed solar power-from-orbit systems all transfer energy via Poynting flux — E×B/μ0\mathbf{E}\times\mathbf{B}/\mu_0.

Machine Learning / EM Simulation

FDTD (finite-difference time-domain) solvers based on the wave equation design antennas, photonic chips, and radar-cross-section of stealth aircraft. Learned PDE solvers (Fourier neural operators) are now approximating these solutions 1000× faster than classical methods.


Common Pitfalls

Pitfall 1 — E and B are not 90° out of phase. They oscillate at right angles in space but in phase in time. The intuition that “magnetic is the derivative of electric” from RLC circuits does not apply to free-space radiation.
Pitfall 2 — Forgetting that c depends on the medium.Inside glass, water, or any dielectric, light slows to c/nc/n. But its frequency stays the same — only the wavelength shrinks. That is why a stick in water looks bent: refraction comes from the change in phase speed at the boundary.
Pitfall 3 — Treating polarization as a property of the photon, not the field. Polarization is a phase relation between two orthogonal field components — it lives in the full classical wave. Single photons inherit it through quantum superposition, but the statement “a photon is polarized vertically” is shorthand for “the electric field of the wave is pointing vertically when the photon hits.”
Pitfall 4 — Confusing energy density with intensity.Energy density uu has units J/m³ (energy per volume). Intensity S\langle S\rangle has units W/m² (power per area). They're related by S=cu\langle S\rangle = c\,\langle u\rangle — energy density times the speed at which it streams past you.
Pitfall 5 — Thinking the speed of light requires a medium. Mechanical waves need a substance to vibrate in. EM waves don't — they propagate through pure vacuum because the coupling is between two fields that exist independently of any material. This is why Michelson and Morley failed to find the “luminiferous aether”: there is none.

Test Your Understanding

Five quick questions to check the intuition. Tap an answer to see the explanation.

Loading quiz…

Summary

We took the universal wave equation utt=c2uxxu_{tt} = c^{2}\,u_{xx} — the same one that governs strings and drums — and showed that Maxwell's four field equations, applied in vacuum, force both E\mathbf{E} and B\mathbf{B} to obey it with wave speed

c  =  1μ0ε0    2.998×108  m/s.\displaystyle c \;=\; \frac{1}{\sqrt{\mu_0\varepsilon_0}} \;\approx\; 2.998\times 10^{8}\;\text{m/s}.

Three lessons to carry forward:

  1. Universality. The wave equation is not about strings or drums or light — it is the mathematical signature of any system where a restoring response is proportional to spatial curvature. Recognizing it lets you import every tool you have built (D'Alembert solution, separation of variables, normal modes, Fourier series, finite differences, autograd) directly into a new physical domain.
  2. Light is not special. It is just the EM solution at frequencies that happen to interact with the rods and cones in our eyes. Radio waves, microwaves, X-rays, and gamma rays are the same kind of object obeying the same wave equation.
  3. From two lab constants, the speed of light. The number c=1/μ0ε0c = 1/\sqrt{\mu_0\varepsilon_0} is the most spectacular “unintended consequence” in the history of physics: two pieces of static-electricity bookkeeping combine to predict the speed of light to four-digit accuracy.
What comes next. In §27.8 we apply the same wave equation to seismic waves — the elastic disturbances that propagate through the Earth's crust during an earthquake. Two species of wave (P and S) appear, with different speeds — and the time delay between them lets seismologists locate epicentres from a single station. Same equation, different medium, life-saving application.
Loading comments...