Vector calculusFree · No sign-up

Divergence Calculator

This divergence calculator finds ∇·F, the net outward flow of a vector field per unit volume, with steps in Cartesian, cylindrical or spherical coordinates. Evaluate it at a point to label the point a source, a sink or divergence-free; the field map marks sources in orange and sinks in teal. Students and engineers use it for vector calculus homework, Gauss's law and fluid-flow checks.

See the field map
  • Cylindrical and spherical formulas built in
  • Source, sink or divergence-free
  • Flux arrows around the point
4
coordinate systems
2D + 3D
vector fields
8
ready-made examples
Divergence engine
Coordinate system
Vector field F = ⟨P, Q, R⟩
P =
Q =
R =
p =
Preview
—Full solution ↓

Results

Your divergence, as sources and sinks

Arrows show the field in the slice. The dashed circle around your point shows the outward flow (orange) and inward flow (teal) through its edge.

Interactive diagram

Field map and divergence

div > 0 sourcediv < 0 sink

Divergence

Terms

Step-by-step solution

—

    Step by step

    How to Use the Divergence Calculator

    To use the divergence calculator, follow these 5 steps. The result and the map update as you type.

    1. 1

      Pick the coordinate system

      Choose 2D, Cartesian, cylindrical (r, θ, z) or spherical (ρ, φ, θ). The labels of the 3 inputs change to match.

    2. 2

      Type the components

      Use the variables of the system: x^2*y in Cartesian, r*sin(theta) in cylindrical, 1/rho^2 in spherical.

    3. 3

      Add a point (optional)

      Enter coordinates in the same system, angles in radians, for example 2, pi/4, 1.

    4. 4

      Read the result

      Check the divergence formula, its value at the point and the label: source, sink or divergence-free.

    5. 5

      Explore the map

      Drag the point across the map. Watch the flux arrows around the circle grow, shrink or flip.

    Try an example:

    Definition

    What Is the Divergence of a Vector Field?

    The divergence of a vector field is a scalar that measures the net outward flux of the field per unit volume at a point. For F = ⟨P, Q, R⟩, the divergence is written div F or ∇ · F, the dot product of the nabla operator with F.

    The limit definition reads in 3 parts: take a tiny region V around the point p, add up the flow of F out through its boundary, and divide by the volume |V|. In 2D, the region is a small disk and the volume is its area.

    The sign of the result sorts every point into 1 of 3 types:

    • div F > 0: a source, more flow leaves than enters.
    • div F < 0: a sink, more flow enters than leaves.
    • div F = 0: divergence-free, inflow and outflow balance.

    Divergence is a topic of Calculus III (multivariable calculus) and vector calculus, next to the gradient and the curl.

    Flux-circle explorer: shrink the circle and flux / area becomes div F
    flux out of the circle—
    flux / area—
    div F at (0.6, 0.4)—
    field—

    Orange arrows on the circle mark outflow and teal arrows mark inflow; the shading is div F. For ⟨x³, y³⟩, flux / area equals 1.56 + 1.5r², so it reaches div F = 1.56 as r goes to 0. For the swirl, the flux is 0 at every radius.

    The word divergence in other subjects
    SubjectWhat "divergence" meansFormula or test
    Vector calculus (this page)net outflow of a vector field
    Series (divergence test)a series fails to have a finite sumΣaₙ diverges, if lim aₙ ≠ 0
    Improper integralsan integral grows without bound∫₁^∞ 1/x dx diverges
    Statistics (KL divergence)distance between 2 probability distributions
    Trading (RSI divergence)price and an indicator move apartnew price high, lower RSI high
    Optics (beam divergence)the spread angle of a laser beamθ = λ/(πw₀), in milliradians (mrad)

    A helium-neon laser with wavelength λ = 633 nm and beam waist w₀ = 0.5 mm has a Gaussian beam divergence half-angle of 633 × 10⁻⁹ / (π × 0.5 × 10⁻³) ≈ 0.403 mrad, or 0.023°. Series and integral divergence are covered by the improper integral calculator.

    Formula

    Divergence Formula in Cartesian Coordinates

    The divergence formula in Cartesian coordinates adds 3 partial derivatives: the partial derivative of each component with respect to its own variable.

    For a 2D field F = ⟨P, Q⟩, the divergence drops the z-term: ∇ · F = ∂P/∂x + ∂Q/∂y. The components carry 2 common names, Fx, Fy, Fz or P, Q, R, and both name the same functions.

    The formula comes from the dot product. Write ∇ = ⟨∂/∂x, ∂/∂y, ∂/∂z⟩ and multiply it component by component with ⟨P, Q, R⟩. Mixed terms such as ∂P/∂y never appear in the divergence; those belong to the curl.

    Example: F = ⟨x²y, yz, xz²⟩ gives ∂(x²y)/∂x = 2xy, ∂(yz)/∂y = z and ∂(xz²)/∂z = 2xz, so ∇ · F = 2xy + z + 2xz. At (1, 2, 3), the value is 4 + 3 + 6 = 13.

    Term breakdown: each partial derivative, then the sum (live engine)

    — The terms come from the same symbolic engine as the calculator. ⟨yz, xz, xy⟩ has 3 zero terms: every component skips its own variable.

    Symbolab, eMathHelp and Wolfram Alpha return ∇ · F as a formula. Mathematica uses Div[{P, Q, R}, {x, y, z}], and Python's SymPy has sympy.vector.divergence. MATLAB's divergence function and NumPy work on sampled grids and return numbers at the grid points.

    Cylindrical (r, θ, z)

    Divergence in Cylindrical Coordinates

    The divergence of F = Fr r̂ + Fθ θ̂ + Fz ẑ in cylindrical coordinates is:

    The extra r in the first term is the area of the cell faces. A cylindrical cell between r and r + dr has an outer face larger than its inner face, by the factor (r + dr)/r. The same Fr on both faces carries more flow out than in, so the product rFr is what has to change for a nonzero divergence.

    The rule gives 3 quick results for Fr = rⁿ:

    • Fr = r: ∇ · F = (1/r)(2r) = 2, a source.
    • Fr = 1: ∇ · F = 1/r, a weaker source far from the axis.
    • Fr = 1/r: ∇ · F = 0 for r > 0, the field of a long straight line charge.

    Enter θ in radians. In the calculator, pick Cylindrical and type the components in r, theta and z.

    Cell explorer: flux through the inner and outer faces of a cylindrical cell
    flux in at r = 1 (r·F_r)—
    flux out at r = 1.6 (r·F_r)—
    ∇ · F—
    cell—

    The flux through each curved face is r · Fr per radian of angle per unit height. At Fr = r⁻¹, inflow and outflow are both 1 and the divergence is 0.

    Spherical (ρ, φ, θ)

    Divergence in Spherical Coordinates

    The divergence of F = Fρ ρ̂ + Fφ φ̂ + Fθ θ̂ in spherical coordinates, with φ measured from the +z axis, is:

    The factors ρ² and sin φ come from the area of a spherical cell face, ρ² sin φ dφ dθ. A face at distance ρ grows with ρ², so a radial field has to fall like 1/ρ² to keep the same flux through every sphere.

    Divergence of radial fields in spherical coordinates
    Fρρ² Fρ∇ · F
    ρρ³3
    1ρ²2/ρ
    1/ρρ1/ρ²
    1/ρ²10 (for ρ > 0)

    Physics texts (ISO 80000-2) swap the 2 angle letters: θ for the polar angle and φ for the azimuth. The calculator uses φ from +z and θ around the z-axis, both in radians.

    Cell explorer: flux through the inner and outer faces of a spherical cell
    flux in at ρ = 1 (ρ²F_ρ)—
    flux out at ρ = 1.6 (ρ²F_ρ)—
    ∇ · F—
    cell—

    The flux through each face is ρ² Fρ per unit solid angle. Slide to Fρ = ρ⁻²: the 2 faces carry the same flux, the divergence is 0, and the field is the field of a point charge.

    Method

    How to Calculate Divergence in 3 Steps

    To calculate divergence, find the partial derivative of each component with respect to its own variable, add the results, and evaluate the sum at the point. The 3 steps below use F = ⟨sin(xy), cos(xy), ez⟩ at (1, 1, 0).

    01

    Find the partial derivative of each component

    To differentiate P = sin(xy) in x, hold y constant and use the chain rule; do the same for Q in y and R in z:

    02

    Add the 3 partial derivatives

    To get the divergence formula, add the terms in order:

    The result is a scalar function of x, y and z.

    03

    Evaluate at the point

    To evaluate at (1, 1, 0), substitute x = 1, y = 1 and z = 0:

    The value is positive, so (1, 1, 0) is a source.

    Physical meaning

    What Divergence Means Physically

    Divergence means the rate at which a flow expands or compresses at a point: positive divergence marks a source, negative divergence marks a sink, and zero divergence marks an incompressible flow.

    01

    Sources (Positive Divergence)

    A source is a point where div F > 0 and the field flows outward. A lawn sprinkler head, a gas heating up and a positive electric charge are sources. F = ⟨x, y⟩ has div F = 2 at every point.

    02

    Sinks (Negative Divergence)

    A sink is a point where div F < 0 and the field flows inward. A drain, a gas being compressed and a negative charge are sinks. F = ⟨−x, −y⟩ has div F = −2 at every point.

    03

    Divergence-Free (Incompressible) Fields

    A divergence-free field has div F = 0 at every point, so the inflow and outflow of every small region balance. F = ⟨x, −y⟩ squeezes in y and stretches in x by the same rate: 1 − 1 = 0.

    For incompressible flow, the velocity field v satisfies ∇ · v = 0. Water and other liquids at ordinary pressures meet this condition, and computational fluid dynamics (CFD) solvers enforce it in every cell. In a nozzle, ∇ · v = 0 gives A₁v₁ = A₂v₂: halve the cross-section area, and the speed doubles.

    A magnetic field is divergence-free everywhere: ∇ · B = 0, one of Maxwell's equations. Magnetic field lines form closed loops and never start or end at a point.

    Sources, sinks and divergence-free fields
    TypeSignPhysical examples
    Sourcediv F > 0sprinkler, expanding gas, positive charge
    Sinkdiv F < 0drain, compressed gas, negative charge
    Divergence-freediv F = 0liquid flow, magnetic field B

    Gauss's theorem

    The Divergence Theorem

    The divergence theorem states that the total flux of F out through a closed surface S equals the triple integral of div F over the solid V inside it. The theorem is called Gauss's theorem or Ostrogradsky's theorem.

    The theorem turns a surface integral into a volume integral, and the volume integral is often easier. For F = ⟨x, y, z⟩ and the unit ball, ∇ · F = 3, so the flux is 3 × (4/3)π = 4π ≈ 12.566. The direct surface integral agrees: F · n = 1 on the unit sphere, times the area 4π.

    In 2D, the theorem is the normal form of Green's theorem:

    For F = ⟨x², y²⟩ on the unit square [0, 1] × [0, 1], the right side carries flux 1, the top carries 1, and the left and bottom carry 0, for a total of 2. The double integral of 2x + 2y over the square is 1 + 1 = 2. The flux through a surface is computed by the surface integral calculator, and the volume side by the triple integral calculator.

    Divergence theorem explorer: flux through the square = ∬ div F dA
    right—
    top—
    left—
    bottom—
    total flux ∮ F · n ds—
    ∬ div F dA—

    F = ⟨x², y²⟩. Orange arrows mark sides with net outflow and teal arrows mark net inflow. Move and resize the square: the 2 totals stay equal.

    Comparison

    Divergence vs Curl

    Divergence measures how much a field spreads out from a point and returns a scalar; curl measures how much a field rotates around a point and returns a vector.

    Divergence and curl compared
    DivergenceCurl
    Notation∇ · F, div F∇ × F, curl F
    Product with ∇dot productcross product
    Resultscalarvector
    Measuresoutflow per unit volumerotation per unit area
    Zero meansincompressibleirrotational
    ⟨x, y, 0⟩2⟨0, 0, 0⟩
    ⟨−y, x, 0⟩0⟨0, 0, 2⟩
    Integral theoremdivergence theoremStokes' theorem
    Same size, different behaviour: a source and a swirl

    Left: ⟨x, y⟩, div = 2, curl = 0, every arrow points away from the origin. Right: ⟨−y, x⟩, div = 0, curl = 2, every arrow circles the origin and no shading appears.

    3 identities link the operators: ∇ · (∇ × F) = 0 for every smooth F, ∇ × (∇f) = 0 for every smooth f, and ∇ · (∇f) = ∇²f, the Laplacian. The rotation side is computed by the curl calculator.

    Practice

    Worked Examples

    There are 4 worked examples below: a polynomial field at a point, the radial field, the point-charge field and a cylindrical field. Each one loads into the calculator with one click.

    Cartesian

    div ⟨x²y, yz, xz²⟩ at (1, 2, 3)

    1. ∂P/∂x:
    2. ∂Q/∂y:
    3. ∂R/∂z:
    4. At (1, 2, 3):

    Answer: , a source. The map shows the slice z = 3.

    radial

    Radial Field ⟨x, y, z⟩

    1. Each term:
    2. Sum:
    3. Spherical check, Fρ = ρ:

    Answer: at every point. The flux out of a sphere of radius R is 3 × (4/3)πR³ = 4πR³.

    spherical

    Point Charge 1/ρ² Is Divergence-Free

    F = ρ̂/ρ², the field of a point charge (up to a constant).

    1. Multiply by ρ²:
    2. Differentiate:
    3. Divergence:

    Answer: away from the origin. The flux through every sphere around the charge is still 4π: the whole source sits at ρ = 0, where ∇ · F = 4πδ³(r), the form behind Gauss's law.

    cylindrical

    Cylindrical Field F_r = r

    F = r r̂, with Fθ = 0 and Fz = 0.

    1. Multiply by r:
    2. Differentiate and divide by r:
    3. Cartesian check, ⟨x, y, 0⟩:

    Answer: at every point. Adding Fz = z raises the divergence to 3, the radial field ⟨x, y, z⟩.

    Questions

    Frequently Asked Questions

    Is divergence a scalar or a vector?

    Divergence is a scalar, while the field it comes from is a vector field. The dot product ∇ · F adds 3 numbers into 1: for F = ⟨x²y, yz, xz²⟩, ∇ · F = 2xy + z + 2xz, a scalar function, and its value at (1, 2, 3) is the single number 13.

    What does zero divergence mean?

    Zero divergence means the field has no net outflow at the point: the flow into every small region around it equals the flow out. A field with div F = 0 everywhere is called divergence-free, incompressible or solenoidal. Liquid flow (∇ · v = 0), the magnetic field (∇ · B = 0) and the swirl ⟨−y, x⟩ are divergence-free.

    Why does the spherical formula have extra terms?

    The spherical formula has extra terms since the faces of a spherical cell change size with position: the area element is ρ² sin φ dφ dθ. The ρ² and sin φ factors inside the derivatives track that area, and the 1/ρ² and 1/(ρ sin φ) factors outside divide by the cell volume. Without them, F_ρ = 1/ρ² would show a false nonzero divergence.

    What is the divergence of a curl?

    The divergence of a curl is always 0: ∇ · (∇ × F) = 0 for every vector field F with continuous second partial derivatives. The mixed partial derivatives cancel in pairs, for example ∂²R/∂x∂y − ∂²R/∂y∂x = 0. A curl field is divergence-free, which is the reason ∇ · B = 0 lets B be written as ∇ × A.

    Where is divergence used in physics?

    Divergence is used in electromagnetism, fluid dynamics, heat transfer and electronics. There are 4 core equations with divergence: Gauss's law ∇ · E = ρ/ε₀, ∇ · B = 0, the continuity equation ∂ρ/∂t + ∇ · (ρv) = 0, and heat diffusion ∂T/∂t = α∇²T. In circuits and semiconductors, ∇ · J = −∂ρ/∂t states charge conservation; CFD codes use ∇ · v = 0 for nozzle and pipe flow.

    This divergence calculator finds ∇·F with steps in 4 coordinate systems, evaluates it at a point and shows sources and sinks on a field map.