Documentation Center

  • Trial Software
  • Product Updates

divergence

Divergence of vector field

Syntax

divergence(V,X)

Description

divergence(V,X) returns the divergence of the vector field V with respect to the vector X in Cartesian coordinates. Vectors V and X must have the same length.

Input Arguments

V

Vector of symbolic expressions or symbolic functions.

X

Vector with respect to which you compute the divergence.

Examples

Compute the divergence of the vector field V(x, y, z) = (x, 2y2, 3z3) with respect to vector X = (x, y, z) in Cartesian coordinates:

syms x y z
divergence([x, 2*y^2, 3*z^3], [x, y, z])
ans =
9*z^2 + 4*y + 1
 

Compute the divergence of the curl of this vector field. The divergence of the curl of any vector field is 0.

syms x y z
divergence(curl([x, 2*y^2, 3*z^3], [x, y, z]), [x, y, z])
ans =
0
 

Compute the divergence of the gradient of this scalar function. The result is the Laplacian of the scalar function:

syms x y z
f = x^2 + y^2 + z^2;
divergence(gradient(f, [x, y, z]), [x, y, z])
ans =
6

More About

expand all

Divergence of a Vector Field

The divergence of the vector field V = (V1,...,Vn) with respect to the vector X = (X1,...,Xn) in Cartesian coordinates is the sum of partial derivatives of V with respect to X1,...,Xn:

See Also

| | | | | | |

Was this topic helpful?