acalculator

What is the divergence of a field?

Type the three components P, Q and R of a vector field in x, y and z. The page gives the divergence div F, and the curl as well.

Your numbers

div F
-2y z + z + e^x

The divergence of (e^x, y z, -y z^2) is -2y z + z + e^x.

curl F
(-z^2 - y, 0, 0)

div F: -2y z + z + e^x. The divergence of (e^x, y z, -y z^2) is -2y z + z + e^x.

How to calculate

Finds the divergence div F = ∇ · F of a vector field F = (P, Q, R), and its curl, checked numerically.

Example with the default inputs (P (i component) e^x, Q (j component) y z, R (k component) -y z^2): The divergence of (e^x, y z, -y z^2) is -2y z + z + e^x.

Method: div F = ∂P/∂x + ∂Q/∂y + ∂R/∂z, each partial derivative from a CAS, checked.

  • Radians. An answer that fails its check is not shown.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. P (i component) e^x, Q (j component) y z, R (k component) -y z^2 gives div F -2y z + z + e^x.Source: OpenStax Calculus Vol. 3 (Strang and Herman, 2016), 6.5, Ex. 6.48
  2. P (i component) y z, Q (j component) x z, R (k component) x y gives div F 0, curl F (0, 0, 0).Source: OpenStax Calculus Vol. 3 (Strang and Herman, 2016), 6.5, Ex. 6.56
  3. P (i component) x^2 z, Q (j component) e^y + x z, R (k component) x y z gives div F x y + 2x z + e^y, curl F (x z - x, x^2 - y z, z).Source: OpenStax Calculus Vol. 3 (Strang and Herman, 2016), 6.5, Ex. 6.52

How it works

For a vector field F = (P, Q, R), where P, Q and R are functions of x, y and z, the page computes

  • div F = P_x + Q_y + R_z, and
  • curl F = (R_y − Q_z, P_z − R_x, Q_x − P_y),

where P_x means ∂P/∂x, and so on.

Partial derivatives. Each partial derivative comes from a computer algebra system (nerdamer, open source), with the other two letters held constant. Each is checked: at 15 fixed test points in x, y and z (values such as 0.21, −0.37, 0.57, 1.33, −0.91 and up to ±8.93), a five-point central difference with steps h = 0.001 × max(1, |value|) and h/2 must match the formula to 10⁻⁶ × max(1, |slope|) (plus 10⁻¹¹ × |f| / h for rounding). Points where the function is not real, or where the two steps disagree, are skipped; at least 3 must agree and none may disagree.

Simplifying. The divergence, and each curl component, has the pairs of terms that cancel as written removed, and is then simplified by three candidates: that form; the algebra’s expanded form; and that expanded form expanded again after each cos(u)² is written as 1 − sin(u)². The shortest written form is kept, and each expanded form must equal the unsimplified expression at the 15 test points to 10⁻⁹.

What you can type

  • Each component is a function of x, y and z; a component may be a number such as 0.
  • pi (or π) is π and e is Euler’s number. Functions: sqrt, ln, exp, abs, sin, cos, tan and their inverses, sinh, cosh, tanh. Angles are in radians.

How answers are written

Terms that are numbers times powers of the letters come first, highest total degree first, then by the powers of x, y and z in that order; other terms follow; a constant comes last. An answer that holds a number the algebra rounded, has two or more number terms the algebra could not add into one (1e-300 + 1e300 + 1), fails its check, or takes over 3 seconds is not shown.

Worked examples by hand

F = (eˣ, yz, −yz²) (OpenStax Calculus Volume 3, section 6.5, Example 6.48). P_x = eˣ, Q_y = z, R_z = −2yz, so div F = eˣ + z − 2yz, written by the page as −2y z + z + e^x.

F = (yz, xz, xy) (Example 6.56). P_x = 0, Q_y = 0, R_z = 0, so div F = 0, and its curl is (0, 0, 0).

F = (x²z, eʸ + xz, xyz) (Example 6.52, where OpenStax finds the curl). P_x = 2xz, Q_y = eʸ and R_z = xy, so div F = x y + 2x z + e^y. The curl is (xz − x, x² − yz, z).

Other questions people ask

What is the divergence of a vector field?

For F = (P, Q, R), the divergence is the scalar function div F = ∇ · F = ∂P/∂x + ∂Q/∂y + ∂R/∂z. It measures how much the field flows out of a tiny box around each point, per unit of volume.

What does the sign of the divergence mean?

Positive divergence at a point is a source: more of the field flows out than in. Negative divergence is a sink. Zero divergence everywhere means the field is source-free (incompressible), like the flow of water.

How do I find the divergence of a 2D field?

Type P and Q and set R to 0. The divergence is then ∂P/∂x + ∂Q/∂y. For F = (x, y) it is 1 + 1 = 2.

What is the difference between divergence and curl?

The divergence is a number at each point and measures outflow. The curl is a vector at each point and measures rotation. The page shows both from the same checked partial derivatives; the curl calculator heads its answer with the curl.

What is the divergence theorem?

For a solid E with a closed outward surface S, the flux of F out of S equals the triple integral of div F over E: ∬_S F · dS = ∭_E div F dV. A field with div F = 0 has zero net flux through every closed surface.

Is the divergence of a curl always zero?

Yes. For any field G whose components have continuous second partial derivatives, div(curl G) = 0, because the mixed partial derivatives cancel in pairs.

How is the answer checked?

Each partial derivative comes from a computer algebra system and must match a numeric difference quotient at 15 test points in x, y and z. The simplified divergence must equal the unsimplified sum at the same points. An answer that fails is not shown.