 This lecture is part of Berkeley Math 115, an introductory undergraduate course on number theory, and we'll be more about primitive roots for numbers p to the n where p is an odd prime So I just recall what we where we got to at the end of the previous lecture What we were doing was we were trying to show that the only numbers with primitive roots were the numbers 1, 2, 4 p to the n and 2 p to the n for p an odd prime And we proved most of this we proved that numbers that weren't of this form didn't have primitive roots and We proved that numbers of this form had primitive roots provided n was equal to 1 So we've still got the case of p to the n where p is an odd prime And n is greater than 1 to talk about So what I want to do is to show that in these cases and there's always a primitive root And the first case is to show that p squared always has a primitive root and To do this We just pick Primitive root Let's call it g of p. We know that p has a primitive root by the previous lecture This means that g to the p minus 1 is common to 1 mod p and not for any smaller numbers and So phi of p minus 5 p is p minus 1 and phi of p squared is p times p minus 1 So the order of g is p minus 1 modulo p. So the order of g mod p squared is either p minus 1 or p times p minus 1 because it must divide P times p minus 1 by Euler and it must be divisible by p minus 1 because it's a primitive root mod p So if it's order is p times p minus 1 then g is a primitive root Mod p squared. So we're done So we've got to examine this case where the order of g mod p squared is p minus 1 So In this case we have g to the p minus 1 is congruent to 1 mod p squared now we look at g plus p and We notice that g plus p to the p minus 1 and which is equal to g to the p minus 1 plus P minus 1 times p here. We're expanding by the by the Taylor series So that's that's really p minus 1 choose 1. So we have p minus 1 choose 2 P squared plus higher powers. So this is congruent to 1 plus p minus 1 times p Mod p squared and we notice that this thing here is not congruent to 1 mod p squared. So this means that g plus p does not have order p minus 1. So it must have order P times p minus 1 because it's a primitive root modulo p. So either g or g plus p is a primitive root mod p squared It's quite possible that both of them are primitive roots mod p squared, of course But there's at least one. So p squared is okay. There's always a primitive root modulo p squared Now what about p to the n for n greater than or equal to 3? And this gets a little bit tricky because we notice that 2 cubed has no primitive root So we'd better explain why the prime 2 behaves differently from all the all the odd primes and here we have the following theorem if g is a primitive root mod p squared and p is an odd prime Then g is a primitive root mod p to the n for any n greater than or equal to 1 and The idea is we just use induction on n So we've got to show that it is a primitive root mod p to the n and it's a primitive root mod p to the n plus 1 So what we want to do we need to show that e to the p minus 1 times p to the n minus 1 equals 1 plus t times p to the n for some t not divisible by p because this will show that This Is a primitive root modulo p to the p to the n plus 1 So it holds or n equals 1 by Assumption because we assumed it's a primitive root mod p squared now we raise both sides the power of p and we get G to the p minus 1 to the p to the n And now we expand this by the binomial theorem So we get 1 plus p t p to the m plus p choose 2 T squared p to the 2 m plus higher powers And Now We use the fact that p is not to so this is divisible by p if He is greater than 2 if p equals 2 then there's a tool in the denominator which cancels it out and All these extra terms are divisible by a rather large power of p. So so this is of the form One plus t times p to the m plus 1 plus something Divisible by p to the n plus 2 so it's again of this form here So if you've got a primitive root modulo p squared Then it's also a primitive root modulo p cubed and p to the 4 and so and provide p is odd because if p is even We run into this problem that the binomial coefficient is not necessarily divisible by p So that's why things go wrong for p equals 2 There's a sort of technical point in the middle of the proof where you need to use the fact that p is odd So for example Let's find a primitive root or 3 to the 7 well we can start with a primitive root of 3 and the simplest primitive root of 3 is just minus 1 and The problem is this is not a primitive root of 3 squared and it only is order 2 So what we do is we take minus 1 plus 3 and then this is a primitive root mod 3 squared this is of course just 2 and so it's a primitive root mod 3 to the 3 to the 7 because once you found a primitive root modulo 3 squared It's automatically a primitive root modulo any power of 3 So let's just summarize everything we've proved or sort of proved so we have a big summary So the following are equivalent first of all m has primitive roots and We saw it if m has a primitive root then it has phi of phi of m primitive roots Otherwise it has so it either has phi or phi of m primitive roots or it has zero primitive roots And the third condition is that m is equal to 1 or 2 or 4 or p to the n or 2 p to the n Where p is an odd prime So that gives a an explicit description of everything the fourth condition is that Wilson is it is that x squared congruent to 1 Mod m implies x is congruent to plus or minus 1 mod m in other words There are only 2 or possibly 1 square roots of 1 and we sort of saw Sort of more or less prove this in the course of of finding all the numbers of primitive roots week we saw that If m has a primitive root then there can only be two solutions of this and Conversely, if there are any two solutions of this you see that m has to be one of these numbers that we've that we've checked And the fifth condition is that Wilson's theorem holds So Wilson's theorem says that if you take the product over all a such that a is co-prime to m This is over or all things modulo m such that a is co-prime to m then this is congruent to minus 1 Mod m and we recall we showed that this is actually equivalent to condition 4 If you want you can show directly that if m has a primitive root Then this product is congruent to minus 1 because the product is Over all the powers of a primitive root and you can easily work that out So the numbers that don't have this property so the numbers with this property are 1 2 3 4 5 6 7 8 doesn't 9 does 10 does 11 does 12 doesn't 13 does 14 does 15 doesn't 16 doesn't and so on so so um to start off with or almost all numbers do have primitive roots But the ones without primitive roots start becoming more and more common Um, there's one Sort of loose end. We haven't really talked about So you remember we can reduce the case of arbitrary m to the case of prime powers By using the Chinese remainder theorem for odd prime powers. We've shown there's a primitive root But what happens if we're working mod 2 to the n for n large? Well, it turns out there's something pretty close to a primitive root. So 5 is almost a primitive root More precisely um any number mod 2 to the n um co-prime To 2 to the n is of the form Plus or minus 5 to the 5 to the k So without this minus sign that would just say 5 was a primitive root because everything would be a power of it But but we in general we have to put a minus sign in um So um that the numbers of the form 5 to the k are the ones that are the form 1 mod 4 And the ones of the form minus 5 to the k are the ones that are minus 1 mod 4 So we sort of get a primitive root if we restrict numbers that are co-prime to 2 to the n and also congruent to 1 modulo 4 The proof of this is a little bit like the proof that We have a primitive root for odd prime numbers So we can say 5 is congruent to 5 mod 8 which is rather trivial 5 squared is congruent to 9 mod 16 5 to the 4 is congruent to 17 mod 32 5 to the 8 is congruent to 33 mod 64 and so on and you can sort of prove by induction that in general 5 to the 2 to the n is Is is congruent to 1 plus 2 to the n plus 2 modulo 2 to the n plus 3 And what this does is it shows that 5 has order 2 um the n plus 1 Modulo 2 to the n plus 3 so to order exactly this And that means that the numbers of the form plus or minus 5 to the n form 2 to the n plus 2 numbers mod 2 to the n plus 3 and as that's the number of things co-prime to 2 to the n plus 3 Every number co-prime to 2 to the n plus 3 is is either a power of 5 or minus a power of 5 So we've almost got a primitive root modulo 2 to the n except we have to add an extra sign in So what are some applications of primitive roots? Well primitive roots can be used to define logarithms Except logarithms and number theory are usually called indices So um, suppose we pick g is a primitive root mod mod p then any A not congruent to zero mod p is of the form Um G to the n Mod p so we can think of n is a sort of log to base g of of the number a So we can now use these sort of periodic logarithms or indices in much the same way that you use logarithms Um for ordinary arithmetic So if we want to multiply numbers suppose we want to multiply a times b If we work out the logarithm of a we can write a is equal to G to the n and we might might write b is equal to g to the m So a times b is equal to g to the m plus n So if you want to multiply numbers mod p, we take their logarithms add up the logarithms and Um, then take g to the power of that. Well, that seems a bit silly But I'm in the days before computers. It was actually quite a neat way of multiplying numbers and some old Books on number theory would sometimes contain tables of logarithms and indices. So I've actually got a picture of one here um, so this is the nobredov's book on number theory and at the end he's got this table of indices which tells you the um the sort of logarithm of a number two to the base of some primitive root and he also um, so there's a table of indices and Um, there's also a table of that the smallest primitive root of various primes So, um, if you look through it, you can see the smallest primitive root is usually fairly small It's usually less than 10 for small primes. Well, there's an example where it's 19 So it occasionally gets a bit big But if you go all the way up to prime top to about 4,000 it doesn't get much bigger than that So there's one that's equal to 22 Um, there's one that's 23, but I can't see any bigger than that So the the smallest primitive root is usually pretty small. In fact, there's a I'm judging from this table. There's a pretty good chance the smallest primitive root is two or three Um, so you can also do things like work out powers as well as multiply things If we want to work on a to the k Then this will be just g to the n Um, to the k which is equal to g to the n k So you work out n, you multiply it by k, and then you then you Look that's up on your table of anti logarithms. Sorry, I forgot to Um, magnify down. So so I was just saying to work out a to the k You just write it as g to the power of n to the power of k Um, um, so Um, another application is to prove that a number is prime So most of you've got a very large number p and we've done some primality tests And we we've we've decided it's probably prime according to these primality tests But say we were a bit paranoid and we would like to be absolutely certain that it's prime Um, well there are some um algorithms that will actually do that, but they're a bit complicated So here's a simple test if we can factor p minus 1 explicitly then then it's quite easy to prove p is prime So we can find A primitive root Of p. So that's a number a That's called. No, that's a number g of order p minus 1 and we can prove that it's of order p minus 1 we just check g does not have order dividing p minus 1 over q where q is a prime factor of p minus 1 So we just have to look at all the numbers g to the p minus 1 over q for q a prime q divides p minus 1 and just check that this is not congruent to 1 Modulo p. So if we find a number g with this property Then this implies that g has ordered exactly p minus 1 um, so This would imply that p must actually be prime. For example Suppose you want to check that 101 is prime when we factor 101 minus 1, which is 2 squared times 5 squared. So we just need to find g such that g to the 100 over 2 is not congruent to 1 and g to the 100 over 5 is not congruent to 1 And this will then show that g has order 40 and so is a primitive root Of course, I should have said we we also need to check that g to the 100 is congruent to 1 but if it isn't congruent to 1 then we would have shown that 101 isn't prime So we would be done So we just need to check these and then we've got a complete proof that 101 is prime Of course for 101 that's a Bit silly but for larger numbers this can actually be used to give primality proofs I must admit this is not a terribly good method because it relies on factoring p minus 1 And factoring p minus 1 is rather difficult There are faster, but rather more complicated ways to prove that numbers really are prime Um, okay, I think that'll be all about primitive roots