# Divergence example

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