 This lecture is part of Berkeley Math 115, an introductory undergraduate course on number theory, and will be about quadratic reciprocity. So just quickly recall, we have the genre symbol, an A P, which is plus one if A is a quadratic residue, in other words, a square modulo P, and A not zero, and it's minus one if not, and zero if A is congruent to zero. And we found a few basic properties of it. For example, we worked out that minus one P is equal to plus one if and only if P is congruent to one, mod four, I should have said P is always an odd prime. And we worked out that two was a quadratic residue, so this is plus one if and only if P is congruent to plus or minus one modulo eight. And we also know it's multiplicative, A B P equals A P B P, and it's periodic, so A plus N P P is the same as A P. And there's one more really vital property of this symbol, which is the law of quadratic reciprocity, which says that if P and Q are distinct, an odd and prime, then P Q times Q P is equal to minus one to the P minus one over two times Q minus one over two, which is kind of really rather astonishing because the question of whether P is a quadratic residue of Q seems to have nothing to do with the question of whether Q is a quadratic residue of P, but this formula says they're very closely related. This number here is minus one if P and Q are both three mod four, and one if one of them is one mod four, so you can write this as P Q equals Q P unless P and Q are both congruent to three mod four, in which case P Q is minus Q P. And these properties of the quadratic residue symbol give a reasonably efficient way of calculating it, because if we want to calculate something like A P, we can factorize A into a product plus or minus one times the power of two times Q one times Q two and so on. And so multiplicativity reduces the problem of calculating this, the problem of finding minus one P, which we already know, two P, which we already know, and Q I P, and we can sort of calculate Q I P. If Q I is bigger than P, we can reduce it mod P and make it smaller. If Q I is less than P, we can use the quadratic reciprocity to turn this upside down and continue making things smaller. It'll probably be easier if I do an example. So let's calculate this Legendre symbol. So this happens to be a prime and I want to know whether or not 1,001 is a quadratic residue. So first of all, we factorize 1,001. So this is seven times 11 times 13 over 99991. So this becomes seven over 99991 times 11 over 99991. And now we can figure out each of these using the quadratic reciprocity law. So for example, here seven and 99991 are both three modulo four. So this is equal to minus 99991 over seven. And now we reduce 99991 modulo seven and this becomes minus three seven. And if we're being really lazy, we can just use quadratic reciprocity again. So three and seven are both three mod four. So we can invert this and we get a minus sign. And then we reduce this, reduce seven mod three. So this becomes one three. And now one three we know is equal to one. And we do 1199991 in the same way. So again, 11 is three mod four. So we get 999991 11 with a minus sign. And this is minus 1111, which is minus one. And finally 1399991 we do in the same way. So this becomes plus 999991 13 because one of these two primes is one mod four. So we get a plus sign here. And then we reduce this modulo 13. So this becomes eight 13. And now this is two 13 cubed. And two 13 is minus one because two is congruent to five modulo 13. So this is minus one cubed, which is equal to minus one. So finally, we finish off by taking these three numbers and multiplying them together and we get one times minus one times minus one which is equal to plus one. So 1001 is a square or quadratic residue mod 999991. If you want to actually work out what it's the square of it turns out to be congruent to 38521 squared. Just in case you don't believe my calculation with the quadratic residue symbol. So previous lecture, we did a few cases of working out what AP was, the various small values of A. For instance, we did three P and we did five P and it's sort of obvious we could have used the same method to work out seven P and 11 P but the method was getting pretty tiresome. So what we're going to do is use the law of quadratic reciprocity to find an easier way to work it out. By the way, the previous method does at least show that AP depends only on P modulo 4a. You remember the formula we had for this sort of obviously only dependent on P modulo 4a. Anyway, let's do an example of, let's find the prime such that 13P is equal to one and that's easy because 13P is equal to P13. That's because P13 is congruent to one mod 4 so we can just invert this using the law of quadratic reciprocity and P13 is easy to work out because we just have to find the squares mod 13. So if we work out 0 squared, 1 squared, 2 squared, 3 squared, 4 squared, 5 squared and 6 squared modulo 13, we get 1, 4, 9, 3, 12 and minus 3 is 10. We don't need to do 7 squared because that's the same as 6 squared and 8 squared is the same as 5 squared and so on. So 13 is square mod P is equivalent to asking for P, I should say P, let's take P not equal to 2 or 13 because these are special cases. So otherwise it's equivalent to P being congruent to 1, 4, 9, 3, 12 or 10 mod 13. And then you can check that 2, 13 is actually a square modulo 2 and it's also a square modulo 13 that's just 0. So let's do a slightly different case. Let's try and find the prime such that 7P is equal to 1. This is a little bit different because this is equal to minus P7. So it's equal to minus P7 if P is congruent to 3 mod 4 plus P7 if P is congruent to 1 modulo 4. So for P congruent to 1 modulo 4, the condition that P is a quadratic residue of 7 says that P is congruent to 1, 2 or 4 mod 7. If P is congruent to 3 mod 4 then P must be a non-residue mod 7 so we get P is congruent to 3, 5 or 6 mod 7. So we've got two slightly different cases. Either P is 3 mod 4 and 3, 5, 6 mod 7 or P is 1 mod 4 and 1, 2 or 4 mod 7. And this is obviously by the Chinese remainder theorem we can give this as a condition mod 28. So this is the same as saying P is congruent to 1, 9, 25, 3, 19 or 27 or 28 because these are the numbers that satisfy these two conditions. And as before we see that now P depends on, so the quadratic residue symbol depends only on P modulo 4 times the numerator whereas in this case it only depended on P modulo the numerator. So now I'm going to give a proof of the quadratic reciprocity theorem and there's a lot of choice in this that there are well over 300 published proofs of this and every single one of them involves some slightly tricky, non-obvious idea. There doesn't seem to be any really easy straightforward proof of the quadratic reciprocity law. Gauss himself started off this mania for finding proofs by finding eight different proofs of the quadratic reciprocity law. Of course strictly speaking there aren't really 300 completely different proofs because quite a few of these proofs are minor variations of each other. So what I'm going to do is to give one of the, what I think is one of the easiest proofs at least it's one of the ones that's easy to remember the main idea. So with many mathematical proofs there's a sort of key idea of powering it and the key idea is usually fairly short but a bit tricky to think of and then in order to make this key idea work you've got to do a lot of routine calculation but the routine calculation doesn't require any thought to just sort of plow ahead with it. So what we're going to do is to give the key idea of this proof and then work out the routine calculation. So here's the main idea and we work modulo p times q where p and q are distinct odd primes and we're going to try and prove the quadratic reciprocity rule for these primes and what we're going to do is to take all numbers in z modulo pz pqz star so we're taking numbers mod pq that are co-prime to p and q and we're going to arrange them into p minus one times q minus one over two pairs where each pair consists of a number a and minus a and we're going to take a product of one element of each pair and this product will be well-defined opt to sine because we get a sort of sine ambiguity because we don't know which element of this pair we're taking and there are three ways, natural ways we can do this product the first is we can take the product over all a that means the product over all a co-prime to pq with zero less than a is less than pq over two or a second product we can do is we can take the product over all a such that naught is less than a is less than q over two where this time we've reduced a modulo q so we reduce a modulo q and check that it's between naught and p over q over two and thirdly we can do the same thing we take the product over all elements a such that naught is zero is less than a is less than p over two here we're taking a mod p and saying a mod p must be between zero and p p over two and in order to work these out let's first just quickly recall a couple of results we're going to be using so first of all we first of all recall the Chinese remainder theorem which says that z modulo pq can be identified with z modulo pz times z modulo qz in other words an integer modulo pq is uniquely determined by something modulo p and something modulo q and we're going to use this for the integers co-prime to p for the unit so we also get that the things mod pq that are co-prime to pq can also be written as pairs like this the second result we're going to use is a quadratic residue symbol is congruent to p to the q minus one over two modulo q so this is just Euler's result okay having recalled those two results now we're going to work out the product in several different ways and I think that this will be easiest to understand if we just do a specific case so we might take p equals five q equals seven so we're going to write out all the numbers from zero one up to 34 that's a modulo pq and we're going to write them in the sort of Chinese remainder theorem form so here they're going to be zero one two three four five or six modulo q zero one two three or four modulo p so we just write out all these numbers and we get zero one two three four five six seven eight nine ten eleven twelve thirteen and then here we get fourteen and we jump down here we get fifteen sixteen seventeen eighteen nineteen then we get twenty twenty one terms in here twenty two twenty three twenty four up there and then we jump down here twenty five twenty six twenty seven here we jump up to twenty eight twenty nine thirty thirty one thirty two thirty three thirty fourth is actually worked so here we've got thirty five thirty five numbers identified modulo p and modulo q except we want to throw away the ones that are divisible by five and the ones that are divisible by seven well the ones divisible by five are here and the ones divisible by seven are up here and now there are three ways we can choose half of these numbers first of all we can choose the red ones which are these ones here so these are the numbers that are less than q over two modulo q so that they're common to one two or three modulo seven next we have the blue numbers these are the ones that are less than p over two modulo p and finally we have the numbers that are less than p q over two so that's less than seventeen so we get one two three four five six seven eight nine ten eleven should be twelve I've missed one though here they are so so these gold numbers are less than p q over two which is seventeen five so in each case there are twelve numbers and the product of the red numbers and the product of the blue numbers and the product of the gold numbers are all the same modulo pq up to a factor of plus or minus one and now we can work out some of these products so we can work out this product of all the red numbers modulo q so modulo p getting my p's and q's muddled up and that's quite easy because we first of all multiply all these numbers together and these are one two three and four modulo five so we get p minus one factorial and then these ones are one two three four mod five so we get p minus one factorial and then we get another factor of p minus one factorial so we get p minus one factorial to the q minus one over two which in this case is five minus one factorial to the seven minus one over two and we do much the same with the blue numbers here so here and the product of all these numbers is going to be q minus one factorial where q is seven and product of all these is going to be q minus one factorial so we get a factor of q minus one factorial to the p minus one over two modulo q so we can work out the product of the blue numbers mod q and the product of the red numbers modulo p by the way if you remember wilson's theorem you can actually you actually know that p minus one factorial happens to be minus one but we're not actually going to use that and now what is the difference between the product of the red numbers and the product of the blue numbers well the red product is in fact equal to the blue product times five minus one over two times minus one to the five minus one over two times seven minus one over two and that's easy to see because let's compare the difference between the red numbers and the blue numbers is we're changing the product of these numbers here where I've used orange to mark them although unfortunately orange looks rather like red and so for each of these we've had to change the sign so 32 changes sign to three and six changes sign to 29 and so on so we've got a sign change for every number in this rectangle this rectangle has size p minus one over two times q minus one over two so we get this this factor here between the red and blue factors next we want to calculate the red and blue factors we want to calculate the product of all the gold numbers modulo p and modulo q so this means we take all the numbers one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen so this is this is up to pq minus one over two and now we're taking p equals five and we throw away all the numbers that are divisible by five because we want numbers that are co-prime to five and then we then we multiply them all together let's see what we get well we get here we get five minus one factorial modulo p and here we get five minus one factorial and here we get five minus one factorial and here we get well five minus one over two factorial because we only get halfway through before we run into pq minus one over two so at first sight we seem to get this number five minus one factorial cubed divided by five minus one over two factorial but we made a mistake because we accidentally included the multiples of seven so we've got a multiple of seven there and a multiple of seven there so we better divide out by these multiples of seven so we have to divide out by seven times two times seven and this is equal to seven to the five minus one over two times five minus one over two factorial so if we put this all together we find that this the gold product is congruent to five minus one factorial to the seven minus one over two times five minus one over two factorial divided by seven to the five minus one over two times five minus one over two factorial and incidentally these two factorials cancel out so this expression isn't as bad as it looks at first sight now let's do the other case where we do it for where we do it for seven instead so this time we take the numbers one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen and seventeen and this time we cross off all the multiples of seven so we cross off seven and fourteen and what we left with is seven minus one factorial here we're working mod seven and here we also get seven minus one factorial because these are numbers from one to six modulo seven again and here we get seven minus one over two factorial and again we forgot to throw out the multiples of five so there are some multiples of five we should not have included in this product so we should divide this by five times two times five times three times five which is equal to five to the seven minus one over two times seven minus one over two factorial because you can see this goes up to seven minus one over two times five so as just as before this sum becomes seven minus one factorial times seven minus one factorial over two divided by this expression here and now we can do the same thing for any p and q and you see that what we get is if we take the numbers one two three up to pq minus one over two and we want to work out what the product is mod p after crossing off all the multiples of p and all the multiples of q what we're getting is p minus one factorial times p minus one factorial all the way up to times p minus one over two factorial which is like this product here or this product here and then we have to divide it by q times two q all the way up to times p minus one over two q and if we work this out it's just equal to p minus one factorial to the q minus one over two times p minus one over two factorial all divided by q to the p minus one over two times p minus one over two factorial and just as before these p minus one over two factorial cancels out so we've worked out product over all numbers modulo pq and now we're going to put everything together in one big page and to do this let's write down the three products so we've got the first product which is the product over all n co-prime to pq with nought zero less than n is less than pq over two and then we have the red product which is the product over all n such that zero is less than n is less than q over two except here we take n to be modulo q and then we have the blue product which was kind of similar we have the product over all n co-prime to pq except we take zero is less than n is less than p over two modulo where n is now taken modulo p and now we're going to work out what the ratios between these products are well we worked out what the ratio between these two was it was just minus one p minus one over two times q minus one over two because we just had to change all the signs in some rectangle now let's work out what difference between these two is well these two differ by sign so let's recall what they were well this is congruent to p minus one factorial to the q minus one over two mod p and we worked out what this one one was mod p it was congruent to p minus one factorial to the q minus one over two divided by q to the p minus one over two modulo p so you remember that was on the previous sheet where we had this expression here and these p minus one over two is cancelled out so I'm not bothering to write them in here and now if we compare this expression with this expression we see that almost the same we've got this p minus one factorial to the something or other and the p minus one factorial to the same thing so the only difference is this and we know these differ by these two products differ by a sign so the sign must be q to the p minus one over two modulo p but by Euler's theorem this is just equal to q the Legendre symbol q p so these two differ by q p and comparing these two is almost exactly the same except we changed p and q so this one is congruent to q minus one factorial to the p minus one over two modulo q and if we want to work out this modulo q we get q minus one factorial to the p minus one over two divided by my p's and q's we've got p to the q minus one over two mod q and now if we compare this expression with this expression we see the difference as a factor of p to the q minus one over two mod q which by Euler's theorem is just p the Legendre symbol pq so to summarize we've got three numbers here which differing by signs and the difference between these two is that is a sign of q p the difference between these two is a sign of pq and the difference between these two is the sign of minus one to the p minus one over two times q minus one over two and that obviously means that the product of any two of these signs must be the same as the third one so we get pq times qp equals minus one p minus one over two times q minus one over two which is the law of quadratic reciprocity so this so as you see the calculations for this proof is a bit messy but the fundamental idea is very simple all you do is remember this triangle which has three products in so they're the three obvious ways of choosing half the elements of the formula pq and these three products all differ by signs and the signs of the three terms in the quadratic reciprocity law and so the three terms in the quadratic reciprocity law must have product equal to one okay so next lecture I'll be giving another proof of the quadratic reciprocity law using Gaussian sums which tends to be most mathematicians favourite proof