 This video is part of an online undergraduate course about the theory of numbers and will be about quadratic reciprocity. So I'll start with an example to illustrate it. So last lecture we proved, or rather I left this as an exercise to prove, that five is a quadratic residue of p if and only if p is congruent to one or four modulo five. We're assuming p is not equal to two or five, of course, because these always go wrong. And this in turn is equivalent to p being a quadratic residue of five, because one and four are exactly the squares mod five. And this is an example of reciprocity. So reciprocity roughly means you can switch the numerator and the denominator of the Legendre symbol. So five is a quadratic residue of a prime, odd prime, if and only if the odd prime is a quadratic residue of five. Which is actually a rather strange fact. There seems to be no obvious reason why these two things should have anything whatsoever to do with each other. So let's see if that works for other primes. So the Legendre symbol for three in p is equal to plus one if and only if p is congruent to one or eleven modulo twelve. On the other hand, p is a quadratic residue of three if and only if p is congruent to one or seven mod twelve. And so these are definitely not equivalent conditions. However, we can improve this by looking instead at where the minus three is a quadratic residue of p. And this is equal to minus one p times three p by multiplicativity. And this is one if p is one or if p is one mod four. So this is equal to one if and only if p is congruent to one modulo three. So we see that five p is always equal to p five. But the analog for three is that minus three p is equal to p three. And Euler and Gauss did a lot of calculations of calculating these quadratic residue symbols. And what they found was that this identity holds if you replace five by any prime of the form one mod four. And something like this holds if you replace three by any prime of the form three mod four. So we get Euler and Gauss's law of quadratic reciprocity which says the following. It says pq is equal to qp except when it's not equal to qp. More precisely, this happens if p or q is congruent to one modulo four and pq is equal to minus qp if p and q is congruent to three modulo four. So this is often written in various slightly different forms. For example, we might write it as pq times qp is equal to minus one to the p minus one over two times q minus one over two. Because this expression here is odd exactly when p and q are three modulo four. So now I want to prove the law of quadratic reciprocity. And there's a big problem with the proof in that there's rather too much choice. There are something more than 200 different published proofs of this. And I know this because this book here, it's a really nice book about reciprocity laws. You see, here's the original quadratic reciprocity law that we just wrote down. And in one of the appendix, appendix B, he has a list of proofs classified according to who did them and what ideas the proof used. So the very first proof is due to Legendre in 1788 except Legendre's proof was incomplete because he sort of assumed Dirichlet's theorem which hadn't actually been proved at the time. So the first actual proof was found by Gauss. And the second, third, fourth, fifth and sixth proof were also found by Gauss. He found eight proofs altogether because if you look further down the page there are another couple of proofs by him down here. And people kind of inspired by Gauss finding a large number of proofs. And we have an entire page of proofs here and it goes on and on. So the next page is more proofs and there are more proofs here and more proofs here and more proofs here and ending with proof number 196 in the year 2000. So you can see that's pretty much one proof a year and this is about 20 years ago. So I guess there are maybe 220 published proofs by now. So we've got a serious problem about which of these proofs do we select. And all of the proofs have one thing in common that at some points you need to think of a rather clever non-obvious idea. There seems to be no completely straightforward proof of this law. And the proof which seems to involve the simplest non-obvious ideas, the proof that uses Gauss sums. So what is a Gauss sum and how did Gauss think of them? The Gauss sum traditionally denoted by a tau is given by we sum over all x mod p. So we're taking x equals 0, 1, up to p minus 1. And you sum the Legendre symbol where the x is a square or not mod p and you multiply it by epsilon to the x. So what is epsilon? Well, epsilon is a p-th root of 1, more precisely epsilon is equal to e to the 2 pi i over p. And so in particular 1 plus epsilon plus epsilon squared and epsilon plus epsilon to the p minus 1 is equal to 0. And now we notice that epsilon to the x is actually well defined even though x is only defined mod p. Because if you add a multiple of p to x, this doesn't change epsilon to the x because epsilon to the p is equal to 1. So Gauss sums are well defined. And if you've come across Gauss sums for the first time, your first question is probably how on earth did Gauss think of such a funny looking expression? So I'm not actually quite sure but here's one way he might have thought of it. So Gauss constructed a 17 sided polygon by ruler and compass and he did this by looking at 17th roots of unity. And we also want the group of numbers modulo 17 that are non-zero optimum multiplication. So let's write down this group. So all its elements look like this. And what Gauss needed in constructing the 17 sided polygon was he needed, among other things, he wanted a quadratic irrational that is a polynomial in zeta. And the one he used was given as follows. What you do is this is a group under multiplication. It has a unique subgroup of index 2 consisting of all squares. So we take all things that are squares modulo 17, which are these numbers here. And then he just sums over this group of order 8 of the powers of zeta. So you might put alpha equals zeta to the 1 plus zeta to the 2 plus zeta to the 4 plus zeta to the 8 plus zeta to the 9 plus zeta to the 13 plus zeta to the 15 plus zeta to the 16. Well, there's a slightly neater way of writing alpha which is to use the Gauss sum. So the Gauss sum is going to be 1 plus 2 times zeta to 1 plus 2 times zeta squared and so on because you get two copies of each square because, for example, 4 is 2 squared but it's also minus 2 squared. So we see that in fact tau is equal to 1 plus 2 alpha. So it's actually the Gauss sum is the neatest way of writing a quadratic irrational in terms of zeta. And now Gauss wanted to show that it was a quadratic irrational and the formula for tau is very neat. It just says that tau squared is equal to 17. So that's what a Gauss sum is and we'll now show how to use Gauss sums in order to prove the law of quadratic reciprocity. So I'm going to try and fit the entire proof onto one page. So we need two lemmas. The first pink lemma says that tau squared is equal to minus 1 to the p minus 1 over 2 times p. And we just recall that tau is equal to sum over x of xp times epsilon to the x. And now tau squared is got by multiplying this sum by itself. And we can multiply this sum by itself by writing a double sum where we sum over all x and y of xp times epsilon to the x times yp times epsilon to the y. And now we can rearrange this a little bit. First of all, we can just sum over x and y none zero because if x or y is zero, these terms vanish. And then the Legendre symbol is multiplicative so this becomes xyp and we get epsilon to the x plus y. And now we want to simplify this Legendre symbol because x times yp is a bit difficult to think about. So what we do is we make the following change of variable. We change x to x times y. And we can do this because y is none zero so this map has an inverse and it's a sort of acceptable change of variable. And now this sum becomes sum over xy not equal to zero of xp times epsilon to the xy plus y. And it looks a bit at first sight as if I've made a mistake because shouldn't there be a y squared in here? That should really be xy squared. Well no because you notice that y squared p is equal to one so we can drop the factor of y squared from there. And now what we want to do is sum over y. So we're going to take this bit here and just sum it over y not equal to zero and ask what is that equal to? Well that's easy to work out because if we sum over all y of epsilon to the ay this is equal to not if a is not congruent to zero. And it's equal to p if a is congruent to zero. So this sum here we have to subtract one because we're summing over none zero y and we get minus one if x plus one is not congruent to zero. And p minus one if x plus one is congruent to zero. So we can work out the sum over y. And now we're just left with the sum over x. And first of all we've got a term p here coming from x equals minus one which gives us minus one pp. And then we have to sum over all these minus ones over all x. So we've got minus xp. Well we can simplify it. This sum here is just zero because there are just as many quadratic residues as none residues. So all these terms cancel out and we're just left with this. And now by Euler's identity minus one p is just equal to minus one to the power of p minus one over two. So we've proved this identity here. So this is the first identity. And now we need a second orange identity. And the pink identity we work out tau squared for the orange identity we will work out tau to the power of q. And we're going to work out tau to the power of q modulo p using the fact that x plus y to the q is congruent to x to the q plus y to the q mod q. So we take the sum for tau and to raise it to the power of q we just need to work out raise all the terms to the power of q. So this is going to be a sum over x of xp to the power of q times epsilon to the qx. And you notice we're doing this modulo q, but we also need to allow q times polynomials in epsilon. So it should really be modulo q times all polynomials in epsilon. So both sides are going to be polynomials in epsilon and all the coefficients have to be congruent modulo q. Well we can simplify this a bit. q is odd and this is plus or minus one so we can delete this because q is odd. So one or minus one to the power of any odd number is the same. And now we're going to make a change of variable. We're going to change x to x over q in order to make this exponent nicer. So this becomes sum over all x of xp times qp times epsilon to the x. So you might think this should be a q to the minus one, not a q, but of course q to the minus one p is equal to qp because the ratio is a square. And now the sum over x here if we ignore this Jacobi symbol is just the Gaussian sum again. So this just becomes qp times tau. So that's our second lemma. Now we prove the law of quadratic reciprocity. And we start with qp and now we're going to apply the orange lemma. And notice that this is just tau to the q minus one because we just take tau to the q is equal to that and we just divide both sides by tau. And we can write this as tau squared to the power of q minus one over two, obviously. And now we're going to apply the pink lemma in order to work this out. So this is now congruent to, well tau squared is given by this expression here. So we just fill that in. It's minus one to the p minus one over two times p all to the power of q minus one over two. And now this is congruent to minus one to the p minus one over two times q minus one over two times pq. And why is that? Well it's because Euler's lemma states that this p to the q minus one over two is congruent to pq. And now if you look at this we see we've got qp is equal to this sine times pq which is exactly the law of quadratic reciprocity. I should say this makes the proof look almost trivial because the formula for tau squared we already have if we've don't been doing cyclotomy and constructing 17 sided polygons. So really there's just one line there and one line there in order to prove the law. This is really misleading. It took people like Gauss and Euler and Legendre many years before they managed to find a proof. And the first proof Gauss found was actually a lot more complicated than this. I mean he probably should have in an ideal world he would have taken his results about cyclotomy from 17 sided polygons and immediately noticed this could be used to prove the law of quadratic reciprocity. But as I said it took several more years before he was able to do this. So another way of motivating Gauss sums is that they're actually very similar to gamma functions. So I'll just explain why. So you should think of a Gauss sum as a sort of gamma function. So let's just recall what a gamma function is. Euler's gamma function which is a sort of variation of the factorial for real numbers is just the integral from law to infinity of e to the minus t, t to the s minus 1 dt. And the Gauss sum is equal to sum over all x of epsilon to the x times the Legendre symbol. And what you notice about the Gauss sum and the gamma functions they have nothing whatsoever in common at first sight. They're completely different formulas. But now let's take a closer look. So here we've got a sum over all x in the field z modulo pz. And an integral is a sort of sum. And here we're integrating over the field r or at least the positive elements of r. Okay so there's a, we're forgetting about the negative numbers but never mind. So the sum over a field should be thought of as very closely analogous to the integral over, well half a field whatever. And then this epsilon to the x, well that's something to the power of x. And this is something to the power of t. Well that's fine. These obviously now correspond. And what about the Legendre symbol? That doesn't look very much like t to the power of s minus 1. Well actually it does because you notice that xyp is equal to xpyp. And tu to the s minus 1 is equal to t to the s minus 1 times u to the s minus 1. So they are indeed both multiplicative. And you can think of these as both characters of the multiplicative group of a field if you're into representation theory. So really these are very similar and the similarity extends to identities they satisfy. So we've proved tau squared is equal to minus 1p times p for example. What's the analog for the gamma function? Well it's the reflection formula for the gamma function which says gamma of s, gamma 1 minus s is equal to pi over sine pi s. And again at first sight these two formulas don't seem to have an awful lot in common. But if you look at the proofs, the proofs are almost identical. Well they're not almost identical but they have a fair amount in common. So you remember we proved this by taking the sum at sine of the x plus y times xyp. And saying this is equal to sum over xy of xp times epsilon to the xy plus y where we changed x to x times y. And one way of proving this formula is to write this product as a sort of double integral. In the same way we write this as a double sum and we get e to the minus t minus u, t to the s minus 1u to the minus s d t du. And now we make the change of variable t goes to t u. And if we then carry out the integration over u this becomes the integral over t of 1 over t plus 1 t to the s minus 1 dt. And you notice this change of variable looks very much like that change of variable. And this bit turns out to give you the right hand side of this identity. So you can think of Gauss sums as being a sort of gamma function over finite fields. Or I guess you could also think of a gamma function as being a Gauss sum over the reals if you prefer to do things backwards. Now I'll show how to use the law of quadratic reciprocity to work out the Legendre symbol. So let's try and work out a p for say 1001 divided by 99991. And I said we could do it using Euler's method. You can work out a to the p minus 1 over 2 modulo p. And that would be a pretty unpleasant calculation to do by hand on this example although it would be fairly fast on a computer. But if you're working by hand it's much easier because as everybody who does metero arithmetic knows 1001 is 7 times 11 times 13. So we can factor it like this. And now I can work out each of these three factors very quickly using quadratic reciprocity. So for example this one turns out to be we can turn it upside down but get a minus sign because 7 and this number are both 3 mod 4. And now I can reduce this mod 7 and this becomes minus 3 7. And if I'm feeling really lazy I can use quadratic reciprocity again and say this is now plus 7 3 because 3 and 7 are both 3 mod 4. And now I can reduce 7 mod 3 again and say this is 1 3 and this is finally equal to plus 1. I can work out these two in the same way. This is plus 1 and this is plus 1. So this number here is plus 1 and we see that 1001 is a square modulo 99991. In case you're interested it's actually 38521 squared unless I've made a mistake. And you see in order to work this out let's summarize all the properties of the Legendre symbol that we need. First of all we have the easy properties ap equals bp if a is congruent to b mod p and abp is equal to ap times bp. Next we have the cases for minus 1 and 2. So this is equal to minus 1 to the p minus 1 over 2 and 2p is equal to minus 1 to the p squared minus 1 over 8. Which if you think about it is just a rather funny way of saying this is 1 if p is plus or minus 1 mod 8 and minus 1 if p is plus or minus 3 mod 8. And finally we have the quadratic reciprocity law and qp. And using these rules we can work out ap for any a and p provided we know how to factorize numbers. Because you can see by repeatedly factorizing the numerator and using these laws we can keep on reducing p and q in a way that's kind of rather reminiscent of Euler's algorithm for finding the greatest common denominator. However there's a problem that factorizing numbers can be really hard if a or if a and p have hundreds or thousands of digits. Well there's a modification of the Legendre symbol called the Jacoby or Jacoby symbol that we will talk about next lecture. Which means you can work out the Legendre symbol without having to factorize anything. As a final example I just show how to use quadratic reciprocity to test firman numbers to see if they're primes. So you remember the firman number is 2 to the 2 to the n plus 1 and we want to know is fn prime. And n might be you know maybe around 20 or something in which case this firman number will have somewhere of the order of a million digits. So there's actually no way you can check whether it's prime by trial and error. Well suppose fn is prime. Then let's look at whether 3 is a quadratic residue of fn or 3fn. Well we can use quadratic reciprocity to say this is fn3 because fn is 1 mod 4 unless n is, well if fn is 3 that's not true. But let's take fn greater than 3. If you have trouble whether checking 3 is prime you really have problems. So this uses quadratic reciprocity. And this is equal to 2 3 because fn is 2 mod 3 as you can easily check and this is equal to minus 1. So 3 is not a quadratic residue modulo fn. So 3 to the fn minus 1 over 2 is congruent to minus 1 mod fn. That's if fn is prime. And now let's try and do it the other way round. If 3 to the fn minus 1 over 2 is congruent to minus 1 mod fn. Well we look at this. This is just 3 to the 2 to the 2 to the n over 2. So this means that 3 to the 2 to the 2 to the n is congruent to 1. That means the order of 3 divides 2 to the 2 to the n. It's not very often you get a tower of 4 exponentials in a serious way. And that means the order of 3 must be a factor of this number. But the only proper factors of this number divide this and 3 to the power of this is not congruent to 1. So the order of 3 is exactly equal to 2 to the 2 to the n which is fn minus 1. Well the order divides phi of fn by Euler's theorem. And since the order is fn minus 1, the only way this can happen is that phi of fn is equal to fn minus 1. So fn is prime. So we see that fn is prime is equivalent to saying that 3 to the fn minus 1 over 2 is congruent to 1 mod fn. And as I mentioned earlier in earlier lectures, this identity here can be checked reasonably easily on a computer even if fn has about a million digits by repeatedly squaring 3. Okay, that's all for quadratic reciprocity this lecture. As I said, next lecture will be about the Jacobi or possibly Jacobi symbol.