Divergence
Divergence measures the change in density of a fluid flowing according to a given vector field.
Background
What we're building to
- Interpret a vector field as representing a fluid flow.
- The divergence is an operator, which takes in the vector-valued function defining this vector field, and outputs a scalar-valued function measuring the change in density of the fluid at each point.
- This is the formula for divergence:Here, , , are the component functions of .
Changing density in fluid flow
Take a look at the following vector field:
So that's the picture, but what's the function?
The inputs to are points in two-dimensional space, , and the outputs are two-dimensional vectors, which in the vector field are attached to the corresponding point .
A nice way to think about vector fields is to imagine the fluid flow they could represent. Specifically, for each point in two-dimensional space, imagine a particle sitting at flowing in the direction of the vector attached to that point, . Moreover, suppose the speed of the particle's movement is determined by the length of that vector. The following animation shows what this might look like for our given function for just a brief instant:
Notice, during this fluid flow, some regions tend to become less dense with dots as particles flow away, such as the upper middle section. On the other hand, down and to the left of that region, particles tend to flow towards each other and the dots get more dense.
Key question: For a given vector-valued function , how can we measure the change in density of particles around a point as these particles flow along the vectors given by ?
We can answer this question using a variation of the derivative called divergence. We'll talk more about fluid flow below, but first, let's establish the notation and formula used to express this concept.
Notation and formula for divergence
The notation for divergence uses the same symbol "" which you may be familiar with from the gradient. As with the gradient, we think of this symbol loosely as representing a vector of partial derivative symbols.
We write the divergence of a vector-valued function like this
This is mildly nonsensical since isn't really a vector. Its entries are operators, not numbers. Nevertheless, using this dot product notation is super helpful for remembering how to compute divergence, just take a look:
More generally, the divergence can apply to vector-fields of any dimension. This means can have any number of input variables, as long as its output has the same dimensions. Otherwise, it couldn't represent a vector field. If we write component-wise like this:
Then the divergence of looks like this:
Let's summarize this with a quick diagram:
Interpretation of divergence
Let's say you evaluate the divergence of a function at some point , and it comes out negative.
This means a fluid flowing along the vector field defined by would tend to become more dense at the point . For example, the following animation shows a vector field with negative divergence at the origin.
On the other hand, if the divergence at a point is positive,
the fluid flowing along the vector field becomes less dense around . Here's an example:
Finally, the concept of zero-divergence is very important in fluid dynamics and electrodynamics. It indicates that even though a fluid flows freely, its density stays constant. This is particularly handy when modeling incompressible fluids, such as water. In fact, the very idea that a fluid is incompressible can be tightly communicated with the following equation:
Such vector fields are called "divergence-free." Here's an example of what that might look like:
Sources and sinks
Sometimes, for points with negative divergence, instead of thinking about a fluid getting more dense after a momentary fluid motion, some people imagine the fluid draining at that point while the fluid flows constantly. Here's what this might look like:
As such, points of negative divergence are often called "sinks."
Likewise, instead of thinking of points with positive divergence as becoming less dense during a momentary motion, these points might be thought of as "sources" constantly generating more fluid particles.
Divergence in higher dimensions
Although all the diagrams and animations I'm making show the two-dimensional case, you should understand that all these concepts could apply to three or more dimensions as well.
Try this as a good mental exercise to test if you understand what divergence represents: Imagine a three-dimensional vector field, and picture what points of positive, negative, and zero divergences might look like.
Example 1: Compute and interpret divergence
Problem: Define a vector field by
Compute the divergence, and determine whether the point is more of a source or a sink.
Step 1: Compute the divergence.
Step 2: Plug in .
Step 3: Interpret. Is the fluid more of a source or a sink at ?
Confusing signs
It always trips me up that positive divergence indicates a negative change in density, and that a negative divergence indicates a positive change in density. Isn't that confusing? The sources/sinks interpretation helps a bit, because points of positive divergences are generating more fluid, while points of negative divergence are sucking it away.
Personally, the way I always remember is to think of the case when is the identity function, taking the point to the vector . The resulting vector field has all vectors pointing away from the origin (can you see why?), and it's relatively quick to compute .
So each time I return to divergence after not having seen it for a while and think "hmm, is it positive or negative divergence that indicates a loss in density," I go through this little exercise and remember, "Ah yes, that's how it goes, positive divergence indicates an outward flow."
Further resources
In the next article, I'll give an intuition for why the formula for divergence has anything to do with fluid flow.
Later on, once line integrals and surface integrals are covered, I talk about the formal definition of divergence.
Summary
- Interpret a vector field as representing a fluid flow.
- The divergence is an operator, which takes in the vector-valued function defining this vector field, and outputs a scalar-valued function measuring the change in density of the fluid at each point.
- The formula for divergence iswhere , , are the component functions of .
Keep in mind, though, divergence is used in all sorts of contexts which can have nothing to do with fluid. Electrodynamics is a big one, for example. The fluid flow interpretation is very useful, and gives a much stronger intuition than a blind use of symbols would, but it should be taken with a grain of salt from time to time.