Electromagnetic Theory · Divergence Theorem — Worked Examples

#30 Unit-cube flux, the singular inverse-square field and Gauss’s law

Check the divergence theorem on a cube, then account for the singular origin when deriving the flux of a point-charge field.

Question

Original English final frame showing cancellation of internal flux, unit-cube volume and surface integrals both equal to three halves, or the sphere flux four pi with the singular-source and Gauss-law equations.
Use outward normals on the full closed boundary. A singular field requires its source distribution or an excluded inner boundary; pointwise zero away from the source is not the whole volume contribution.

Verify the divergence theorem by calculating both sides. In the writing lines, D denotes the scalar divergence of A, F is its total outward boundary flux, and I is the volume integral of divergence. F_E is electric flux, Q is total enclosed electric charge, and q is the single point charge in the worked example. The use of D here is a scalar shorthand, not the electric displacement vector. The vector A is given by its components in the stated orthonormal Cartesian or spherical basis. For a continuously differentiable field on a neighborhood of a bounded volume with a suitable piecewise smooth closed boundary, the outward surface integral of A dot the normal equals the volume integral of divergence. Cubes are allowed; their edges have zero surface measure. If the volume has an inner cavity, its complete boundary includes that cavity with the outward-from-the-volume normal pointing into the hole. The source’s compact integral symbols denote a surface integral on S and a three-dimensional volume integral on V; they are not a line integral and a one-dimensional integral. For small cells, divergence at a sample point times the cell volume approximates flux, becoming exact in the refinement limit. Cancellation on a shared face is exact because the two outward normals are opposite. The planar grid is an illustration of this cancellation, not a quantitative three-dimensional flux measurement. The unit cube is 0≤x,y,z≤1 and A=(x²y,y²z,z²x). Its divergence is 2xy+2yz+2zx. Each cyclic term integrates to 2 times one half times one half times one, which is one half; three terms give 3/2. This use of symmetry relies on the identical coordinate limits of this cube. The original middle line combines “+ (cyclic)” and “×3” as a compact reminder: there are three total equal terms, not the first term plus three additional copies. The next displayed arithmetic line and spoken calculation make that total explicit. Preserve the leading factor two in each integral. For surface flux, the lower faces x=0,y=0,z=0 have normals −e_x,−e_y,−e_z and zero normal field components here. This does not mean the entire vector field vanishes on each face. The upper x face has normal e_x and normal component y, integrated over y,z∈[0,1] to give one half. The upper y face has normal e_y and normal component z, integrated over x,z to give one half. The upper z face has normal e_z and normal component x, integrated over x,y to give one half. Thus F=3/2=I. The symbols F_x,F_y,F_z denote these upper-face fluxes; L_x,L_y,L_z denote the lower-face fluxes, and I_x denotes the volume contribution of 2xy. For the second example let R>0 be the fixed sphere radius, while r is the variable radial coordinate. Spherical θ is polar from +z, φ is azimuth, and angles use radians. The field A=(1/r²)e_r is defined only for r>0. On the sphere, the outward normal is e_r, so the normal component is 1/R². The scalar area element d S=R² sinθ d θ d φ gives flux element d F=sinθ d θ d φ. Integrate θ from zero to π and φ from zero to 2π: the factors are 2 and 2π, yielding F=4π independent of R. In these writing lines d S is scalar area, unlike the source’s vector area element; the normal component has already been taken. The classical divergence is zero away from the origin, but the original field is undefined at the origin. One cannot apply the smooth theorem on the full ball and silently fill this hole with zero. The narration’s word “infinite” is an informal description of concentrated source strength, not a literal classical divergence value. The precise statement is distributional divergence equal to 4π times the three-dimensional Dirac delta at the origin. A delta distribution is defined by its integrals against test functions; it is not an ordinary function with an infinite value at one point. Integrating the source distribution over a volume that encloses the origin gives 4π. An equivalent check avoids delta notation: remove a small concentric ball of radius a<R. The field is smooth on the shell. The outer flux is +4π, while the inner boundary normal points toward the origin and has flux −4π. Their sum is zero, equal to the integral of the pointwise zero divergence on that shell. Shrinking the hole does not eliminate its finite boundary contribution. A smooth regularization A_ε=(x,y,z)/(r²+ε²)^(3/2) has divergence 3ε²/(r²+ε²)^(5/2); its integrated divergence tends to 4π as ε decreases, although it tends to zero at every fixed point away from the origin. This illustrates why exchanging this singular limit and integration loses the source. Multiplying the normalized radial field by k=q/(4π ε_0) gives the vacuum point-charge electric field. The enclosing electric flux is q/ε_0. For general charge distributions, the field law divergence E=ρ_q/ε_0 together with the divergence theorem gives F_E=Q/ε_0, where Q is enclosed charge; superposition extends the single-charge example. Gauss’s law contains physical information from the electric-field law, so it is not a consequence of a geometric theorem alone. A closed surface excluding the point charge has zero net flux even though the field on that surface need not vanish. Keep charges off the integration surface unless an additional boundary prescription is supplied. Gauss’s law holds for appropriate closed surfaces regardless of symmetry. Symmetry is what lets it determine a field magnitude easily: choose parts where the normal component is constant, or where flux vanishes. The statement about Gaussian-surface calculations refers to this method; not every example requires a point delta source. Smooth charge densities and other idealized charge distributions require their own source descriptions. Stokes’s theorem, treated next, relates oriented surface curl to circulation along its boundary.

Written solution and narration transcript(shows the full solution)

Below are all the lines written in the notebook together with the full narration transcript.

  1. 1. From local divergence to total flux

    Original English final frame showing cancellation of internal flux, unit-cube volume and surface integrals both equal to three halves, or the sphere flux four pi with the singular-source and Gauss-law equations.
    Use outward normals on the full closed boundary. A singular field requires its source distribution or an excluded inner boundary; pointwise zero away from the source is not the whole volume contribution.
    Divergence theorem
    Divergence and curl describe local properties.
    Now connect local divergence to total flux.
    Assume a suitable closed boundary and a smooth field throughout its volume.
    Outward boundary flux equals the volume integral of divergence.
    Write the two integrals as F and I:
    F=I\displaystyle F = I
    Why do interior contributions cancel?
    Subdivide the volume into small cells.
    For a sufficiently small cell, divergence times volume approximates its flux.
    Shared faces have equal fluxes with opposite outward normal signs.
    Only the external boundary remains after summing the cells.
    Take the limit to obtain the volume integral.
    This is the divergence theorem.
    Apply it to electric fields.
    Closed electric flux:
    FE=Qε0\displaystyle F_{E} =\frac{ Q}{\varepsilon _{0}}
    Verify the statement with two examples.

    Narration transcript

    Hello friends, welcome back. The last two videos taught us divergence — a local property at every point of a vector field — and curl. Today we move from local to global, with the divergence theorem. The statement is simple but powerful. The flux of A through a closed surface S equals the integral of the divergence of A over the volume V enclosed by S. In symbols: the closed surface integral of A dot dS, equals the triple volume integral of nabla dot A, dV. Why does this work intuitively? Imagine cutting V into millions of tiny boxes. Each box has its own little flux outflow given by its divergence times its volume. When you add them all up, every interior face is shared between two boxes — the flux out of one is flux into its neighbor — so they cancel. The only surfaces that survive the sum are the outermost ones, which is exactly the boundary surface S. So the sum of every tiny divergence equals the total flux through the outer skin. That is the divergence theorem. This is one of the most useful results in electromagnetics. It turns Maxwell's differential law nabla dot E equals rho over epsilon zero into Gauss's law in integral form: the total flux of E through any closed surface equals the enclosed charge divided by epsilon zero. We will see exactly how that happens at the end of the video.

  2. 2. Unit-cube verification

    Original English final frame showing cancellation of internal flux, unit-cube volume and surface integrals both equal to three halves, or the sphere flux four pi with the singular-source and Gauss-law equations.
    Use outward normals on the full closed boundary. A singular field requires its source distribution or an excluded inner boundary; pointwise zero away from the source is not the whole volume contribution.
    Worked example 1: a unit cube
    Cartesian vector components:
    A=(x2y,y2z,z2x)\displaystyle A = \left(x^{2} y, y^{2} z, z^{2} x\right)
    Each coordinate ranges from zero to one.
    Compute the volume integral and the six outward face fluxes.
    Consider the volume integral.
    Known divergence:
    D=2xy+2yz+2zx\displaystyle D = 2 x y + 2 y z + 2 z x
    Integrate over the whole unit cube.
    The three cyclic terms have equal integrals on this cube.
    Separate the coordinate integrals.
    Each term contains the leading factor two.
    First term integral:
    Ix=2(12)(12)1=12\displaystyle I_{x} = 2\cdot \left(\frac{1}{2}\right)\cdot \left(\frac{1}{2}\right)\cdot 1 =\frac{ 1}{2}
    Three equal terms:
    I=3(12)=32\displaystyle I = 3\cdot \left(\frac{1}{2}\right) =\frac{ 3}{2}
    Volume result:
    I=32\displaystyle I =\frac{ 3}{2}
    Now compute outward surface flux.
    Account for all six faces.
    At the lower x face, use the negative x normal.
    Lower x-face flux:
    Lx=0\displaystyle L_{x} = 0
    Other lower-face fluxes:
    Ly+Lz=0\displaystyle L_{y} + L_{z} = 0
    Only the three upper faces contribute.
    The upper x face has the positive x normal.
    Normal field component at the upper x face:
    Ax=y\displaystyle A_{x} = y
    Integrate y over its unit square.
    Upper x-face flux:
    Fx=(12)1=12\displaystyle F_{x} = \left(\frac{1}{2}\right)\cdot 1 =\frac{ 1}{2}
    Normal field component at the upper y face:
    Ay=z\displaystyle A_{y} = z
    Upper y-face flux:
    Fy=12\displaystyle F_{y} =\frac{ 1}{2}
    Upper z-face flux:
    Fz=12\displaystyle F_{z} =\frac{ 1}{2}
    Add the six face contributions:
    F=12+12+12=32\displaystyle F =\frac{ 1}{2 }+\frac{ 1}{2 }+\frac{ 1}{2 }=\frac{ 3}{2}
    The direct calculations agree.
    Comparison:
    F=I=32\displaystyle F = I =\frac{ 3}{2}
    The theorem holds for this smooth field on the cube.

    Narration transcript

    Worked example one — a unit cube. Let A be the same field we have been carrying since PS05: x squared y x-hat, plus y squared z y-hat, plus z squared x z-hat. Take V to be the unit cube, x, y, z each between zero and one. We will compute both sides of the divergence theorem and check they agree. Volume side first. The divergence we already know — PS05 computed it: nabla dot A equals two x y, plus two y z, plus two z x. Triple integral over the unit cube. By symmetry, each of the three terms gives the same answer: integrate two x y over the cube. The integrals separate. Two times the integral of x from zero to one, times the integral of y from zero to one, times the integral of dz from zero to one. That is two times one half, times one half, times one — which is one half. Three identical terms gives three halves. So the volume side is three over two. Now the surface side. The cube has six faces; we hit each one. On the face x equals zero, the outward normal is minus x-hat, and A dot minus x-hat equals minus A x equals minus x squared y, which is zero on the face. So that face gives zero. By the same logic, the faces y equals zero and z equals zero each give zero. Only three faces are alive. On the face x equals one, the outward normal is x-hat. A dot x-hat is x squared y, which is one squared times y, equal to y. Integrate y over y from zero to one and z from zero to one. That is one half times one, equals one half. On the face y equals one, A dot y-hat is y squared z which is z. Integrate z dx dz, equals one half. Same for the face z equals one. Three faces, each contributes one half, total three over two. Both sides match. Three over two equals three over two. The divergence theorem is verified for this cube and this field.

  3. 3. Singular radial field and Gauss’s law

    Original English final frame showing cancellation of internal flux, unit-cube volume and surface integrals both equal to three halves, or the sphere flux four pi with the singular-source and Gauss-law equations.
    Use outward normals on the full closed boundary. A singular field requires its source distribution or an excluded inner boundary; pointwise zero away from the source is not the whole volume contribution.
    Worked example 2; spherical components:
    A=(1r2,0,0)\displaystyle A = \left(\frac{1}{r^{2}}, 0, 0\right)
    The sphere is centered on the singular origin.
    Consider the volume integral.
    Away from the origin:
    D=0\displaystyle D = 0
    Integrating only that pointwise zero omits the singular source.
    Keep this omission in mind.
    Now calculate the outward surface flux.
    At radius R:
    Ar=1R2\displaystyle A_{r} =\frac{ 1}{R^{2}}
    Scalar sphere area element:
    dS=R2sinθdθdφ\displaystyle d S = R^{2} \sin \theta d \theta d \varphi
    Flux element:
    dF=(1R2)(R2sinθdθdφ)\displaystyle d F = \left(\frac{1}{R^{2}}\right)\left(R^{2} \sin \theta d \theta d \varphi \right)
    Cancel the squared radius factors.
    Polar angle ranges from zero to π; azimuth from zero to 2π.
    The polar sine integral is two; the azimuthal integral is 2π.
    Product:
    F=22π=4π\displaystyle F = 2\cdot 2\pi = 4\pi
    The outward flux is independent of positive radius R.
    Explain the apparent mismatch.
    The naive volume calculation ignored the origin.
    The surface flux includes the enclosed singular source.
    The smooth theorem requires the field to be defined throughout the volume.
    Which hypothesis failed?
    The theorem itself has not failed.
    Classical divergence is undefined at the origin.
    Distributional divergence contains a three-dimensional Dirac delta at the origin.
    Its total weight in the enclosing volume:
    I=4π\displaystyle I = 4\pi
    Accounting for the singular source restores equality.
    Connect this calculation to a point charge.
    Multiply by the physical coefficient:
    k=q4πε0\displaystyle k =\frac{ q}{4\pi \varepsilon _{0}}
    Electric-field components:
    E=(q4πε0r2,0,0)\displaystyle E = \left(\frac{q}{4\pi \varepsilon _{0} r^{2}}, 0, 0\right)
    The surface integral now measures electric flux.
    Enclosed point-charge flux:
    FE=qε0\displaystyle F_{E} =\frac{ q}{\varepsilon _{0}}
    This is the integral form of Gauss’s law.
    Use the field law together with the divergence theorem and the source distribution.
    Symmetry can simplify the electric-flux calculation.

    Narration transcript

    Worked example two — a sphere of radius R, with the inverse square radial field from PS05 and PS06: A equals one over r squared, in r-hat. This one is going to be subtle, because the field is singular at the origin, and that is exactly where the lesson lives. Volume side first. Inside the sphere, but excluding the origin, the divergence we computed in PS05: nabla dot A is zero. So if you naively integrate zero over the volume, you get zero. Hold that. Surface side. On the sphere of radius R, A dot r-hat equals one over R squared. The surface element of a sphere is R squared sine theta d theta d phi. So A dot dS becomes one over R squared, times R squared, times sine theta d theta d phi. The R squareds cancel. We are left with sine theta d theta integrated from zero to pi, and d phi integrated from zero to two pi. Sine theta from zero to pi gives two; d phi gives two pi. Product: four pi. The surface integral of A dot dS is four pi. Stop and feel the contradiction. The volume side gave zero. The surface side gave four pi. The divergence theorem says they should match. What went wrong? Nothing went wrong. The issue is that nabla dot A is not zero at the origin — it is infinite. Specifically, nabla dot A equals four pi times the three-dimensional Dirac delta function at the origin. When you integrate that delta over the volume, you pick out four pi, exactly matching the surface side. The divergence theorem is restored, but only because we are honest about the singularity. And here is why this matters. Multiply both sides by q over four pi epsilon zero. The field one over r squared r-hat becomes the electric field of a point charge q. The surface integral becomes the flux of E. The volume side becomes q over epsilon zero — the enclosed charge over epsilon zero. That is Gauss's law in integral form. Gauss's law is exactly the divergence theorem applied to the inverse square field, with the singularity properly handled. Every Gaussian surface calculation in electrostatics is built on this.

  4. 4. Divergence theorem recap

    Original English final frame showing cancellation of internal flux, unit-cube volume and surface integrals both equal to three halves, or the sphere flux four pi with the singular-source and Gauss-law equations.
    Use outward normals on the full closed boundary. A singular field requires its source distribution or an excluded inner boundary; pointwise zero away from the source is not the whole volume contribution.
    Divergence theorem recap
    For a smooth field, outward closed-surface flux equals integrated divergence.
    Local divergence contributions add to the boundary flux.
    Two worked examples.
    First: the polynomial field on the unit cube.
    Both direct calculations give:
    F=I=32\displaystyle F = I =\frac{ 3}{2}
    All six faces and all three volume terms are included.
    Second: the inverse-square field on a sphere about the origin.
    The outward surface result is:
    F=4π\displaystyle F = 4\pi
    The missing contribution is a delta distribution at the singular origin.
    Gauss’s law:
    FE=Qε0\displaystyle F_{E} =\frac{ Q}{\varepsilon _{0}}
    Cylinders, planes and coaxial structures provide useful symmetric cases.
    Choose symmetry so the normal field component is constant or vanishes on each part.
    The field law supplies enclosed charge; the theorem relates the integrals.
    Next: Stokes’s theorem connects curl with boundary circulation.
    End of the worked examples.

    Narration transcript

    Quick recap. The divergence theorem says the flux of a vector field through any closed surface equals the volume integral of its divergence inside. Local sources, summed up, equal global flux. Two worked examples. First, the unit cube with the polynomial field from PS05. Both sides came out to three halves. That is a clean, no-tricks verification — pick a region, pick a field, both sides match. Second, a sphere with the inverse square radial field from PS06. Naive volume integral gave zero, surface integral gave four pi. The mismatch was resolved by recognizing that the divergence is a delta function at the origin, not zero. Multiply through by q over four pi epsilon zero, and the result is Gauss's law: flux of E through any closed surface equals enclosed charge over epsilon zero. Every Gauss-surface problem we will see — cylindrical shell, charged plane, coaxial cable — rides on this theorem. Instead of integrating flux head-on, we choose a surface matched to the symmetry, make the integral trivial, and tie the result to the enclosed charge. The whole trick is the reward of the divergence theorem. Next time, the partner result: Stokes's theorem, which connects curl to circulation around a closed loop, and Maxwell's other two integral equations come out of it. See you then.

Source video: Electromagnetic Theory (v2) #30 | Problem Solving #07: Divergence Theorem & Gauss's Law (8:46)