# Electromagnetism — Maxwell's Equations Explained

> Master Maxwell's equations with clear explanations, KaTeX notation, and Mermaid diagrams. Learn Gauss's law, Faraday's law, and electromagnetic wave theory.

## Introduction

Maxwell's equations are the foundation of classical electromagnetism, describing how electric and magnetic fields are generated and interact. These four elegant equations unify electricity, magnetism, and optics into a single theoretical framework.

This guide covers Maxwell's equations in both integral and differential forms, explains their physical meaning, and shows how to document electromagnetic concepts effectively using KaTeX and Mermaid diagrams.

> **Prerequisites:** This guide assumes familiarity with vector calculus (gradient, divergence, curl) and basic KaTeX syntax. See our [Calculus in Technical Documentation](/docs/math/calculus/calculus-technical-docs) guide for vector calculus notation.

## Maxwell's Equations Overview

Maxwell's equations consist of four fundamental laws that describe all classical electromagnetic phenomena. Here they are in their most common differential form:

```markdown

**Maxwell's Equations in Differential Form**

**1. Gauss's Law for Electricity**
$$
\\nabla \\cdot \\vec{E} = \\frac{\\rho}{\\varepsilon_0}
$$

**2. Gauss's Law for Magnetism**
$$
\\nabla \\cdot \\vec{B} = 0
$$

**3. Faraday's Law of Induction**
$$
\\nabla \\times \\vec{E} = -\\frac{\\partial \\vec{B}}{\\partial t}
$$

**4. Ampère-Maxwell Law**
$$
\\nabla \\times \\vec{B} = \\mu_0 \\vec{J} + \\mu_0 \\varepsilon_0 \\frac{\\partial \\vec{E}}{\\partial t}
$$

```

### Key Symbols

```markdown

| Symbol | Meaning | SI Unit |
|:------:|:--------|:--------|
| $\\vec{E}$ | Electric field | V/m |
| $\\vec{B}$ | Magnetic field | T (Tesla) |
| $\\rho$ | Charge density | C/m³ |
| $\\vec{J}$ | Current density | A/m² |
| $\\varepsilon_0$ | Permittivity of free space | F/m |
| $\\mu_0$ | Permeability of free space | H/m |
| $c$ | Speed of light | m/s |

**Fundamental constants**:
$$
\\varepsilon_0 \\approx 8.854 \\times 10^{-12} \\text{ F/m}
$$

$$
\\mu_0 = 4\\pi \\times 10^{-7} \\text{ H/m}
$$

$$
c = \\frac{1}{\\sqrt{\\mu_0 \\varepsilon_0}} \\approx 3 \\times 10^8 \\text{ m/s}
$$

```

## Gauss's Law for Electricity

Gauss's law relates the electric field to the charge distribution that creates it. It states that the electric flux through any closed surface is proportional to the enclosed charge.

```markdown

**Differential Form**:
$$
\\nabla \\cdot \\vec{E} = \\frac{\\rho}{\\varepsilon_0}
$$

**Integral Form**:
$$
\\oint_S \\vec{E} \\cdot d\\vec{A} = \\frac{Q_{\\text{enc}}}{\\varepsilon_0}
$$

**Physical Meaning**: Electric field lines originate from positive charges and terminate on negative charges. The divergence of $\\vec{E}$ is non-zero only where charges exist.

**Example - Point Charge**:

For a point charge $q$ at the origin:
$$
\\vec{E} = \\frac{q}{4\\pi\\varepsilon_0 r^2} \\hat{r}
$$

Using a spherical Gaussian surface of radius $r$:
$$
\\oint_S \\vec{E} \\cdot d\\vec{A} = E \\cdot 4\\pi r^2 = \\frac{q}{\\varepsilon_0}
$$

```

```markdown

\`\`\`mermaid
flowchart TB
    subgraph "Electric Field from Point Charge"
        Q(("+q"))
        Q --> E1["→"]
        Q --> E2["↗"]
        Q --> E3["↑"]
        Q --> E4["↖"]
        Q --> E5["←"]
        Q --> E6["↙"]
        Q --> E7["↓"]
        Q --> E8["↘"]
    end
    
    style Q fill:#f59e0b,stroke:#d97706,color:#fff
\`\`\`

```

## Gauss's Law for Magnetism

Gauss's law for magnetism states that there are no magnetic monopoles—magnetic field lines always form closed loops. The net magnetic flux through any closed surface is zero.

```markdown

**Differential Form**:
$$
\\nabla \\cdot \\vec{B} = 0
$$

**Integral Form**:
$$
\\oint_S \\vec{B} \\cdot d\\vec{A} = 0
$$

**Physical Meaning**: Unlike electric field lines, magnetic field lines have no beginning or end. They always form closed loops. There are no isolated magnetic "charges" (monopoles).

**Consequence**: If you cut a bar magnet in half, you get two smaller magnets, each with both a north and south pole—never an isolated pole.

**Mathematical Implication**:
$$
\\vec{B} = \\nabla \\times \\vec{A}
$$

where $\\vec{A}$ is the magnetic vector potential. Since the divergence of a curl is always zero:
$$
\\nabla \\cdot (\\nabla \\times \\vec{A}) = 0
$$

```

## Faraday's Law of Induction

Faraday's law describes how a changing magnetic field creates an electric field. This is the principle behind electric generators, transformers, and inductors.

```markdown

**Differential Form**:
$$
\\nabla \\times \\vec{E} = -\\frac{\\partial \\vec{B}}{\\partial t}
$$

**Integral Form**:
$$
\\oint_C \\vec{E} \\cdot d\\vec{l} = -\\frac{d\\Phi_B}{dt}
$$

where the magnetic flux is:
$$
\\Phi_B = \\int_S \\vec{B} \\cdot d\\vec{A}
$$

**Physical Meaning**: A time-varying magnetic field induces a circulating electric field. The negative sign (Lenz's law) indicates the induced field opposes the change in flux.

**EMF in a Loop**:
$$
\\mathcal{E} = -\\frac{d\\Phi_B}{dt} = -\\frac{d}{dt}\\int_S \\vec{B} \\cdot d\\vec{A}
$$

**Example - Rotating Loop**:

For a loop of area $A$ rotating with angular velocity $\\omega$ in a uniform field $B$:
$$
\\Phi_B = BA\\cos(\\omega t)
$$

$$
\\mathcal{E} = BA\\omega\\sin(\\omega t)
$$

```

## Ampère-Maxwell Law

The Ampère-Maxwell law describes how magnetic fields are generated by electric currents and changing electric fields. Maxwell's crucial addition of the displacement current term completed the equations and predicted electromagnetic waves.

```markdown

**Differential Form**:
$$
\\nabla \\times \\vec{B} = \\mu_0 \\vec{J} + \\mu_0 \\varepsilon_0 \\frac{\\partial \\vec{E}}{\\partial t}
$$

**Integral Form**:
$$
\\oint_C \\vec{B} \\cdot d\\vec{l} = \\mu_0 I_{\\text{enc}} + \\mu_0 \\varepsilon_0 \\frac{d\\Phi_E}{dt}
$$

**Two Source Terms**:

1. **Conduction current**: $\\mu_0 \\vec{J}$ — moving charges create magnetic fields

2. **Displacement current**: $\\mu_0 \\varepsilon_0 \\frac{\\partial \\vec{E}}{\\partial t}$ — changing electric fields create magnetic fields

**Physical Meaning**: Magnetic field lines circulate around both electric currents and regions where the electric field is changing.

**Example - Long Straight Wire**:

For current $I$ in a long wire:
$$
\\oint_C \\vec{B} \\cdot d\\vec{l} = B \\cdot 2\\pi r = \\mu_0 I
$$

$$
B = \\frac{\\mu_0 I}{2\\pi r}
$$

```

> **Maxwell's Key Insight:** Maxwell added the displacement current term $\varepsilon_0 \frac{'{\\partial \\vec{E}}{\\partial t}'}$, which was not in Ampère's original law. This term ensures charge conservation and, crucially, predicts that changing electric fields produce magnetic fields—enabling electromagnetic waves to propagate through empty space.

## Electromagnetic Waves

Maxwell's equations predict the existence of electromagnetic waves—self-propagating oscillations of electric and magnetic fields. This was one of the greatest theoretical predictions in physics.

```markdown

**In Free Space** (no charges or currents):
$$
\\nabla \\cdot \\vec{E} = 0, \\quad \\nabla \\cdot \\vec{B} = 0
$$

$$
\\nabla \\times \\vec{E} = -\\frac{\\partial \\vec{B}}{\\partial t}, \\quad \\nabla \\times \\vec{B} = \\mu_0 \\varepsilon_0 \\frac{\\partial \\vec{E}}{\\partial t}
$$

**Derivation**:

Take the curl of Faraday's law:
$$
\\nabla \\times (\\nabla \\times \\vec{E}) = -\\frac{\\partial}{\\partial t}(\\nabla \\times \\vec{B})
$$

Using the vector identity $\\nabla \\times (\\nabla \\times \\vec{E}) = \\nabla(\\nabla \\cdot \\vec{E}) - \\nabla^2 \\vec{E}$:
$$
-\\nabla^2 \\vec{E} = -\\mu_0 \\varepsilon_0 \\frac{\\partial^2 \\vec{E}}{\\partial t^2}
$$

**Wave Equation**:
$$
\\nabla^2 \\vec{E} = \\mu_0 \\varepsilon_0 \\frac{\\partial^2 \\vec{E}}{\\partial t^2}
$$

**Wave Speed**:
$$
c = \\frac{1}{\\sqrt{\\mu_0 \\varepsilon_0}} = 299,792,458 \\text{ m/s}
$$

```

```markdown

**Plane Wave Solution**:

For a wave propagating in the $z$-direction:
$$
\\vec{E} = E_0 \\cos(kz - \\omega t) \\hat{x}
$$

$$
\\vec{B} = B_0 \\cos(kz - \\omega t) \\hat{y}
$$

**Wave Parameters**:
- Wave number: $k = \\frac{2\\pi}{\\lambda}$
- Angular frequency: $\\omega = 2\\pi f$
- Phase velocity: $c = \\frac{\\omega}{k} = f\\lambda$

**Field Relationship**:
$$
\\frac{E_0}{B_0} = c
$$

**Energy Density**:
$$
u = \\frac{1}{2}\\varepsilon_0 E^2 + \\frac{1}{2\\mu_0}B^2 = \\varepsilon_0 E^2
$$

**Poynting Vector** (energy flux):
$$
\\vec{S} = \\frac{1}{\\mu_0}\\vec{E} \\times \\vec{B}
$$

**Intensity**:
$$
I = \\langle S \\rangle = \\frac{1}{2}c\\varepsilon_0 E_0^2
$$

```

## Integral vs Differential Forms

Maxwell's equations can be written in either integral or differential form. Each has its advantages depending on the problem at hand.

```markdown

**Gauss's Law (Electricity)**:

| Integral | Differential |
|:---------|:-------------|
| $\\displaystyle\\oint_S \\vec{E} \\cdot d\\vec{A} = \\frac{Q_{\\text{enc}}}{\\varepsilon_0}$ | $\\nabla \\cdot \\vec{E} = \\frac{\\rho}{\\varepsilon_0}$ |

**Gauss's Law (Magnetism)**:

| Integral | Differential |
|:---------|:-------------|
| $\\displaystyle\\oint_S \\vec{B} \\cdot d\\vec{A} = 0$ | $\\nabla \\cdot \\vec{B} = 0$ |

**Faraday's Law**:

| Integral | Differential |
|:---------|:-------------|
| $\\displaystyle\\oint_C \\vec{E} \\cdot d\\vec{l} = -\\frac{d\\Phi_B}{dt}$ | $\\nabla \\times \\vec{E} = -\\frac{\\partial \\vec{B}}{\\partial t}$ |

**Ampère-Maxwell Law**:

| Integral | Differential |
|:---------|:-------------|
| $\\displaystyle\\oint_C \\vec{B} \\cdot d\\vec{l} = \\mu_0 I + \\mu_0\\varepsilon_0\\frac{d\\Phi_E}{dt}$ | $\\nabla \\times \\vec{B} = \\mu_0 \\vec{J} + \\mu_0\\varepsilon_0\\frac{\\partial \\vec{E}}{\\partial t}$ |

```

> **When to Use Each Form:** **Integral form**: Best for problems with high symmetry (spherical, cylindrical, planar) where you can choose a convenient Gaussian surface or Amperian loop. **Differential form**: Best for deriving wave equations, understanding local field behavior, and computational electromagnetics.

## Maxwell's Equations in Matter

In materials, we introduce auxiliary fields to account for the response of matter to electromagnetic fields.

```markdown

**Auxiliary Fields**:

Electric displacement: $\\vec{D} = \\varepsilon_0 \\vec{E} + \\vec{P} = \\varepsilon \\vec{E}$

Magnetic field intensity: $\\vec{H} = \\frac{\\vec{B}}{\\mu_0} - \\vec{M} = \\frac{\\vec{B}}{\\mu}$

**Maxwell's Equations in Matter**:
$$
\\nabla \\cdot \\vec{D} = \\rho_f
$$

$$
\\nabla \\cdot \\vec{B} = 0
$$

$$
\\nabla \\times \\vec{E} = -\\frac{\\partial \\vec{B}}{\\partial t}
$$

$$
\\nabla \\times \\vec{H} = \\vec{J}_f + \\frac{\\partial \\vec{D}}{\\partial t}
$$

**Constitutive Relations** (linear media):
$$
\\vec{D} = \\varepsilon \\vec{E}, \\quad \\vec{B} = \\mu \\vec{H}
$$

where $\\varepsilon = \\varepsilon_0 \\varepsilon_r$ and $\\mu = \\mu_0 \\mu_r$

```

## Applications

Maxwell's equations have countless applications in technology and science. Here are some key examples with their governing equations.

```markdown

**Capacitor**:

Electric field between parallel plates:
$$
E = \\frac{\\sigma}{\\varepsilon_0} = \\frac{V}{d}
$$

Capacitance:
$$
C = \\frac{\\varepsilon_0 A}{d}
$$

---

**Inductor**:

Magnetic field in a solenoid:
$$
B = \\mu_0 n I
$$

Inductance:
$$
L = \\mu_0 n^2 V
$$

---

**Transformer**:

Voltage ratio:
$$
\\frac{V_s}{V_p} = \\frac{N_s}{N_p}
$$

---

**Antenna Radiation**:

Radiated power:
$$
P = \\frac{\\mu_0 c}{12\\pi}\\left(\\frac{I_0 \\ell \\omega}{c}\\right)^2
$$

---

**Waveguide**:

Cutoff frequency:
$$
f_c = \\frac{c}{2a}
$$

```

## Best Practices

> **Use Vector Notation Consistently:** Always use arrows ($\vec{'{E}'}$) or bold ($\mathbf{'{E}'}$) for vector quantities. Be consistent throughout your documentation.

> **Include Units:** Electromagnetic quantities have specific SI units. Include them in definitions and final answers: `$E = 100 \text{'{ V/m}'}$`

> **Show Both Forms When Appropriate:** For educational content, showing both integral and differential forms helps readers understand the connection between local and global behavior.

> **Use Diagrams for Field Visualization:** Electromagnetic fields are inherently spatial. Use Mermaid diagrams to show field line patterns, wave propagation, and circuit configurations.

> **Define Your Coordinate System:** Specify whether you're using Cartesian, cylindrical, or spherical coordinates, especially for problems with specific symmetry.

## Common Mistakes

> **Confusing E and D, B and H:** $\vec{'{E}'}$ and $\vec{'{D}'}$ are different fields, as are $\vec{'{B}'}$ and $\vec{'{H}'}$. In vacuum they differ only by constants, but in matter they have different physical meanings.

> **Forgetting the Displacement Current:** The term $\varepsilon_0 \frac{'{\\partial \\vec{E}}{\\partial t}'}$ in Ampère's law is essential for wave propagation and charge conservation. Don't omit it.

> **Sign Errors in Faraday's Law:** The negative sign in Faraday's law (Lenz's law) is crucial—it determines the direction of induced currents. Always include it.

> **Mixing Gaussian and SI Units:** Electromagnetic equations look different in Gaussian (CGS) and SI units. Stick to one system consistently. This guide uses SI units.

> **Incorrect Surface/Path Orientation:** In integral forms, the surface normal and path direction must follow the right-hand rule. Incorrect orientation leads to sign errors.

## Quick Reference

| Law | Differential Form | Physical Meaning |
| --- | --- | --- |
| Gauss (E) | $\nabla \cdot \vec{'{E}'} = \rho/\varepsilon_0$ | Charges create E fields |
| Gauss (B) | $\nabla \cdot \vec{'{B}'} = 0$ | No magnetic monopoles |
| Faraday | $\nabla \times \vec{'{E}'} = -\partial\vec{'{B}'}/\partial t$ | Changing B creates E |
| Ampère-Maxwell | $\nabla \times \vec{'{B}'} = \mu_0\vec{'{J}'} + \mu_0\varepsilon_0\partial\vec{'{E}'}/\partial t$ | Currents and changing E create B |

### Key Formulas

| Quantity | Formula |
| --- | --- |
| Speed of light | $c = 1/\sqrt{'{\\mu_0\\varepsilon_0}'}$ |
| Wave equation | $\nabla^2\vec{'{E}'} = \mu_0\varepsilon_0 \partial^2\vec{'{E}'}/\partial t^2$ |
| Poynting vector | $\vec{'{S}'} = \vec{'{E}'} \times \vec{'{B}'}/\mu_0$ |
| Energy density | $u = \varepsilon_0 E^2/2 + B^2/(2\mu_0)$ |
