# Interchange of Gradient and Divergence.

It's very very often and in many books depending on author there is mostly interchange of gradient $D$ and divergence $\nabla$.

What should I be careful about while dealing with such cases?
For example say $\int_\Omega v\Delta u$ using integration by parts and assuming that the boundary term vanishes this becomes $\int_\Omega Dv\cdot Du$.

Very often I also see the expression $\int_\Omega\nabla v\cdot\nabla u$, so this leads me to confusion sometimes.

-
$\Delta=\nabla^2$ doesn't really fit in your pattern: So this leads me to confusion... –  draks ... Jul 26 '12 at 19:25
I suggest writing $\mathrm{div}$ for divergence. It's annoying that \div is used for division in $\LaTeX$ but you can DeclareMathOperator. –  user31373 Jul 26 '12 at 23:01

These are cases when index notations becomes extremely helpful. Denote by $\partial_1 = \partial_x, \partial_2 = \partial_y, \partial_3 = \partial_z$ and for a vector write its components as $$\vec{v} = v_1 \hat{x} + v_2 \hat{y} + v_3 \hat{z}$$ Then the divergence of a vector field is $$\vec{\nabla}\cdot\vec{v} = \sum_{i = 1}^3 \partial_i v_i$$ The gradient vector of a scalar field has components $$(\vec{\nabla f})_i = \partial_i f$$ and the Laplacian of a function is $$\triangle f = \sum_i \partial_i \partial_i f$$

When doing computations, do them term by term (that is, expand out the sums if necessary) and in the end, when the $\partial_i$ hits on a scalar quantity, it is a gradient, and when the $\partial_i$ hits on a vector quantity indexed also by $i$ you get a divergence.

To illustrate: if $f$ be function a $\vec{v}$ a vector field, then the object $f \vec{v}$ is a vector field. Let us compute its divergence. We do it like so:

$$\vec{\nabla}\cdot(f\vec{v}) = \sum_i \partial_i \left( f v_i\right)= \sum_i (\partial_i f)v_i + f \partial_i v_i \tag{1}$$

The first term then is interpreted as the dot product of the gradient vector $\vec{\nabla f}$ against the vector $\vec{v}$, so for this term "the divergence outside changed to a gradient inside". The second term contains the divergence of the vector field $\vec{v}$ it self, multiplied against the function $f$. So for this term the divergence remains a divergence.

The use of index notations is also extremely helpful when there are multiple sets of indices in play. Let $\vec{v}$ be a vector field, we can consider the gradient of its divergence $\vec{\nabla}(\vec{\nabla} \cdot \vec{v})$. Now, since partial derivatives commute, what happens when we try to interchange the derivatives? In index notation you have

$$\underbrace{\partial_j}_{\text{the gradient}} \underbrace{\sum_i \partial_i v_i}_{\text{the divergence}} = \sum_i \partial_j \partial_i v_i = \sum_i \partial_i (\partial_j v_i)$$

which is now a divergence of an object with two indices (a tensor field, in fact). Using indices help enormously in keeping track where various operators hit: for example compare the above expression with the similar but different expression $$(\triangle \vec{v})_j = \sum_i \partial_i \partial_i v_j$$

As an aside, (1) is basically the same as the integration by parts formula which you described.

-
It can be confusing because the divergence and the gradient are two different things that happen to share the same symbol, $\nabla$. The notation is slightly idiosyncratic: the gradient of $u$ is denoted $\nabla u$, which is the same as your $Du$, while the divergence is written $\nabla\cdot u$. So you can always tell whether $\nabla$ means gradient or divergence depending on whether or not it is followed by a dot.