Gauss and Stokes

Compare independently computed integral pairs, analytic references and individual quadrature contributions.

About this tool

Compare two independently computed sides

Choose Stokes or Gauss, a vector field, radius 0.1–5, resolution n = 8–64 and orientation ε = +1 or −1. Calculate evaluates both sides separately and compares them with a common analytic reference. The probe selects one exact index from the left-hand quadrature without recomputing the integrals. Coordinates, fields and integral values are dimensionless examples.

Stokes: circle and disk

The disk D lies in the xy plane. Stokes' theorem compares ∮C F · dr with ∬D curl F · (0,0,ε) dA. For ε = +1, C₊ runs counterclockwise as seen from +z; for ε = −1, C₋ runs clockwise and the normal reverses with it.

The left approximation uses n oriented straight chords of an inscribed polygon. Each contribution is F at the chord midpoint dotted with the chord vector, equivalently F · t times chord length. This approximates the continuous circular integral; it is not exact circle integration. The right side uses n² equal-weight disk samples at r = R√((j + 1/2)/n), θ = 2π(k + 1/2)/n, each weighted by πR²/n². Polygon area is reported separately from disk area πR².

Gauss: closed sphere and ball

Gauss' divergence theorem normally uses the outward normal: ∯∂V F · n_out dS = ∭V div F dV. Here the chosen normal is εn_out. For inward orientation the comparison is therefore ∯∂V F · (−n_out) dS = −∭V div F dV. The minus sign applies to the volume integral as well.

The sphere has n² equal-area samples. With μ = z/R = −1 + 2(j + 1/2)/n and the same angular midpoints, each sample represents area 4πR²/n². The volume uses n equal-volume shells at r = R∛((j + 1/2)/n) with those angular samples: n³ points, each weighted by 4πR³/(3n³). Both sums use compensated summation. The selected cell is bounded by μ = −1 + 2j/n and −1 + 2(j + 1)/n, and θ = 2πk/n and 2π(k + 1)/n.

Fields and exact references

Swirl F = (−y,x,0) has curl (0,0,2). Twist F = (1+x²+y²)(−y,x,0) has curl (0,0,2+4(x²+y²)). Both have zero divergence. Radial F = (x,y,z), shear F = (x,0,0) and cubic F = (x³,y³,z³) have divergences 3, 1 and 3(x²+y²+z²), respectively, and zero curl. Uniform F = (0,0,1) has zero divergence and curl.

Stokes references are ε2πR² for swirl and ε2πR²(1+R²) for twist; all other fields give zero. Gauss references are ε4πR³ for radial, ε4πR³/3 for shear and ε12πR⁵/5 for cubic; all other fields give zero. The error columns give the absolute difference of each numerical side from its reference. Left minus right compares the two approximations directly.

For swirl at R = 1 and ε = +1, the reference is 2π. The chord approximation is n sin(2π/n), illustrating the polygon error as n increases. For radial Gauss at R = 1, both orientations give magnitude 4π with the chosen sign.

Read the drawing and probe

Stokes always uses the xy view. Gauss offers an oblique view and projections onto xy, xz and yz. Sphere wires are transparent; line crossings make no occlusion claim. The position marker, field components, unit tangent or normal, measure, integrand and contribution all refer to the same chosen sample.

A single field scale s = 0.35R / max|F| over all model probes is used for every F arrow. It preserves differences in magnitude and limits the largest spatial arrow to 0.35R. Normal or tangent arrows have length 0.25R; the legend gives both actual factors. Projection can shorten an arrow or reduce it to a point. A field arrow is not independently normalized.

Changing a main input clears the old result. Switching to Gauss selects the radial field; switching to Stokes selects swirl. Invalid probe input hides its values and markers while retaining the static region. Every calculation starts with probe 0. Navigation retains the result; reloading or changing language restores valid settings and waits for Calculate.

Sources

OpenStax: Stokes' theorem and OpenStax: the divergence theorem. The quadrature rules above are explicit numerical approximations.