Divergence Calculator

Compute divergence for 2D or 3D vector fields and interpret the field as a source, sink, or zero-divergence field.

Results are calculated automatically as you enter data.

Formula and interpretation
Result Enter vector components.

▼ See explanations and tips below ▼

What Is Divergence?

Divergence is a way to measure how a vector field behaves near a single point. A vector field assigns a vector to each point in a plane or in space. For example, the arrows in a velocity field might show how a fluid is moving at each location.

The divergence at a point asks a local question: is the field spreading outward from that point, squeezing inward toward it, or balancing inward and outward flow? The answer is a scalar value, not a vector. That means divergence has size and sign, but it does not point in a direction.

A positive divergence value means the field is source-like at that point. In a flow interpretation, more is leaving a tiny region around the point than entering it. A negative divergence value means the field is sink-like. More is entering than leaving. A value near zero means little or no net local expansion, even though the field may still be moving or rotating.

Divergence is used throughout vector calculus because it connects local behavior to broader ideas such as flux, sources, sinks, incompressible flow, and the divergence theorem.


Why Divergence Matters

Divergence helps turn a picture of arrows into a measurable statement. Instead of only saying that arrows seem to spread out or come together, divergence gives a formula-based result.

This matters in several common settings:

  • In vector calculus, divergence helps describe vector fields before studying flux integrals and the divergence theorem.
  • In fluid-flow models, divergence helps identify local expansion, compression, or incompressible behavior.
  • In physics and engineering, divergence appears in field equations, conservation laws, and source-density interpretations.
  • In math coursework, divergence is a common step before comparing related concepts such as gradient, curl, flux, and conservative fields.

The key idea is local behavior. A field can have positive divergence at one point, negative divergence at another point, and zero divergence somewhere else.


Key Terms to Know

  • Vector field: A rule that assigns a vector to each point, such as \(\mathbf{F}(x,y)\) in the plane or \(\mathbf{F}(x,y,z)\) in space.
  • Component: One coordinate part of a vector field. In \(\mathbf{F}=\langle P,Q,R\rangle\), the components are \(P\), \(Q\), and \(R\).
  • Partial derivative: A derivative with respect to one variable while the other variables are held fixed.
  • Del or nabla: The operator \(\nabla\), used in vector calculus notation for gradient, divergence, and curl.
  • Divergence: The scalar function \(\nabla \cdot \mathbf{F}\) formed by adding the coordinate-matched partial derivatives of a vector field.
  • Flux: A measure of how much of a vector field passes through a curve or surface.
  • Source: A location where the field behaves as though it is locally expanding outward.
  • Sink: A location where the field behaves as though it is locally contracting inward.
  • Incompressible field: In a velocity-field interpretation, a field with zero divergence, meaning no net local volume expansion.
  • Cartesian coordinates: The usual \(x\), \(y\), and \(z\) coordinate system. The formulas in this article use Cartesian coordinates.
  • Jacobian trace: In Cartesian coordinates, the divergence of a vector field can also be viewed as the trace of its derivative matrix.

How Divergence Works

For a two-dimensional Cartesian vector field,

$$ \mathbf{F}(x,y)=\langle P(x,y),Q(x,y)\rangle $$

the divergence is

$$ \nabla \cdot \mathbf{F}=\frac{\partial P}{\partial x}+\frac{\partial Q}{\partial y} $$

For a three-dimensional Cartesian vector field,

$$ \mathbf{F}(x,y,z)=\langle P(x,y,z),Q(x,y,z),R(x,y,z)\rangle $$

the divergence is

$$ \nabla \cdot \mathbf{F}=\frac{\partial P}{\partial x}+\frac{\partial Q}{\partial y}+\frac{\partial R}{\partial z} $$

Each term compares a field component with motion in the same coordinate direction:

  • \(\frac{\partial P}{\partial x}\) measures how the \(x\)-component changes as \(x\) changes.
  • \(\frac{\partial Q}{\partial y}\) measures how the \(y\)-component changes as \(y\) changes.
  • \(\frac{\partial R}{\partial z}\) measures how the \(z\)-component changes as \(z\) changes.

The formula does not add every possible partial derivative. Cross-direction changes such as \(\frac{\partial P}{\partial y}\) or \(\frac{\partial Q}{\partial x}\) are important in other vector-calculus ideas, especially curl, but they are not part of the Cartesian divergence formula.

After finding the symbolic divergence, you can evaluate it at a point by substituting the point coordinates. For example, if

$$ \nabla \cdot \mathbf{F}=3x+2z $$

then at \((x,y,z)=(1,2,3)\),

$$ \nabla \cdot \mathbf{F}(1,2,3)=3(1)+2(3)=9 $$

The \(y\) coordinate may still matter in other fields, but in this example the final divergence expression does not contain \(y\).


Examples of Divergence in Practice

Example 1: A Simple Source-Like Field

Consider the two-dimensional vector field

$$ \mathbf{F}(x,y)=\langle x,y\rangle $$

Here, \(P=x\) and \(Q=y\). The divergence is

$$ \nabla \cdot \mathbf{F}=\frac{\partial}{\partial x}(x)+\frac{\partial}{\partial y}(y) $$
$$ \nabla \cdot \mathbf{F}=1+1=2 $$

The divergence is positive everywhere. In a flow interpretation, this field behaves like local expansion: arrows move outward and the local flow is source-like.


Example 2: A Simple Sink-Like Field

Now consider

$$ \mathbf{F}(x,y)=\langle -x,-y\rangle $$

The divergence is

$$ \nabla \cdot \mathbf{F}=\frac{\partial}{\partial x}(-x)+\frac{\partial}{\partial y}(-y) $$
$$ \nabla \cdot \mathbf{F}=-1-1=-2 $$

The result is negative everywhere. This is sink-like behavior: the field locally contracts inward.


Example 3: Rotation Without Divergence

A field can rotate without expanding or contracting. Consider

$$ \mathbf{F}(x,y)=\langle -y,x\rangle $$

The divergence is

$$ \nabla \cdot \mathbf{F}=\frac{\partial}{\partial x}(-y)+\frac{\partial}{\partial y}(x) $$

Since \(-y\) does not change with \(x\), and \(x\) does not change with \(y\),

$$ \nabla \cdot \mathbf{F}=0+0=0 $$

This field has circular motion around the origin, but its divergence is zero. That is a useful reminder: divergence measures local expansion or contraction, not rotation.


Example 4: A 3D Field Evaluated at a Point

For the three-dimensional field

$$ \mathbf{F}(x,y,z)=\langle x^2,xy,z^2\rangle $$

the divergence is

$$ \nabla \cdot \mathbf{F}=\frac{\partial}{\partial x}(x^2)+\frac{\partial}{\partial y}(xy)+\frac{\partial}{\partial z}(z^2) $$
$$ \nabla \cdot \mathbf{F}=2x+x+2z $$
$$ \nabla \cdot \mathbf{F}=3x+2z $$

At \((1,2,3)\),

$$ \nabla \cdot \mathbf{F}(1,2,3)=3(1)+2(3)=9 $$

The positive value means the field is source-like at that point.


How to Interpret the Result

The main divergence result is the numeric value of \(\nabla \cdot \mathbf{F}\) at the selected point. The symbolic divergence shows the formula before the point coordinates are substituted.

A positive result means source-like expansion, and a negative result means sink-like contraction. Only an exact result of \(0\) is classified as zero divergence; small nonzero values remain visible in scientific notation and retain their sign.

The magnitude also matters, but only in context. A divergence of \(10\) is stronger than a divergence of \(0.1\) in the same model and coordinate scale. However, comparing magnitudes across different models can be misleading unless the variables, scaling, and physical units are consistent.

The partial-derivative breakdown is often the most useful part for learning. It shows which component contributed to the final sum. For instance, a positive \(\frac{\partial P}{\partial x}\) can be offset by a negative \(\frac{\partial Q}{\partial y}\), producing a smaller total divergence or even zero.

The vector-field preview can help you build intuition, but the visual pattern is not the proof. The calculation comes from the symbolic partial derivatives and the numeric evaluation at the chosen point.


Common Mistakes and Misconceptions

A common mistake is treating divergence as the direction of the vector field. Divergence is not an arrow. It is a scalar measurement of local expansion or contraction.

Another mistake is assuming that outward-looking arrows always mean positive divergence. A field can point outward while slowing down enough that local divergence is not positive. A graph is helpful, but the formula gives the reliable answer.

Students also often confuse divergence with curl. Divergence measures source-like or sink-like behavior. Curl measures rotational tendency. A field can have zero divergence and still rotate, as in \(\mathbf{F}=\langle -y,x\rangle\).

When entering expressions, use explicit multiplication. Write 2x, xy, or (x+1)*(y+1), not 2x, xy, or (x+1)(y+1).

Use only the variables allowed for the selected dimension. In 2D mode, use \(x\) and \(y\). In 3D mode, use \(x\), \(y\), and \(z\). Do not enter a \(z\)-dependent expression while using 2D mode.

Be careful with logarithms and trigonometry. The calculator treats log as the natural logarithm, the same as ln. Trigonometric inputs use radians, not degrees.

Finally, check the domain of the expression at the chosen point. Expressions such as \(\ln(x)\), \(\sqrt{x}\), and derivatives involving \(\operatorname{abs}(x)\) may fail or become undefined at certain real-valued points.


When to Use Divergence

Use divergence when you need to know whether a Cartesian vector field is locally expanding, contracting, or balancing inflow and outflow.

It is especially useful when you want to:

  • classify a point as source-like, sink-like, or zero-divergence;
  • check a vector-calculus homework problem involving \(\nabla \cdot \mathbf{F}\);
  • compare source, sink, and rotational examples;
  • prepare for flux integrals or the divergence theorem;
  • analyze a 2D field \(\langle P,Q\rangle\) or a 3D field \(\langle P,Q,R\rangle\) in Cartesian coordinates;
  • see how each component contributes to the final divergence value.

Divergence is not the right tool when the main question is rotation, circulation, or tangential spinning. For that, curl is usually the related concept to study.


Limitations and Things to Keep in Mind

The formula used here is for Cartesian coordinates. Polar, cylindrical, and spherical coordinate systems use different divergence formulas. Do not enter a non-Cartesian field and expect the Cartesian formula to automatically adjust.

The calculator works with real-valued expressions. It does not support complex-valued outputs, piecewise-defined vector fields, multi-argument functions, or variables other than \(x\), \(y\), and \(z\).

Supported functions include sin, cos, tan, exp, ln, log, sqrt, and abs. Constants such as pi, \(\pi\), and e are supported. Coordinates can be entered as decimals or in scientific notation, such as 1e-3.

The calculator requires finite values at the selected point. It evaluates the original component expressions before simplifying derivative formulas, so an expression such as 0/x is rejected at x=0 rather than being treated as zero. If a component or derivative evaluates to NaN, infinity, or an undefined real value, the result is rejected instead of being interpreted.

The derivative of an absolute-value expression is not defined where the inside expression is zero. Some power expressions with variable exponents may also become invalid in real-valued arithmetic because their derivative can involve a logarithmic form.

Very large or very small finite values are displayed in exponential notation when needed. Nonzero values are not rounded to zero for the result or its source/sink interpretation.

The symbolic simplification is meant to support the calculation, not to replace a full computer algebra system. For finite decimal algebra, the calculator preserves exact rational values while summing the coordinate-aligned partials so a small residual is not lost beside a large coefficient; supported functions are evaluated numerically. For coursework, proofs, engineering analysis, or scientific work, review the symbolic derivative and verify important results independently.

In 3D mode, the visual preview is the \(P\)-\(Q\) vector projection in the \(xy\) plane at the selected \(z\) value. It is not a full three-dimensional rendering and does not draw the \(R\) component; clicking the preview updates \(x\) and \(y\) only.


How to Use This Calculator

  1. Select whether the vector field is 2D or 3D.
  2. Enter the \(P\) and \(Q\) component expressions. In 3D mode, also enter the \(R\) component.
  3. Enter the evaluation point: \(x\) and \(y\) in 2D, or \(x\), \(y\), and \(z\) in 3D.
  4. Review the main divergence result, symbolic divergence, interpretation, and partial-derivative table.
  5. Use the vector-field preview to inspect nearby field values and local divergence.
  6. Click the preview to update the \(x\) and \(y\) coordinates from a plotted point, if helpful.
  7. Try the example fields to compare source-like, sink-like, and zero-divergence behavior.
  8. Download the preview as a PNG after a valid vector-field graph is drawn, if you need a saved image.

Frequently Asked Questions

Is divergence a scalar or a vector?

Divergence is a scalar. It gives a signed value at each point, not a direction. The original vector field has arrows, but its divergence is a scalar field.


What does positive divergence mean?

Positive divergence means the field is locally source-like at the selected point. In a flow interpretation, more is leaving a tiny region around the point than entering it.


What does zero divergence mean?

Zero divergence means there is no net local expansion or contraction in the field at that point. It does not mean the vector field is zero. A field can move or rotate while still having zero divergence.


Can a rotating field have zero divergence?

Yes. The field \(\mathbf{F}=\langle -y,x\rangle\) rotates around the origin, but its divergence is \(0\). Rotation is measured by curl, not by divergence.


Does this work for polar, cylindrical, or spherical coordinates?

No. The formulas shown here are Cartesian divergence formulas. Other coordinate systems have different formulas because their coordinate directions and scale factors change from point to point.


Why does the calculator require explicit multiplication?

The expression parser expects multiplication to be written directly. Use 2x, xy, or (x+1)*(y+1) instead of 2x, xy, or (x+1)(y+1).


Why does log act like ln?

In this calculator, log is interpreted as the natural logarithm. Use ln or log for natural logarithms, and do not assume log means base \(10\).


Sources and References

Books and Open Textbooks

  1. Gilbert Strang and Edwin “Jed” Herman. Calculus Volume 3. OpenStax, 2016. Sections 6.5, “Divergence and Curl,” and 6.8, “The Divergence Theorem.” Section 6.5 and Section 6.8.
  2. Joel Feldman, Andrew Rechnitzer, and Elyse Yeager. CLP-4 Vector Calculus. University of British Columbia, 2017–2024. Sections 4.1, “Gradient, Divergence and Curl,” and 4.2, “The Divergence Theorem.” Textbook page and PDF text.

Online Educational Sources

  1. Massachusetts Institute of Technology OpenCourseWare. “Part B: Flux and the Divergence Theorem.” 18.02SC Multivariable Calculus, accessed June 28, 2026. MIT OpenCourseWare.
  2. Paul Dawkins. “Curl and Divergence.” Paul’s Online Notes, Calculus III, Lamar University, last modified November 16, 2022. Paul’s Online Notes.
  3. Duane Q. Nykamp. “The Idea of the Divergence of a Vector Field.” Math Insight, accessed June 28, 2026. Math Insight.