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:

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.
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
Divergence
Terms
Step-by-step solution
—Step by step
To use the divergence calculator, follow these 5 steps. The result and the map update as you type.
Pick the coordinate system
Choose 2D, Cartesian, cylindrical (r, θ, z) or spherical (ρ, φ, θ). The labels of the 3 inputs change to match.
Type the components
Use the variables of the system: x^2*y in Cartesian, r*sin(theta) in cylindrical, 1/rho^2 in spherical.
Add a point (optional)
Enter coordinates in the same system, angles in radians, for example 2, pi/4, 1.
Read the result
Check the divergence formula, its value at the point and the label: source, sink or divergence-free.
Explore the map
Drag the point across the map. Watch the flux arrows around the circle grow, shrink or flip.
Definition
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:
Divergence is a topic of Calculus III (multivariable calculus) and vector calculus, next to the gradient and the curl.
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.
| Subject | What "divergence" means | Formula 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 integrals | an integral grows without bound | ∫₁^∞ 1/x dx diverges |
| Statistics (KL divergence) | distance between 2 probability distributions | |
| Trading (RSI divergence) | price and an indicator move apart | new 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
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.
— 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)
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ⁿ:
Enter θ in radians. In the calculator, pick Cylindrical and type the components in r, theta and z.
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 (ρ, φ, θ)
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.
| Fρ | ρ² Fρ | ∇ · F |
|---|---|---|
| ρ | ρ³ | 3 |
| 1 | ρ² | 2/ρ |
| 1/ρ | ρ | 1/ρ² |
| 1/ρ² | 1 | 0 (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.
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
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).
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:
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.
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
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.
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.
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.
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.
| Type | Sign | Physical examples |
|---|---|---|
| Source | div F > 0 | sprinkler, expanding gas, positive charge |
| Sink | div F < 0 | drain, compressed gas, negative charge |
| Divergence-free | div F = 0 | liquid flow, magnetic field B |
Gauss's 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.
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 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 | Curl | |
|---|---|---|
| Notation | ∇ · F, div F | ∇ × F, curl F |
| Product with ∇ | dot product | cross product |
| Result | scalar | vector |
| Measures | outflow per unit volume | rotation per unit area |
| Zero means | incompressible | irrotational |
| ⟨x, y, 0⟩ | 2 | ⟨0, 0, 0⟩ |
| ⟨−y, x, 0⟩ | 0 | ⟨0, 0, 2⟩ |
| Integral theorem | divergence theorem | Stokes' theorem |
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
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.
Answer: , a source. The map shows the slice z = 3.
Answer: at every point. The flux out of a sphere of radius R is 3 × (4/3)πR³ = 4πR³.
F = ρ̂/ρ², the field of a point charge (up to a constant).
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.
F = r r̂, with Fθ = 0 and Fz = 0.
Answer: at every point. Adding Fz = z raises the divergence to 3, the radial field ⟨x, y, z⟩.
Questions
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.
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.
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.
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.
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.