[Intro Music]

When you first learned about the pythagorean theorem

that the sum of the squares of the two shorter sides on a right triangle always equals the square of its hypotenuse

I'm guessing that you came to be pretty familiar with a few examples like the 3-4-5 triangle

Or the 5-12-13 triangle, and I think it's easy to take for granted that these even exist

Examples were the sum of two perfect squares happens to be a perfect square

But keep in mind for comparison if you were to change that exponent to any whole number

Bigger than 2 you go from having many integer solutions to no solutions whatsoever. This is Fermat's famous last theorem

Now there's a special name for any triplet of whole numbers ABC where a squared plus B. Squared equals C

Squared it's called a pythagorean triple

And what we're going to do here is find every single possible example and moreover

We'll do so in a way where you can visualize how all of these triples fit together

this is an old question pretty much as old as they come in math there are some babylonian clay tablets from

1800 BC more than a millennium before pythagoras himself that just lists these triples and

By the way while we're talking about the pythagorean theorem

It would be a shame not to share my favorite proof for anyone who hasn't already seen this

you start off by drawing a square on each side of the triangle and

If you take that C square and add four copies of the original triangle around it

You can get a big square whose side lengths are a plus b

But you can also arrange the a square in the b square together with four copies of the original triangle

To get a big square whose side lengths are a plus b

What this means is that the negative space in each of these diagrams the area of that big square?

Minus 4 times the area of the triangle is from one perspective

Clearly a squared plus b squared but from another perspective it's C squared

Anyway back to the question of finding whole number solutions?

Start by reframing the question slightly

Among all of the points on the plane with integer coordinates

That is all of these lattice points where gridlines cross

Which ones are a whole number distance away from the origin?

for example the point 3 4 is a distance 5 away from the origin and

The point 12 5 is a distance 13 away from the origin the question of finding pythagorean triples is

completely equivalent to finding lattice points which are a whole number distance away from the origin of

Course for most points like 2 1 the distance from the origin is not a whole number

but it is at least the square root of a whole number in this case 2 squared plus 1 squared is 5

so that distance that hypotenuse there is the square root of 5

Now taking what might seem like a strange step but one

Which will justify itself in just a moment think of this as the complex plane

so that every one of these points like 2-1 here is actually an individual complex number in this case 2 plus š²

What this gives is a surprisingly simple way to modify it to get a new point whose distance away from the origin is

Guaranteed to be a whole number just square it

algebraically when you square a complex number

Expanding out this product and matching up all of the like terms because everything here just involves multiplying and adding integers

each component of the result is guaranteed to be an integer in this case you get 3 plus 4š²

but you can also think of complex multiplication more geometrically you take this line drawn from the origin to the number and

consider the angle it makes with the horizontal axis as well as its length which in this case is the square root of 5

the effect of multiplying

Anything by this complex number is to rotate it by that angle and to stretch out by a factor equal to that length

so when you multiply the number by itself the effect is to double that Angle and

Importantly to square its length

Since the length started off as the square root of some whole number

This resulting length is guaranteed to be a whole number in this case five

here let's try it with another example start off with some complex number that has integer coordinates like 3 plus 2i

in this case the distance between this number in the origin is the square root of

3 squared plus 2 squared which is the square root of 13

now multiply this complex number by itself

The real part comes out to 3 squared plus 2š² squared which is 9 minus 4 and?

The Imaginary Part is 3 times 2 Plus 2 times 3

so the result is 5 plus 12š² and

the magnitude of this new number is 13 the square of the magnitude of their starting number 3 plus 2i

So simply squaring our randomly chosen lattice point gives us the 5 12 13

triangle

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 š² and just by taking it square

You generate a pythagorean triple in this case 4 plus

š² squared is 15 plus 8š² 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 0?

then the triple at the end is going to include a 0 for example 2 plus 2š² squared gives 8š² 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 vš² 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 watch the zeta-function video is

to watch every point of z on the plane move over to the point z squared

So for example the point 3 plus 2š² is going to move over to 5 plus 12š²

The point š² 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 [gridlines] 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 way 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 six plus 8š² 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 vš² squared is 6 plus 8š²

Likewise, you will never hit 9 plus 12š²

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

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 missed the point 4 plus 3i

there are no integers U and V so that U plus vš² squared is 4 plus 3š² in

Fact you'll never hit any points whose imaginary component is odd

However, we do hit 8 plus 6š² that's 3 plus š² squared

so even though we miss 4 plus 3š² it's just 1 half times the point that we do hit and

by the way, you'll never have to scale down by anything smaller than 1/2 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 will 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 one

This gives us some point on the unit [circle] x squared plus y squared equals one 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 and

Keep in mind by the way, I'm drawing only finitely many of these dots and lines, but if I drew all

Infinitely many lines corresponding [to] every possible squared lattice point. It would actually fill every single pixel of the screen

Now if our method was incomplete if we were missing a pythagorean triple out there somewhere

it would mean that there's some rational point on this circle that we never hit once we project everything on to the circle and

Let me show you why that cannot happen?

Take any one of those rational points and draw a line between it and the point at negative one

When you compute the rise over run slope of this line?

The rise between the two points is rational and the run is also rational

So the slope itself is just going to be some rational number

So if we can show [that] our method of squaring complex numbers it counts for every possible rational slope here

It's going to guarantee that we hit every possible rational point of the unit circle, right?

Well, let's think through our method we start off with some point U plus vš² that has integer coordinates and this number

Makes some angle off of the horizontal which I'm going to call theta

squaring this number the resulting angle off the horizontal is 2 times theta and

Of course when you project that onto the unit circle

It's along the same radial line

So the corresponding rational point of the unit circle also has that same Angle 2 times theta and here

I'll bring in a nice little bit of circle Geometry

Which is that anytime you have an angle between two points on the circumference of a circle?

And it's center

That turns out to [be] exactly [2] times the angle made by those same points and any other point on the circle circumference

Provided that that other point isn't between the original two points

What this means for [our] situation is that the line between negative 1 and the rational point on the circle?

must make an Angle Theta with the horizontal

in

other words that line has the same slope as the line between the origin and our initial complex number U plus, Vi

but look at the rise over run slope of the line defined by a choice of integers U and V the

Slope is V divided by U and of course we can choose V and u to be whatever integers. We want and

Therefore we do indeed account for every possible rational slope

So there you go the radial lines from our method determined by all possible choices of U and V

Must pass through every rational point on this circle, and that means our method must hit every possible pythagorean triple

if

You haven't already watched the video about [pie] hiding and prime regularities the topics there are

highly related to the ones here it also involves some pretty surprising things that happen when you

Reframe a problem about lattice points in terms of complex numbers, so I'd say that that video pairs particularly well with this one

Both this video and that were supported in part by remix who's looking to recruit software engineers?

Particularly those with some background in math which could potentially mean from among some of you

Remix makes a planning platform for public transit

this means offering a product to cities that helps them find the most efficient and cost-effective ways to serve the communities and

demographics that they want

What they provide is already leaps and bounds ahead of how many cities go about this problem?

But they're always pushing to make things better which opens the doors to some seriously interesting optimization problems

For those of you in a position to be applying to a place like this you'd get to work with an incredibly capable team

Tackling problems that lie nicely in that intersection of stuff that matters and stuff that's interesting

There are links on the screen and in the description if you'd like to learn more

you