 This lecture is part of Berkeley Math 115, an introductory undergraduate course on number theory, and will be about the Jacobi symbol, or possibly the Jacobi symbol if you're German. So recall that we have the Legendre symbol denoted by A B, which is equal to plus one if A is a square mod B, not if A is congruent to zero, and minus one if A is not square. That should be a non-zero square. And this is defined whenever B is prime. And it's quite often rather annoying to have B restricted to be a prime number, as we will see later on in this lecture. So there are two extensions of the Legendre symbol. The first is called the Jacobi symbol. It's again denoted by A P. And this time it's defined with B, any B odd and positive. And it's not defined like this. The Jacobi symbol is defined in the following way. We define A P1 P2 opt Pn. So here B is odd and positive, so it can be factorized as odd primes. And we just define this to be A P1 times A P2 all the way up to times A Pn. There's a further extension of the Jacobi symbol to the Kroniker symbol that I'll discuss in a later lecture. And the Kroniker symbol is defined for all integers A and B. So what properties does the Jacobi symbol have? Well, quite a lot of its properties are the same as for the Legendre symbol. First of all, it's multiplicative in A. So A1 A2 B is equal to A1 B times A2 B. And this is very easy. It follows immediately from the same property that the Legendre symbol has plus some easy calculation. Secondly, it's multiplicative in B. So A B1 B2 is equal to A B1 times A B2. And again, this is easy. So I'll just leave the proof as a straightforward exercise. Then the Legendre symbol, we know that minus one B is equal to plus one if B is congruent to one mod four, and minus one if B is congruent to three, mod four. And the same holds true for the Jacobi symbol. And just before this is easy because this side is multiplicative in B. And you can easily check this side is multiplicative. And fourthly, we have two B, sorry, two B is equal to plus one if B is congruent to plus or minus one mod eight and minus one if B is congruent to plus or minus three mod eight. And just as before, this follows because both sides are multiplicative in B. So we'll again mark that down as easy. Next, we've got periodicity. So A plus NB B is equal to A B. And as before, it's very easy. And then we've got the law of quadratic reciprocity, which says that A B is equal to minus one to the A minus one over two times B minus one over two B A, where A B are odd, positive and distinct. So they don't need to be distinct, but anyway. And this needs a little bit more work to check that we will do on the next page. But just before doing that, I'll mention one further property that A B plus N A is not equal to A B in general. For instance, we can see an example of this if we just take A two, sorry, if we take two B, then this does not appear two in B, it actually is period eight in B. In fact, in general, you find A B plus four N A is equal to A B. So it is periodic in B, but the period is four A in general, not just A. Incidentally, it has period A B plus N A is equal to A B if A is common to zero or one, mod four, but not in general. So periodicity in the denominator is a little bit trickier. Anyway, the one thing we want to prove, which isn't quite straightforward, is this law of quadratic reciprocity for the Jacobi symbol. And what we do is we notice that if A is equal to P one, P two and so on, and B is equal to Q one, Q two, whether Pi and Q i are odd primes, then what's A B? Well, this is just equal to the product over all i and j of Pi Q j by the multiplicity of the multiplicativity of the Jacobi symbol in A and B. And similarly, B A is just equal to the product over all i and j of Q j times P i. So let's multiply A B and B A together, and we get the product over all i j of Pi Q j times Q j P i. And we know what these are by the usual law of quadratic reciprocity for the Legendre symbol. So this is just a product over all i and j of minus one if Pi Q j are both common to three mod four. And we can see that this is just minus one, the M N, where M is equal to the number of Pi that are three mod four and N is equal to the number of Q j that are three modulo four. However, if we look at if we look at whether A is three mod four, you see that M is even is equivalent to A being congruent to one, one four, and similarly N being even is equivalent to B being congruent to one, one four. And conversely, if M is odd, then A is three mod four and vice versa. So this is just equal to minus one to the A minus one over two times B minus one over two. Because this will be even if A is one mod four and odd if A is three mod four. So we've got the law of quadratic reciprocity even for the Legendre symbol when the denominators don't have to be prime numbers. So we've had seven properties of the Legendre symbol that extend the Jacobi symbol in a straightforward way. We now have the big warning. There is one property that doesn't extend for the Legendre symbol. And we know that A B is equal to plus one implies A is square modulo B. This is where B is prime. And this still holds the Jacobi symbol if B is a prime number, but is false in general. So it's just emphasised that for Jacobi, A B equals plus one does not imply A is a square. I mean, A might be a square, but it's not necessarily a square. And if this is minus one, then A is definitely not a square, but you can get cases like this. Suppose we take B to be a product of two primes P and Q. Then by definition of the Jacobi symbol, this is equal to A P times A Q. And now let's take this to be minus one and this to be minus one. Then this side will be plus one. And this means A is not a square mod P because of this. So it's not a square modulo P Q because if it was a square modulo P Q, it would also be a square modulo P. And you can get an explicit example of this by taking A equals two, P equals three, Q equals five say. So we have two 15 is equal to two three times two five, which is equal to minus one times minus one, which is equal to plus one. So the Jacobi symbol two 15 is plus one, but two is definitely not a square modulo 15 and not even a square modulo three. So this is the one thing you have to be careful about when using the Jacobi symbol. Incidentally, this is you may have been wondering why we didn't just define the Jacobi symbol to be one if A is a square. And the problem is that if we do that, it's not multiplicative in the denominator, which will be really annoying as we will see in a moment. Um, so what's the advantage of this? Well, when we were computing the Legendre symbol for A, B, we want to change this to plus or minus B, A whenever A is smaller than B and sort of continue. Well, it's only works for a prime number when we're working with the Legendre symbol. And this is rather a nuisance because if A is not a prime number, say A is equal to P times Q, we have to compute it by writing AB equals PB times QB. And then we can invert this as plus or minus B, P times plus or minus BQ. Um, and when we were computing Jacobi symbols in the previous lecture, we sort of had to do this. You know, we sometimes had to factorize the numerator and that's fine if A is small, but if A is really large, then factorizing A can be really rather difficult. Well, for the Jacobi symbol, we don't need to factorize A. So there's no need to factor the number A. And this makes it much easier to work out the Jacobi symbol really fast. So let's do an example. Suppose we want to compute, um, suppose you want to compute, say, minus 200299991 as a Jacobi symbol. Um, so what we do is we first pull out all the factors of minus one and two in the numerator. So this is minus one, nine, nine, nine, nine, one times two, nine, nine, nine, nine, nine, one times a thousand and one, nine, nine, nine, nine, nine, one. Now we work out what these are. Well, this is plus one because this is minus one, um, mod eight. And this is equal to minus one because this is three modulo four. So, um, um, um, and we can now invert this using the quadratic reciprocity law without bothering to factorize a thousand and one. So this just becomes minus nine, nine, nine, nine, one thousand and one. So the minus sign comes from that times that. And we don't get a minus sign by inverting because a thousand and one is one modulo four. And now we can divide nine, nine, nine, nine, nine, one by a thousand and one. And we get minus eight, nine, two thousand and one. And now, um, we want to invert, but we can't because the numerator is even. So we, we take out all the factors of two. So this is a minus minus. Um, and then we've got two factors of two. So we get two, a thousand and one squared times two, 23, thousand and one. So that's eight, 92 divided by four. And, um, whatever this is, we're squaring it so we don't really care whether it's one or minus one. And this becomes, um, minus thousand and one, two, 23. So now we've inverted these and a thousand and one is one mod four. So we don't get an extra sign. And this is equal to minus one, oh, nine, two, 23, where we've divided a thousand and one by two, 23. And now we can invert using quadratic reciprocity again. And we get this is minus 223, 109. And now we divide 223 by 109. This is minus 109, five. And now we divide 109 by five. And this becomes minus four, five. And now we pull out the factors of two. So this is minus two, five squared times one, five. And now one, five. Well, we've now got down to, um, one is obviously a square modulo five. So this is just minus one. So you notice this is really just Euclid's algorithm, except we take out factors of two. And we also keep track of signs. So Euclid's algorithm, we've got two numbers and we're constantly swapping them and dividing one by the other. And this is exactly what we were doing here, except that every now and then we need to take out an extra factor of two. And we also need to keep track of whenever we get an extra sign from swapping these two numbers. So whenever these are both three modulo four, we have to put an extra sign in. And it's just as fast as Euclid's algorithm. Incidentally, that there's an even more efficient form of this. So you remember, there's a form of Euclid's algorithm without division. So you remember, we could do Euclid's algorithm instead of dividing a number by another, we could just subtract and then take out factors of two. And you can do exactly the same thing for the Jacobi symbol. For instance, I'll just do 223109. And now let's try and do it without without any division. I suppose we've sort of forgotten how to do division or something. So what we do instead of dividing 223 by 109, we just subtract and we get 114109. And then we take out the factor of two. So we get, this is 2109 times 57109. And 2109 is minus ones, that's minus 57109. And now these are both odd, so we can invert this. So it's minus 10957. Because these 109 is one mod four, so we don't get a sign. And this is equal to minus 5257, where now we've, instead of, we've just subtracted 57 from 109. And now we take out factors of two. So this is equal to minus 257 squared times 1357. And now that's going to be minus 5713. Because we're just inverting these by quadratic reciprocity. And now we don't divide 57 by 13, we just subtract. So we get minus 4413. And now we take out all factors of two. So this is going to be minus 213 squared times 1113. And now we can invert using quadratic reciprocity yet again, and we get minus 11, so minus 1311. And now we subtract 11 from 13. So this is minus 211. And now we know what this is. 211 is minus one. So this is equal to plus one. So you see, if we don't do division, it sometimes takes slightly more steps. But in practice, it's a lot easier to do because we're just doing subtraction rather than division. And subtraction is a lot easier than division, especially if these were really big numbers. You notice this algorithm works just fine if these are numbers with hundreds or thousands of digits in them. And if they had hundreds or thousands of digits, we couldn't work out the Jacobi symbol by factorizing these numbers, because that would be too difficult. So key point is the Jacobi or Legendre symbol, A, B is really fast to calculate. I mean, really fast means even if A and B have thousands or even millions of digits, we can calculate it in a very small amount of time. So let's have an application of this. So remember, we had a sort of primality test, which says that if A to the P minus one is not congruent to one mod of P, this implies P is not a prime. The trouble is, if A to the P minus one is congruent to one mod of P, P still might not be prime. So if we take P equals five, six, one, this is the famous Carmichael number, first Carmichael number, then P is equal to three times 11 times 17. And we saw earlier that A to the five, six, one minus one is congruent to one mod five, six, one, whenever A is co-prime to five, six, one. So this, this primality test breaks down for some Carmichael numbers. However, using the Jacobi symbol, we can do better because if P is prime, then A P is congruent to minus, is congruent to A to the P minus one over two modulo P. And now we can work out this fast using Russian exponentiation, Russian peasant method for doing exponentiation, and we can work out this fast using the fact that it's a Jacobi symbol. Notice we need to use Jacobi symbols rather than Legendre symbols in order to get a fast algorithm working this out because if we restrict ourselves to Legendre symbols, we would have to factorize various numbers, and this would be very, very slow. So for example, we can now show that five, six, one is not prime by say taking A equals five. And then we find five, six, one is not congruent to five to the power of 280 mod five, six, one. So that's five, six, one minus one over two. And that's because we can calculate this because it's five, six, one, five using the quadratic reciprocity theorem, which is one, five by dividing, which is even plus one. And on the other hand, five to the power of 280 turns out to be congruent to 67 mod five, six, one. So there are two ways to calculate this. You can either do it honestly by using the Russian peasant method of calculating it, which takes a lot of time. Or what I actually did was I cheated. What you do is you just have to check that these equal modulo all the factors of 561 to 311 and 17. And you can see that this is minus one modulo 17. And it's plus one modulo three and 11. But of course, that's kind of cheating because we're using the fact we already know this isn't prime. But anyway, so that gives you a fast primality test, which is a little bit better than the than the test just using Fermat's theorem. And if it fails less often, there's a bit of a problem with the definition of the the Jacobi symbol. We notice the definition is a bit of a mess. So we first define AP, the P prime to be plus one if A is a square and so on. And then we define AP for AB for B, not a prime, just by saying it's a product of these various numbers. And this definition is frankly a bit of a mess. We're defining it in two completely different steps that are very little to do with each other. And we can ask, is there a one step definition of the Jacobi symbol AB that works for all B without having to divide into cases when B is a prime or not a prime. And the answer is yes, it's due to Zolotov. What he did was he showed that AP, so AB for all B is equal to the sign of the permutation of multiplication by A on the integers modulo BZ. So I'll now explain what this means. Well, first of all, a permutation just means a bijection from a set to itself. And we notice that if we take Z modulo BZ and multiply by A and map it to Z modulo BZ, then this is a bijection provided A and B are co-prime. I should say that this definition only works for AB co-prime. If A and B is greater than one, then the symbol AB is equal to zero. So now what do we mean by the sign of a permutation? So suppose we've got a permutation sigma and suppose it acts on a set S, which may be his elements S1, S2 and so on. So what we do is we pretend these elements of S are variables and we form the following product. We form the product delta, which is the product over i less than j of S i minus S j. So it's sort of S1 minus S2, S1 minus S3, S2 minus S3 and so on. And then we can check that sigma acts on delta by acting on all the variables and this is obviously going to be either plus or minus delta because it's going to be the product over all pairs of variables S i and S j of their difference. So we get all pairs S i minus S j, except we might have S j minus S i. So it would be the other way round. And this sign here is called the sign of the permutation sigma. So let's work out an example. Suppose that sigma takes swaps S1 and S2 and maps S3 to itself. So we take delta, which is now going to be S1 minus S2, S1 minus S3 times S2 minus S3 and sigma of delta is going to be where we just swap one and two. So it's S2 minus S1 times S2 minus S3 times S1 minus S3. And now if you look we've got the same three factors. We've got this factor and this factor and this factor. So we've swapped these two factors and this one we've changed sign. So we've got a minus one here. So sigma of delta is equal to minus delta. So epsilon sigma is equal to minus one and sigma is called an odd permutation. So we say the permutation is even or odd depending whether it changes delta to plus delta or minus delta. So Zolotov showed that AB is equal to epsilon of A where this means the permutation multiplication by A on Z modulo BZ. So let's check that this is true. First of all we have to check it when B is equal to a prime. And now both sides are multiplicative. So it's enough to check that GB is equal to epsilon G, G being a primitive root of B, which is now prime. So it has a primitive root. And that's because if GB is equal to epsilon G then G to the iB will be equal to epsilon G to the i because both sides are multiplicative. And for G a primitive root we know that GB is equal to minus one because primitive roots are not squares. So this is just minus one to the B minus one over two mod B which is equal to minus, so it's equal to G to the B minus one over two mod B which is minus one because G is a primitive root. On the other hand we need to know what does the permutation G look like on the integers mod B. And the integers mod B look like this. They look like zero, G to the zero, G to the one, up to G to the B minus one. And multiplication by A or by G looks like this. First of all it obviously takes zero to itself and then it just maps all these variables around in a big cycle. And this is a cycle of even length. And a cycle of even length is an odd permutation, as you can check fairly easily. It's very annoying that cycles of even length are odd permutations and cycles of odd length are even permutations but there's nothing we can do about it. Anyway so this means that silent G is equal to minus one if G is a primitive root so this is equal to G B. So this verifies that Zolotar's definition in the case that the denominator is prime. Now we need to check what happens if the denominator is not prime. I'm just going to do the case of two primes to simplify notation. The case of several primes is pretty similar except you can just take these to be two odd numbers. So let's just do this for p and q primes to give the main idea. And so we have two permutations. Let's put sigma is multiplication by a on the set z modulo p z and tau is multiplication by a on the set z modulo q z. So we have a p is just the sign of sigma and a q is just the sign of tau. And now we use the Chinese remainder theme. We notice that z modulo p q z can be identified with the product of the set z modulo p z times z modulo q z. And here we've got this permutation sigma which is multiplication by a tau which is multiplication by b. And on this we've now got the on this set here we sorry it's not multiplication by b it's multiplication by a again. And now on this set we've got the permutation sigma times tau because whenever we've got a permutation sigma on a set and a permutation tau on another set we obviously get a sort of product permutation on the product of the two sets. And this permutation sigma times tau just corresponds to multiplication by a on the set z modulo p q z. So we just want to check that the sign of sigma times tau is equal to the sign of sigma times the sign of tau. And you may sort of think this is obvious but there's actually a subtle trap here. So it's a warning. Suppose sigma is a permutation of x and tau is a permutation of a set y then epsilon sigma times tau is not equal to the sign of sigma times the sign of tau in general. So here this is a permutation of x times y and it's quite easy to find examples of this. So we could just take x to be a two point set and y to be a two point set. So this is going to be x, this is going to be y and x times y is going to look like that. And let's take sigma to be to be this permutation here and let's take tau just to be permutation that maps everything to its cell. So tau is one on y and then we see that the sign of sorry that should be a tau sign of tau is just plus one and the sign of sigma is minus one because it just swaps two points of x. But the sign of sigma times tau, well sigma times tau swaps these two points and these two points. So it's an even permutation. So we wanted this formula here in order to finish our proof of Zolotov's result. But this isn't actually true for all permutations. So what is the correct result? Well again we take sigma is a permutation of x and tau is a permutation of y. So sigma times tau is a permutation of x times y and the sign of sigma times tau is the sign of sigma times the sign of tau. Well I just said it wasn't that so obviously I've got to fix something. Well it's actually the sign of sigma times the size of y times the silent tau times the size of x. And the reason for that is we can just look at sigma on x times y. So here we've got to set x and here we've got to set y and if we've got a permutation sigma on x, so sigma might do something like this, then sigma on x times y has y copies of sigma on x. So that's silent of sigma on x times y is the sign of sigma on x to the power of size of y. And this permutation here is sigma times tau is just sigma on x times y meaning we have sigma acting on the first coordinate of x times tau on x times y. So that proves this formula here. Well now if we go back we wanted to show that when x is the integer's modulo pz and y is the integer's modulo qz we want sigma, so epsilon sigma, epsilon sigma times tau is equal to epsilon of sigma times epsilon of tau. Well in fact epsilon of sigma times tau is equal to epsilon of sigma to the size of y times epsilon of tau the size of x. However x equals y, so x, y are both odd because p and q are odd. So we're okay because epsilon sigma to the y is equal to epsilon of sigma and epsilon of tau the x is equal to epsilon of tau. So this formula that we needed was okay because p and q are both odd, if odd numbers. There's another thing you've got to be a little bit careful of and so we have another warning so that ab is equal to the sine of a on z modulo bz. It is not in general the sine of a on z modulo bz star that the elements the b that are co-prime to a and if you try defining it like this everything just goes wrong. This is true if b is prime but not in general. So that's the summary of the Jacobi symbol. In the next lecture I'll say a little bit about further generalization of the Jacobi symbol which is the chronic symbol. By the way I should also just mention that Zolotov used his definition to give another proof of the law of quadratic reciprocity but since we've already had two proofs I don't think we need a third.