# Multivariable Calculus: Change of Variables

## Change of Variables

**Transcript:** OK, so far we've learned how to do double integrals in terms of xy coordinates, also how to switch to polar coordinates. But, more generally, there's a lot of different changes of variables that you might want to do. OK, so today we're going to see how to change variables, if you want, how to do substitutions in double integrals. OK, so let me start with a simple example.

Let's say that we want to find the area of an ellipse with semi-axes a and b. OK, so that means an ellipse is just like a squished circle. And so, there's a and there's b. And, the equation of that ellipse is x over a squared plus y over b squared equals one. That's the curve, and the inside region is where this is less than one. OK, so it's just like a circle that where you have rescaled x and y differently. So, let's say we want to find the area of it. Maybe you know what the area is. But let's do it as a double integral.

So, you know, if you find that the area is too easy, you can integrate any function other than ellipse, if you prefer. But, let's do it just with area. So, we know that we want to integrate just the area element, let's say, dx dy over the origin inside the ellipse. That's x over a2 plus y over b2 less than 1. Now, we can try to set this up in terms of x and y coordinates, you know, set up the bounds by solving for first four x as a function of y if we do it this order and, well, do the usual stuff. That doesn't look very pleasant, and it's certainly not the best way to do it. OK, if this were a circle, we would switch to polar coordinates. Well, we can't quite do that yet. But, you know, an ellipse is just a squished circle. So, maybe we want to actually first rescale x and y by a and b.

So, to do that, what we'd like to do is set x over a to be u, and y over b be v. So, we'll have two new variables, u and v, and we'll try to redo our integral in terms of u and v. So, how do we do the substitution? So, in terms of u and v, the condition, the region that we are integrating on will become u^2 v^2 is less than 1, which is arguably nicer than the ellipse. That's why we are doing it. But, we need to know what to do with dx and dy. Well, here, the answer is pretty easy because we just change x and y separately. We do two independent substitutions. OK, so if we set u equals x over a, that means du is one over adx.

And here, dv is one over bdy. So, it's very tempting to write, and here we actually can write, in this particular case, that dudv is (1/ab)dxdy, OK? So, let me rewrite that. OK, so I get dudv equals (1/ab)dxdy, or equivalently dxdy is ab times dudv. OK, so in my double integral, I'm going to write (ab)dudv. OK, so now, my double integral becomes, well, the double integral of a constant in terms of u and v. So, I can take the constant out. I will get ab times double integral over u^2 v^2<1 of du dv. And, that is an integral that we know how to do. Well, it's just the area of a unit circle.

So, we can just say, this is ab times the area of the unit disk, which we know to be pi, or if somehow you had some function to integrate, then you could have somehow switched to polar coordinates, you know, setting u equals r times cos(theta), v equals r times sin(theta), and then doing it in polar coordinates. OK, so here the substitution worked pretty easy. The question is, if we do a change of variables where the relation between x and y and u and v is more complicated, what can we do? Can we still do this, or do we have to be more careful? And, actually, we have to be more careful. So, that's what we are going to see next. Any question about this, first?

No? OK. OK, so, see the general problem when we try to do this is to figure out what is the scale factor? What's the relation between dxdy and dudv? We need to find the scaling factor. So, we need to find dxdy versus dudv. So, let's do another example that's still pretty easy, but a little bit less easy. OK, so let's say that for some reason, we want to do the change of variables: u equals 3x-2y, and v equals x y. Why would we want to do that? Well, that might be to simplify the integrand because we are integrating a function that happens to be actually involving these guys rather than x and y.

Or, it might be to simplify the bounds because maybe we are integrating over a region whose equation in xy coordinates is very hard to write down. But, it becomes much easier in terms of u and v. And then, the bounds would be much easier to set up with u and v. Anyway, so, whatever the reason might be, typically it would be to simplify the integrant or the bounds. Well, how do we convert dxdy to dudv? So, we want to understand, what's the relation between, let's call dA the area element in xy coordinates. So, dA is dxdy, maybe dydx depending on the order. And, the area element in uv coordinates, let me call that dA prime just to make it look different.

So, that would just be dudv, or dvdu depending on which order I will want to set it up in. So, to find this relation, it's probably best to draw a picture to see what happens. Let's consider a small piece of the xy plane with area delta(A) corresponding to just a box with sides delta(y) and delta(x). OK, and let's try to figure out what it will look like in terms of u and v. And then, we'll say, well, when we integrate, we're really summing the value of the function of a lot of small boxes times their area.

But, the problem is that the area of the box in here is not the same as the area of the box in uv coordinates. There, maybe it will look like, actually, if you see that these are linear changes of variables, you know that the rectangle will become a parallelogram after the change of variables. So, the area of a parallelogram delta(A) prime, well, we will have to figure out how they are related so that we can decide what conversion factor, what's the exchange rate between these two currencies for area?

OK, any questions at this point? No? Still with me mostly? I see a lot of tired faces. Yes? Why is delta(A) prime a parallelogram? That's a very good question. Well, see, if I look at the side of a rectangle, say there's a vertical side, it means I'm going to increase y, keeping x the same. If I look at the formulas for u and v, they are linear formulas in terms of x and y. So, if I just increase y, see that u is going to decrease at a rate of two. v is going to increase at a rate of one at constant rates. And, it doesn't matter whether I was looking at this site or at that site. So, basically straight lines become straight lines. And if they are parallel, they stay parallel.

So, if you just look at what the transformation, from xy to uv does, it does this kind of thing. Actually, this transformation here you can express by a matrix. And, remember, we've seen what matrices do the pictures. We just take straight lines to straight lines. They keep the notion of being parallel, but of course they mess up lengths, angles, and all that. OK, so let's see. So, let's try to figure out, what is the area of this guy?

Well, in fact, what I've been saying about this transformation being linear, and transforming all of the vertical lines in the same way, all the horizontal lines in the same way, it tells me, also, I should have a constant scaling factor, right, because how much I've scaled my rectangle doesn't depend on where my rectangle is. If I move my rectangle to somewhere else, I have a rectangle of the same size, same shape, it will become a parallelogram of the same size, same shape somewhere else.

So, in fact, I can just take the simplest rectangle I can think of and see how its area changes. And, if you don't believe me, then try with any other rectangle. You will see it works exactly the same way. OK, so I claim that the area scaling factor -- -- here in this case doesn't depend on the choice of the rectangle. And I should say that because we are actually doing a linear change of variables --

So, you know, somehow, the exchange rate between uv and xy is going to be the same everywhere. So, let's try to see what happens to the simplest rectangle I can think of, namely, just the unit square. And, you know, if you don't trust me, then while I'm doing this one, do it with a different rectangle. Do the same calculation, and see that you will get the same conversion ratio. So, let's say that I take a unit square --

-- so, something that goes from zero to one both in x and y directions. OK, and let's try to figure out what it looks like on the other side. So, here the area is one. Let's try to draw it in terms of u and v coordinates, OK? So, here we have x equals 0, y equals 0. Well, that tells us u and v are going to be 0. Next, let's look at this corner. Well, in xy coordinates, this is one zero. If you plug x equals 1, y equals 0, you get u equals 3; v equals 1. So, that goes somewhere here. And so, this edge of the square will become this line here, OK?

Next, let's look at that point. So that point here was (0,1). If I plug x equals zero y equals one I will get (-2,1). So, this edge goes here. Then, if you put x equals one, y equals one, you will get u equals 1, v equals 2. So, I want (1,2). And, these edges will go to these edges here. And, you see, it does look like a parallelogram. OK, so now what the area of this parallelogram? Well, we can get that by taking the determinant of these two vectors. So, one of them is <3,1>, and the other one is <-2,1>. That will be 3 2. That's 5. OK, this parallelogram is apparently five times the size of this square. Here, it looks like it's less because I somehow changed my scale. I mean, my unit length is smaller here than here.

But, it should be a lot bigger than that. OK, and if you do the same calculations not with zero and one, but with x and x plus delta x, and so on, you will still find that the area has been multiplied by five. So, that tells us, actually for any other rectangle, area is also multiplied by five. So, that tells us that dA prime, the area element in uv coordinate is worth five times more than the area element in the xy coordinate.

So, that means du dv is worth five times dx dy. What's so funny? What? Oh. [LAUGHTER] OK, rectangle. OK, is that OK now? Did I misspell other words? No? OK, it's really hard to see when you are up close. It's much easier from a distance. OK, so yeah, so we've said our transformation multiplies areas by five. And so, dudv is five times dxdy. So, if I'm integrating some function, dx dy, then when I switch to uv coordinates, I will have to replace that by one fifth dudv. OK, and of course I would also, here my function would probably involve x and y. I will replace them by u's and v's. And, the bounds, well, the shape of my origin in the xy coordinates I will have to switch to some shape in the uv coordinates.

And, that's also something that might be easy or might be tricky depending on what origin we are looking at. So, usually we will do changes of variables to actually simplify the region so it becomes easier to set up the bounds. So, anyway, so this is kind of an illustration of a general case. And, why is that? Well, here it looks very easy. We are just using linear formulas, and somehow the relation between dx dy and du dv is the same everywhere. If you take actually more complicated changes of variables that's not true because usually you will expect that there are some places where the rescaling is enlarging things, and some of other places where things are shrunk, so, certainly the exchange rate between dudv and dxdy will fluctuate from point to point. It's the same as if you're trying to change dollars to euros.

It depends on where you do it. You will get a better rate or a worse one. So, of course, we'll get a formula where actually this scaling factor depends on x and y or on u and v. But, if you fix a point, then we have linear approximation. And, linear approximation tells us, oh, we can do as if our function is just a linear function of x and y. So then, we can do it the same way we did here. OK, so let's try to think about that.

So, in the general case, well, that means we will replace x and y by new coordinates, u and v. And, u and v will be some functions of x and y. So, well, we'll have an approximation formula which tells us that the change in u, if I change x or y a little bit, will be roughly (u sub x times change in x) (u sub y times change in y). And, the change in v will be roughly (v sub x delta x) (v sub y delta y). Or, the other way to say it, if you want in matrix form is delta u delta v is, sorry, approximately equal to matrix |u sub x, u sub y, v sub x, v sub y| times matrix |delta x, delta y|, OK?

So, if we look at that, what it tells us, in fact, is that if we take a small rectangle in xy coordinates, so that means we have a certain point, x, y, and then we have a certain width. This is going to be too small. Well, so, I have my width, delta x. I have my height, delta y. This is going to correspond to a small uv parallelogram. And, what the shape and the size of the parallelogram are depends on the partial derivatives of u and v. So, in particular, it depends on at which point we are. But still, at a given point, it's a bit like that. And, so if we do the same argument as before, what we will see is that the scaling factor is actually the determinant of this transformation.

So, that's one thing that maybe we didn't emphasize enough when we did matrices at the beginning of a semester. But, when you have a linear transformation between variables, the determinant of that transformation represents how it scales areas. OK, so one way to think about it is just to try it and see what happens. Take this side. This side in x, y coordinates corresponds to delta x and zero. And, now, if you take the image of that, if you see what happens to delta u and delta v, that will be basically u sub x delta x and v sub x delta x. There's no delta y. For the other side, OK, so maybe I should do it actually. So, you know, if we move in the x, y coordinates by delta x and zero, then delta u and delta v will be approximately u sub x delta x, and v sub x delta x.

And, on the other hand, if you move in the other direction along the other side of your rectangle, zero and delta y, then the change in u and the change in v will correspond to, well, how does u change? That's u sub y delta y, and v changes by v sub y delta y. And so, now, if you take the determinant of these two vectors, OK, so these are the sides of your parallelogram up here. And, if you take these sides to get the area of the parallelogram, you'll need to take the determinant. And, the determinant will be the determinant of this matrix times delta x times delta y.

So, the area in uv coordinates will be the determinant of a matrix times delta x, delta y. And so, what I'm trying to say is that when you have a general change of variables, du dv versus dx dy is given by the determinant of this matrix of partial derivatives. It doesn't matter in which order you write it. I mean, you can put in rows or columns. If you transpose a matrix, that doesn't change the determinant. It's just any sensible matrix that you can write will have the correct determinant.

OK, so what we need to know is the following thing. So, we define something called the Jacobian of a change of variables and used the letter J, or maybe a more useful notation is partial of u, v over partial of x, y. That's a very strange notation. I mean, that doesn't mean that we are actually taking the partial derivatives of anything. OK, it's just a notation to remind us that this has to do with the ratio between dudv and dxdy.

And, it's obtained using the partial derivatives of u and v with respect to x and y. So, it's the determinant of the matrix |u sub x, u sub y, v sub x, v sub y|, the matrix that I had up there. OK, and what we need to know is that du dv is equal to the absolute value of J dx dy. Or, if you prefer to see it in the easier to remember version, it's (absolute value of d of (u, v) over partial xy) times dx dy. OK, so this is just what you need to remember, and it says that the area in uv coordinates is worth, well, the ratio to the xy coordinates is given by this Jacobian determinant except for one small thing.

It's given by, actually, the absolute value of this guy. OK, so what's going on here? What's going on here is when we are saying the determinant of the transformation tells us how the area is multiplied, there's a small catch. Remember, the determinants are equal to areas up to sine. Sometimes, the determinant is negative because of reversing the orientation of things. But, the area is still the same. Area is always positive. So, the area elements are actually related by the absolute value of this guy. OK, so if you find -10 as your answer, then du dv is still ten times dx dy.

OK, so I didn't put it all together because then you would have two sets of vertical bars. See, this is a vertical bar for absolute value. This is vertical bar for determinant. They're not the same. That's the one thing to remember. OK, any questions about this? No? OK. So, actually let's do our first example of that. Let's check what we had for polar coordinates. Last time I told you if we have dx dy we could switch it to r dr d theta. And, we had some argument for that by looking at the area of a small circular sector. But, let's check again using this new method. So, in polar coordinates I'm setting x equals r cosine theta, y equals r sine theta.

So, the Jacobian for this change of variables, so let's say I'm trying to find the partial derivatives of x, y with respect to r, theta. Well, what is, OK, let me actually write them here again for you. And, so what does that become? Partial x over partial r is just cosine theta. Partial x over partial theta is negative r sine theta. Sorry, I guess I'm going to run out of space here. So, let me do it underneath. So, we said x sub r is cosine theta; x sub theta is negative r sine theta.

y sub r is sine; y sub theta is r cosine. And now, if we compute this determinant, we'll get (r cosine squared theta) (r sine squared theta). And, that simplifies to r. So, dx dy is, well, absolute value of r dr d theta. But, remember that r is always positive. So, it's r dr d theta. OK, so that's another way to justify how we did double integrals in polar coordinates. OK, any questions on that? Where? Yeah, OK.

Yeah, so this one seems to be switching. Well, it depends what you do. So, OK, actually here's an important thing that I didn't quite say. So, I said, you know, we are going to switch from xy to uv. We can also switch from uv to xy. And, this conversion ratio, the Jacobian, works both ways. Once you have found the ratio between du dv and dx dy, then it works one way or it works the other way. I mean, here, of course, we get the answer in terms of r. So, this would let us switch from xy to r theta. But, we can also switch from r theta to xy. Just, we'd write dr d theta equals (1 over r) times dx dy. And then we'd have, of course, to replace r by its formula in xy coordinates.

Usually, we don't do that. Usually, we actually start with xy and switch to polar. But, so in general, when you have this formula relating du dv with dx dy, you can use it both ways, either to switch from du dv to dx dy or the other way around. And, the thing that I'm not telling you that now I should probably tell you is I could define two Jacobians because if I solve for xy in terms of uv instead of uv in terms of xy, then I can compute two different Jacobians.

I can compute partial uv over partial xy, or I can compute partial xy over partial uv if I have the formulas both ways. Well, the good news is these guys are the inverse of each other. So, the two formulas that you might get are consistent. OK, so useful remark -- So, say that you can compute both -- -- these guys. Well, then actually, the product will just be 1. So, they are the inverse of each other. So, it doesn't matter which one you compute. You can compute whichever one is the easiest to compute no matter which one of the two you need.

And, one way to see that is that, in fact, we're looking at the determinant of these matrices that tell us the relation in variables. So, if one of them tells you how delta u delta v relate to delta x delta y, the other one does the opposite thing. It means they are the inverse matrices. And, the determinant of the inverse matrix is the inverse of the determinant. So, they are really interchangeable. I mean, you can just compute whichever one is easiest. So here, if you wanted, dr d theta in terms of dx dy, it's easier to do this and then move the r over there than to first solve for r and theta as functions of x and y and then do the entire thing again. But, you can do it if you want. I mean, it works.

Oh yeah, the other useful remark, so, I mentioned it, but let me emphasize again. So, now, the ratio between du dv and dx dy, it's not a constant anymore, although there it used to be five. But now, it's become r, or anything. In general, it will be a function that depends on the variables. So, it's not true that you can just say, oh, I'll put a constant times du dv. Yes? It would still work the same. You could imagine drawing a picture where r and theta are the Cartesian coordinates, and your picture would be completely messed up. It would be a very strange thing to do to try to draw, you know, I'm going to do it, but don't take notes on that. You could try to draw picture like that, and then a circle would start looking like, you know, a disk would look like that. It would be very counterintuitive. But, you could do it. And that would be equivalent to what we did with a previous change of variables.

So, in this case, certainly you would never draw a picture like that. But, you could do it. OK, so now let's do a complete example to see how things fit together, how we do everything. So, let's say that we want to compute, so I have to warn you, it's going to be a very silly example. It's an example where it's much easier to compute things without the change of variables. But, you know, it's good practice in the sense that we're going to make it so complicated that if we can do this one, then we can do that one. So, let's say that we want to compute this. And, of course, it's very easy to compute it directly.

But let's say that for some evil reason we want to do that by changing variables to u equals x and v equals xy. OK, that's a very strange idea, but let's do it anyway. I mean, normally, you would only do this kind of substitution if either it simplifies a lot the function you are integrating, or it simplifies a lot the region on which you are integrating. And here, neither happens. But anyway, so the first thing we have to do here is figure out what we are going to be integrating. OK, so to do that, we should figure out what dx dy will become in terms of u and v. So, that's what we've just seen using the Jacobian. OK, so the first thing to do is find the area element. And, for that, we use the Jacobian. So, well, let's see, the one that we can do easily is partials of u and v with respect to x and y.

I mean, the other one is not very hard because here you can solve easily. But, the one that's given to you is partial of u and v with respect to x and y, so partial u partial x is one. Partial u partial y is zero. Partial v partial x is y. And partial v partial y is x. So that's just x. So, that means that du dv is x dx dy. Well, it would be absolute value of x, but x is positive in our origin. So, at least we don't have to worry about that.

OK, so now that we have that, we can try to look at the integrand in terms of u and v. OK, so we were integrating x squared y dx dy. So, let's switch it. Well, let's first switch the dx dy that becomes one over x du dv. So, that's actually xy du dv. And, what is xy in terms of u and v? Well, here at least we had a little bit of luck. xy is just v. So, that's v du dv. So, in fact, what we'll be computing is a double integral over some mysterious region of v du dv.

Now, last but not least, we'll have to find what are the bounds for u and v in the new integral so that we know how to evaluate this. In fact, well, we could do it du dv or dv du. We don't know yet. Oh, amazing. It went all the way down this time. OK, so it could be dv du if that's easier. So, let's try to find the bounds. In this case, that's the hardest part. OK, so let me draw a picture in xy coordinates and try to understand things using that. OK, so x and y go from zero to one. The region that we want to integrate over was just this square.

Let's try to figure out how u and v vary there. So, let's say that we're going to do it du dv. OK, so What we want to understand is how u and v vary in here. What's going to happen? So, the way we can think about it is we try to figure out how we are slicing our origin. OK, so here, we are integrating first over u. That means we start by keeping u constant, no, by keeping v constant as u changes. OK, so u changes as v is constant. What does it mean that I'm keeping v constant. Well, what is v? v is xy.

So, that means I keep xy equals constant. What does the curve xy equals constant look like? Well, it's just a hyperbola. y equals constant over x. So, if I look at the various values of v that I can take, for each value of v, if I fix a value of v, I will be moving on one of these red curves. OK, and u, well, u is the same thing as x. So, that means u will increase. Here, maybe it will be 0.1 and it will increase all the way to one here. OK, so we are just traveling on each of these slices. Now, so the question we must answer here is for a given value of v, what are the bounds for u? So, I'm traveling on my curve, v equals constant, and trying to figure out, when do I enter my origin? When do I leave it?

Well, I enter it when I go through this side. So, the question is, what's the value of u here? Well, we don't know that very easily until we look at these formulas. So, u equals x, OK, but we don't know what x is at that point. v equals x and v equals xy. What do we go here? Well, we don't know x, but we know y certainly. OK, so let's forget about trying to find u. And, let's say, for now, we know y equals one. Well, if we set y equals one, that tells us that u and v are both equal to x. So, in terms of u and v, the equation of this uv coordinate is u equals v.

OK, I mean, the other way to do it is, say that you know you want y equals one. You want to know what is y in terms of u and v. Well, it's easy. y is v over u. So, let me actually add an extra step in case that's, so, we know that y is v over u equals one. So, that means u=v is my equation. OK, so when I'm here, when I'm entering my region, the value of u at this point is just v, u equals v.

That's the hard part. Now, we need to figure out, so, we started u equals v. u increases, increases, increases. Where does it exit? It exits one when we are here. What's the value of u here? One. That one is easier, right? This side here, so, this side here is x equals one. That means u equals one. So, we start at u equals one. Now, we've done the inner integral. What about the outer? So, we have to figure out, what is the first and what is the last value of v that we'll want to consider? Well, if you look at all these hyperbola's, xy equals constant. What's the smallest value of xy that we'll ever want to look at in here?

Zero, OK. Let me actually, where's my yellow chalk? Is it, no, ah. So, this one here, that's actually v=0. So, we'll start at v equals zero. And, what's the last hyperbola we want to look at? Well, it's the one that's right there in the corner. It's this one here. And, that's v equals one. So, v goes from zero to one. OK, and now, we can compute this. I mean, it's not particularly easier than that one, but it's not harder either. How else could we have gotten these bounds, because that was quite evil. So, I would like to recommend that you try this way in case it works well. Just try to picture, what are the slices in terms of u and v, and how you travel on them, where you enter, where you leave, staying in the xy picture. If that somehow doesn't work well, another way is to draw the picture in the uv coordinates.

So, switch to a uv picture. So, what do I mean by that? Well, we had here a picture in xy coordinates where we had our sides. And, we are going to try to draw what it looks like in terms of u and v. So, here we said this is x equals one. That becomes u equals one. So, we'll draw u equals one. This side we said is y equals one becomes u equals v. That's what we've done over there. OK, so u equals v. Now, we have the two other sides to deal with.

Well, let's look at this one first. So, that was x equals zero. What happens when x equals zero? Well, both u and v are zero. So, this side actually gets squished in the change of variables. It's a bit strange, but it's a bit the same thing as when you switch to polar coordinates at the origin, r is zero but theta can be anything. It's not always one point is one point. So anyway, this is the origin, and then the last side, y equals zero, and x varies just becomes v equals zero.

So, somehow, in the change of variables, this square becomes this triangle. And now, if we want to integrate du dv, it means we are going to slice by v equals constant. So, we are going to integrate over slices like this, and you see for each value of v, we go from u equals v to u equals one. And, v goes from zero to one. OK, so you get the same bounds just by drawing a different picture. So, it's up to you to decide whether you prefer to think on this picture or draw that one instead. It depends on which problems you're doing.