Accelerating the pace of engineering and science

# divergence

Divergence of vector field

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```

$div\left(V\right)=\nabla \cdot V=\sum _{i=1}^{n}\frac{\partial {V}_{i}}{\partial {x}_{i}}$