5 min read
On this page

Vector Calculus

Vector calculus studies differentiation and integration of vector fields. It connects calculus to physics (fluid flow, electromagnetism) and provides the mathematical foundation for simulations, mesh processing, and differential geometry.

Vector Fields

A vector field F assigns a vector to each point in space:

F: ℝⁿ → ℝⁿ
F(x, y, z) = (P(x,y,z), Q(x,y,z), R(x,y,z))

Examples:

  • Gravitational field: F = -GMm/r² · r̂ (points toward mass)
  • Velocity field of a fluid
  • Gradient field: F = ∇f (always a vector field if f is differentiable)

Gradient, Divergence, and Curl

Gradient (∇f)

For scalar field f: ℝ³ → ℝ:

∇f = (∂f/∂x, ∂f/∂y, ∂f/∂z)

Points in the direction of steepest increase. Already covered in multivariable calculus.

Divergence (∇ · F)

For vector field F = (P, Q, R):

∇ · F = ∂P/∂x + ∂Q/∂y + ∂R/∂z

A scalar value measuring the "outflow" at a point.

  • div F > 0: source (field radiates outward)
  • div F < 0: sink (field converges inward)
  • div F = 0: incompressible (no net flow in/out)

Example: F = (x, y, z). ∇ · F = 1 + 1 + 1 = 3. Uniform expansion.

Example: F = (-y, x, 0) (rotation). ∇ · F = 0. Purely rotational, no expansion.

Curl (∇ × F)

For vector field F = (P, Q, R):

∇ × F = (∂R/∂y - ∂Q/∂z, ∂P/∂z - ∂R/∂x, ∂Q/∂x - ∂P/∂y)

Computed as a determinant:

∇ × F = det [ê₁    ê₂    ê₃  ]
             [∂/∂x  ∂/∂y  ∂/∂z]
             [ P     Q     R  ]

A vector measuring the rotation/circulation at a point.

  • curl F = 0: irrotational field
  • |curl F|: rate of rotation
  • Direction of curl F: axis of rotation (right-hand rule)

Example: F = (-y, x, 0). ∇ × F = (0, 0, 2). Rotating counterclockwise around z-axis.

Identities

∇ × (∇f) = 0              (curl of gradient is zero)
∇ · (∇ × F) = 0           (divergence of curl is zero)
∇ · (fF) = f(∇·F) + F·∇f  (product rule)
∇ × (fF) = f(∇×F) + (∇f)×F
∇²f = ∇ · ∇f = ∂²f/∂x² + ∂²f/∂y² + ∂²f/∂z²   (Laplacian)

Line Integrals

Scalar Line Integral

Integral of a scalar function along a curve C parameterized by r(t), a ≤ t ≤ b:

∫_C f ds = ∫ₐᵇ f(r(t)) ‖r'(t)‖ dt

Computes the "weighted length" of the curve.

Vector Line Integral (Work)

Integral of a vector field along a curve:

∫_C F · dr = ∫ₐᵇ F(r(t)) · r'(t) dt

Computes the work done by force F along path C.

Path Independence

∫_C F · dr depends only on endpoints (not the path) iff F is conservative:

F = ∇f    for some scalar function f (the potential function)

In this case: ∫_C F · dr = f(endpoint) - f(start).

Test for conservative field (simply connected domain):

∇ × F = 0  ⟺  F is conservative

Surface Integrals

Scalar Surface Integral

For surface S parameterized by r(u, v):

∫∫_S f dS = ∫∫_D f(r(u,v)) ‖r_u × r_v‖ du dv

Flux Integral

Flow of vector field F through surface S:

∫∫_S F · dS = ∫∫_S F · n̂ dS = ∫∫_D F(r(u,v)) · (r_u × r_v) du dv

where n̂ is the outward unit normal.

Fundamental Theorems

Green's Theorem

Relates a line integral around a closed curve C to a double integral over the enclosed region D (in 2D):

∮_C (P dx + Q dy) = ∫∫_D (∂Q/∂x - ∂P/∂y) dA

Special cases:

  • Area of D: A = ½ ∮_C (x dy - y dx)
  • If ∂Q/∂x - ∂P/∂y = 0 everywhere → path independence

Stokes' Theorem

Generalizes Green's theorem to 3D. Relates a line integral around a closed curve C to a surface integral over any surface S bounded by C:

∮_C F · dr = ∫∫_S (∇ × F) · dS

The circulation of F around C equals the flux of curl F through S.

Consequence: If ∇ × F = 0, then ∮_C F · dr = 0 for any closed curve (conservative field).

Divergence Theorem (Gauss's Theorem)

Relates flux through a closed surface S to a volume integral over the enclosed region V:

∫∫_S F · dS = ∫∫∫_V (∇ · F) dV

The net outward flux through S equals the total divergence inside V.

Physical interpretation: The amount of "stuff" flowing out through the boundary equals the amount of "stuff" being created inside (sources minus sinks).

Hierarchy

These three theorems are all instances of the generalized Stokes' theorem from differential forms:

∫_{∂Ω} ω = ∫_Ω dω

The integral over the boundary equals the integral of the exterior derivative over the interior.

| Theorem | Dimension | Boundary integral | Interior integral | |---|---|---|---| | Fundamental Theorem of Calculus | 1D | f(b) - f(a) | ∫ f'(x) dx | | Green's Theorem | 2D | ∮ (P dx + Q dy) | ∫∫ (Q_x - P_y) dA | | Stokes' Theorem | 3D (surface) | ∮ F · dr | ∫∫ (∇ × F) · dS | | Divergence Theorem | 3D (volume) | ∫∫ F · dS | ∫∫∫ ∇ · F dV |

Conservative Fields

A vector field F is conservative if any of the following equivalent conditions hold:

  1. F = ∇f for some potential function f
  2. ∮_C F · dr = 0 for every closed curve C
  3. ∫_C F · dr is path-independent
  4. ∇ × F = 0 (in a simply connected domain)

Finding the potential function: Integrate each component and reconcile:

f = ∫ P dx,  check consistency with ∂f/∂y = Q, ∂f/∂z = R

The Laplacian

∇²f = ∂²f/∂x² + ∂²f/∂y² + ∂²f/∂z²

Harmonic functions: f satisfying ∇²f = 0 (Laplace's equation). These arise in steady-state heat distribution, electrostatics, and fluid potential flow.

Poisson's equation: ∇²f = g (source term). Foundation of many physics simulations.

On graphs: The discrete Laplacian L = D - A is the graph-theoretic analog. Laplacian smoothing, spectral clustering, and graph neural networks all use it.

Applications in CS

  • Fluid simulation: Navier-Stokes equations use divergence, gradient, curl, and Laplacian. Divergence-free velocity fields model incompressible fluids.
  • Electromagnetism simulation: Maxwell's equations are vector calculus statements. Used in antenna design, signal propagation modeling.
  • Mesh processing: Discrete differential geometry on triangle meshes. Laplacian smoothing, mean curvature flow, parameterization.
  • Computer graphics: Normal vectors, surface shading (Phong model uses dot products with surface normals), volumetric rendering.
  • Physics engines: Potential fields for path planning (gradient descent on potential functions). Force field computation.
  • Machine learning on graphs: Graph Laplacian defines smoothness. Spectral GNNs use eigenvectors of the Laplacian.
  • Finite element methods: Weak formulations use integration by parts (divergence theorem) to derive variational forms.
  • Image processing: Gradient magnitude for edge detection. Laplacian for blob detection. Poisson image editing uses ∇²f.