Mathematical Infrastructure
Divergence, Curl, and Line Integrals
The vector-calculus operators that appear in Fokker-Planck, score-based diffusion, and PINN papers. Definitions of divergence, curl, gradient, line integrals, and Green's theorem in the plane. Compact, not encyclopedic.
Prerequisites
Why This Matters
Open the Fokker-Planck equation page and the first line is . Open physics-informed neural networks and the loss is built from PDE residuals like or . Without the vocabulary of divergence, gradient, curl, and line integral, those expressions are runes.
This page collects the operators with their definitions, the one identity each ML paper actually uses, and Green's theorem in the plane. Stokes' theorem in and the divergence theorem in are mentioned for completeness; the full integration-on-manifolds treatment lives in differential-geometry texts and is not redone here.
The Three Operators
Gradient, Divergence, Curl
Let be the formal vector of partial derivatives. For sufficiently smooth functions on an open set in :
- The gradient of a scalar field is the vector field .
- The divergence of a vector field is the scalar field .
- In dimension , the curl of is the vector field .
- The Laplacian of a scalar field is .
Three identities are worth memorizing.
Divergence is the Trace of the Jacobian
Statement
For a vector field with Jacobian , Consequence: divergence-free fields are exactly those whose Jacobian has trace zero everywhere. The pointwise volume-deformation rate of the flow equals at .
Intuition
The Jacobian is the linear approximation of the flow at . Its trace is the sum of eigenvalues, which is the rate of change of volume of an infinitesimal box transported by the flow. When the trace is zero the flow is volume-preserving; when it is positive the flow expands volume. This is exactly Liouville's theorem for the flow .
Why It Matters
The continuity equation says mass is locally conserved by the velocity field . The Fokker-Planck equation and the probability flow ODE used in score-based diffusion are both continuity equations with specific drift fields. Reading either page assumes you can compute in coordinates.
A second identity threads through electromagnetism and fluid mechanics: curl of a gradient is zero, , and divergence of a curl is zero, . Both follow from equality of mixed partials. They are the cohomological reason that "irrotational" and "solenoidal" decompositions (Helmholtz) are well-defined on simply connected domains.
A third identity is the product rule for divergence: . This is the identity used to derive the integration-by-parts formula in score matching (Hyvärinen 2005), where the gradient log-density replaces inside the divergence.
Line Integrals
Let be a piecewise- curve and a continuous vector field on a region containing the image of .
Line Integral of a Vector Field
The line integral of along is It is independent of orientation-preserving reparametrizations and changes sign under reversal of orientation.
A field is conservative on an open set if for some scalar potential . The fundamental theorem of line integrals gives, for a conservative field, , which depends only on endpoints. Conversely, on a simply connected open set, with is conservative. Outside simply connected domains the converse can fail; the standard counterexample is on the punctured plane, which is curl-free yet has nonzero loop integral around the origin.
Green's Theorem in the Plane
Green's Theorem
Statement
Let be a bounded region whose boundary is a piecewise- simple closed curve, oriented counterclockwise. Let be . Then
Intuition
The integrand on the right is the scalar curl of the planar field . Green's theorem says: the circulation of a planar vector field around a loop equals the integral of its curl over the enclosed region. The divergence form of the same theorem (sometimes called the divergence-in-the-plane theorem) reads , where is the outward unit normal.
Why It Matters
Green's theorem is the two-dimensional ancestor of two flagship results: the divergence theorem in , and Stokes' theorem on oriented surfaces in . The integration-by-parts identity underlying Hyvärinen score matching is the divergence theorem applied to with vanishing boundary contributions at infinity. The Helmholtz decomposition used in incompressible fluids and in some neural-PDE solvers is also a Green-type consequence.
Failure Mode
Boundary regularity matters. A region with infinitely many boundary oscillations (a "rough" boundary that is not piecewise-) breaks the classical statement. For modern Lipschitz-domain or BV-domain extensions, see Evans-Gariepy. The orientation rule (counterclockwise) is essential; reversing it flips the sign of the right side.
Worked Example: Divergence of an Affine Drift
Let with , . The Jacobian is constant: . By the divergence-as-trace identity, everywhere. If is the negative of a positive-definite matrix (a stable linear drift), then and the flow contracts volumes exponentially. This is the linear case of the Fokker-Planck contraction analysis for Ornstein-Uhlenbeck processes.
Common Confusions
Curl is a 3D operator (and a scalar in 2D)
The full is defined in and returns a vector field. In what is called "curl" is the scalar that appears in Green's theorem; it is the -component of the curl of the 3D embedding . In dimensions the natural object is a 2-form (an antisymmetric matrix), not a vector. ML papers stay in or for fluid and EM applications, so this confusion rarely bites — but the convention difference matters when reading higher-dimensional differential geometry.
Conservative is a global property
The condition is local. The condition for a global potential is global and depends on the topology of the domain. On a simply connected open set the two coincide; on the punctured plane they do not. ML rarely cares because most domains are convex or contractible, but in optimal-control and Hamiltonian-flow papers the distinction is real.
Exercises
Problem
Let on . Compute and the 2D scalar curl . Then evaluate the line integral of around the unit circle traversed counterclockwise.
Problem
Show that for any vector field and scalar field , This is the product rule for divergence used in deriving the Fokker-Planck drift terms and in Hyvärinen's score-matching integration-by-parts.
References
Related Topics
Last reviewed: April 18, 2026
Prerequisites
Foundations this topic depends on.
- The Jacobian MatrixLayer 0A
- Vector Calculus Chain RuleLayer 0A
- Vectors, Matrices, and Linear MapsLayer 0A