# Active Calculus - Multivariable

## Section12.6The Divergence of a Vector Field

As we saw in Section 12.1, there are many physical and theoretical representations for vector fields. A natural question is “Where exactly is the vector field created?” With the vector field in Figure 12.6.1, imagine sketching a curve that follows the direction of the vector field by treating the vectors in the vector field as tangent vectors to your curve. No matter where you start, you should observe that the vector field decreases in strength as you move along the flow. We wish to understand (as a function of position), how much of the vector field is created (or destroyed) at a given location.

### Preview Activity12.6.1.

In this preview activity, we will look at several two-dimensional vector fields and try to assess when the vector field has increased or decreased in strength over a given region. We begin with graphs of the three vector fields, $$\vF\text{,}$$ $$\vG\text{,}$$ and $$\vH\text{.}$$ Parts a, b, and c ask you to answer the same three questions about the vector field and square illustrated in each of the figures. Part d asks you to think further about the third vector field.

#### (a)

For each of the vector fields $$\vF\text{,}$$ $$\vG\text{,}$$ and $$\vH$$ and the square centered on $$P_1\text{,}$$ $$P_2\text{,}$$ and $$P_3$$ (respectively), which statement do you think best applies?
1. More of the vector field is going into the square than going out.
2. Less of the vector field is going into the square than going out.
3. The same amount of the vector field is going into the square as is going out.

#### (b)

For each of the vector fields $$\vF\text{,}$$ $$\vG\text{,}$$ and $$\vH$$ (and corresponding square), does your answer to part a suggest that the vector field is being created, destroyed, or is unchanging in strength inside the square? Write a sentence to explain your thinking for each vector field.

#### (c)

Would the answer to parts a or b change if you used a smaller square centered on $$P_1\text{,}$$ $$P_2\text{,}$$ and $$P_3$$ for the corresponding vector fields? Write a sentence to explain your thinking for each vector field.

#### (d)

Thinking now only about the vector field $$\vH\text{,}$$ would your answers to parts a, b, or c change if you considered squares around points $$P_4\text{,}$$ $$P_5\text{,}$$ or $$P_6\text{?}$$ Write a couple of sentences to explain your thinking.

### Subsection12.6.1Definition of the Divergence of a Vector Field

We begin this subsection by stating a definition that captures analytically the ideas you reasoned aboug geometrically in Preview Activity 12.6.1. After the statement of the definition, we discuss what it means.

#### Definition12.6.5.

The divergence of a vector field
\begin{equation*} \vF(x,y)=\langle F_1(x,y),F_2(x,y), F_3(x,y)\rangle \end{equation*}
is given by
\begin{equation*} \divg(\vF)=\frac{\partial F_1}{\partial x}+\frac{\partial F_2}{\partial y} + \frac{\partial F_3}{\partial z}\text{.} \end{equation*}
In two dimensions, the definition is analogous by omiting the third term.
The divergence of a vector field is a scalar measurement at a point that measures how the strength of the vector field is changing as we look small neighborhoods around our point. While Subsection 12.6.2 will show the details for how the divergence is defined, we can make the following qualitative argument: If we are looking at how the strength of the vector field is changing in a small neighborhood of the point $$(a,b)\text{,}$$ then we only need to look how fast the horizontal component is changing horizontally and how the vertical component is changing vertically. We make this measurement of changing strength of the vector field by measuring how much of a vector field flows into versus out of a small neighborhood of our point (as was done in Preview Activity 12.6.1). When looking at a small neighborhood of the point (as shown by the square in Figure 12.6.15), only the change of the horizontal component of the vector field contributes to flow in or out on the sides and only the change in the vertical component contributes to flow in or our on the top and bottom.

#### Example12.6.6.

Let $$\vF=\langle x, y \rangle\text{.}$$ Then
\begin{equation*} \divg(\vF)= \dfrac{\partial}{\partial x} (x)+ \dfrac{\partial}{\partial y} (y) = 1+1=2\text{.} \end{equation*}
From our conceptual description above, $$\divg(\vF)$$ being positive means that our vector field is increasing in strength. Since the divergence of $$\vF$$ does not have a dependence on the input point, that means the vector field is increasing in strength, regardless of which point we consider. In the interactive element below, you can change the point you would like plotted and the size of the region around the point. You should see that regardless of what point you select or how small you make the region around the point, there will be more of the vector field flowing out of the region than in.

#### Example12.6.8.

Let $$\vG=\langle y,-x \rangle\text{.}$$ We can compute that
\begin{equation*} \divg(\vG)= \dfrac{\partial}{\partial x} (y)+ \dfrac{\partial}{\partial y} (-x) = 0\text{.} \end{equation*}
From our conceptual description of divergence, $$\divg(\vG)$$ being zero means that our vector field is not changing in strength. Since the divergence of $$\vG$$ does not have a dependence on the input point, that means the vector field is not changing in strength, regardless of which point we consider.
In the interactive element below, you can change the point you would like plotted and the size of the region around the point. You should see that regardless of what point you select or how small you make the region around the point, there will be exactly as much of the vector field flowing into the region as is flowing out (on the other side).

#### Example12.6.10.

Let $$\vH=\langle x^2-y,y^2-x \rangle\text{,}$$ which means that
\begin{equation*} \divg(\vH)= \dfrac{\partial}{\partial x} (x^2-y)+ \dfrac{\partial}{\partial y} (y^2-x) = 2x+2y\text{.} \end{equation*}
In constrast to the previous examples, you can see that the value of divergence of $$\vH$$ will depend on the input point choosen. For instance, $$\divg(\vH)$$ will be $$4$$ at the point $$(1,1)\text{.}$$ This means that for a small region around $$(1,1)$$ there should be more of the vector field flowing out of the region than into it. Use the interactive element below to verify this.
The divergence of $$\vH$$ at the point $$(-1,1)$$ will be zero. If you look at this point in Figure 12.6.11, you will see that there is exactly as much of the vector field flowing into the region around $$(-1,1)$$ as is flowing out.
The divergence of $$\vH$$ at the point $$(-2,0)$$ is $$-4\text{.}$$ This should mean that there is more of the vector field flowing into the region around $$(-2,0)$$ than is flowing out. You should be able to see how difference regions of the $$xy$$-plane will have different values for $$\divg(\vH)\text{.}$$
Another way to “see” divergence on a vector field plot is to look at what happens to the magnitude of vectors as you move along the flow of the vector field. If the vector field is increasing in magnitude as you move along the flow of a vector field, then the divergence is positive. If the vector field is decreasing in magnitude as you move along the flow of a vector field, then the divergence is negative. If the vector field does not change in magnitude as you move along the flow of the vector field, then the divergence is zero. Also, remember that the divergence of a vector field is often a variable quantity and will change depending on location. The next activity asks you to graphically examine the divergence of three vector fields.

#### Activity12.6.2.Graphical Representations of Divergence.

##### (a)
For this part of the activity, consider the vector field $$\vF$$ shown in Figure 12.6.12.
###### (i)
Draw a circle in the first quadrant of the vector field $$\vF$$ depicted in Figure 12.6.12. Based on the flow of the vector field into or out of the circle, do you think the vector field is increasing in strength, decreasing in strength, or not changing in overall strength in the first quadrant?
###### (ii)
As you move along the flow of the vector field in the first quadrant of Figure 12.6.12, does your vector field increase in magnitude, decrease in magnitude, or have constant magnitude?
###### (iii)
Draw a circle in each of quadrants II, II, and IV. Based on the flow of the vector field into or out of your circles, do you think the vector field is increasing in strength, decreasing in strength, or not changing in overall strength in quadrants II, II, and IV?
###### (iv)
As you move along the flow of the vector field in the third quadrant of Figure 12.6.12, does your vector field increase in magnitude, decrease in magnitude, or have constant magnitude.
###### (v)
Based on your arguments above, describe why the divergence of $$\vF$$ is negative for all points in the $$xy$$-plane.
##### (b)
Look at the plot of the vector field $$\vG$$ in Figure 12.6.13 and state whether you think the vector field is increasing in strength, decreasing in strength, or not changing in overall strength in each of the four quadrants. You can make your argument in terms of the change in magnitude along the flow of the vector field or in terms of the net flow into or out of a small region on the plane. You may need to make separate arguments for each of the four quadrants.
##### (c)
Look at the plot of the vector field $$\vH$$ in Figure 12.6.14 below and state whether you think the vector field is increasing in strength, decreasing in strength, or not changing in overall strength in each of the four quadrants. You can make your argument in terms of the change in magnitude along the flow of the vector field or in terms of the net flow into or out of a small region on the plane. You may need to make separate arguments for each of the four quadrants.
The next activity of this section asks you to do some algebraic calculations of divergence using Definition 12.6.5.

#### Activity12.6.3.

##### (a)
Calculate the divergence of the vector fields given below.
• $$\displaystyle \vF(x,y)=\langle -x,-y\rangle$$
• $$\displaystyle \vG(x,y)=\langle y,x \rangle$$
• $$\displaystyle \vH(x,y)=\langle xy,1-x\rangle$$
##### (b)
Explain how your answers to the questions in Activity 12.6.2 can be explained by using your results from part a of this activity.

### Subsection12.6.2Measuring the Change in Strength of a Vector Field

In this subsection, we examine the details of how to measure the density of the “creation” or “destruction” of the vector field in a classic calculus fashion. Specifically, we will measure how the strength of the vector field changes in a region around a point. Next, using a limit, we examine what happens to our measurement as we shrink the region. Because vector fields change in a continuous fashion, the vector fields don’t actually change at a single point. Rather, we will measure the density for the change in strength of the vector field.
We will develop all of our measurements in a two dimensional setting for now. However, our arguments can be applied to three (or more) dimensions. We start in the same fashion as in Preview Activity 12.6.1. Namely, we will look at how much of the vector field is going into or out of a square centered at a point $$(a,b)\text{.}$$ For this development, we will consider a two-dimensional vector field given by $$\vF(x,y)=\langle{F_1(x,y),F_2(x,y)}\rangle\text{.}$$
We can parametrize the top edge of the box by $$\vr_{\text{top}}(t) = \langle a+t,b+h\rangle$$ with $$-h\leq t\leq h\text{.}$$ Similarly, the bottom, right, and left can be parametrized by
\begin{align*} \vr_{\text{bottom}}(t) \amp = \langle a+t,b-h\rangle\\ \vr_{\text{right}}(t) \amp = \langle a+h,b+t\rangle\\ \vr_{\text{left}}(t) \amp = \langle a-h,b+t\rangle \end{align*}
all of which use parameter values in $$-h\leq t\leq h\text{.}$$
The amount of the vector field $$\vF$$ that is created inside the square around the point $$(a,b)$$ can be measured by the net amount of the vector field coming into or going out of the square. The amount of vector flow that goes through each of the boundary segments can be measured by looking at just the orthogonal component of the vector field on each particular segment. For instance, on the top segment, the vertical component $$F_2$$ determines how much of the vector field goes in or out of the square. Integrating just the vertical component $$F_2$$ of the vector field $$\vF$$ over the points on the top segment of our square will therefore measure how much of the vector field goes through the top of the square.
The same argument applies to the bottom edge of our square. Similarly, if we want to measure how much of $$\vF$$ goes through either the left or right side of the square, we need to integrate the horizontal component $$F_1\text{.}$$ Hence, the net flow $$N$$ of the vector field into or out of the square will be given by
\begin{align*} N=\int_{-h}^{h} \amp F_2(a+t,b+h) dt - \int_{-h}^{h} F_2(a+t,b-h) dt \\ \amp + \int_{-h}^{h} F_1(a+h,b+t) dt -\int_{-h}^{h} F_1(a-h,b+t) dt\text{.} \end{align*}
Notice that the integrals corresponding to the left and bottom segments are subtracted because we need to pay attention to the orientation of the vector field relative to the square. A positive vertical component of the vector field ($$F_2$$) will correspond to flow out on the top of the square but will correspond to the vector field flowing into the square on the bottom. In the integrals above, we are counting the flow out of the square as positive and the flow in as negative.
We are measuring the net flow through the square as a scalar quantity. By decreasing $$h\text{,}$$ we can look at what happens to our amount of flow out of the square as we shrink to the point $$(a,b)\text{.}$$ In order for this to make sense across different size of squares, we will change what we are measuring to be a density argument by calculating flow in (or out) per unit area. This will allow us to compare our net flow calculations across squares with different areas. In other words, we want to consider what happens to
\begin{align*} \frac{1}{(2h)^2}\amp\left(\int_{-h}^{h} F_2(a+t,b+h) dt - \int_{-h}^{h} F_2(a+t,b-h) dt \right.\\ \amp\left. +\int_{-h}^{h} F_1(a+h,b+t) dt -\int_{-h}^{h} F_1(a-h,b+t) dt \right) \end{align*}
as $$h$$ goes to zero.
Before we compute our limit, we will take a moment to simplify our integrals in order to make the limit easier to evaluate. Recall that in single-variable calculus, we defined the average value of a function
1
activecalculus.org/single/sec-4-3-definite-integral.html#XCM
$$f$$ on an interval $$[a,b]$$ to be
\begin{equation*} f_{\text{AVG}[a,b]} = \frac{1}{b-a}\cdot \int_a^b f(t)\, dt\text{.} \end{equation*}
It turns out that we can say something stronger: there will be a value $$t^*$$ in the interval $$[a,b]$$ so that
\begin{equation*} f(t^*)(b-a) = \int_a^b f(t)\, dt \end{equation*}
when $$f$$ is continuous on $$[a,b]\text{.}$$ (You can think of the left-hand side as being the area of a rectangle with the interval $$[a,b]$$ as its base.) We use this fact, sometimes called the Mean Value Theorem for Integrals, to simplify here. Applying the Mean Value Theorem for Integrals to the first integral gives
\begin{equation*} \int_{-h}^{h} F_2(a+t,b+h) dt = (2h) \enspace F_2(t^*_1,b+h)\text{,} \end{equation*}
where $$t^*_1$$ is some value in the interval $$(a-h,a+h)\text{.}$$ Applying the Mean Value Theorem for Integrals to each of the other integrals allows us to simplify the expression above for the net flow $$N$$ to be
\begin{equation*} (2h) \left(F_2(t^*_1,b+h)-F_2(t^*_2,b-h)+F_1(a+h,t^*_3)-F_1(a-h,t^*_1)\right)\text{,} \end{equation*}
where $$t^*_1$$ and $$t^*_2$$ are values in $$(a-h,a+h)$$ and $$t^*_3$$ and $$t^*_4$$ are values in $$(b-h,b+h)\text{.}$$ Thus our flow density can be measured by looking at the limit as $$h\to 0$$ of the net flow (in or out) over the square divided by the area of the square.
\begin{align*} \amp\text{Flow Density}(a,b)=\lim_{h\rightarrow 0} \frac{\text{net flow}}{\text{area}} \\ \amp = \lim_{h\rightarrow 0} \frac{(2h) \left(F_2(t^*_1,b+h)-F_2(t^*_2,b-h)+F_1(a+h,t^*_3)-F_1(a-h,t^*_1)\right)}{4h^2}\text{.} \end{align*}
To simplify the limit further, we will reorganize our limit expression. Specifically, we collect the $$F_2$$ and $$F_1$$ terms separately. This gives
\begin{align*} \amp\text{Flow Density}(a,b) = \\ \amp\lim_{h\rightarrow 0}\left[ \frac{F_1(a+h,t^*_3)-F_1(a-h,t^*_1)}{2h}+\frac{F_2(t^*_1,b+h)-F_2(t^*_2,b-h)}{2h}\right]\text{.} \end{align*}
Recall the central difference method of estimating derivatives from Section 1.5.2
2
activecalculus.org/single/sec-1-5-units.html#VjW
and as $$h\to 0\text{,}$$ the numbers $$t^*_1,t^*_2$$ must go to $$a$$ and $$t^*_3,t^*_4$$ must go to $$b\text{.}$$ Therefore, after evaluating our limit, the flow density is
\begin{equation*} \text{Flow Density}(a,b)= \frac{\partial F_1}{\partial x} (a,b)+\frac{\partial F_2}{\partial y} (a,b)\text{.} \end{equation*}
While this simplification may seem a bit amazing and magical, our conceptual steps should help us make sense of the result. If we are looking at how the strength of the vector field is changing in a small neighborhood of the point $$(a,b)$$ then we only need to look how fast the horizontal component is changing horizontally and how the vertical component is changing vertically. How the horizontal component changes over small steps in the vertical direction will give us information about how the direction of the vector field changes but not how the strength of the vector field is changing.
The arguments we made about measuring how much of the vector field flows into or out of a square has straightforward generalization to three (or more) dimensions. However, doing so requires a method for measuring how much of a vector field flows through a surface. This will be the subject of Section 12.9.

### Subsection12.6.3Summary

• The divergence of a vector field $$\vF(x,y)=\langle F_1(x,y),F_2(x,y)\rangle$$ is computed as
\begin{equation*} \divg(\vF)=\frac{\partial F_1}{\partial x}+\frac{\partial F_2}{\partial y} \end{equation*}
In three dimensions, the divergence of the vector field $$\vG(x,y)=\langle{G_1(x,y,z),G_2(x,y,z),G_3(x,y,z)}\rangle$$ is computed as
\begin{equation*} \divg(\vG)=\frac{\partial G_1}{\partial x}+\frac{\partial G_2}{\partial y}+\frac{\partial G_3}{\partial z} \end{equation*}
• The divergence of a vector field measures the density of change in the strength of the vector field. In other words, the divergence measures the instantaneous rate of change in the strength of the vector field along the direction of flow.
• The accumulation of the divergence over a region of space will measure the net amount of the vector field that exits (versus enters) the region.
• The key ideas when interpreting divergence are:
• A positive divergence means that the vector field is growing in strength.
• A negative divergence means that the vector field is decreasing in strength.
• A zero divergence means that the vector field is not changing in strength.

### Exercises12.6.4Exercises

#### 1.

Find the divergence of each of the following vector fields at all points where they are defined.
(a) $$\displaystyle \mathrm{div} \left( \, \left(3x^{2}-\sin\!\left(xz\right)\right)\boldsymbol{i}+4\boldsymbol{j}-\sin\!\left(xz\right)\boldsymbol{k} \, \right) =$$
(b) $$\displaystyle \mathrm{div} \left( \, \frac{x}{\left(x^{2}+y^{2}+z^{2}\right)^{1.5}}\boldsymbol{i}+\frac{y}{\left(x^{2}+y^{2}+z^{2}\right)^{1.5}}\boldsymbol{j}+\frac{z}{\left(x^{2}+y^{2}+z^{2}\right)^{1.5}}\boldsymbol{k} \, \right) =$$
(c) $$\displaystyle \mathrm{div} \left( \, 3e^{xy}\boldsymbol{i}+3\cos\!\left(xy\right)\boldsymbol{j}+2e^{\ln\!\left(x^{2}+y^{2}+2\right)}\boldsymbol{k} \, \right) =$$

#### 2.

Consider $$\displaystyle \mbox{div}\,\left(\frac{-y\vec i + x\vec j}{(x^2 + y^2)^{3}}\right)\text{.}$$
(a) Is this a vector or a scalar?
• vector
• scalar
(b) Calculate it:
$$\mbox{div}\,\left(\frac{-y\vec i + x\vec j}{(x^2 + y^2)^{3}}\right) =$$ + =

#### 3.

Let $$f(x,y) = a x y + a x^2 y + y^3.$$
(a) $$\mathrm{div} ( \mathrm{grad} ( f ) ) =$$
(b) Find $$a$$ so that $$\mathrm{div} ( \mathrm{grad} ( f ) ) = 0$$ for all $$x, y.$$
$$a =$$

#### 4.

1. Let $$\vF=\langle{F_1,F_2,F_3}\rangle$$ and let
\begin{equation*} \vG = (\frac{\partial F_3}{\partial y}-\frac{\partial F_2}{\partial z})\vi- (\frac{\partial F_3}{\partial x}-\frac{\partial F_1}{\partial z})\vj + (\frac{\partial F_2}{\partial x}-\frac{\partial F_1}{\partial y})\vk \end{equation*}
Show that $$\divg(\vG)=\vec{0}\text{.}$$ Vector fields with a zero divergence everywhere in their domain are called divergence-free vector fields.
2. Which of the following vector fields are divergence-free?
1. $$\displaystyle \vF=\langle{-y,z,x}\rangle$$
2. $$\displaystyle \vF=\langle{\cos(yz),3xe^{z-x},6(x+y+z)^3}\rangle$$
3. $$\displaystyle \vF=\langle{4xyz,y^2z,yz^2}\rangle$$
4. $$\vF=\nabla f$$ where $$f$$ is a scalar function of $$x\text{,}$$ $$y\text{,}$$ and $$z$$
3. Let $$\vF_1=\langle{3(x-z)^2,2\cos(x)+3yz+y,-(z-1)^2+e^{xy}}\rangle\text{.}$$ Calculate the divergence of $$\vF_1$$ and give a point where $$\divg(\vF_1)=0\text{.}$$
4. Is $$\vF_1$$ a divergence free vector field?

### Subsection12.6.5Notes to Instructors and Dependencies

This section relies heavily on understanding vector fields from Section 12.1. We have separated the details of how the flux density of a region leads to the definition and understanding of the divergence (Subsection 12.6.2). The second subsection is optional, but is worthwhile reading for students who are interested in a good conceptual understanding of how divergence is developed.