 This lecture is part of an online course on the theory of numbers, and will be about primitive roots. So, first of all, explain what a primitive root is. So suppose you pick some modulus m, so this is a positive integer, then a primitive root of m is a number a, so that all elements of z over mz times, you remember this group is the numbers modulo m that are co-prime to m. Then all elements of this group have to be powers of a. And let's see some examples of this, just to get an idea of what's going on. Suppose you take m equals one, then z over mz, the multiplicative group z over mz just has one element one, and that's obviously a primitive root, that's kind of trivial for m equals two. It's equally trivial as just one element, that's a primitive root. m equals three, there are two elements, and this time we can see that both of them are powers of two. So let's put the primitive root in this fluorescent pink colour. For m equals four, there are just two elements, and again there's an obvious primitive root. For m equals five, we have to stop and think for about a second because there are now four elements, and four isn't a primitive root because it's square is one, so the powers of four are just four and one. But you can easily check that two and three are primitive roots. m equals six, nothing much happens, there are two elements, one and five, and five is the primitive root. For m equals seven, things are now getting a little bit more complicated, so there are six elements in this group. And what we want to do is to find an element of order six so that all its powers are these six elements. And six won't do because six squared is equal to one, and one won't do because its first power is one. And what about two? Well, two won't do because two cubed is equal to one, and similarly four cubed equals one. However, the elements three and five work fine. So if you look at the powers of three, you get one, three, nine is two, then you multiply that by three and you get six, and you multiply that by three and you get four. So you get all the powers. So what are the primitive roots for m equals eight? Well, the elements of zero for mz star are one, three, five and seven, and we see one squared equals one, three squared equals one, five squared equals one, seven squared equals one. So there are no primitive roots. So there may be no primitive roots at all of a number, so this happens for eight. So let's try to go a bit further. For m equals nine, we have one, two, four, five, seven and eight, and you can check the primitive roots. And now two and five for ten, you get the elements one, three, seven and nine, and nine squared is one, so that's not a primitive root, and three and seven are primitive roots. So if we stop and look at this collection of data on primitive roots, you can see it's rather hard to see any patterns going on. The primitive roots seem to be some almost random collection of numbers. So we need to answer the following questions. First of all, which numbers have primitive roots? So all numbers up to ten except eight have primitive roots, and what's so special about eight that prevents this from happening? Well, we also want to do things like find out how many primitive roots there are, and finally, obvious question, what use are primitive roots? Well, to see what use they are, let's stop by just looking at the case m equals eleven, so we get one, two, three, four, five, six, seven, eight, nine, ten, as the elements of z over eleven z, the multiplicative group, and which of these are primitive roots? Well, one isn't obviously, ten isn't because its square is one, and you can see three, four, five and nine are not because their fifth power is equal to one, and we're left with the primitive roots two, six, seven and eight. And now let's suppose a number a is a primitive root of some number m, and we're going to take a to be two and m to be eleven just to show what's going on. Now what I'm going to do is I'm going to write out the number zero, one, two, three, four, five, six, seven, eight, nine, which are the elements of z modulo ten z, and I'm going to write out the elements of z modulo eleven z star. So as you know, the elements of z modulo eleven z are one, two, four, eight, five, ten, nine, seven, three, six. And why have I written them in this rather funny order? Well, I'm writing them in the order where these are the numbers two to the n. So two to the five is thirty two, which is ten modulo eleven and so on. So we have a map from z modulo ten z to z modulo eleven z start taking n to two to the n, where this two is a primitive root. And what we notice is that this map is a homomorphism. Well, so what's a homomorphism? Well, a homomorphism is a map that preserves the group structure. So f of a plus b is f of a times f of b. And you have to be a bit careful because the group structure here is written additively and the group structure here is written multiplicatively. So preserving the group structure, we have to change a plus to a times. And it's also a bijection. And a homomorphism between groups that's also a bijection is called an isomorphism. And an isomorphism is just a fancy way of saying that two things are really the same. So what do I mean by saying they're really the same? Well, they're sort of really the same as groups provided you just relabel all the elements. And so we have to relabel the elements by relabeling eight as three and six as nine. And we have to relabel the group operation from addition to multiplication. But apart from that, these are really the same groups that addition in here just corresponds exactly to multiplication here. And what this means is that any group theoretic property of this group can be turned into a group theoretic property of this group. For example, suppose we want to know in this group what are the solutions of x to the five equals one? Well, they're the solutions of five x equals zero in this group because zero corresponds to one and fifth powers correspond to multiplication by five. And the elements with five x equals one are easy to find. They're just the five multiples of two. And so the elements with x to the five equals one are just the corresponding elements in this group which makes them easy to find. You see, adding two to something is definitely easier than multiplying something by say four. So the advantage of a primitive root is it turns, in some sense, it turns multiplicative problems into additive problems. So next I should explain where the name primitive root comes from. Well, in complex analysis, we have roots of one which are solutions to x to the n equals one. And if you look at, say, the sixth roots of one, remember the sixth roots of one lie nicely on a certain form of sort of regular hexagon. So that we have one and minus one and we've e to the two pi i over six and e to the two times two pi i over six and so on. And if you look at the orders of these roots, this one has ordered one, this one has ordered two, these two have ordered three and these two have ordered six. And these are called primitive sixth roots of one. So there are two primitive sixth roots of one and primitive means all other sixth roots of one are powers of them. So if we take the six powers of this one, we get all of these things here. And this is exactly what happens in say z over 11 z star. We have 10 tenth roots of one by Fermat, because Fermat's theorem says that all elements of this are actually tenth roots of one. And the primitive ones are the ones of order 10 so that every tenth root of one is a power of one of these primitive ones. And this is exactly the definition we gave of a primitive root modulo 11. So a primitive root modulo prime and a primitive root of one in the complex numbers are really more or less the same thing. There are nth root of one that has ordered exactly n. Now we get to the following problem, which numbers m have primitive roots. So we saw earlier that all numbers up to 11 other than 8 have primitive roots. And so let's try and see some properties that numbers with primitive roots have. So suppose if a is a primitive root of m, then we get an isomorphism from z modulo 5 of m of z to z over mz star, which just takes a number n to 8 the n. So remember 5m is the order of z over mz star. And you see this group here has at most two elements of order dividing two. So if this is in general true for z over kz. So if k is even there are two elements of order dividing two. And if k is odd there's only one which is zero. So we get either zero or zero and k over two. So if there's a primitive root this is only two. This is only at most two solutions to x squared equals one. So if there are four elements with x squared equals one or at least four elements there's no primitive root. And this will give us a way to check where the numbers have primitive roots on it. And actually it turns out that conversely if there are most two elements with x squared equals one then there is a primitive root. That's a little bit harder to show. We might more or less show it later. So let's see how this allows us to eliminate some things. Suppose we look at the group z over mnz star with m and n co-prime. Now we apply the Chinese remainder theorem. And we recall this says that this is really isomorphic to z over mz star times z over nz star. You remember there was a one-to-one correspondence between elements of this group and pairs where you pick an element of this group and an element of this group provided m and n a co-prime of course. And now this has two solutions to x squared equals one which are plus or minus one if m is greater than or equal to three. If m is two then one is equal to minus one so these two solutions become the same. And similarly this is two solutions if n is greater than or equal to three. So all together we get when I say two solutions this has at least two solutions. This has at least four solutions to x squared equals one if m and n are greater than or equal to three. So if there's a primitive root of a number we can't write it as the product of two co-prime numbers both of which are at least three. So this gives us the following possibilities. So the only possibilities for a primitive root a number has to be that form p to the k for p prime or two times p to the k. And we're allowed two here because you remember m and n had to be at least three which means we can allow a factor of two that is co-prime to that. So these are the only numbers that can't be written like that. So the question is can all numbers of this form be given primitive roots? And the answer is no there's still one other obstruction because if you look at two to the k for k greater than or equal to three this is four solutions to x squared equals one. And two of these solutions are obvious they're one and minus one and the other two solutions are two to the k over two and minus two to the k over two. So the only numbers which so if m has primitive roots then m is equal to one of the numbers one to four or p to the k for p odd k greater than or equal to one or two p to the k for p odd and greater than or equal to one. And in fact all these numbers turn out to have primitive roots. Well how do we show this? Well the first step is to do the case when k equals one. So we now have the following problem does z over pz star have a primitive root. Here of course p is prime and this was shown by Euler although he actually struggled with it quite a bit. It turns out it's actually rather tricky to show that z over pz star has a primitive root and the point is in general there seems to be no easy way to write down a primitive root of a prime. I mean you can sort of find one in practice by trial and error without too much difficulty but there's no easy way to write down a formula that always gives you a primitive root of a prime. And the proof will be sort of rather indirect we will show that it has a primitive root by counting up all the elements that aren't primitive roots and showing that there are less than p minus one of them. Anyway let's start the proof. We need the following key point which says that a polynomial of degree n with coefficients in z modulo pz has at most n roots in z modulo pz. And you may think well you already know this. There's a theorem in algebra saying that any polynomial of degree n has at most n roots. So what's the big deal about this? Well the point is this is actually false mod m if m is not prime. So for example we've got this degree two polynomial x squared minus one and let's try and solve it in find roots in z modulo eight z. Well there's just four roots. The four roots are one, three, five and seven. So it is not true in general that a degree n polynomial has at most n roots. However Euler discovered that this is still true if we work modulo p. And let's try and see why this still works if we're working modulo a prime. So suppose we've got some polynomial f of x which is x to the n plus a n minus one x to the n minus one and so on plus a zero. And suppose a is a root. I guess I should make it clear that a is a variable not a word. Then we can write f of x equals x minus a times x to the n minus one plus something or other. And let's call this factor b of x. So this means f of a equals zero. And this argument works perfectly fine modulo any integer and we can just copy the usual proof of algebra. You remember you divide this polynomial by x minus a and the quotient is this and the remainder must be zero because f of a equals zero. So this is fine modulo any number. And now suppose c is a root of f. Then c minus a times g of c is equal to common to zero mod p. So c minus a is common to zero or gc is common to zero and this is the key step. The reason for this is because p is prime. So let's put a big orange box around this because this is the key point where we use that p is a prime. That's because if p divides c minus a times g of c it must divide one of these two. That's the sort of almost a defining property of prime. So c equals is common to a or g of c equals naught and by induction there are at most n minus one solutions. So this equation because the degree of g is n minus one. So there are at most n roots of f modulo p. We should point out that this definitely fails if p is not a prime. For instance suppose we work mod eight and we look at the polynomial x squared minus one. Well this is a root x equals one so we can write it as x minus one times x plus one. But now we notice that three and five are roots of x squared minus one but they're not roots of x minus one or of x plus one. So this step really does break down. So you can see if we put x equals three then this number is two and this number is four which are both none zero. Their product is zero because you can get two none zero numbers mod eight whose product is zero. So that works fine for primes but not for arbitrary numbers. Now we notice that z modulo p z star has at most n elements of order dividing n, this is for any n. And this follows because these are just the roots of x to the n minus one is common to zero modulo p. And we just showed that a polynomial has at most n roots. And now we notice that z over p z star has at most five of n elements of order exactly n. So here we're looking at the order dividing n, here we're looking at the order being exactly n. So suppose there is at least one element of order n. So suppose a has order n. If there isn't one element then there are certainly less than five n because there are none of them. Then we find one a squared up to eight to the n minus one are all of order n. So all of order dividing n. And so there are n of these and there are most n elements of order dividing n. So these are all elements of order dividing n. In particular all elements of order n occur among these. And we notice that a i has order n if and only if i is co-prime to n. If i isn't co-prime to n then you can easily see that that a to the i has order less than n. So order is n is equivalent to saying that i is in z sorry that i is co-prime to n. So the number of elements of order n is just five n. Because this is the number of numbers co-prime to n. So we see that in fact we can say that z over pz star has either five n elements of order exactly n or it is none at all. So we can now do some counting to show the existence of a primitive root. So first of all we recall the following formula that the sum of d divides n of five d is equal to n. Now we're going to take the special case n equals p minus one and we get sum over d divides p minus one of five d is equal to p minus one. On the other hand let's count the number of elements in the group. So we know the sum of d divides p minus one of the number of elements of order d is also equal to p minus one. Because this is every element of z over p minus one z has some order d which must divide p minus one by Fermat's theorem. So this is just the order of z over pz star. Every element of order. So that should be z over pz star. It's isomorphic to the first group but I don't want to confuse them. Now we notice that these two sums are the same but if we look at this term here and this term here we notice that this term here is less than or equal to this term here because we just proved it on the previous sheet. Now if two sums are equal and every term in one sum is less than or equal to every term in the other sum all the terms must in fact be equal. So we say in fact equal as the sums are the same. So z over pz times has exactly five of d elements of order d whenever d divides p minus one. So it is five p minus one elements of order p minus one and these elements are the primitive roots. So it has primitive roots and in fact we can now calculate the number of primitive roots modulo p. It's just five p minus one. So let's give an example of this. So let's solve the following problem. How many solutions are there? Two, x cubed is common to one modulo 97 and the second problem is what are they? Well problem one, we want to solve x cubed is common to one mod 97. So we put x equals g to the k where g is a primitive root and at the moment we don't care what the primitive root is. So we want to solve g to the 3k is common to one mod 97 and this is equivalent to solving 3k is common to zero mod 97 minus one by the isomorphism between z modulo 96 and z modulo 97 star. Now solving 3k is zero mod 97 minus one is really easy. We just see that k is equal to 96 over three or zero or two times 96 over three which is zero, 32 or 64. So we can see there are three solutions and we can see there are three solutions with very little calculation. We just had to notice in fact the only thing we use is that 97 is one modulo three and this works for any prime that's one modulo three. There will always be three solutions to this. Now we have the problem. What are the solutions? Well for this we should find a primitive root and the easy way to find them a primitive root is to look them up in my book of primitive roots. So I actually have a book. Here we have the theory of numbers by Vinogradov and in the back of it he has this nice table, tables of primitive root. So for every prime he lists a primitive root and he lists the powers of that primitive root and he also lists the inverse of this. So here for instance for 37 a primitive root is two and two to the 23 for example is going to be five. And on the other hand if you want to know what the power of five, what you need to raise two to the power of to get 23, sorry to get five you look at in this table so you look up five and you see the answer is 23. So this is a sort of table of anti logarithms and this is a table of logarithms. Anyway let's go to the prime number 97. Let me magnify this a bit so you can actually see it. And you see from this that it says that five is a primitive root and here it gives the various powers of five. And we want five to the power of 32 and you see it says here that five to the power of 32 is 35 and five to the power of 64 is 61. So the solutions are five to the 32 equals 35 and five to the 64 which is equal to 61. I should say congruent to 61. So in the days before computers people actually wrote out these tables of primitive roots and used them to do calculations modulo p and you could use them to solve equations like that and so on. Okay so that settles the problem of primitive roots modulo p they always exist. In the next lecture we will discuss primitive roots modulo powers of p and also relate them to a theorem called Wilson's theorem.