# Multivariable Calculus: Gradient Fields

## Gradient Fields

**Transcript:** We were looking at vector fields last time. Last time we saw that if a vector field happens to be a gradient field -- -- then the line integral can be computed actually by taking the change in value of the potential between the end point and the starting point of the curve. If we have a curve c, from a point p0 to a point p1 then the line integral for work depends only on the end points and not on the actual path we chose.

We say that the line integral is path independent. And we also said that the vector field is conservative because of conservation of energy which tells you if you start at a point and you come back to the same point then you haven't gotten any work out of that force. If we have a closed curve then the line integral for work is just zero. And, basically, we say that these properties are equivalent being a gradient field or being path independent or being conservative. And what I promised to you is that today we would see a criterion to decide whether a vector field is a gradient field or not and how to find the potential function if it is a gradient field.

So, that is the topic for today. The question is testing whether a given vector field, let's say M and N compliments, is a gradient field. For that, well, let's start with an observation. Say that it is a gradient field. That means that the first component of a field is just the partial of f with respect to some variable x and the second component is the partial of f with respect to y. Now we have seen an interesting property of the second partial derivatives of the function, which is if you take the partial derivative first with respect to x, then with respect to y, or first with respect to y, then with respect to x you get the same thing.

We know f sub xy equals f sub yx, and that means M sub y equals N sub x. If you have a gradient field then it should have this property. You take the y component, take the derivative with respect to x, take the x component, differentiate with respect to y, you should get the same answer. And that is important to know. So, I am going to put that in a box. It is a broken box. The claim that I want to make is that there is a converse of sorts. This is actually basically all we need to check.

Conversely, if, and I am going to put here a condition, My equals Nx, then F is a gradient field. What is the condition that I need to put here? Well, we will see a more precise version of that next week. But for now let's just say if our vector field is defined and differentiable everywhere in the plane. We need, actually, a vector field that is well-defined everywhere. You are not allowed to have somehow places where it is not well-defined. Otherwise, actually, you have a counter example on your problem set this week. If you look at the last problem on the problem set this week, it gives you a vector field that satisfies this condition everywhere where it is defined. But, actually, there is a point where it is not defined. And that causes it, actually, to somehow --

I mean everything that I am going to say today breaks down for that example because of that. I mean, we will shed more light on this a bit later with the notion of simply connected regions and so on. But for now let's just say if it is defined everywhere and it satisfies this criterion then it is a gradient field. If you ignore the technical condition, being a gradient field means essentially the same thing as having this property. That is what we need to check.

Let's look at an example. Well, one vector field that we have been looking at a lot was - yi xj. Remember that was the vector field that looked like a rotation at the unit speed. I think last time we already decided that this guy should not be allowed to be a gradient field and should not be conservative because if we integrate on the unit circle then we would get a positive answer. But let's check that indeed it fails our test. Well, let's call this M and let's call this guy N.

If you look at partial M, partial y, that is going to be a negative one. If you take partial N, partial x, that is going to be one. These are not the same. So, indeed, this is not a gradient field. Any questions about that? Yes? Your question is if I have the property M sub y equals N sub x only in a certain part of a plane for some values of x and y, can I conclude these things? And it is a gradient field in that part of the plane and conservative and so on.

The answer for now is, in general, no. And when we spend a bit more time on it, actually, maybe I should move that up. Maybe we will talk about it later this week instead of when I had planned. There is a notion what it means for a region to be without holes. Basically, if you have that kind of property in a region that doesn't have any holes inside it then things will work. The problem comes from a vector field satisfying this criterion in a region but it has a hole in it. Because what you don't know is whether your potential is actually well-defined and takes the same value when you move all around the hole. It might come back to take a different value. If you look carefully and think hard about the example in the problem sets that is exactly what happens there.

Again, I will say more about that later. For now we basically need our function to be, I mean, I should still say if you have this property for a vector field that is not quite defined everywhere, you are more than welcome, you know, you should probably still try to look for a potential using methods that we will see. But something might go wrong later. You might end up with a potential that is not well-defined.

Let's do another example. Let's say that I give you this vector field. And this a here is a number. The question is for which value of a is this going to be possibly a gradient? If you have your flashcards then that is a good time to use them to vote, assuming that the number is small enough to be made with. Let's try to think about it. We want to call this guy M. We want to call that guy N.

And we want to test M sub y versus N sub x. I don't see anyone. I see people doing it with their hands, and that works very well. OK. The question is for which value of a is this a gradient? I see various people with the correct answer. OK. That a strange answer. That is a good answer. OK. The vote seems to be for a equals eight. Let's see. What if I take M sub y? That is going to be just ax. And N sub x? That is 8x. I would like a equals eight. By the way, when you set these two equal to each other, they really have to be equal everywhere. You don't want to somehow solve for x or anything like that. You just want these expressions, in terms of x and y, to be the same quantities. I mean you cannot say if x equals z they are always equal.

Yeah, that is true. But that is not what we are asking. Now we come to the next logical question. Let's say that we have passed the test. We have put a equals eight in here. Now it should be a gradient field. The question is how do we find the potential? That becomes eight from now on. The question is how do we find the function which has this as gradient? One option is to try to guess. Actually, quite often you will succeed that way. But that is not a valid method on next week's test. We are going to see two different systematic methods. And you should be using one of these because guessing doesn't always work.

And, actually, I can come up with examples where if you try to guess you will surely fail. I can come up with trick ones, but I don't want to put that on the test. The next stage is finding the potential. And let me just emphasize that we can only do that if step one was successful. If we have a vector field that cannot possibly be a gradient then we shouldn't try to look for a potential. It is kind of obvious but is probably worth pointing out. There are two methods. The first method that we will see is computing line integrals.

Let's see how that works. Let's say that I take some path that starts at the origin. Or, actually, anywhere you want, but let's take the origin. That is my favorite point. And let's go to a point with coordinates (x1, y1). And let's take my favorite curve and compute the line integral of that field, you know, the work done along the curve. Well, by the fundamental theorem, that should be equal to the value of the potential at the end point minus the value at the origin. That means I can actually write f of (x1, y1) equals --

-- that line integral plus the value at the origin. And that is just a constant. We don't know what it is. And, actually, we can choose what it is. Because if you have a potential, say that you have some potential function. And let's say that you add one to it. It is still a potential function. Adding one doesn't change the gradient. You can even add 18 or any number that you want. This is just going to be an integration constant. It is the same thing as, in one variable calculus, when you take the anti-derivative of a function it is only defined up to adding the constant. We have this integration constant, but apart from that we know that we should be able to get a potential from this.

And this we can compute using the definition of the line integral. And we don't know what little f is, but we know what the vector field is so we can compute that. Of course, to do the calculation we probably don't want to use this kind of path. I mean if that is your favorite path then that is fine, but it is not very easy to compute the line integral along this, especially since I didn't tell you what the definition is. There are easier favorite paths to have.

For example, you can go on a straight line from the origin to that point. That would be slightly easier. But then there is one easier. The easiest of all, probably, is to just go first along the x-axis to (x1, 0) and then go up parallel to the y-axis. Why is that easy? Well, that is because when we do the line integral it becomes M dx N dy. And then, on each of these pieces, one-half just goes away because x, y is constant.

Let's try to use that method in our example. Let's say that I want to go along this path from the origin, first along the x-axis to (x1, 0) and then vertically to (x1, y1). And so I want to compute for the line integral along that curve. Let's say I want to do it for this vector field. I want to find the potential for this vector field. Let me copy it because I will have to erase at some point. 4x squared plus 8xy and 3y squared plus 4x squared. That will become the integral of 4x squared plus 8 xy times dx plus 3y squared plus 4x squared times dy.

To evaluate on this broken line, I will, of course, evaluate separately on each of the two segments. I will start with this segment that I will call c1 and then I will do this one that I will call c2. On c1, how do I evaluate my integral? Well, if I am on c1 then x varies from zero to x1. Well, actually, I don't know if x1 is positive or not so I shouldn't write this. I really should say just x goes from zero to x1. And what about y? y is just 0. I will set y equal to zero and also dy equal to zero. I get that the line integral on c1 --

Well, a lot of stuff goes away. The entire second term with dy goes away because dy is zero. And, in the first term, 8xy goes away because y is zero as well. I just have an integral of 4x squared dx from zero to x1. By the way, now you see why I have been using an x1 and a y1 for my point and not just x and y. It is to avoid confusion. I am using x and y as my integration variables and x1, y1 as constants that are representing the end point of my path. And so, if I integrate this, I should get four-thirds x1 cubed. That is the first part. Next I need to do the second segment.

If I am on c2, y goes from zero to y1. And what about x? x is constant equal to x1 so dx becomes just zero. It is a constant. If I take the line integral of c2, F dot dr then I will get the integral from zero to y1. The entire first term with dx goes away and then I have 3y squared plus 4x1 squared times dy. That integrates to y cubed plus 4x1 squared y from zero to y1. Or, if you prefer, that is y1 cubed plus 4x1 squared y1.

Now that we have done both of them we can just add them together, and that will give us the formula for the potential. F of x1 and y1 is four-thirds x1 cubed plus y1 cubed plus 4x1 squared y1 plus a constant. That constant is just the integration constant that we had from the beginning. Now you can drop the subscripts if you prefer. You can just say f is four-thirds x cubed plus y cubed plus 4x squared y plus constant. And you can check. If you take the gradient of this, you should get again this vector field over there. Any questions about this method? Yes?

No. Well, it depends whether you are just trying to find one potential or if you are trying to find all the possible potentials. If a problem just says find a potential then you don't have to use the constant. This guy without the constant is a valid potential. You just have others. If your neighbor comes to you and say your answer must be wrong because I got this plus 18, well, both answers are correct. By the way.

Instead of going first along the x-axis vertically, you could do it the other way around. Of course, start along the y-axis and then horizontally. That is the same level of difficulty. You just exchange roles of x and y. In some cases, it is actually even making more sense maybe to go radially, start out from the origin to your end point. But usually this setting is easier just because each of these two guys were very easy to compute.

But somehow maybe if you suspect that polar coordinates will be involved somehow in the answer then maybe it makes sense to choose different paths. Maybe a straight line is better. Now we have another method to look at which is using anti-derivatives. The goal is the same, still to find the potential function. And you see that finding the potential is really the multivariable analog of finding the anti-derivative in the one variable.

Here we did it basically by hand by computing the integral. The other thing you could try to say is, wait, I already know how to take anti-derivatives. Let's use that instead of computing integrals. And it works but you have to be careful about how you do it. Let's see how that works. Let's still do it with the same example. We want to solve the equations. We want a function such that f sub x is 4x squared plus 8xy and f sub y is 3y squared plus 4x squared. Let's just look at one of these at a time. If we look at this one, well, we know how to solve this because it is just telling us we have to integrate this with respect to x.

Well, let's call them one and two because I will have to refer to them again. Let's start with equation one and lets integrate with respect to x. Well, it tells us that f should be, what do I get when I integrate this with respect to x, four-thirds x cubed plus, when I integrate 8xy, y is just a constant, so I will get 4x squared y. And that is not quite the end to it because there is an integration constant. And here, when I say there is an integration constant, it just means the extra term does not depend on x. That is what it means to be a constant in this setting. But maybe my constant still depends on y so it is not actually a true constant. A constant that depends on y is not really a constant. It is actually a function of y.

The good news that we have is that this function normally depends on x. We have made some progress. We have part of the answer and we have simplified the problem. If we have anything that looks like this, it will satisfy the first condition. Now we need to look at the second condition. We want f sub y to be that. But we know what f is, so let's compute f sub y from this. From this I get f sub y. What do I get if I differentiate this with respect to y? Well, I get zero plus 4x squared plus the derivative of g.

I would like to match this with what I had. If I match this with equation two then that will tell me what the derivative of g should be. If we compare the two things there, we get 4x squared plus g prime of y should be equal to 3y squared by 4x squared. And, of course, the 4x squares go away. That tells you g prime is 3y squared. And that integrates to y cubed plus constant. Now, this time the constant is a true constant because g did not depend on anything other than y. And the constant does not depend on y so it is a real constant now. Now we just plug this back into this guy. Let's call him star.

If we plug this into star, we get f equals four-thirds x cubed plus 4x squared y plus y cubed plus constant. I mean, of course, again, now this constant is optional. The advantage of this method is you don't have to write any integrals. The small drawback is you have to follow this procedure carefully. By the way, one common pitfall that is tempting. After you have done this, what is very tempting is to just say, well, let's do the same with this guy. Let's integrate this with respect to y. You will get another expression for f up to a constant that depends on x. And then let's match them.

Well, the difficulty is matching is actually quite tricky because you don't know in advance whether they will be the same expression. It could be you could say let's just take the terms that are here and missing there and combine the terms, you know, take all the terms that appear in either one. That is actually not a good way to do it, because if I put sufficiently complicated trig functions in there then you might not be able to see that two terms are the same. Take an easy one.

Let's say that here I have one plus tangent square and here I have a secan square then you might not actually notice that there is a difference. But there is no difference. Whatever. Anyway, I am saying do it this way, don't do it any other way because there is a risk of making a mistake otherwise. I mean, on the other hand, you could start with integrating with respect to y and then differentiate and match with respect to x.

But what I am saying is just take one of them, integrate, get an answer that involves a function of the other variable, then differentiate that answer and compare and see what you get. By the way, here, of course, after we simplified there were only y's here. There were no x's. And that is kind of good news. I mean, if you had had an x here in this expression that would have told you that something is going wrong.

g is a function of y only. If you get an x here, maybe you want to go back and check whether it is really a gradient field. Yes? Yes, this will work with functions of more than two variables. Both methods work with more than two variables. We are going to see it in the case where more than two means three. We are going to see that in two or three weeks from now. I mean, basically starting at the end of next week, we are going to do triple integrals, line integrals in space and so on.

The format is first we do everything in two variables. Then we will do three variables. And then what happens with more than three will be left to your imagination. Any other questions about either of these methods? A quick poll. Who prefers the first method? Who prefers the second method? Wow. OK. Anyway, you will get to use whichever one you want. And I would agree with you, but the second method is slightly more effective in that you are writing less stuff. You don't have to set up all these line integrals. On the other hand, it does require a little bit more attention.

Let's move on a bit. Let me start by actually doing a small recap. We said we have various notions. One is to say that the vector field is a gradient in a certain region of a plane. And we have another notion which is being conservative. It says that the line integral is zero along any closed curve. Actually, let me introduce a new piece of notation. To remind ourselves that we are doing it along a closed curve, very often we put just a circle for the integral to tell us this is a curve that closes on itself. It ends where it started. I mean it doesn't change anything concerning the definition or how you compute it or anything. It just reminds you that you are doing it on a closed curve.

It is actually useful for various physical applications. And also, when you state theorems in that way, it reminds you,oh.. I need to be on a closed curve to do it. And so we have said these two things are equivalent. Now we have a third thing which is N sub x equals M sub y at every point. Just to summarize the discussion. We have said if we have a gradient field then we have this. And the converse is true in suitable regions. We have a converse if F is defined in the entire plane. Or, as we will see soon, in a simply connected region.

I guess some of you cannot see what I am writing here, but it doesn't matter because you are not officially supposed to know it yet. That will be next week. Anyway, I said the fact that Nx equals My implies that we have a gradient field and is only if a vector field is defined in the entire plane or in a region that is called simply connected. And more about that later. Now let me just introduce a quantity that probably a lot of you have heard about in physics that measures precisely fairly ought to be conservative. That is called the curl of a vector field.

For the definition we say that the curl of F is the quantity N sub x - M sub y. It is just replicating the information we had but in a way that is a single quantity. In this new language, the conditions that we had over there, this condition says curl F equals zero. That is the new version of Nx equals My. It measures failure of a vector field to be conservative. The test for conservativeness is that the curl of F should be zero. I should probably tell you a little bit about what the curl is, what it measures and what it does because that is something that is probably useful. It is a very strange quantity if you put it in that form. Yes?

I think it is the same as the physics one, but I haven't checked the physics textbook. I believe it is the same. Yes, I think it is the same as the physics one. It is not the opposite this time. Of course, in physics maybe you have seen curl in space. We are going to see curl in space in two or three weeks. Yes? Yes. Well, you can also use it. If you fail this test then you know for sure that you are not gradient field so you might as well do that. If you satisfy the test but you are not defined everywhere then there is still a bit of ambiguity and you don't know for sure. OK.

Let's try to see a little bit what the curl measures. Just to give you some intuition, let's first think about a velocity field. The curl measures the rotation component of a motion. If you want a fancy word, it measures the vorticity of a motion. It tells you how much twisting is taking place at a given point. For example, if I take a constant vector field where my fluid is just all moving in the same direction where this is just constants then, of course, the curl is zero.

Because if you take the partials you get zero. And, indeed, that is not what you would call swirling. There is no vortex in here. Let's do another one where this is still nothing going on. Let's say that I take the radial vector field where everything just flows away from the origin. That is f equals x, y. Well, if I take the curl, I have to take partial over partial x of the second component, which is y, minus partial over partial y of the first component, which is x. I will get zero. And, indeed, if you think about what is going on here, there is no rotation involved. On the other hand, if you consider our favorite rotation vector field --

-- negative y and x then this curl is going to be N sub x minus M sub y, one plus one equals two. That corresponds to the fact that we are rotating. Actually, we are rotating at unit angular speed. The curl actually measures twice the angular speed of a rotation part of a motion at any given point. Now, if you have an actual motion, a more complicated field than these then no matter where you are you can think of a motion as a combination of translation effects, maybe dilation effects, maybe rotation effects, possibly other things like that.

And what a curl will measure is how intense the rotation effect is at that particular point. I am not going to try to make a much more precise statement. A precise statement is what a curl measures is really this quantity up there. But the intuition you should have is it measures how much rotation is taking place at any given point. And, of course, in a complicated motion you might have more rotation at some point than at some others, which is why the curl will depend on x and y. It is not just a constant because how much you rotate depends on where you are.

If you are looking at actual wind velocities in weather prediction then the regions with high curl tend to be hurricanes or tornadoes or things like that. They are not very pleasant things. And the sign of a curl tells you whether you are going clockwise or counterclockwise. Curl measures twice the angular velocity of the rotation component of a velocity field. Now, what about a force field? Because, after all, how we got to this was coming from and trying to understand forces and the work they do. So I should tell you what it means for a force. Well, the curl of a force field --

-- measures the torque exerted on a test object that you put at any point. Remember, torque is the rotational analog of the force. We had this analogy about velocity versus angular velocity and mass versus moment of inertia. And then, in that analogy, force divided by the mass is what will cause acceleration, which is the derivative of velocity. Torque divided by moment of inertia is what will cause the angular acceleration, namely the derivative of angular velocity. Maybe I should write that down.

Torque divided by moment of inertia is going to be d over dt of angular velocity. I leave it up to your physics teachers to decide what letters to use for all these things. That is the analog of force divided by mass equals acceleration, which is d over dt of velocity. And so now you see if the curl of a velocity field measure the angular velocity of its rotation then, by this analogy, the curl of a force field should measure the torque it exerts on a mass per unit moment of inertia.

Concretely, if you imagine that you are putting something in there, you know, if you are in a velocity field the curl will tell you how fast your guy is spinning at a given time. If you put something that floats, for example, in your fluid, something very light then it is going to start spinning. And the curl of a velocity field tells you how fast it is spinning at any given time up to a factor of two. And the curl of a force field tells you how quickly the angular velocity is going to increase or decrease. OK.

Well, next time we are going to see Green's theorem which is actually going to tell us a lot more about curl and failure of conservativeness.