And also from a more theoretical standpoint, it'd be nice to have a general construct that tells us the conditions for whether or not a zero exists inside a given region. Now remember, in one dimension the main insight was that if a continuous function is positive at one point and negative at another, then somewhere in between it must be zero. So how do we extend that into two dimensions? We need some sort of analog of talking about signs. One way to think about what signs even are is directions. Positive means you're pointing to the right along the number line, and negative means you're pointing to the left. Two dimensional quantities also have direction, but for them the options are much wider, they can point anywhere along a whole circle of possibilities. So the same way that in one dimension we were asking whether a given function is positive or negative on the boundary of a range, which is just two points, for 2D functions we're going to be looking at the boundary of a region, which is a loop, and ask about the direction of the function's output along that boundary. For example, we see that along this loop around this zero, the output goes through every possible direction, all the colors of the rainbow, red, yellow, green, blue, back to red, and everything in between along the way. But along this loop over here, with no zeros inside of it, the output doesn't go through every color, it goes through some of the orangish ones, but never, say, green or blue. And this is promising, it looks a lot like how things worked in one dimension. Maybe in the same way that if a 1D function takes both possible signs on the boundary of a 1D region, there was a zero somewhere inside, we might hypothesize that if a 2D function hits outputs of all possible directions, all possible colors, along the boundary of a 2D region, then somewhere inside that region it must go to zero. So that's our guess, and take a moment to think about if this should be true, and if so, why? If we start thinking about a tiny loop around some input point, we know that since everything is continuous, our function takes it to some tiny loop near the corresponding output. But look, for most tiny loops, the output varies in color. If you pick any output point other than zero, and draw a sufficiently tight loop near it, the loop's colors are all going to be about the same color as that point. A tight loop over here is all bluish, yellowish, you certainly aren't going to get every color of the rainbow. The only point where you can tighten loops around it while still getting all the colors is the colorless origin, zero itself. So it is indeed the case that if you have loops going through every color of the rainbow, tightening and tightening, narrowing in on a point, then that point must in fact be a zero. And so, let's set up a 2D equation solver just like our one-dimensional equation solver. When we find a large region whose border goes through every color, split it into two, and then look at the colors on the boundary of each half. In the example shown here, the border on the left half doesn't go through all colors, there are no points that map to the orangish-yellowish directions, for example. So I'll grey out this area as a way of saying we don't want to search it any further. The right half does go through all the colors, spends a lot of time in the green direction, then passes through yellow-orange-red, as well as blue-violet-pink. Now remember, what that means is that points of this boundary get mapped to outputs of all possible directions. So we'll explore it further, subdividing again and checking the boundary for each region. The boundary of the top is all green, so we'll stop searching there. But the bottom is colorful enough to deserve a subdivision. And just continue like this. Check which subregion has a boundary covering all possible colors, meaning points of that boundary get mapped to all possible directions, and keep chopping those regions in half like we did for the one-dimensional case, eventually leading us to a zero over the func- Well, hang on a second. What happened here? Neither of those last subdivisions on the bottom right passed through all the colors, so our algorithm stopped because it didn't want to search through either of those, but it also didn't find a zero. Okay, clearly something's wrong here. And that's okay, being wrong is a regular part of doing math. If we look back, we had this hypothesis, and it led us to this proposed algorithm, so we were mistaken somewhere. And being good at math isn't about being right the first time, it's about having the resilience to carefully look back and understand the mistakes, and understand how to fix them. Now the problem here is that we had a region whose border went through every color, but when we split it in the middle, neither subregion's border went through every color, we had no options for where to keep searching next, and that broke the zero finder. Now in one dimension, this sort of thing never happened. Any time you had an interval whose endpoints have different signs, if you split it up, you know that you're guaranteed to get some subinterval whose endpoints also have different signs. Or, put another way, any time you have two intervals whose endpoints don't change signs, if you combine them, you'll get a bigger interval whose endpoints also don't change sign. But in two dimensions, it's possible to find two regions whose borders don't go through every color, but whose boundaries combine to give a region whose border does go through every color. And in just this way, our proposed zero-finding algorithm broke. In fact, if you think about it, you can find a big loop whose border goes through every possible color without there being a zero inside of it. Now that's not to say that we were wrong in our claims about tiny loops when we said that a forever narrowing loop going through every color has to be narrowing in on a zero. But what made a mess of things for us is that this does-my-border-go-through-every-color-or-not property doesn't combine in a nice, predictable way when you combine regions. But don't worry, it turns out we can modify this slightly to a more sophisticated property that does combine to give us what we want. The idea is that instead of simply asking whether we can find a color at some point along the loop, let's keep more careful track of how these colors change as we walk around that loop. Let me show you what I mean with an example. I'll keep a little color wheel up here in the corner to help us keep track. When the colors along a path of inputs move through the rainbow in a specific direction, from red to yellow, yellow to green, green to blue, or blue to red, the output is swinging clockwise. But on the other hand, if the colors move the other way through the rainbow, from blue to green, green to yellow, yellow to red, or red to blue, the output is swinging counterclockwise. So walking along this short path here, the colors wind a fifth of the way clockwise through the color wheel. And walking along this path here, the colors wind another fifth of the way clockwise through the color wheel. And of course that means that if you go through both paths, one after the other, the colors wind a total of two-fifths of a full turn clockwise. The total amount of winding just adds up, and this is going to be key, this is the kind of straightforward combining that will be useful to us. Now when I say total amount of winding, I want you to imagine an old-fashioned odometer that ticks forward as the arrow spins clockwise, but backwards counterclockwise. So counterclockwise winding counts as negative clockwise winding. The outputs may turn a lot, but if some of that turning is in the opposite direction, it cancels out. For example, if you move forward along this path, and then move backwards along that same path, the total amount of winding ends up being zero. The backwards movement literally rewinds through the previously seen colors, reversing all the previous winding, and returning the odometer back to where it started. For our purposes, we'll care most about looking at the winding along loops. For example, let's say we walk around this entire loop clockwise. The outputs that we come across wind around a total of three full clockwise turns. The colors swung through the rainbow, ROYGBIV, in order, from red to red again, and then again, and again. In the jargon mathematicians use, we say that along this loop, the total winding number is three. Now for other loops, it could be any other whole number, maybe a larger one if the output swings around many times as the input walks around a single loop, or it could be a smaller number if the output only swings around once or twice, or that winding number could even be a negative integer if the output was swinging counterclockwise as we walk clockwise around the loop. But along any loop, this total amount of winding has to be a whole number. I mean, by the time you get back to where you started, you'll have the same output that you started with. Incidentally, if a path actually contains a point where the output is precisely zero, then technically you can't define a winding number along that, since the output has no particular direction. Now this isn't going to be a problem for us, because our whole goal is to find zeros, so if this ever comes up, we just lucked out early. Alright, so the main thing to notice about these winding numbers