Solution (source code)

= Solution

\b[<Stokes theorem> converts <circulation> around an oriented boundary into <curl> <flux> through a spanning surface.] For a sufficiently smooth <vector field> on an oriented piecewise smooth surface $S$,
$$
\boxed{\oint_{\partial S}\mathbf A\cdot d\mathbf l=\int_S(\nabla\times\mathbf A)\cdot\mathbf n\,dS.}
$$
The boundary orientation follows the <right-hand rule> relative to $\mathbf n$. The field must be smooth on the surface, not merely on its boundary; a singularity crossing the surface cannot be ignored. For a fixed loop, applying the theorem to Faraday's differential law gives the <integral> <flux> law of induction.

The planar form is <Green theorem>. For a region $D$ with positively oriented boundary and sufficiently smooth $P,Q$,
$$
\boxed{\oint_{\partial D}(P\,dx+Q\,dy)=\iint_D(Q_x-P_y)\,dx\,dy.}
$$
The outer boundary is counterclockwise and any holes have clockwise boundaries. For instance $P=-y/2,Q=x/2$ makes the area of $D$ equal to half the <line integral> of $x\,dy-y\,dx$; the unit circle gives area $\pi$.

A closely related use of “<Green's theorems>” in field theory is <Green's identities>, obtained by applying the <divergence theorem> to $\phi\nabla\psi$:
$$
\int_V(\phi\nabla^2\psi+\nabla\phi\cdot\nabla\psi)\,dV=\oint_{\partial V}\phi\,\partial_n\psi\,dS,
$$
and, after subtracting the expression with $\phi,\psi$ exchanged,
$$
\boxed{\int_V(\phi\nabla^2\psi-\psi\nabla^2\phi)\,dV=\oint_{\partial V}(\phi\partial_n\psi-\psi\partial_n\phi)\,dS.}
$$
These relate interior sources to boundary data in <electrostatics> and other boundary-value problems. For example, a <harmonic potential> difference vanishing on a <Dirichlet boundary condition> has zero <integral> of its squared <gradient> by the first identity, establishing uniqueness. Both the planar <circulation> theorem and the field identities are included here to make the convention clear.