Main content

## Multivariable calculus

# Divergence example

An example of computing and interpreting the divergence of a two-dimensional vector field. Created by Grant Sanderson.

## Want to join the conversation?

- Sorry if I may sound ignorant by posing this question but does this have to do with fluid mechanics? how do you apply it to magnetic fields?(10 votes)
- Great question!

The concept of divergence has a lot to do with fluid mechanics and magnetic fields.

For instance, you can think about a water sprout as a point of positive divergence (since the water is flowing away from the sprout, we call these 'sources' in mathematics and physics) and a water vortex as a point of negative divergence, or convergence (since the water is flowing toward the vortex - these are known as 'sinks').

In terms of magnetic fields, we consider north poles to be 'sources' (i.e. regions of positive divergence, where magnetic flux flows away) and south poles to be 'sinks' (i.e. regions of negative divergence, where magnetic flex flows toward). If you search 'bar magnetic field vectors' on Google images, you'll see this visually.

Hope this helps.(12 votes)

- Hallo, on thing that confuses me is the relation to the electric field. For a positive divergence in a region short arrows must go in and longer must come out (Its only magnitude). The divergence of the electric field is equal to
**charge density over epsilon (Permittivity constant)* . div(*E**) = p/e. But the electric field is going weaker and weaker how far you are away from the charge that is creating it. This should mean long arrows go in and short out and that would be negative divergence. But a positive charge creates a positive divergence right?(4 votes) - Hi! I recently commented under JensOhlmann's question but maybe the best way is to ask my own question separately. Here it is.

"Thanks for the answer Andres, but I think there's still something missing. I think I have the same doubt of JensOhlmann but I'll reframe the question in a different way. The divergence of the electric field is equal to charge density over epsilon (Permittivity constant). Div(E) = p/e, ok, and yes, if you have a single positive charge, the divergence is nonzero only where the charge is located. In the rest of the space, the divergence is zero. Up to this point, everything is fine. But, as JensOhlmann was saying: the electric field becomes weaker and weaker the further you are away from the charge. This should mean that in every point in space, except for the point where the charge is located, long arrows go in and short out. So, like it seems to say in the video (around 2.20), this would mean that there would be negative divergence in every point in space, except where the charge is (of course if the charge is positive). This reasoning, if Maxwell is right, has a flaw. Therefore it has one! What am I missing? Thanks in advance for your help!"(3 votes) - *Does changing the order of differentiation have any meaning in interpreting the field?*

If we change the order of partial differentiation, that is, differentiate P(x,y) w.r.t 'y' and Q(x,y) w.r.t 'x', the divergence of V(x,y) = (x-2x) = -x. Now, taking x=0 which corresponds to the y-axis, the divergence of V(x,y) should go to 0. But looking at the vector field, the divergence is positive throughout the y-axis.(2 votes) - So, form physical point of view what is the meaning of the magnitude of the divergence (let's take the example of the fluid flow)?(1 vote)
- The larger the magnitude of the divergence, the more the particles diverge or converge.

Imagine y=10 and y=1 in the video. The divergence would be 30 and 3, respectively. The fluid particles would fan out a lot more at y=10 than they would at y=1. Now imagine y=-10 and y=-1. The divergence would be -30 and -3, respectively. There would be a large amount of fluid particles entering the area at y=-10. At y=-1, there would be less fluid particles entering than at y=-10.

The higher the value of divergence (not the absolute value, but the value itself) indicates more diverging flow than a lower value, even when the values themselves are negative.(2 votes)

- How to calculate divergence and vorticity for the following horizontal, two dimentional velocity fields:

v= a(xi+yi) , v= b(-yi+xi), v= c(xi-yi)

Sketch these fields in x-y cordinate syste with source at x=y=0.(1 vote) - So divergence is the same as flux?(1 vote)
- what's that y = 9 actually tells you?.(1 vote)
- I think in real-life situations, divergence is zero. (since matter cannot be formed or destroyed.

Therefore this equation doesn't work for fluids I guess!(1 vote)- Yes, divergence is actually used in fluid mechanics to prove conservation of mass which gives us an equation known as Continuity Equation.(1 vote)

## Video transcript

- [Voiceover] So I've got a
vector field here, v of x y. Where the first component of
the output is just x times y, and the second component is
y squared, minus x squared. And the picture of this
vector field is here. This is what that vector field looks like. And what I'd like to do
is compute and interpret the divergence of v. So, the divergence of v,
as a function of x and y. And in the last couple of
videos I explained that the formula for this, and
hopefully it's more than just a formula, but something
I have an intuition for, is the partial derivative
of p with respect to x. By p, I mean that first component. So if you're thinking about
this as being p of x y and q of x y. So I could use any letters
right, and p and q are common. But the upshot is it's
the partial derivative of the first component with
respect to the first variable. Plus, the partial derivative
of that second component, with respect to that second variable, y. And as we actually plug
this in and start computing the partial derivative of p
with respect to x of this guy, with respect to x. X looks like a variable,
y looks like a constant. The derivative is y, that constant. And then the partial derivative
of q, that second component, with respect to y. We look here. Y squared looks like a
variable and it's derivative is two times y. And then x just looks like a constant so nothing happens there. So in the whole, the divergence
evidently just depends on the y value. It's three times y. So what that should mean is
if we look at, for example, let's say we look our points
for y equals zero, we'd expect the divergence to be zero. The fluid neither goes towards
nor away from each point. So y equals zero corresponds
with this x axis of points. So to give it a point here,
evidently it's the case that the fluid kind of flowing
in from above is bounced out by how much fluid flows away from it here and wherever you look. I mean, here its only
flowing in by a little bit, and I guess it's flowing
out just by that same amount and that all cancels out. Whereas, let's say we take
a look at y equals three. So in this case the
divergence should equal nine. So we'd expect there to be
positive divergence when y is positive. So if we go up, and y is
equal to one, two, three. And if we look at a point
around here, I'm gonna kinda consider the region around it. You can kinda see how the
vectors leaving it seem to be bigger. So the fluid flowing out of
this region is pretty rapid. Whereas the fluid flowing
into it is less rapid. So on the whole, in a region
around this point, the fluid I guess is going away. And you look anywhere where y is positive and if you kind of look
around here, the same is true, where fluid does flow into it, it seems. But the vectors kind of going
out of this region are larger. So you'd expect on the whole
for things to diverge away from that point. In contrast, if you look at
something where y is negative, let's say it was y is equal
to negative four, it doesn't have to be three there. So there would be a
divergence of negative 12. So you'd expect things to
definitely converging towards your specific points. So you go down to, I guess I
said y equals negative four. But really, I'm thinking of
anything where y is negative. Let's say we take a
look at this point here. Fluid flowing into it
seems to be according to large vectors. So it's flowing into
it pretty quickly here. But when it's flowing out
of it, it's less large. It's flowing out of it in a
kind of a lackadaisical way. So, it kinda makes sense,
just looking at the picture the divergence tends to be
negative when y is negative. And what's surprising, What
I wouldn't have been able to tell just looking
at the picture, is that the divergence only
depends on the y value. But once you compute everything,
it's only dependent on the y value here. And that as you go kind
of left and right on the diagram there. As we look left and right, the value of the divergence doesn't change. That's kind of surprising. It makes a little bit of sense. You don't see any notable
reason that the divergence here should be any different than here. But, I wouldn't have known that
they were exactly the same.