# Chapter 1: Introduction to Software # # # The main purpose of this section is to give you a chance to practice # using Maple. # It has several functions which are relevant to this section. For # making computations # in the integers modulo n there is a built-in function modp. Thus # > modp(25+87,13); 8 # # and # > modp(2^12,7); 1 # # For any real number a the function evalf(a,m) will compute the first m # digits of a. # For example, # > evalf(1/7,20); .14285714285714285714 # # So we see that the period of 1/7 is 1,4,2,8,5,7 as discussed above. # Similarly # > evalf(1/19,40); .05263157894736842105263157894736842105263 # # Thus the period of 1/19 is 0,5,2,6,3,1,5,7,8,9,4,7,3,6,8,4,2,1 which # has length 18. And # > modp(10^18 - 1, 19); 0 # # but for smaller k , > 10^k-1;# is not congruent to 0 mod 19. We can do these calculations # for all the primes less than 30 say, and tabulate the results. They # confirm theorem 1.3. # Interestingly # # 1001 = > 10^3;# + 1 = 7*11*13 , # # so that # > 10^3;# + 1 = 0 mod 7 . # # Similarly, # > modp(10^9 + 1, 19); 0 # # What do you think is going on? Experiment a bit and try to make a # conjecture. # # Given a pair of integers a and b, the function igcdex will compute (a, # b) and # integers s and t such that (a, b) = as + bt . For example, # > igcdex(57,21,'s','t'); 3 > s;t; 3 -8 # # This means that 3 = 3*57 - 8*21 . If we want to find the # multiplicative # inverse of 105 in > F[197];# , we can enter # > igcdex(105,197,'s','t'); 1 > s;t; -15 8 # # So 1 = -15*105 + 8*197 and -15 = 182 is the multiplicative inverse # of 105 . # # In the package NumberTheory`NumberTheoryFunctions` there is a function # called # chrem which will solve two such congruences simultaneously. In fact it # will solve a # system: you simply enter # > chrem([b1, ..., br], [n1, ..., nr]); # # So in our example: # > chrem([14,6],[24,31]); 254