# 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.

-
"Even otherwise, you can't take the gradient of a vector field or the divergence of a scalar field" is one of those statements I'd be very careful about making: it may be a convenient mnemonic now, but one day the student may learn about the Navier-Stokes equations or about co-differentials in Riemannian geometry... – Willie Wong Jul 26 '12 at 20:11
@Willie, that's true, I was being sloppy. In fluid dynamics one does take the gradient of velocity, but does the divergence of a scalar field ever make sense? I'll update my answer once I get your response. – Rahul Jul 26 '12 at 20:35
Divergence can be defined (relative to a specified index) for any tensor field on a Riemannian manifold; and it can be defined for any multi-vectors (think dual of differential forms) on a orientable smooth manifold. Naturally this extends to the scalar field as a rank-0 contravariant tensor field. Of course, necessarily also its divergence is 0 (the same as the exterior derivative of a top form). With regards to the divergence of the scalar field, it is less important than the thing about gradients of vector fields, and I was just picking bones (because it is there to pick). – Willie Wong Jul 26 '12 at 21:32
Also, you may want to add a few words about why after integrating by parts, the divergence can become a gradient... – Willie Wong Jul 26 '12 at 21:35
@Willie, I just deleted the parts that weren't universally correct. Perhaps you could post an answer elaborating your last comment (though isn't it the Laplacian that's being integrated here?). – Rahul Jul 27 '12 at 4:16