 Welcome back. We are looking at the theorem of Lagrange that if you take z by Pz and take a polynomial of degree D with coefficients coming from z by Pz then there are at most D roots. This is a result that we have looked just towards the end of the last lecture. So here is the result. A polynomial of degree D over Zp has at most D roots in Zp and we have also noticed these two remarks that the number of roots can of course be smaller than D and it is also essential then that we work modulo prime. So just to recall it for you I will make it clear that here you can take the example of x to the 4 plus 1 and you can take this example where P is 3. So here there is a polynomial of degree 4 and in Z 3 there are no roots at all or you may also take P equal to 7 even in 7 Z modulo 7 Z we have no root at all for x to the 4 plus 1. This is like saying that minus 1 is a fourth power. If you had any solution to this polynomial any root of this polynomial would give you a raise to 4 is minus 1 modulo 7 minus 1 is 6 modulo 7. So this would say that 6 is a fourth power modulo 7 but once is by computing squares that 6 is not even a square. So we do not get any root here and therefore the number of roots is indeed less than degree which is that 0. Whereas if you do not work modulo a prime and then we have seen that x to the 2 which is x square minus 1 modulo 8 has 4 roots. So this number is bigger than the number of degree this is your number of roots and the D here is 2 which is less than 4 which is the number of roots. So to have Lagrange's theorem it is essential that you work modulo a prime and not modulo a composite number. So let us go about proving this result the proof is not very difficult it is quite easy but before we prove this let me just remark one thing. So suppose I start with a polynomial f of degree D so what we have is we have it to be x ad x to the d plus a d minus 1 x raise to d minus 1 plus dot dot dot a 1 x plus a 0. This is a polynomial that we have and assume that we have some element in Z p then f x minus f a is x minus a into g x where g is a polynomial degree D minus 1. This is something which holds in general this is because what we have is that we have f x which is given by this formula and then f a would be also given similarly you will have a d a power d plus a d minus 1 a power d minus 1 plus dot dot dot plus a 1 a plus a 0. So recall here that these a i are taken as coefficients they are elements in Z p there is no relation between a i and a that is something that we should not forget about. So when you take the differences you will look at ad x power d minus ad a power d and this can be written as ad x minus a into a polynomial e in degree d minus 1. Similarly you will have this the difference of ad minus 1 x minus a into a polynomial of degree d minus 2. So what we are really looking at this at this point is that x to the i minus a to the i is x minus a x raise to i minus 1 and then you have some terms here and finally you will have a power i minus 1. This is the polynomial that we will look at this is the polynomial which is x power i minus a power i upon x minus a. So combining all these polynomials for different degrees will give you the polynomial g x this is what we get. So the most important thing for us from this point is this point that f x minus f a is actually a x minus a into g x where g has to be a polynomial of degree d minus 1 because if f is your polynomial of degree d minus 1 then that will tell you that a sub d has to be non-zero this is not equal to 0 and it is the same coefficient that you are going to get here when you look at the d minus 1 coefficient it is the same coefficient that you have. So g is also a polynomial of degree d minus 1 this is the most important thing that we need to remember. So f x minus f a is x minus a into a polynomial g x where g is a polynomial degree d minus 1. So we have one less degree for g than the degree of f. Now so assume that as a root in Zp call it alpha. So we have an element alpha in Zp with the property that f alpha is 0 and then by applying this result where you put a equal to alpha what we get is f x equal to x minus a into some polynomial of g x where degree g is d minus 1 this is because instead of f a we will get 0 there. So this f alpha equal to 0 this is the thing which we put here and so on this side we get only f x we do not get f x minus some constant that constant is 0. So on the left hand side we simply get f x. So this is only f x and on the right hand side we have x minus alpha into g x. So what this tells us is that whenever we have a root for the polynomial f then x minus alpha divides the polynomial f. You can actually write f x as x minus alpha into another polynomial of smaller degree. This is the thing that we need to take ahead from this second slide that f x is now x minus alpha into g x where you have f alpha to be 0. So if alpha in g p is a 0 of f then f x equal to x minus alpha into g x. Now suppose that there is one more root beta. So if beta in g p beta not equal to alpha is a root f then f beta is 0 which implies that alpha minus beta or actually you will have beta minus alpha g beta equal to 0. But since you have that beta is not equal to alpha that tells you that this is non-zero and if this is non-zero what we should get is g beta equal to 0. What is happening here is that we are looking at elements in g p z by p z and once you put these values in the polynomial the g beta or beta minus alpha these are all elements in z by p z and these are all represented by natural numbers. So actually these are looking these are some natural numbers and we are simply going modulo the prime p that is what we are doing. So when we say that some product is 0 then it tells us that p divides the product because something is 0 in z modulo p z only means that when you divide by p the remainder is 0 that means p divides that natural number. But p being a prime has the property that when p divides a product of two numbers p has to divide one of the two and therefore if one of them is not 0 modulo p. So here beta minus alpha is not 0 in z p that means p does not divide beta minus alpha but p divides the product of beta minus alpha into g beta. So p has to divide the other thing which is g beta and therefore g beta has to be 0. So we get that if you have any such other root then beta is a root of g. Now g is of degree d minus 1 and we apply induction hypothesis we will start our induction with polynomials of degree 1 which are linear polynomials and those we have already observed that a linear polynomial where the coefficient of x is not 0 gives you a unique root. So the result is true for degree equal to 1 and then we apply induction hypothesis to the polynomial g g has degree d minus 1 and the polynomial and degree d minus 1 can have at most d minus 1 roots. Together with the root alpha which might also be a root of g in that case we will not have to count alpha separately but even if alpha is not a root of g you may have to just add that single root. So whenever you are counting the distinct roots of the polynomial f you are looking at the distinct roots of the polynomial g once you have taken one root alpha out and then you add this single root alpha to the list of the roots of g. So by induction hypothesis g has most d minus 1 roots and hence f has at most d roots that completes the proof. So you may wonder where does this proof fail when you have a modulus which is not a prime when you have a composite modulus and the point is exactly that you may have 8 for instance where we had 4 roots for it. 8 divides product of 2 but when it 8 does not divide 1 it does not imply that 8 divides the other one. So check this as a basic exercise check where this fails. So we have proved Lagrange's theorem which says that whenever you have a polynomial of degree d over the z by pz then such a polynomial can have at most d roots and when we are saying at most d roots we are counting the roots distinctly. If the roots come with multiplicity then of course this number will further go down but let us not worry about that. There is one very nice corollary of this result. So let us see this corollary. The corollary says that if you have a polynomial in degree d with coefficients coming from integers and suppose modulus sum prime you have the number of zeros to be more than d then p must divide ai for every i. So first of all we are starting with a polynomial which is defined over integers or you may also take a polynomial over natural numbers but integers is more desirable and then we look at modulo sum prime p. So p is a prime and suppose that the number of zeros is more than d then what we should get is that p divides the coefficients for all i. This is the basic statement which we would now like to prove. So consider the polynomial f tilde by reducing each ai mod p. So we will have a polynomial f tilde x which is given by ad x power d plus dot dot dot plus a1 x plus a0 but we are looking at not necessarily the ai but ai tilde where the ai tilde are congruent to ai mod p and you may assume that your ai tilde are between 0 to p. So we now have a polynomial over zp. We have a polynomial over the set z by pz and here by our assumption we have more than d roots. This is what we have seen that there are more than d0. So this f tilde has more than d roots in zp. So what is going wrong? Lagrange's theorem told us that whenever you have a polynomial of degree d it can have at most d roots. It seems that here we have a polynomial of degree d. We have this polynomial ad tilde x power d plus the next coefficient will be ad minus 1 tilde x power d minus 1 plus dot dot dot plus a1 x a1 tilde x plus a0 tilde. So since we have a polynomial of degree d it should have at most d roots but our assumption says that we are getting more than d roots. So what must be happening is that Lagrange's the hypothesis in Lagrange's theorem must not be satisfied. So there are many hypothesis has many parts. Let us go from the last part. The last part was that we are working modulo a prime that is certainly true here. We are looking at the prime p and we are working modulo p. So that is alright. Then we go further and we see that the hypothesis says that you have a polynomial of degree d. Somehow this must not be true. But clearly we have something of the type ad tilde x power d plus dot dot dot. How does a polynomial of degree d look if not like this? So if you are saying that this is not a polynomial of degree d then what must happen is that the coefficient of x power d must not be a non-zero element. Because if that is a non-zero element then it is a polynomial of degree d and then we get a contradiction somehow. So the ad tilde should not be 0, should not be non-zero. Ad tilde should be 0 which means that p will divide ad tilde but ad tilde is congruent to ad modulo p so p will divide ad. Once you have that ad tilde becomes 0 modulo p the degree of the polynomial has reduced. And if any ai tilde had been non-zero modulo p you would get a polynomial of degree smaller than d and again the fact that the number of roots is more than p d would give you a contradiction. So what must happen therefore is that every coefficient must be divisible by p. So then p divides ai tilde for each i and hence p divides ai for each i. The only way a polynomial which is defined over natural numbers has more than d roots over a prime p will be where the polynomial when reduced to z by pz gives you a 0 polynomial and that would happen exactly when the prime p divides all the coefficients of the polynomial and that is what we have. So the corollary says that if you have a polynomial of some degree d and modulo some prime you have more than p roots d roots then the prime p should divide the all the coefficients of the polynomial f. We will this is a very pretty corollary. There are many nice applications of this. We will see some of these applications when we go to assignments but right now I will go ahead and prove one small result which is called Fermat's last Fermat's little theorem. This is also pronounced as fl t. This is also short form as fl t but this is not that famous fl t which was the Fermat's last theorem. This is the Fermat's little theorem. What does this theorem say? The theorem says that if you have any non-zero element in zp then raising that element to the power p minus 1 will give you 1. That is a very remarkable. You take any prime just compute p minus 1 and then for any non-zero number. For 0 of course you raise it to any power and you are going to get 0. You will not get 1 but if you raise any non-zero number to the power p minus 1 then you will get only 1. You are not going to get any other answer. So let us see one basic proof. There are several proofs of this. If you happen to know group theory then there is a quick proof which would come. The proof if I can just tell you orally would be this that the integers co-prime to p form a group under multiplication because when you have a and b in zp and both a and b are non-zero then the product is also non-zero. Return in other way whenever ab is 0 then a is 0 or b is 0 modulo p. So if you are taking both a and b to be non-zero the product is going to be non-zero. Therefore the set of the natural numbers from 1 to p minus 1 is closed under the product taken modulo p. Whenever you take product of any 2 you get it to be a non-zero element. So it is again an element from 1 to p minus 1 and this is a group because every element has an inverse and then the order of this group is p minus 1 and this is the basic fact from group theory that any element to raised to the order of the group will give you 1. So that tells that a power p minus 1 is 1 modulo p but since we are doing number 3 there are some nice number theoretic proofs. So consider this set 0, 1, 2, 3 dot, dot, dot up to p minus 1. You will immediately recognize that this is nothing but gp with respect to addition and product modulo p. This is the set gp that I have listed further since a is not 0 and it is an element in gp. What we get is that ai equal to aj for ij in gp gives i equal to j. You can cancel a from both the sides. So this tells you that ai is congruent to aj modulo p but since a and p are co-prime you can simply cancel a from both the sides and that will give you that i is j and therefore if I write the elements a into 0 which is actually 0, a into 1, a into 2, dot, dot, dot all the way up to a into p minus 1 then I am going to get once again p elements. The cardinality of this set is equal to p. We are going to get different p elements. So thus the non-zero elements these sets 1 or you may just consider you will have the sets i where you have 0 less than or equal to i less than p and a into i. The non-zero elements in both these sets are the same and hence when I take the product of all these numbers so I have 1 into 2 into 3 and I take the product up to p minus 1 I am going to get a into 1 into a into 2 into a into 3, dot, dot, dot a into p minus 1. On both the sides we should get the same number because these are all the non-zero elements coming from these two different sets. So when I have two sets and I am taking the non-zero elements in those two sets and take the product if these numbers themselves are same perhaps they will be permuted when I multiply by a but the set the numbers as a set are same then the product should give me the same value. So here we know this is congruent to minus 1 modulo p so this is in particular not 0 and here I can take a common from each term I will get it to be p minus 1 and I once again remember this is p minus 1 factorial and here I am getting the same number. So by cancelling the number p minus 1 factorial which is a non-zero number we get that 1 has to be equal to so we get that p minus 1 factorial is equal to a raise to p minus 1 into p minus 1 factorial but since this is equal to minus 1 which is not a 0 quantity we simply cancel it out to get that a raise to p minus 1 is 1 in Zp which is to say that a raise to p minus 1 is congruent to 1 modulo p. So it is a very beautiful small fact and this such a fact actually tells you whether a number can be prime or not because if you take some number 8 for instance and you raise some element to 7th power and you do not get the congruent to be 1 modulo 8 then of course your 8 cannot be prime. So for big numbers this is quite a useful test of primality that you take a number from 1 to n minus 1 and raise that number to the power n minus 1 if the result modulo n is not 1 modulo n then your number n cannot be a prime. However as fate would have it there are some naughty composite numbers n which satisfy Fermat's little theorem we will have to treat with them separately that is not part of our course we will perhaps talk about them in the next lecture but only to give you information about it. So I hope to see you in our next lecture. Thank you.