Div
Details
- Div is also known as the contracted covariant derivative.
- Div[f,x] can be input as ∇x.f. The character ∇ can be typed as
del
or \[Del], and the character . is an ordinary period. The list of variables x is entered as a subscript. - An empty template ∇. can be entered as
del.
, and
moves the cursor from the subscript to the main body. - All quantities that do not explicitly depend on the variables given are taken to have zero partial derivative.
- In Div[f,x], if f is an array of dimensions {n1,…,nk-1,nk}, then x must have length nk, and the resulting divergence is an array of dimensions {n1,…,nk-1}.
- In Div[f,{x1,…,xn},chart], if f is an array, then it must have dimensions {n,…,n}. The components of f are interpreted as being in the orthonormal basis associated with chart.
- For coordinate charts on Euclidean space, Div[f,{x1,…,xn},chart] can be computed by transforming f to Cartesian coordinates, computing the ordinary divergence, and transforming back to chart. »
- A property of Div is that if chart is defined with metric g, expressed in the orthonormal basis, then Div[g,{x1,…,xn},chart] gives zero. »
- Coordinate charts in the third argument of Div can be specified as triples {coordsys,metric,dim} in the same way as in the first argument of CoordinateChartData. The short form in which dim is omitted may be used.
- Div[f,VectorSymbol[…]] computes the divergence with respect to the vector symbol. »
- Div works with SparseArray and structured array objects.
Examples
open all close allBasic Examples (4)
Divergence of a vector field in Cartesian coordinates:
Div[{f[x, y, z], g[x, y, z], h[x, y, z]}, {x, y, z}]Divergence of a vector field in cylindrical coordinates:
Div[{f[r, θ, z], g[r, θ, z], h[r, θ, z]}, {r, θ, z}, "Cylindrical"]Divergence in two-dimensional polar coordinates:
Div[{r Sin[θ], -r Cos[θ]}, {r, θ}, "Polar"]Use
del
to enter ∇ and
to enter the list of subscripted variables:
Subscript[∇, {x, y, z}].{y, -x, z}Use
del.
to enter the template ∇., fill in the variables, press
, and fill in the function:
Subscript[∇, {x, y, z}].{y, -x, z}Scope (7)
In a curvilinear coordinate system, a vector with constant components may have a nonzero divergence:
Div[{1, 1, 1}, {r, θ, ϕ}, "Spherical"]//ExpandDivergence of a rank-2 tensor:
Div[{{x y, x y^2, x y^3}, {x^2y, x^2y^2, x^2y^3}, {x^3y, x^3y^2, x^3y^3}}, {x, y, z}]Divergence specifying metric, coordinate system, and parameters:
Div[{f[ϕ, ψ], 1}, {ϕ, ψ}, {{"Confocal", {a, b}}, "Euclidean"}]//SimplifyDiv works on curved spaces:
Div[{f[u, v, w], g[u, v, w], h[u, v, w]}, {u, v, w}, {"Stereographic", {"Sphere", 1}}]//FullSimplifyThe divergence of
with respect to itself is expressed in terms of SymbolicIdentityArray[{n}]:
x = VectorSymbol["x", n, Reals];Div[x, x]Applying TensorExpand gives the expected answer, namely the dimension:
TensorExpand[%]The divergence of
scaled by its squared norm:
Div[x.x x, x]//FullSimplifyThe divergence of a constant affine transformation of
equals the trace of the linear part:
Div[MatrixSymbol["m", {n, n}, ℝ]. x + VectorSymbol["y", n, ℝ], x]//TensorExpandThe power rule for a divergence is the sum of the power rule for the individual components:
x = VectorSymbol["x", n];
Div[x ^ k, x]//ArraySimplifyWrite out this result in three dimensions:
Block[{n = 3}, ComponentExpand[%]]The divergence of the coordinate vector in n dimensions:
Div[Inactive[Table][Subscript[x, i], {i, 1, n}], Inactive[Table][Subscript[x, j], {j, 1, n}]]Activate the sum to get the simple result:
Activate[%]Applications (3)
Determine whether a fluid flow is incompressible:
Div[{y , -x }, {x, y}]StreamPlot[{y, -x}, {x, -1, 1}, {y, -1, 1}]For the function
, define the associated conjugate vector field
:
w[x_, y_] = {u[x, y], -v[x, y]}The Cauchy–Riemann equations for
are equivalent to
being divergence free and curl free:
Div[w[x, y], {x, y}] == 0Curl[w[x, y], {x, y}] == 0The divergence of the rank-2 stress tensor equals the force at each point of a static elastic medium:
σ[r_, θ_, φ_] = SymmetrizedArray[{{1, 1} -> σrr[r, θ, φ], {1, 2} -> σrθ[r, θ, φ], {1, 3} -> σrφ[r, θ, φ], {2, 2} -> σθθ[r, θ, φ], {2, 3} -> σθφ[r, θ, φ], {3, 3} -> σφφ[r, θ, φ]}, {3, 3}, Symmetric[All]];
Div[σ[r, θ, φ], {r, θ, φ}, "Spherical"]//Simplify//NormalProperties & Relations (9)
Div reduces the rank of array by one:
Div[{a[x, y], b[x, y]}, {x, y}]Div[{{a[x, y], b[x, y]}, {c[x, y], d[x, y]}}, {x, y}]Div[{f1,f2,…,fn},{x1,x2,…,xn}] is the trace of the gradient of f:
Div[{x ^ 2y, z x y, z ^ 3}, {x, y, z}] == Tr[Grad[{x ^ 2y, z x y, z ^ 3}, {x, y, z}]]Compute Div in a Euclidean coordinate chart c by transforming to and then back from Cartesian coordinates:
TransformedField["Polar" -> "Cartesian", {f[r, θ], g[r, θ]}, {r, θ} -> {x, y}]Div[%, {x, y}]//SimplifyFullSimplify[TransformedField["Cartesian" -> "Polar", %, {x, y} -> {r, θ}], r > 0 && -π < θ < π]The result is the same as directly computing Div[f,{x1,…,xn},c]:
Div[{f[r, θ], g[r, θ]}, {r, θ}, "Polar"]The two-argument form Div[f,vars] is essentially Listable in its first argument:
(rect = {{a[x, y], b[x, y]}, {c[x, y], d[x, y]}, {e[x, y], f[x, y]}})//MatrixFormDiv[rect, {x, y}]Div[#, {x, y}]& /@ rectDiv[array,vars,sys] is effectively Grad followed by TensorContract on the last two slots:
Div[{{a[r, θ], b[r, θ]}, {c[r, θ], d[r, θ]}}, {r, θ}, "Polar"]TensorContract[Grad[{{a[r, θ], b[r, θ]}, {c[r, θ], d[r, θ]}}, {r, θ}, "Polar"], {{2, 3}}]However, this operation is not, in general, Listable:
Div[#, {r, θ}, "Polar"]& /@ {{a[r, θ], b[r, θ]}, {c[r, θ], d[r, θ]}}If chart is defined with metric g, expressed in the orthonormal basis, Div[g,{x1,…,xn},chart] is zero:
Div[IdentityMatrix[3], {r, θ, φ}, "Spherical"]Div contracts the innermost index of the array, which for matrices means acting on rows:
(square = {{a[x, y], b[x, y]}, {c[x, y], d[x, y]}})//MatrixFormDiv[square, {x, y}]To contract into a different index, use Grad followed by an explicit TensorContract:
TensorContract[Grad[{{a[x, y], b[x, y]}, {c[x, y], d[x, y]}}, {x, y}], {{1, 3}}]In the matrix case, acting on columns can be achieved by first transposing the matrix square:
Div[Transpose@square, {x, y}]The divergence of a curl is zero:
Div[Curl[{f[x, y, z], g[x, y, z], h[x, y, z]}, {x, y, z}], {x, y, z}]Even for non-vector inputs, the result is zero:
Div[Curl[f[x, y, z], {x, y, z}], {x, y, z}]//NormalThis identity is respected by the Inactive form of Div:
Div[Inactive[Curl][{f[x, y, z], g[x, y, z], h[x, y, z]}, {x, y, z}], {x, y, z}]Div[Inactive[Curl][f[x, y, z], {x, y, z}], {x, y, z}]//NormalDiv preserves the structure of SymmetrizedArray objects:
sa = SymmetrizedArray[{{1, 1, 1} -> x ^ 2, {1, 1, 2} -> y ^ 2, {2, 1, 2} -> x y}, {2, 2, 2}, Symmetric]The divergence maintains symmetries not involving the final slot:
div = Div[sa, {x, y}]Interactive Examples (1)
View expressions for the divergence of a vector function in different coordinate systems:
systems = {{"Cartesian", "Polar", "Bipolar", "PlanarParabolic"}, {"Cartesian", "Cylindrical", "Spherical", "CircularParabolic", "BipolarCylindrical"}, {"Cartesian", "Hyperspherical"}, {"Cartesian", "Hyperspherical"}};Manipulate[
If[Not@MemberQ[systems[[dimension - 1]], system], system = "Cartesian"];
Block[{f, varNames, vars, vec},
varNames = CoordinateChartData[{system, dimension}, "StandardCoordinateNames"];
vars = ToExpression /@ varNames;
vec = Subscript[f, HoldForm[#]]@@vars& /@ varNames;
Inactive[Div][vec, vars] == Simplify@Div[vec, vars, system]],
{dimension, Range[2, 5]},
{{system, "Cartesian"}, systems[[dimension - 1]], ControlType -> SetterBar}, SaveDefinitions -> True]See Also
Grad Curl Laplacian CoordinateChartData Dot D DSolve NDSolve DEigensystem NDEigensystem DEigenvalues NDEigenvalues
Characters: \[Del]
Tech Notes
Text
Wolfram Research (2012), Div, Wolfram Language function, https://reference.wolfram.com/language/ref/Div.html (updated 2024).
CMS
Wolfram Language. 2012. "Div." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Div.html.
APA
Wolfram Language. (2012). Div. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Div.html
BibTeX
@misc{reference.wolfram_2026_div, author="Wolfram Research", title="{Div}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Div.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_div, organization={Wolfram Research}, title={Div}, year={2024}, url={https://reference.wolfram.com/language/ref/Div.html}, note=[Accessed: 12-June-2026]}