divergence calculator

Interactive Divergence Calculator

Compute ∇·F for a 2D or 3D vector field at a specific point using central differences.

Enter a vector field and click “Calculate Divergence”.

What Is Divergence?

Divergence measures how much a vector field “spreads out” from a point. In plain language, it answers: is this point behaving like a source, a sink, or neither?

  • Positive divergence: net outflow (source-like behavior)
  • Negative divergence: net inflow (sink-like behavior)
  • Zero divergence: no net local expansion or compression

For a vector field F = (Fx, Fy, Fz), divergence is:

∇·F = ∂Fx/∂x + ∂Fy/∂y + ∂Fz/∂z

How This Calculator Works

Numerical Differentiation

This tool estimates each partial derivative using the central-difference formula:

∂f/∂x ≈ [f(x+h)-f(x-h)]/(2h)

It applies that idea to each component in its matching direction:

  • ∂Fx/∂x
  • ∂Fy/∂y
  • ∂Fz/∂z (3D only)

Then it sums the results to produce the divergence at your chosen point.

Expression Input Tips

You can use standard math syntax with variables x, y, and z.

  • Exponent: x^2 or x**2
  • Functions: sin(x), cos(y), exp(z), sqrt(x*x+y*y)
  • Constants: pi, e

Use explicit multiplication like 2*x, not 2x.

Worked Examples

Example 1: Uniform Expansion Field

Let F = (x, y, z). Then:

  • ∂Fx/∂x = 1
  • ∂Fy/∂y = 1
  • ∂Fz/∂z = 1

So ∇·F = 3. The field is source-like everywhere.

Example 2: Balanced 2D Field

For F = (x^2, -y^2), divergence is 2x - 2y. At (1,1), divergence is 0, meaning local expansion and compression cancel out at that point.

Common Mistakes to Avoid

  • Using the wrong derivative direction (e.g., differentiating Fx with respect to y)
  • Forgetting that this tool computes a point value, not a full symbolic simplification
  • Choosing a very large or very tiny h that can reduce numerical accuracy
  • Typing implicit multiplication (write 3*x, not 3x)

Where Divergence Is Used

Divergence appears in many fields:

  • Fluid dynamics: local expansion/compression of flow
  • Electromagnetism: Gauss’s law and source density interpretation
  • Heat and mass transfer: conservation equations
  • Optimization and simulation: analyzing vector fields in numerical models

Final Note

This divergence calculator is ideal for quick checks, homework validation, and intuition building. If you need exact symbolic derivatives, pair this with a CAS tool; if you need local behavior at specific points, this calculator is fast and practical.

🔗 Related Calculators