[00:00] [Submit subtitle corrections at criblate.com] Whenever I'm making one of these videos, there's sometimes a special moment [00:03] where the act of animating involves solving a whole bunch of little technical puzzlers, [00:07] and then the underlying math I'm trying to explain clicks for me in a [00:11] way that it hadn't before once I see it alive on screen. [00:14] The best versions of those moments often tell me when a video is [00:17] going to be one of my favorites, and putting together the end of [00:20] this piece right here was one such time when I got that feeling. [00:27] Our story doesn't actually start in the math classroom today. [00:30] We begin in the art room. [00:32] Imagine standing in a gallery, looking at a picture of a boat in a harbour, [00:36] and the whole world warps as your gaze shifts upwards and to the right, [00:40] where you see a village on this waterfront. [00:43] Among the tightly clustered buildings, the world warps even more as your gaze shifts [00:48] downwards to the entrance of one building, leading to a hallway full of artwork. [00:53] And at the end of this hall, here you are again, staring at a picture of a boat. [00:58] This is M.C. [00:59] Escher's 1956 lithograph, the Print Gallery, or in Dutch, Prentendentunstelling. [01:05] In a letter that he wrote to his son, describing his creation of a young [01:10] man looking with interest at a print that features himself, [01:13] Escher called this the most peculiar thing I have ever done, [01:16] which for him is saying a lot. [01:18] Escher's art is widely loved around the world, [01:21] frequently featuring paradoxical themes or uniquely satisfying geometric patterns [01:25] with some kind of character. [01:27] This love is especially pronounced among mathematicians, [01:30] since his art often touches on surprisingly deep concepts within math, [01:34] despite the fact that Escher himself had no formal training in the field. [01:39] The Print Gallery offers a perfect example of this unexpected depth. [01:43] In 2003, the mathematicians De Smit and Lenstra offered a delightful [01:47] analysis of what's really going on in this piece and the [01:50] mind-bending self-contained loop that Escher managed to achieve. [01:54] One of my main goals with this video is to offer a visual unpacking of their analysis, [01:59] aiming as always to give you a feeling that you could have rediscovered this yourself. [02:05] Something that unexpectedly pops out of this analysis is an answer to [02:08] the question of what exactly should go in the middle of this picture. [02:12] At first, that might sound like an incoherent question. [02:15] If you come at it from the upper right, it feels like it should be featuring buildings in [02:19] the village, but coming at it from the left, it looks more like part of the picture [02:23] frame. [02:23] Come at it from below, though, and it feels more fitting to be part of the gallery itself. [02:28] Somehow all of the ambiguity about where exactly you are in this [02:31] whole scene is compressed into that blank circle in the middle. [02:36] And just for fun, since we're in the 2020s, I let [02:38] a diffusion model take a stab at filling this in. [02:41] Unsurprisingly, it struggles immensely. [02:43] It just doesn't get it at all. [02:45] And giving the poor machine some credit, of course it struggles. [02:48] This feels like an intrinsically ambiguous and ill-defined part of the scene. [02:52] But nevertheless, by the end, I hope you'll agree there is one, and really only one, [02:57] completion that feels like the right puzzle piece you can slot in. [03:02] Before diving into the math, I want to give you a purely intuitive description for [03:05] how Escher actually made this piece, which breaks up into three different steps. [03:10] Step one is to start out with a straightened out version of the same general concept, [03:15] where a man is looking at a picture. [03:17] That picture contains a harbor, which contains a town, [03:21] that contains a print gallery, that contains that same man, and so on and so forth. [03:26] You could zoom in forever to your heart's content. [03:30] This idea of a self-similar image, where the picture is contained inside itself, [03:34] has a special name to graphic designers. [03:37] It's known as the Droste effect, named after a [03:39] cocoa company that featured it in its branding. [03:42] In fact, this seems to have been a somewhat common marketing [03:45] gimmick for all kinds of early 20th century products. [03:48] The self-similar Droste image that Escher was using, though, [03:52] involves a much, much deeper zoom than any of these, [03:55] where the self-similar copy is 256 times smaller than the original. [04:00] You'll see where that number comes from in just a minute. [04:03] The genius of Escher is that he somehow intuitively realized there must be a way to [04:08] take this concept of a picture nested inside itself and turn it into this warped loop [04:14] where the zooming in happens implicitly as a viewer's gaze wanders around the circle. [04:21] By the way, you might be wondering where I got this straightened out version, [04:24] and the answer is that those two mathematicians I referenced generously let us use it. [04:28] This is something they actually reverse engineered from the original Escher [04:32] piece using the help of two Dutch artists, Hans Richter and Jacqueline Hofstra. [04:37] The way they reverse engineered it is actually super interesting. [04:40] In a certain manner of speaking, it involves taking the logarithm of the original piece. [04:44] I recognize that sentence probably sounds like nonsense right now, [04:48] but later on in this video, I promise that will make abundant sense. [04:52] To outline the basic idea for how Escher made this loop, [04:55] I want to use an example that's simpler than the one he was working with, [04:59] so we'll pull up this custom self-similar Drasta image which has a pie [05:02] creature looking at a framed picture of a house where that same pie creature lives. [05:08] In this example, the self-similar copy is only 16 times smaller than the original, [05:12] and this just makes everything much easier to see all at once. [05:15] What I'll do is keep a separate workspace on the right here to sketch out the [05:20] general goal we have in mind, where the way you might think about it is that you [05:24] want to distribute that 16-fold zoom-in factor across the four corners of the square. [05:30] For example, let's say you want the pie creature itself to [05:33] appear about at the same size in the lower left corner. [05:36] Then if you zoom in by a factor of 2 in the original, [05:39] we'll take what would be in the upper left of that zoomed version and then place it in [05:44] the upper left of our workspace. [05:47] Similarly, zoom in by another factor of 2 and then take the upper right of that zoomed-in [05:52] version and now place an expanded version of that in the upper right of our workspace. [05:58] Finally, one more step, zoom in by another factor of 2, [06:01] take what's in the lower right of that zoomed-in version, blow it up, [06:05] and place it in the lower right of our workspace. [06:08] These four cut-out corners give a rough idea of what we want to create here. [06:13] As long as you can find a smooth way to fill in the gaps between them, [06:17] then as the onlooker's gaze wanders around a circle on this image, [06:21] what they're seeing will zoom in and in and in until it elegantly joins up with the [06:26] self-similar part of the image 16 times smaller. [06:29] We could just try joining it all up naively, something like this, [06:33] but frankly that doesn't really look very good, [06:35] and it's certainly not as smooth and as elegant as what Escher managed to achieve, [06:39] so we still have some work ahead of us. [06:42] This book that I've been pawing through by the way, The Magic of M.C. [06:46] Escher, is something that I got on a delightful visit to the Escher Museum in The Hague, [06:50] which, if you're ever in the Netherlands, I would highly recommend, [06:53] and when we turn to the section about the print gallery, [06:56] it offers us a little peek into what Escher's process actually was. [06:59] For him, step two was to create this warped grid. [07:03] For the animations here, I'm going to pull up a slight modification [07:06] of that grid that is basically just a little nicer mathematically to generate, [07:09] but it illustrates the same key point. [07:11] In his case, the self-similar Droste image he was working with has a scaling [07:16] factor of 256, so to distribute that across the four corners, [07:20] for him it would involve scaling by a factor of four as you walk from one [07:24] corner to the next. [07:26] And if you look closely at his grid, say at one of the squares on the lower right, [07:30] notice how if you follow the top and bottom lines bounding that square over to the lower [07:35] left of the image, those same lines end up enclosing a square that is now four times as [07:40] big. [07:40] And then similarly, if you look at the lines bounding the left and [07:43] right of a small square from that region, and you follow them upward, [07:47] they end up nestled around a square that's nicely four times as big. [07:50] So the grid kind of encodes the scaling from one corner to the next that we want. [07:55] Now for our pet project, where we only need to scale up by a [07:58] factor of two from each corner to the next, we're going to use [08:01] a modified version of this, but it'll be the same general idea. [08:05] You might naturally wonder where on earth does this grid come from, [08:08] but I actually want to postpone that question and skip ahead to step three, [08:12] which is how you can actually use this grid together with the self- similar Drosse image [08:16] to create Escher's final effect. [08:19] The way this works is to first lay down an ordinary square grid on the original image, [08:23] and then let's say you want this portion here to end up in this corner of our final [08:28] version. [08:29] What you would do is take each tiny square inside it and then copy over its [08:33] contents to the corresponding tiny square in the warped version of the grid. [08:38] From there, each neighboring square in our original grid is forced to go [08:42] to the corresponding neighboring square in the warped version, [08:46] so you can kind of just keep following where the image must go by following the grid. [08:52] And the fact that the grid lines on the warped version space out by a factor of [08:56] two as you go from the lower left to the upper left means that the scale of our [09:00] scene automatically gets scaled up by that factor of two as you walk up that line. [09:06] The idea of this process is that as an artist, [09:09] it's relatively straightforward to go piece by piece, [09:12] copying over what's inside one tiny square to another tiny square, [09:15] because at this small scale things are undistorted. [09:19] It's certainly way, way easier than trying to dream up and draw the appropriate [09:23] warped final image starting with nothing but a blank page in front of you. [09:28] So basically with this warped grid in hand, the process of copying over each little [09:33] square is pleasantly automatic, and if we let this automatic process run all the way [09:38] around, it nicely closes up with the initial position, and for that to happen, [09:43] it requires that our original image had this self-similarity when you zoom in by a [09:47] factor of 16. [09:49] I hope you'll agree the final result we have is pretty nice, [09:52] it recreates the same general effect, but more than anything I [09:55] think it gives cause to more deeply appreciate Escher's own composition. [09:59] He was actually very deliberate about the choice of imagery at all of the distinct scales. [10:03] To quote, I quite intentionally chose serial types of objects, [10:07] such for instance as a row of prints along the wall, or blocks of houses in a town. [10:13] Without the cyclic elements, it would be all the more [10:16] difficult to get my meaning over to the random viewer. [10:20] This idea where you have a straight reference image and then a warped grid, [10:23] and you use the two together to create a warped scene, [10:26] is a common process in graphic design. [10:29] It's known as a mesh warp, and Escher didn't invent it for this case, [10:32] it's something that he had used multiple times before for other pieces. [10:36] For our story, the point is that all of the logic for turning [10:40] a Drasta zoom into a loop is abstracted and purified into this grid, [10:44] raising the natural question, where does it come from? [10:48] How do you make this? [10:49] You can kind of imagine as an initial naive approach you might try linearly scaling [10:54] everything from one corner to the next, but if you did that right away you would see a [11:00] conflict. [11:01] These two scaling processes are placing distinct pressures on the individual squares, [11:05] where for example this square wants to get flared out in this direction [11:09] based on the zooming in from the right, but it also wants to get flared [11:13] in this direction based on the zooming out as you go up. [11:16] Escher was evidently pulled to resolve this by [11:19] curving all of the lines to relieve this tension. [11:23] But there's one other crucial constraint that it seems he was guided by, [11:26] one that presumably made the image transfer process easier, [11:30] which made the final result look more natural, [11:32] and which will make the ears of any mathematician immersed in complex [11:36] analysis immediately perk up. [11:38] In his final warped grid, the tiny squares are, well, squares. [11:43] To be clear, this is not at all true for most mesh warps. [11:46] In most cases, the warped grid lines that you draw don't necessarily intersect at right [11:51] angles, and the little regions that they bound will in general be little parallelograms. [11:56] This can still be workable for an artist, you can still kind of do the transfer, [12:00] but presumably the act of copying over from the original to the warped version [12:05] is more awkward when you have that distortion, [12:07] so it would be much nicer if in the warped grid, [12:10] little squares remained at least approximately square. [12:13] And when you look closely at the grid that Escher used for his print gallery, [12:17] it has this property. [12:18] All the lines are intersecting at right angles, and at a small enough scale, [12:22] the regions they bound really are approximately squares. [12:25] Artistically, this has the nice effect that even though the whole [12:29] scene is dramatically warped and distorted at a global scale, [12:32] zoomed in at a local scale, everything is relatively undistorted. [12:36] This is what makes each local part of Escher's image easily recognizable. [12:41] And mathematically, this is where the story really gets interesting. [12:45] You see, this idea of a function from two dimensional space to two dimensional space, [12:49] where tiny squares remain approximately square, [12:52] plays a special role and has a special name in math. [12:55] It's called a conformal map, and one area where it comes up all the time is in [12:59] the study of functions with complex number inputs and complex number outputs. [13:04] At this point, we're going to step back and walk out of the art [13:08] classroom and wander over into the math department, [13:10] where I want to offer you a mini lesson on some of the core ideas from this field. [13:16] The basic game plan from here is that I want to first do a little refresher, [13:20] go over some of the basics of complex numbers and complex functions, [13:23] and then I want to spend some meaningful time building up an intuition [13:26] for what logarithms look like in this context of complex numbers. [13:30] And then once you have that in hand, we're going to step through a completely different [13:34] way that you can think about recreating this effect that Escher had in his print gallery. [13:38] Let's warm up with a review of the basics. [13:41] We typically think about real numbers as living on a one dimensional line, [13:44] the real number line, and complex numbers are two dimensional. [13:48] Specifically, we think of the imaginary constant i, [13:51] defined to be the square root of negative one as being one unit above zero, [13:56] end every other point on this plane represents some combination of a real number [14:01] with some real multiple of i. [14:03] It's typical to use the variable z in referring to a general complex number, [14:07] and the game we want to play is to understand various functions of z. [14:11] A very simple but important example is to multiply z by some constant. [14:16] The function f of z equals two times z has the [14:19] effect of scaling everything up by a factor of two. [14:23] But what about multiplying by something imaginary, [14:25] like i, the square root of negative one? [14:27] Well you know that multiplying one by i gives you i, [14:31] and by definition, i times i is negative one. [14:34] Both of these you'll notice are in 90 degree rotation, and more generally, [14:38] multiplying any value z by i has the effect of a 90 degree rotation. [14:42] And more general than that, when you multiply by any complex constant, [14:46] the effect is some combination of scaling and rotating. [14:50] And there's a nice way to think about exactly how much it should scale and rotate. [14:54] Zero times anything is zero, so the origin has to stay fixed in place, [14:58] and then one times any constant c is that same constant c. [15:02] So that means this point at one has to be dragged over to land [15:05] on whatever that constant c is that we're talking about, [15:08] and that fully determines the amount of scaling and rotating. [15:12] From there, the rest of the grid stays as rigid as it can. [15:15] A key point to emphasize for our story is that if all you're doing [15:18] is multiplying by some constant, shapes are always preserved. [15:22] Anything you might want to draw, like a square, [15:24] can get scaled or rotated, but beyond that, there are no distortions. [15:29] Now things get more interesting for more complicated functions. [15:32] A simple but non-trivial example would be mapping each number z to z squared. [15:37] So the input two is going to have to move to two squared, which is four. [15:41] The input i is going to have to move to i squared, which is negative one. [15:45] Negative one itself would have to get mapped to positive one. [15:48] And in its fullness, here's what it looks like if I let every point among [15:52] the grid lines of this input space move over to their corresponding outputs. [15:57] It's a pretty nice effect, and unlike multiplying by a constant, [16:00] shape is absolutely no longer preserved. [16:02] The grid lines get curved and warped. [16:05] However, and this is a key point, pay attention to what happens at a small scale. [16:09] For example, just focusing on this little square from the input space. [16:12] As you watch the transformation happen again, you can see that [16:16] shape is approximately preserved, at least at a small enough scale. [16:20] Little squares from our original grid remain approximately [16:23] square even after getting processed by the function. [16:26] To use the lingo, the function z squared gives a conformal map. [16:30] And the choice of z squared is really not special here. [16:33] Here's what it looks like if you transform each point z over to z cubed. [16:37] Squares remain approximately square. [16:40] Okay, maybe this example square that I'm highlighting doesn't exactly look [16:43] square in the output, but really it's just because it started off too big. [16:46] To be clear, this conformal property that I'm talking about is a limiting one. [16:50] A particular square might not exactly become square, [16:53] but the idea is that as you zoom in more and more, [16:55] choosing square regions from the input space that are smaller and smaller, [16:59] the resulting output will indeed be better and better approximated by a square. [17:04] And there's also nothing all that special about the [17:06] choice of polynomials like z squared or z cubed. [17:08] For just about any function of complex numbers you could think to write down, [17:12] this property holds. [17:13] Shape is preserved at a small enough scale. [17:15] It's almost like magic. [17:17] The use of complex numbers is very relevant here. [17:20] If instead you were thinking of points in 2D space simply as a pair of real numbers with [17:25] some xy coordinates, and you write down some arbitrary function of x and y to get a [17:29] new pair of numbers, what is way, way more typical as you let points in that input [17:34] space get transformed is that the outputs of those tiny squares get squished and [17:38] distorted. [17:39] Even as you zoom in more and more, the resulting limiting shape [17:42] typically looks like a parallelogram, not necessarily a square. [17:46] So, complex functions really are special in this way. [17:50] And the basic reason that tiny squares remain square comes down to calculus. [17:54] What you're looking at is what it means for these functions to have derivatives. [17:59] That might sound a little strange, but the analogy you can think of is that for most [18:03] functions of real numbers, if you visualize them the ordinary way, [18:07] just with a graph of inputs on the x-axis, outputs on the y-axis, [18:11] as you zoom in more and more to any particular point on that graph, [18:14] it looks more and more like a straight line. [18:17] That is, the rate of change, how much delta f you get for a given delta x, [18:21] approaches a constant. [18:24] This is literally what it means for a function to have a derivative, [18:27] but it's not the only way to visualize it. [18:29] Here's a different way to see the same concept. [18:32] Instead of looking at the graph of a function, [18:34] let's think of the same function but as a transformation. [18:37] That is, you're going to let each of these points on the real number [18:40] line move over to their corresponding outputs on this other number line. [18:45] What you'll notice is that evenly spaced dots from the input space can get warped in [18:49] the output space, meaning the rate of change of the function in general is not constant. [18:55] This spacing between our dots can change from one part of the image to the next. [18:59] But we know that as you zoom in more and more to a particular output, [19:03] the rate of change approaches a constant. [19:06] The dots look more and more evenly spaced. [19:09] Specifically, if you take a tiny patch of dots around a particular input and you [19:13] copy them over to the output space around the corresponding output, [19:17] you can approximately line up all the dots just by scaling everything by a certain [19:22] constant factor. [19:23] This is the same analytical fact as what the slope of a graph is telling you, [19:28] it's just in a different visual context. [19:30] But this context carries over much more easily to thinking about [19:34] complex valued functions as transformations in the complex plane. [19:38] There we're going to think of the neighborhood around a given input [19:42] as a tiny little grid of points, like we were before, [19:44] and we let each point on that grid move over to its corresponding output. [19:49] In this case, what it means for the rate of change to [19:52] approach a constant is basically the exact same equation. [19:56] The visual to have in your head is that if you take that tiny patch of squares [20:00] around the input and copy it over to the corresponding output, [20:04] you can approximately match this up with the output grid lines by multiplying [20:08] by a certain constant, which remember, in the setting of complex numbers, [20:12] means rotating and scaling it in some way, depending on the value of that [20:16] complex constant. [20:17] Since rotation and scaling preserve shape, it means that all the tiny squares from [20:21] the input space remain at least approximately square under this transformation. [20:27] So, stepping back, here's the key point, the reason for talking about any of this at all. [20:31] Even though conformal maps like the one that Escher was using for his print [20:35] gallery are incredibly constrained and highly unusual among the general ways [20:39] that you could continuously squish about two-dimensional space, nevertheless, [20:43] as if by magic, simply by speaking a language of complex numbers, [20:47] you can somehow create entire families of these conformal maps without even [20:51] really trying. [20:52] All you do is mix and match standard functions of complex numbers. [20:56] The one constraint is that these functions have to have derivatives, [20:59] but this will be true for most of the functions you think to write down. [21:03] For our story, decoding what's happening with the print gallery, [21:06] this means that we have an entirely new way to reframe the key question. [21:10] Can you construct some deliberately tailored complex function so that the act of [21:15] zooming in around the inputs looks like walking around a loop among the outputs? [21:21] Now, at this point, with only the bare minimum crash course of complex [21:25] analysis under our belts, it's hard to know where to start without [21:28] first building up a larger palette of functions to work with and [21:31] gaining some familiarity with how they actually behave for complex numbers. [21:35] In this case, there are really only two functions that you need to understand, [21:40] e to the z and the natural log. [21:42] I want to settle in and spend some meaningful time understanding both of these, [21:46] and I think you'll agree that it's time well spent. [21:48] Everybody deserves, in my opinion, at least one time in their [21:51] life to experience the joy of understanding a complex logarithm. [21:55] First though, a necessary prerequisite is to understand the complex exponential. [22:00] Regular viewers will be familiar with what it looks like to raise [22:03] e to the power of a complex number, but a review just never hurts. [22:07] We can start scaffolding the transformation just by focusing on the more familiar [22:12] examples of real number inputs and the real number outputs they correspond to. [22:16] For example, e to the 0 is 1, so this point at 0 maps over to this point at 1. [22:22] And then every time you let that input increase by 1, [22:25] the output grows by a factor of e, meaning it runs away from us actually quite quickly. [22:31] And then on the flip side, as you decrease that input, [22:34] letting it get into the negative numbers, every step to the left corresponds to [22:38] shrinking the output, again by a factor of e. [22:40] In particular, you'll notice in this case that output is always a positive number. [22:44] This of course gets much more interesting when we let [22:47] the inputs and the outputs both be complex numbers. [22:50] And here, everything you need to know comes down to what [22:52] happens as you let the imaginary part of that input increase. [22:56] And what happens there is that the corresponding output walks around a circle. [23:02] If you're wondering why imaginary inputs to an exponential walk you around a [23:06] circle like this, we have discussed it many, many other times on this channel. [23:10] See some of the links on screen and in the description. [23:13] A key point that I'll reiterate here is that what makes the function [23:17] e to the z very nice, as opposed to exponentials with other bases, [23:21] is that as your input walks up at a rate of 1 unit per second, [23:25] the output walks around its circle at a rate of exactly 1 radian per second. [23:30] So in particular, increasing the imaginary part by [23:33] exactly 2 pi causes one full rotation in the output. [23:37] Phrased another way, these vertical line segments that I've been drawing with heights of [23:42] exactly 2 pi each get mapped neatly onto one complete circle when you apply the function. [23:48] You'll notice how I've drawn these particular vertical line segments to be spaced out [23:52] evenly in the real direction, where the real part from 1 to the next increases by 1. [23:57] The corresponding circles on the right each differ by a constant scaling factor, [24:01] specifically the scaling factor e. [24:04] Earlier for the simpler function z squared, I showed it as a transformation, [24:08] moving all of the inputs to the outputs. [24:11] And in this case, for e to the z, if you're curious how that same idea looks, [24:14] it's easiest to take a subset of the grid, like this one here from the input space, [24:19] and here's what it looks like to move each square over to the corresponding output. [24:24] As we actually use this function for our print gallery goals, [24:27] it'll be very helpful to anchor your mind by thinking of these vertical lines and the [24:31] circles they turn into. [24:33] In fact, there's a very playful way that I like to think about how these vertical lines [24:37] turn into concentric circles and how they can carry the full input space along with them. [24:41] What I like to imagine is sort of rolling up that entire z-plane into a tube, [24:46] such that all of those vertical lines end up as circles. [24:50] Specifically, each circle would have a circumference of 2 pi. [24:54] Next, imagine taking this tube, lining it up above the origin of the output space, [24:58] and then kind of squishing it down onto that output space, [25:02] turning all the circles from that tube into these concentric rings of exponentially [25:06] growing size. [25:08] That's just what I like, but however you choose to think about it, [25:11] what I want to be etched into your brain is the idea of vertical lines turning [25:15] into circles. [25:16] Now, the other very important point to emphasize here is [25:19] that multiple different inputs can land on the same output. [25:23] For example, e to the zero is one, but e to the 2 pi i is also one. [25:29] So is e to the negative 2 pi i and e to the 4 pi i and so on. [25:34] In fact, the infinite sequence along any given vertical line spaced out by 2 pi will [25:39] all get collapsed together as that vertical line gets kind of rolled up into a circle. [25:45] We say that the exponential map is many to one, [25:47] although it might not be obvious how this repetition in the vertical [25:51] direction is going to be key to our final recreation of the print gallery effect. [25:56] Okay, so exponentials give us the first ingredient, [25:59] characterized by turning lines into circles, and the second ingredient [26:03] we need is the inverse of such an exponential, known as the natural log, [26:07] where basically the idea is that it unravels those circles back into lines. [26:11] Now, this will be especially fun to visualize and especially relevant to [26:15] our story if we imagine painting this complex plane on the right with a Droste image, [26:20] say the example we were working with earlier with the pi creature looking [26:24] at a picture of a house where that same pi creature lives. [26:28] In other words, it is finally time for you and me to answer that [26:31] question of what it means to take the natural log of a picture. [26:36] Okay, so think about this for a second. [26:38] You already know that a vertical line segment like this one on the left with [26:42] a height of 2 pi gets turned into a circle when you apply the map e to the z. [26:47] So the natural log is going to take a circle of points on this [26:51] image and then straighten them out into one of those lines. [26:55] Similarly, if you looked at a circle which was exactly e times smaller, [26:59] that would also get straightened out into a line with the same height positioned one [27:04] unit to the left. [27:05] And then similarly, every circle in between these two is going to get unwrapped into [27:10] one of these vertical lines between those last two, and more generally, [27:14] smaller and smaller rings from the picture will all get unwrapped into these vertical [27:18] line segments, each one with a height of 2 pi, [27:21] farther and farther to the left in the image. [27:24] The result we get is a bit trippy, but it's pretty cool when you think about it, [27:27] and there's a number of important things that I want you to notice. [27:30] You've probably noticed that it repeats as you move to the left, [27:33] and I'll invite you to ponder why that might be the case in the back of your mind [27:37] for a minute, but before that repetition, I want to talk about a different direction [27:41] in which it repeats. [27:42] The way I've drawn it so far, the imaginary part for the values on the left [27:46] are ranging from 0 up to 2 pi, but that's actually kind of an arbitrary choice. [27:51] Remember, if you keep letting that value z on the left walk up by another 2 pi units, [27:56] the corresponding value e to the z on the right would just keep walking around that [28:01] same circle again, so I hope you'll agree it feels at least enticing to let our [28:05] image repeat in this vertical direction along every one of those vertical lines. [28:12] And it goes the other way too, as you let the imaginary part on the left get smaller [28:17] going down, the corresponding value on that right just keeps walking around that [28:21] same circle, so the pattern that you see should perhaps repeat in that way too. [28:26] To be more explicit, the rule that I'm using to draw this image on the left [28:30] is that for every point z in that plane on the left, [28:33] you look at the corresponding value e to the z on the right, [28:37] and then you assign it a matching color. [28:40] So for example, this warped pi creature and this one and this one all really correspond [28:45] to the same part of the image on the right, the big pi creature in the lower left. [28:51] Another way to think about this is that because the function e to the z is many to one, [28:56] the feeling we get is that the natural logarithm, its inverse, [28:59] wants to be a multi-valued function, something where one input maps to multiple [29:04] different outputs. [29:06] Now in practice, many times you don't want a function to have multiple outputs, [29:10] sometimes that even defies the definition of a function in your context, [29:14] so people will often just choose a band of this plane on the left to be the outputs [29:18] of the natural log. [29:20] In complex analysis, this is called choosing a branch cut for the function. [29:24] For our purposes though, where we want to recreate and understand Escher's piece, [29:28] it's actually nice as to think of the log as a multi-valued function, [29:32] where each point on the right corresponds to a repeating sequence of points on the left, [29:37] spaced out two pi vertically, going infinitely in both directions. [29:41] Now in our special case, you also see this repeating pattern as you move to the left, [29:46] but that is something different entirely. [29:48] You would not see this for most images. [29:51] It arises specifically because we're working with a self-similar Droste image, [29:55] one that looks identical as you zoom in by a certain factor. [29:59] This falls straight out of a core property of logarithms and exponentials. [30:04] Exponentials turn addition into multiplication, [30:08] and logarithms turn multiplication back into addition. [30:12] For example, imagine taking some small value w on this plane on the right, [30:17] and also considering 16 times that value, which is scaled up 16 times farther away from [30:22] the origin. [30:24] Now if we look at the corresponding value, log of w on the left, [30:28] that act of multiplying by 16 now looks like addition, [30:32] specifically shifting to the right by the natural log of 16, [30:36] which is just some real number. [30:39] In fact, this rectangle here in our bizarre warped log image that has a width of log [30:44] 16 and a height of 2 pi contains all the information about the image on the right. [30:50] It corresponds to this annulus of the Droste image, [30:54] and if you were to shift that rectangle exactly log of 16 units to the left, [30:58] you would get a scaled-down version of that annulus exactly 16 times smaller that [31:04] nestles in perfectly like a puzzle piece. [31:07] And if you repeat that infinitely many times, it gives you [31:10] this infinite nesting that characterizes the Droste zoom. [31:14] The way I've drawn things so far, we have this cutoff to the log image on the right side, [31:19] and at this point you know well that vertical lines on the left correspond to circles [31:23] on the right, so you can probably guess that this corresponds to the fact that I gave [31:27] a maximum radius to that Droste image, but of course you don't need to do that. [31:31] In principle, it can extend out infinitely far in all directions, [31:35] following the same self-similar pattern as you scale up, [31:38] and the result for the log image on the left would be to extend as far rightward as [31:43] you want, again with a repeated tiling pattern. [31:47] So to conclude, the logarithm image on the left is periodic vertically, [31:51] basically because rotation on the right is periodic. [31:54] This would happen for any image. [31:56] And then in this special case of a Droste image, it's also periodic horizontally, [32:01] because the Droste image repeats as you zoom in. [32:04] This doubly periodic property is what we'll ultimately [32:07] take advantage of for the final result. [32:10] And we now have all the foundation we need. [32:13] I can now finally describe for you the function that turns [32:16] the Droste zoom into this Escher-style self-contained loop. [32:20] Before just jumping right into it, we have been kind of covering a lot, [32:23] so it might be worth giving some space to let this digest. [32:26] And I was meaning to take 30 quick seconds at some point in this video [32:29] to talk about 3b1b talent, so now might be as good a time as any. [32:32] This is the virtual career fair that I'm experimenting with this year, [32:36] and the basic idea is that you, a person who spends their free time learning about [32:40] things like complex logarithms, are probably interested in working with like-minded, [32:44] curious, and technical teams. [32:46] So if you're seeking or open to a new job, check out the organizations at 3b1b.co. [32:52] talent. [32:52] When you explore that page, you'll find interviews between me and the relevant teams, [32:56] technical puzzles and challenges that they've chosen to feature for you, [32:59] and various other things aimed at giving you a feel for the technical team culture. [33:04] And I just kind of like the idea of exposing this audience to [33:07] aligned career opportunities, so whenever you are looking for a job, [33:10] whether that's now or later, be sure to check it out. [33:14] Okay, so back to our main goal. [33:16] How is it that we can use everything that we've built up about complex functions [33:20] and transformations that give conformal maps and everything like that to [33:24] construct some kind of function that recreates Escher's print gallery effect? [33:28] Maybe it's easiest if I just throw down the whole outline of the function, [33:31] and then we can go through each step in more detail. [33:34] First, take a logarithm, giving this bizarre doubly periodic tiling pattern, [33:38] and then you rotate and scale that tiling pattern in just the right way, [33:43] and then from there you take an exponential, which unworps it, [33:47] but this time with a certain twist. [33:50] This might seem a little bizarre, but there's actually a really [33:52] nice way to motivate and to understand what's really going on here. [33:56] Take a look back at that original Droste image, [33:59] and remember how we want to take this big pie creature and [34:02] somehow identify it with the smaller self-similar copy, 16 times zoomed in. [34:07] I want you to think about a line connecting both of those. [34:11] One way to frame the goal that we have is that we want the final [34:14] function to transform such a line into a closed loop in the final space. [34:19] The endpoints of the line on the top represent the big and the small pie creatures, [34:24] so whatever function identifies those creatures should, at the very least, [34:28] close up this line. [34:29] Now think about what this line looks like in the logarithm of the image. [34:33] The big pie creature corresponds to all these [34:36] multiple copies here next to the imaginary line. [34:39] As we talked about, when you scale down the image, [34:42] it corresponds to shifting to the left in the log, [34:45] so these copies in the log image represent that small pie creature. [34:50] And actually, instead of using this horizontal line, [34:52] we're going to want to take advantage of the fact that this log image is periodic [34:56] in two separate directions. [34:58] So instead, what we'll work with is a diagonal line that connects this [35:03] copy of the big character to this lower left copy of the small one. [35:07] That might seem unmotivated at the moment, and it is, [35:10] but the best way to explain why is just to show you how this plays out, [35:13] and afterwards, if you want, we can contrast with what would have happened if [35:16] you tried using the horizontal line. [35:19] Now this new downward component in the log image corresponds to [35:22] adding some clockwise rotation to the path in the original image. [35:26] Remember, our goal is to turn this into a loop in the final image, [35:30] but you and I just spent like 10 minutes talking extensively about [35:34] a function that turns line segments into circles, namely e to the z. [35:39] What you need to do is get that line segment to end up perfectly vertical [35:43] with a height of 2 pi, and doing this basically comes down to rotating [35:47] and scaling it in just the right way to give it that length and direction. [35:52] Now if you remember, as we were warming up with complex numbers, [35:56] we talked about how multiplication by a constant gives you some combination of [36:00] rotation and scaling, and in this case, one artistic feature we might like is [36:04] for our big pi creature on the lower left to stay fixed in that position, [36:08] and that would mean that this point in our log image needs to stay fixed in place, [36:12] so instead of pivoting around the origin, we really want everything to pivot [36:16] about that point. [36:18] Let's say we label that point something like z naught, [36:21] then here's how the updated formula would look for that rotation and scaling, [36:25] but really most of the content comes down to choosing this constant c that [36:29] you're going to multiply by, and if you like exercises, [36:32] you might enjoy actually taking a moment to work out what specific value [36:35] that constant should take on. [36:38] But right here, since we're being very visual and I want to have a little fun, [36:42] let me show you that constant in its own little complex plane, [36:45] and then also show what happens if I kind of grab it and move it around a little bit. [36:50] Different choices give you different scaling and rotation, [36:53] which after exponentiating gives you all these completely bizarre kaleidoscopic images. [36:58] One way you could think about the whole operation is as a game where [37:01] you're trying to find just the right value that corresponds everything [37:05] to line up as you need them to in that image of the lower right. [37:09] When it is set to that appropriate value and we get this recreated Escher effect, [37:12] in that final image on the lower right, I've been showing this hole in the middle, [37:16] analogous to the hole that Escher had in his original piece. [37:20] But that's actually entirely artificial. [37:22] The output image of the function naturally fills [37:25] that in with its own repeating spiral inward. [37:28] After all, the rotated tiling pattern on the left extends [37:31] infinitely through the whole plane, so when you take its exponential, [37:35] it also fills in everything, except for the point at zero. [37:39] And that's it! [37:40] That is the basic operation. [37:42] Translate to this bizarre looking log space, rotate and scale to realign things, [37:47] and then translate back with an exponential. [37:51] At this point, having recreated our own variation on Escher, [37:54] it might be nice to step through what that same process looks like for Escher's specific [37:59] example, that seaside Maltese town containing a print gallery with a person looking at [38:04] a picture of the town. [38:06] As before, step number one is to place this scene on its own little complex plane, [38:10] where the infinite limiting point about which everything scales is positioned at zero. [38:16] Step two, take a logarithm of this, which in this case gives us a similarly bizarre [38:20] transformation of the whole scene, but there is a little difference this time. [38:24] Because Escher was working with a much deeper zoom, with a scale factor of 256, [38:29] the repeating tiles in this new example actually span a wider part of the complex plane. [38:36] Step three, again, is to rotate and scale this, [38:38] which depends on multiplying by the appropriate choice of a complex constant. [38:43] The constraint is to ensure that this rotated image still repeats every 2 pi [38:48] units vertically, but along a part of the image that was previously diagonal. [38:53] And then step four, plug this all through e to the z, [38:56] and what you get is something very similar to Escher's final picture, [39:00] an image where walking around a loop corresponds to zooming in by a factor of 256. [39:07] And again, when we frame it this way with complex functions, [39:10] there is no hole in the middle. [39:12] That final result is itself a Droste image, albeit this time with a twist, [39:16] where there's a kind of self-similarity spiraling down infinitely far as much as you [39:21] want to zoom in. [39:24] There are a couple things worth noticing about this whole process. [39:27] First off, if you write this idea down as a formula, where you take a log, [39:31] multiply it by a constant, and then exponentiate, [39:33] that can actually be simplified to simply look like raising your input to the [39:37] power of some complex constant. [39:39] And if you reintroduce that offset factor, it just introduces another constant. [39:43] On the one hand, it's very pleasing that this entire complicated [39:46] process can be boiled down to so few symbols on the page, [39:49] but I do think this risks kind of obscuring what's actually going on. [39:53] And then, I had mentioned things would not work [39:55] if you only tried using those horizontal lines. [39:58] If you're curious, here's what it looks like if you try that, [40:00] which would mean rotating everything by 90 degrees and scaling it the appropriate amount. [40:05] You do get something kind of interesting, but it's just not what we're going for. [40:09] And if you think about it, what's basically going on is [40:11] that you are swapping the roles of rotation and of scaling. [40:16] Stepping back from all this, this second perspective where the piece is [40:20] all about rotating in a log space feels completely different from Escher's [40:24] more intuitive approach using his distorted grid and the mesh warp. [40:28] But there is a through line connecting both perspectives. [40:31] For one thing, you can now understand how exactly we've [40:34] been recreating and modifying the grid that Escher had. [40:37] You basically take that same function that we've built up, [40:40] but instead of applying it to an image, you apply it to an ordinary square grid. [40:45] Well, actually not quite an ordinary square grid. [40:48] It's nicest to work with one that gets more dense as [40:50] you zoom in so that it looks the same at all scales. [40:54] When you do this, the logarithm gives you this very beautiful curved tiling pattern. [40:58] And then from there, you do the same trick of rotating things in just [41:02] the right way and then taking an exponential with the result of [41:05] something quite close to what Escher spent many arduous hours constructing. [41:09] And remember, the entire reason that we're using the language of [41:12] complex numbers is the motivation for me having you jump through [41:16] those hoops is that this conformal property falls out as a byproduct. [41:20] Tiny squares from the original grid remain, at least approximately, [41:23] square in the final result. [41:26] Escher said that making this piece gave him some almighty headaches, [41:29] and though maybe you and I had to endure a few headaches ourselves for very [41:33] different reasons, the payoff is that this property is one that we get with no [41:37] added effort. [41:39] Now to be clear, you certainly don't need to understand complex derivatives or [41:42] logarithms to enjoy Escher's work, and I wouldn't want to imply that you do. [41:46] However, when you understand that more mathematical side, [41:49] it gives you the capacity for a very different kind of appreciation for what [41:53] Escher was really doing. [41:55] And this is what I find fascinating about all of this, [41:57] the real connection I want to give between the two storylines. [42:01] If you look at Escher's career, throughout it he was drawn to certain concepts, [42:05] things like representing infinity in a finite space. [42:08] And at the same time, he seemed to be guided by a certain aesthetic, [42:11] often some implicit rigid rule like the idea of little squares remaining little squares [42:16] for this mesh. [42:17] The end result when concept and aesthetic are combined like this is [42:21] that a given piece from Escher often feels like a solution to a puzzle, [42:25] but one where it's not even obvious that a solution should exist. [42:29] Now what I find so thought-provoking is that these visual puzzles [42:32] that he landed on are not merely analogous to the act of doing math. [42:36] The specific structures that he was intuitively drawn to [42:40] often hide within them very real and very deep mathematics. [42:44] In our example, the deeper structure is not just that [42:46] the piece can be described with complex functions. [42:50] The ideas that we've touched on in this storyline are actually [42:53] a lot closer than you might expect to the research frontiers. [42:56] If you look back at our approach in the second half, [42:59] remember how it relied on using this doubly periodic pattern in the complex plane, [43:04] something that repeats in two separate directions. [43:07] There's actually a special name for functions of [43:10] complex numbers that are doubly periodic like this. [43:12] They're known as elliptic functions. [43:14] It would be way too much to explain right here exactly why these functions are so useful, [43:19] but one thing I want to highlight is that those two mathematicians I referenced at [43:23] the start, the ones who provided the analysis of this piece, De Smit and Lenstra, [43:27] are both number theorists, and elliptic functions play a very prominent role in [43:31] modern number theory, providing a kind of bridge to other parts of mathematics. [43:36] This may at least partially explain how it is that they could look at [43:39] this piece and think to construct that function that we laid out here. [43:44] When I look at Escher's work, whether it's the print gallery or many other favorites, [43:48] the reason I love these pieces so much is that they awaken within me [43:52] a very specific feeling that's hard to find elsewhere. [43:55] It's a feeling of things perfectly fitting into place. [43:58] But that's not exactly it. [43:59] It's something more than just the pleasure of seeing a puzzle solved. [44:02] It's an appreciation for the creative genius required [44:05] to even dream up the puzzle in the first place. [44:08] The only other place where I get that feeling is in doing math. [44:11] So the fact that an artist and a mathematician can be drawn to the same structures, [44:16] but for completely different reasons, suggests to me that there's something [44:20] universal in what exactly it is that both of them seem to be drawn to.