There's something kind of magical about actually watching this work. It almost feels like cheating. You can start with any randomly chosen lattice point, like 4 plus i, and just by taking its square, you generate a pythagorean triple. In this case, 4 plus i squared is 15 plus 8i, which has a distance 17 away from the origin. If you play around with this, which I encourage you to do, you'll find that some of the results are kind of boring. If both the coordinates of your starting point are the same, or if one of them is zero, then the triple at the end is going to include a zero. For example, 2 plus 2i squared gives 8i, and even though technically this is indeed a lattice point a whole number distance away from the origin, the triple that it corresponds to is 0 squared plus 8 squared equals 8 squared, which isn't exactly something to write home about. But for the most part, this method of squaring complex numbers is a surprisingly simple way to generate non-trivial pythagorean triples. And you can even generalize it to get a nice formula. If you write the coordinates of your initial point as u and v, then when you work out u plus vi squared, the real part is u squared minus v squared, and the imaginary part is 2 times uv. The resulting distance from the origin is going to be u squared plus v squared. It's kind of fun to work out this expression algebraically and see that it does indeed check out, and it's also fun to plug in some random integers for u and v and get out a pythagorean triple. Essentially, we've created a machine where you give it any pair of integers, and it gives you back some pythagorean triple. A really nice way to visualize this, which will be familiar to any of you who watched the zeta function video, is to watch every point of z on the plane move over to the point z squared. For example, the point 3 plus 2i is going to move over to 5 plus 12i. The point i is going to rotate 90 degrees to its square, negative 1. The point negative 1 is going to move over to 1, and so on. Now when you do this to every single point on the plane, including the grid lines, which I'll make more colorful so they're easier to follow, here's what it looks like. So the grid lines all get turned into these parabolic arcs, and every point where these arcs intersect is a place where a lattice point landed, so it corresponds to some pythagorean triple. That is, if you draw a triangle whose hypotenuse is the line between any one of these points and the origin, and whose legs are parallel to the axes, all three side lengths of that triangle will be whole numbers. What I love about this is that usually when you view pythagorean triples just on their own, they seem completely random and unconnected, and you'd be tempted to say there's no pattern. But here we have a lot of them sitting together really organized, just sitting on the intersections of these nicely spaced curves. Now you might ask if this accounts for every possible pythagorean triple. Sadly, it does not. For example, you will never get the point 6 plus 8i using this method, even though 6-8-10 is a perfectly valid pythagorean triple. There are simply no integers u and v where u plus vi squared is 6 plus 8i. Likewise, you will never hit 9 plus 12i. But these don't really feel like anything new, do they? Since you can get each one of them by scaling up the familiar triple 3-4-5, which is accounted for in our method. In fact, for reasons that I'll explain shortly, every possible pythagorean triple that we miss is just some multiple of a different triple that we hit. To give another example, we miss the point 4 plus 3i. There are no integers u and v, so that u plus vi squared is 4 plus 3i. In fact, you'll never hit any points whose imaginary component is odd. However, we do hit 8 plus 6i, that's 3 plus i squared. So even though we miss 4 plus 3i, it's just one half times the point we do hit. And by the way, you'll never have to scale down by anything smaller than one half. A nice way to think about these multiples that we miss is to take each point that we get using this squaring method and draw a line from the origin through that point out to infinity. Marking all of the lattice points that this line hits will account for any multiples of these points that we might have missed. Doing this for all possible points, you'll account for every possible Pythagorean triple, Every right triangle that you ever have seen or ever will see that has whole number side lengths is accounted for somewhere in this diagram. To see why, we'll now shift to a different view of the pythagorean triple problem, one that involves finding points on a unit circle that have rational coordinates. If you take the expression a squared plus b squared equals c squared and divide out by that c squared, what you get is a over c squared plus b over c squared equals 1. This gives us some point on the unit circle x squared plus y squared equals 1 whose coordinates are each rational numbers. This is what we call a rational point of the unit circle. And going the other way around, if you find some rational point on the unit circle, when you multiply out by a common denominator for each of those coordinates, what you'll land on is a point that has integer coordinates and whose distance from the origin is also an integer. With that in mind, consider our diagram, where we squared every possible lattice point and then drew these radial lines through each one to account for any multiples that we might have missed. If you project all of these points onto the unit circle, each one moving along its corresponding radial line, what you'll end up with is a whole bunch of rational points on that circle.