{VERSION 4 0 "APPLE_PPC_MAC" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 35 "" 0 1 104 64 92 1 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 270 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 271 "" 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0 0 0 0 0 0 }{CSTYLE "" -1 374 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 375 "" 0 1 0 0 0 0 1 2 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 376 "" 0 1 0 0 0 0 0 2 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 377 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 378 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 379 "" 0 1 0 0 0 0 0 2 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 380 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 381 "" 0 1 0 0 0 0 0 2 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 382 "" 0 1 0 0 0 0 0 2 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 383 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 1 " -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Bullet Item" -1 15 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 3 3 1 0 1 0 2 2 15 2 }{PSTYLE "Author" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 8 8 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 259 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 260 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 }} {SECT 0 {EXCHG {PARA 3 "" 0 "" {TEXT -1 33 "Section 28. Introduction t o Maple" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 240 "Maple can be used to \+ do calculations in calculus, linear algebra, algebra, differential equ ations and many other areas of mathematics. Here we just concentrate o n the use of Maple in number theory. For more about Maple go to my hom epage at " }{TEXT 272 32 "http://www.math.usf.edu/~eclark/" }{TEXT -1 40 " and follow either or both of the links" }{TEXT 273 46 " Symbolic Computations in Mathematics COP 4313" }{TEXT -1 5 " and " }{TEXT 303 14 "Maple Links.\n\n" }{TEXT -1 45 "In the USF computer labs you will \+ find either" }{TEXT 309 9 " Maple V " }{TEXT -1 2 "or" }{TEXT 310 10 " Maple 6. " }{TEXT -1 64 "You may use either one.This worksheet was pr epared with Maple 6." }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 34 "Getting \+ Started - Basic Arithmetic" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "When you click on the Maple Icon you Maple will open up as a " }{TEXT 256 9 "worksheet" }{TEXT -1 58 ". To use Maple you type in a command or ex pression at the " }{TEXT 257 6 "prompt" }{TEXT -1 138 ", [ > . Be sur e to put a semicolon at the end of the line. Then press the return key and you will see the result. Here are some examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "2+2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "2-4;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "2*3; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "2^2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "2^4;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "2^1000;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "1123^141; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "12/3;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "2/997;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "evalf(2/997);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "evalf(2/987,100);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "sqrt(9);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "sqrt(3);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "evalf(sqrt(3));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "floor(997.333);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "floor(sqrt(3));" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 19 "floor(sqrt(12345));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "Sometimes we must apply " }{TEXT 326 5 "evalf" }{TEXT -1 29 " to make floor work properly." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "floor(sqrt(2^100 + 1));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "floor(evalf(sqrt(2^100 + 1)));" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 14 "ceil(sqrt(3));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "ceil(5.888);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 12 "Getting Help" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 141 "One can obtain information about various Maple functions by one of several ways. \n \n1. One way is to got to the pull down menu and look under " }{TEXT 299 4 "Help" }{TEXT -1 97 " for one of the various choices for getting help given there. I will illustrate the use in class." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 94 "2. Type a question m ark followed by a command you want to know more about. Here is an exam ple:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "?factor\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 10 "Note that " }{TEXT 300 6 "factor" }{TEXT -1 52 " is used to factor polynomials and not integers -- " }{TEXT 301 7 "ifactor" }{TEXT -1 31 " is used to factor an integer.\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "?ifactor" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 79 "3. Highlight a word you are interested in and go t o the Help pull down menu to " }{TEXT 302 16 "Help on Context." } {TEXT -1 46 " This will bring up the help page on the item." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 157 "4. If you have special difficulties with some aspect of Maple when working the exerc ises you may sent me an email including the program. My email address \+ is " }{TEXT 304 20 "eclark@math.usf.edu " }{TEXT -1 175 "It is possibl e to send me your worksheet as an attachment. If you do please try to \+ indicate carefully exactly what the problem is. Also give the workshee t a name of the form " }{TEXT 305 14 "john_doe.mws " }{TEXT -1 29 "N ote that it should end with " }{TEXT 306 4 ".mws" }{TEXT -1 43 " and t here should be no spaces in the name." }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 29 "Basic Number Theory Functions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 118 "Now we illustrate some \+ number theory functions. Some of these require loading the Maple numb \+ er theory package called " }{TEXT 258 9 "numtheory" }{TEXT -1 30 ". Th is is done by the command " }{TEXT 259 17 "with(numtheory); " }{TEXT -1 201 "To keep from having to remember which require the package and \+ which do not, since this is a number theory course, we load the packag e to begin with. Note that only the commands listed after we execute \+ " }{TEXT 260 16 "with(numtheory);" }{TEXT -1 73 " require it. The oth er commands we use can be used without this command." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "with(numtheory);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "ifactor(1234567);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "127*9721;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "ifactor(2^32 + 1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "10 mod 7;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "-1 mod 10;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "2^340 mod 341;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "10 + 5 mod 3;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "10 + (5 mod 5);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "\nComputing the inverse of an integer a modulo m is very \+ simple in Maple:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "1/385 m od 37981;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 15 "Let's check it:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "385*20125 mod 37981;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "Note that if gcd(a,m) > 1 then the inverse of a modulo m does not exist:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "1/25 mod 1005;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "The command " }{TEXT 327 8 "irem(a,b" }{TEXT -1 66 ") gives the re mainder when a is divided by b. This is the same as " }{TEXT 328 9 "a \+ mod b. " }{TEXT -1 12 "The command " }{TEXT 329 9 "iquo(a,b)" }{TEXT -1 42 " give the quotient when a is divided by b." }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 21 "irem(14,4);\n14 mod 4;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "iquo(14,4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "4*iquo(14,4) + irem(14,4);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 164 "Be careful what you ask Maple to factor. If you ask it to factor a very large number you will have to wait a long time for t he result -- if it finally comes at all." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "divisors(6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "convert(\{1,2,3\},`+`);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "isprime(10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "ispri me(2^7-1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "isprime(2^11- 1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "isprime(2^32 + 1);" }}}{EXCHG {PARA 15 "" 0 "" {TEXT -1 13 "The function " }{TEXT 261 3 "p hi" }{TEXT -1 3 " , " }{XPPEDIT 18 0 "phi;" "6#%$phiG" }{TEXT -1 126 " , will compute the totient function of n, which is the number of posit ive integers not exceeding n and relatively prime to n. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "phi(12);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 12 "phi(123456);" }}}{EXCHG {PARA 15 "" 0 "" {TEXT -1 13 "The function " }{TEXT 35 7 "pi(n), " }{XPPEDIT 18 0 "pi(n);" "6#-% #piG6#%\"nG" }{TEXT -1 83 ", will compute the number of prime numbers \+ less than or equal to the given integer " }{TEXT 35 1 "n" }{XPPEDIT 18 0 "" "6#%#%?G" }{TEXT -1 2 ". " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "pi(2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "pi (3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "pi(4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "pi(1000);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "pi(10000);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "pi(10^6);" }}}{EXCHG {PARA 15 "" 0 "" {TEXT -1 13 "The function " }{TEXT 262 5 "sigma" }{TEXT -1 6 "(n) , " }{XPPEDIT 18 0 "sigma(n); " "6#-%&sigmaG6#%\"nG" }{TEXT -1 54 ", will compute the sum of the pos itive divisors of n. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "di visors(6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "sigma(6);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "sigma(6) - 6;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "sigma(28) - 28;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "2^6*(2^7-1); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "sigma(8128) - 8128;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 13 "The function " }{TEXT 263 3 "tau" }{TEXT -1 6 "(n) , " } {XPPEDIT 18 0 "tau(n);" "6#-%$tauG6#%\"nG" }{TEXT -1 52 ", will comput e the number of positive divisors of n." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "divisors(12);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "tau(12);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "divisors (123456789);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "tau(1234567 89);" }}}{EXCHG {PARA 15 "" 0 "" {TEXT -1 36 "The nth Fermat number is 2^(2^n)+1. " }}{PARA 15 "" 0 "" {TEXT 274 8 "fermat(n" }{TEXT -1 45 " ) returns the nth Fermat number, for n < 20. " }}{PARA 15 "" 0 "" {TEXT -1 76 "For any non-negative integer n and unassigned variable w, the function call " }{TEXT 275 11 "fermat(n,w)" }{TEXT -1 108 " assig ns to w the information which is known (at the time of writing this fu nction) about the Fermat number " }{TEXT 322 9 "fermat(n)" }{TEXT -1 59 ". This information consists of: the primality character of " } {TEXT 276 9 "fermat(n)" }{TEXT -1 82 " (prime, composite or unknown), \+ and, if it is composite, any known prime factors. " }}{PARA 0 "" 0 "" {TEXT -1 3 "If " }{TEXT 277 6 "fermat" }{TEXT -1 149 " is invoked with no arguments, it returns a list of all Fermat numbers whose primality status is known as of the time when this function was written." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "fermat();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "fermat(4, w1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "w1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "fermat(5,w2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "w2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "fermat(9,w3); w3;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "fe rmat(10,w7); w7;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "fermat( 23471,w5); w5;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 4 "The " }{TEXT 269 9 "nextprime" }{TEXT -1 64 " function returns the smallest prime t hat is larger than n. The " }{TEXT 270 9 "prevprime" }{TEXT -1 56 " fu nction returns the largest prime that is less than n." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "nextprime(2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "nextprime(3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "prevprime(5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "nextprime(1000000);\nprevprime(1000000);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "nextprime(10^100);\nprevprime(10^100);" }}} {EXCHG {PARA 15 "" 0 "" {TEXT -1 13 "The function " }{TEXT 278 8 "ithp rime" }{TEXT -1 67 " returns the ith prime number, where the first pri me number is 2. ." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "ithpri me(1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "ithprime(2);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "ithprime(100);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "ithprime(10000);" }}}{EXCHG {PARA 15 "" 0 "" {TEXT -1 13 "The function " }{TEXT 279 8 "mersenne" }{TEXT -1 75 " will compute the nth Mersenne prime. If the argument n is an i nteger then " }{TEXT 268 11 "mersenne(n)" }{TEXT -1 13 " will return \+ " }{TEXT 266 5 "2^n-1" }{TEXT -1 4 " if " }{TEXT 267 5 "2^n-1" }{TEXT -1 91 " is known to be prime. Otherwise, if n is prime, but 2^n-1 is n ot determinably prime, then " }{TEXT 271 11 "mersenne(n)" }{TEXT -1 13 " will return " }{TEXT 264 4 "FAIL" }{TEXT -1 44 ". Finally, if n i s composite it will return " }{TEXT 265 5 "false" }{TEXT -1 2 ". " }} {PARA 15 "" 0 "" {TEXT -1 61 "If the argument is a list with one integ er element [i], then " }{TEXT 280 13 "mersenne([i])" }{TEXT -1 130 " w ill return the ith Mersenne prime. If the value is beyond Maple's prec omputed list of Mersenne primes, an error will be issued. " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "mersenne(2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "mersenne(3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "mersenne(456);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "mer senne(11);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "isprime(2^11- 1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 64 "Now we assign to p the val ue of the smallest prime greater than " }{XPPEDIT 18 0 "10^20;" "6#*$ \"#5\"#?" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "p:=nextprime(10^20);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "me rsenne(p);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "mersenne([1]) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "mersenne([2]);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "mersenne([3]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "q:=mersenne([10]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "ifactor(q+1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "q - (2^89 - 1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "mersenne([38]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "We can compute the gcd by use of the command " }{TEXT 307 6 "igcd: " }{TEXT -1 80 "Note that the computation of the gcd is very fast. Ev en for very large integers." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "igcd(12,15);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "igcd(2^ 10000 - 1,2^11000 -1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 22 "Homework Assignment #1" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 317 10 "p roblem 0." }{TEXT -1 42 " Open a new Maple worksheet. Click on the " } {TEXT 308 1 "T" }{TEXT -1 156 " on the menu bar. This will allow you t o insert text. Next go to the pull down menu on the left side where it says P Normal. Pull this down till you get to " }{TEXT 311 7 "Title. \+ " }{TEXT -1 9 "Now type " }{TEXT 312 25 "Homework Assignment # 1. " } {TEXT -1 72 " Then hit return and type your name. Then click on the bu tton that says " }{TEXT 313 2 "[>" }{TEXT -1 32 " on the menu bar. Nex t click on " }{TEXT 314 1 "T" }{TEXT -1 16 " again and type " }{TEXT 315 9 "problem 1" }{TEXT -1 16 ". Now click on " }{TEXT 316 3 "[> " } {TEXT -1 19 " again. Then solve " }{TEXT 324 9 "problem 1" }{TEXT -1 60 " the next problem. Similarly label each problem in this way." }} {PARA 0 "" 0 "" {TEXT -1 1 "\n" }{TEXT 318 12 "problem 1. " }{TEXT -1 83 "Use maple to find a prime p larger than 1,000 and determine if \+ the Mersenne number " }{XPPEDIT 18 0 "2^p-1;" "6#,&)\"\"#%\"pG\"\"\"F' !\"\"" }{TEXT -1 17 " is prime or not." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT 319 9 "problem 2" }{TEXT -1 39 ". Find the \+ greatest common divisor of " }{XPPEDIT 18 0 "2^12345-1;" "6#,&*$\"\"# \"&XB\"\"\"\"F'!\"\"" }{TEXT -1 9 " and " }{XPPEDIT 18 0 "2^54321- 1;" "6#,&*$\"\"#\"&@V&\"\"\"F'!\"\"" }{TEXT -1 3 ".\n\n" }{TEXT 320 11 "problem 3. " }{TEXT -1 84 " Find the number of primes that contai n exactly 5 digits. Hint: The answer will be " }{XPPEDIT 18 0 "pi(a)-p i(b);" "6#,&-%#piG6#%\"aG\"\"\"-F%6#%\"bG!\"\"" }{TEXT -1 41 " for app roiately chosen integers a and b." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 321 11 "problem 4. " }{TEXT -1 38 " What is know about the Fermat number " }{XPPEDIT 18 0 "2^(2^30)+1 ;" "6#,&)\"\"#*$F%\"#I\"\"\"F(F(" }{TEXT -1 1 "?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 323 11 "problem 5 . " }{TEXT -1 35 "How many elements are in the group " }{XPPEDIT 18 0 "U[n];" "6#&%\"UG6#%\"nG" }{TEXT -1 20 " where n = 270270.\n\n" } {TEXT 325 11 "problem 6. " }{TEXT -1 47 " Find the factorization of th e Mersenne number " }{XPPEDIT 18 0 "2^100-1;" "6#,&*$\"\"#\"$+\"\"\"\" F'!\"\"" }{TEXT -1 1 "." }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 21 "Assi gnment Statements" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 17 "An example of an " }{TEXT 281 10 "assignment" }{TEXT -1 1 " " } {TEXT 282 9 "statement" }{TEXT -1 4 " is:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 5 "x:=2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 23 "This h as the effect of " }{TEXT 286 9 "assigning" }{TEXT -1 11 " 2 to the \+ " }{TEXT 285 8 "variable" }{TEXT -1 49 " x. To see what x is we do the following command:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x;" } {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 17 "You may use as a \+ " }{TEXT 283 8 "variable" }{TEXT -1 5 " (or " }{TEXT 284 4 "name" } {TEXT -1 196 ") any letter followed by a list of numbers or letters wi th no spaces. And note that Maple is case sensitive, that is, it disti nguishes between lower and upper case letters. Here are some examples. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "var:=2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "x*var;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "x1:=7;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "va r1:=10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "x1*var1;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "Some example of use of the assignm ent statement." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "bigprime: =nextprime(10^100);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "litt leprime:=prevprime(10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 " m:=bigprime*littleprime;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "ifactor(m);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "floor(evalf (sqrt(m)));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 24 "Colons versus Semicolons" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 297 "If an assignment statement or other type of st atement is followed by a colon then the output is suppressed. If a sta tement is followed by a semicolon the output is shown if there is any. In some case there is no output. This may happen if Maple is unable t o perform some operations. Some examples:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 6 "x:=22:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 " x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "var1:=5:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "var2:=100;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "var1*var2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "p:=nextprime(10^60):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "isprime(p);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "p;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 91 "This is useful when you don't want to see the output. It may be too large to be meaningful." }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 26 "The for..do..od; Statement" }}{EXCHG {PARA 0 " " 0 "" {TEXT -1 154 "The for..do statement is best explained by exampl es. Here's a simple example: Note that when typing such statements af ter typing the first line hold the " }{TEXT 288 5 "shift" }{TEXT -1 27 " key down while hiting the " }{TEXT 287 6 "return" }{TEXT -1 69 " \+ key. This will suppress the prompt on the next line. Continue using " }{TEXT 289 14 "shift + return" }{TEXT -1 45 " till you do the last lin e and then just use " }{TEXT 290 6 "return" }{TEXT -1 2 ". " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "for j from 1 to 10 do \n p: =ithprime(j):\n print(`The`,j,`-th prime is `,p);\nod:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 2 "A " }{TEXT 293 7 "repunit" }{TEXT -1 161 " is a number whose decimal representations uses only the digit 1. For \+ example, 1, 11, 111, 1111, 11111, and 111111 are repunits. An n digit \+ repunit has the form " }{XPPEDIT 18 0 "(10^n-1)/9;" "6#*&,&)\"#5%\"nG \"\"\"F(!\"\"F(\"\"*F)" }{TEXT -1 94 ". It is an interesting open prob lem to determine which repunits are primes. Let's check a few:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 70 "for n from 2 to 20 do\n k:= (10^n-1)/9:\n print(n, k, isprime(k));\nod:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 160 "So we found only 11 and the one with 19 ones. The res t up to length 20 are all composite.\n\nOne can also have loops inside of loops. As in the following example:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 85 "for i from 2 to 4 do\n for j from 2 to 4 do\n prin t(i,j, `--`, igcd(i,j));\n od;\nod;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "Let's find the perfect numbers less than or equal to 10000:" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 76 "for n from 2 to 10000 do\n \+ if sigma(n) - n = n then \n print(n);\n fi;\nod:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 28 "The if.. then..fi; Statement" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 28 "Consider once more the loop:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "for j from 1 to 10 do \n \+ p:=ithprime(j):\n print(`The`,j,`-th prime is `,p);\nod:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 115 "Suppose I want to exit this \"loop\" as \+ soon as I get a prime greater than 10. We can use the conditional stat ement " }{TEXT 291 14 "if..then...fi " }{TEXT -1 18 "together with th e " }{TEXT 292 5 "break" }{TEXT -1 23 " statement--as follows:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 108 "for j from 1 to 10 do \n p :=ithprime(j):\n if p > 10 then break; fi;\n print(`The`,j,`-th prim e is `,p);\nod:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "Suppose we wan t to find the Mersenne primes " }{XPPEDIT 18 0 "2^n-1;" "6#,&)\"\"#%\" nG\"\"\"F'!\"\"" }{TEXT -1 42 " for n up to 100. Here's one way to do \+ it:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 71 "for n from 2 to 100 \+ do\n if isprime(2^n-1) then print(n,2^n-1); fi;\nod;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 113 "Let's return to the search for prime rep units: The following will work a little better than our previous progr am." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 88 "for n from 2 to 100 \+ do\n k:= (10^n-1)/9:\n if isprime(k) = true then print(n,k); fi;\nod :" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 198 "It is not too difficult to \+ show that if n is composite then a repunit of length n is not prime. S o in searching for prime repunits we may just look at primes. There ar e a couple of ways to do this: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 106 "for n from 2 to 400 do\nif isprime(n) then \n k:=(10^n-1)/9 ;\n if isprime(k) then print(n,k); fi;\nfi;\nod;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 98 "for t from 2 to 70 do\n n:=ithprime(t); \n k:=(10^n-1)/9;\n if isprime(k) then print(n,k); fi;\nod:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "ithprime(70);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 298 51 "There have been only 7 repunit primes fo und so far." }{TEXT -1 32 " The lengths of those found are " }{TEXT 294 1 " " }{TEXT -1 93 "2, 19, 23, 317, 1,031, 49081, and 86453. Act ually the last two have only been proved to be " }{TEXT 296 14 "probab ly prime" }{TEXT -1 48 ". Note that for large numbers the Maple comman d " }{TEXT 295 7 "isprime" }{TEXT -1 15 " is actually a " }{TEXT 297 28 "probabilist primality tester" }{TEXT -1 2 ". " }}}{EXCHG {PARA 259 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 43 "Add ition Using for..do..od and if..then..fi" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "restart: " }{TEXT -1 39 "This command clears the old v ariables. " }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "We first add the primes less than 1000. There are two way s to do this:" }{MPLTEXT 1 0 7 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 89 "S1:=0:\nfor n from 1 to 1000 do\n if isprime(n) = t rue then\n S1:=S1 + n:\n fi;\nod:\nS1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 28 "Here's another way to do it:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 99 "S2:=0:\nfor j from 1 to 1000 do\n p:=ithprime(j): \n if p < 1000 then \n S2:= S2 + p:\n fi:\nod:\nS2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "S1-S2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "Let's use this to \+ compute the sum of 1/n for n from 1 to 1000:\n" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 54 "S3:=0:\nfor n from 1 to 1000 do\n S3:=S3 + 1/n :\nod:\nS3;\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "evalf(S3); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 " " }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 43 "Counting Using for..do..od and if..then..fi" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "Le t's count the number of primes less than or equal to 1000:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 96 "count:=0:\nfor n from 1 to 1000 do \n if isprime(n) = true then \n count:=count+1:\n fi;\nod:\ncount;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "We can check this using the bui ltin function " }{TEXT 330 2 "pi" }{TEXT -1 1 ":" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "with(numtheory):\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "pi(1000);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "N ow let's count the number of positive integers less than 348 that are \+ relatively prime to 348:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "c:=0:\nfor n from 1 to 348 do\n if igcd(n,348) = 1 then \n c:=c+1: \n fi:\nod:\nc;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "We check this \+ using the builtin Euler phi function:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "phi(348);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 " " }} }}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 22 "Homework Assignment #2" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 338 10 "p roblem 0." }{TEXT -1 42 " Open a new Maple worksheet. Click on the " } {TEXT 331 1 "T" }{TEXT -1 156 " on the menu bar. This will allow you t o insert text. Next go to the pull down menu on the left side where it says P Normal. Pull this down till you get to " }{TEXT 332 7 "Title. \+ " }{TEXT -1 9 "Now type " }{TEXT 333 25 "Homework Assignment # 2. " } {TEXT -1 72 " Then hit return and type your name. Then click on the bu tton that says " }{TEXT 334 2 "[>" }{TEXT -1 32 " on the menu bar. Nex t click on " }{TEXT 335 1 "T" }{TEXT -1 16 " again and type " }{TEXT 336 9 "problem 1" }{TEXT -1 16 ". Now click on " }{TEXT 337 3 "[> " } {TEXT -1 19 " again. Then solve " }{TEXT 339 9 "problem 1" }{TEXT -1 62 " the next problem. Similarly label each problem in this way.\n\n" }{TEXT 340 11 "problem 1. " }{TEXT -1 24 "A positive integer n is " } {TEXT 341 8 "abundant" }{TEXT -1 65 " if the sum of the proper divisor s of n is greater than n. It is " }{TEXT 342 9 "deficient" }{TEXT -1 98 " if the sum of the proper divisors of n is less than n. Find \na. the number of abundant integers " }{XPPEDIT 18 0 "n <= 10000;" "6#1% \"nG\"&++\"" }{TEXT -1 1 "," }}{PARA 0 "" 0 "" {TEXT -1 36 "b. the num ber of deficient integers " }{XPPEDIT 18 0 "n <= 10000;" "6#1%\"nG\"&+ +\"" }{TEXT -1 40 ", and\nc. the number of perfect integers " } {XPPEDIT 18 0 "n <= 10000;" "6#1%\"nG\"&++\"" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 343 10 "problem 2." } {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 29 "a. Find the number of pr imes " }{XPPEDIT 18 0 "n <= 10000;" "6#1%\"nG\"&++\"" }{TEXT -1 53 " s uch that n mod 4 = 1.\nb. Find the number of primes " }{XPPEDIT 18 0 " n <= 10000;" "6#1%\"nG\"&++\"" }{TEXT -1 25 " such that n mod 4 = 3.\n \n" }{TEXT 344 9 "problem 3" }{TEXT -1 39 ". Find the number of positi ve integers " }{XPPEDIT 18 0 "x <= 10000;" "6#1%\"xG\"&++\"" }{TEXT -1 11 " such that " }{XPPEDIT 18 0 "x^2+1;" "6#,&*$%\"xG\"\"#\"\"\"F'F '" }{TEXT -1 13 " is prime. \n\n" }{TEXT 345 9 "problem 4" }{TEXT -1 28 ". For each positive integer " }{XPPEDIT 18 0 "n <= 20;" "6#1%\"nG \"#?" }{TEXT -1 24 " find the largest prime " }{XPPEDIT 18 0 "p <= 10^ n;" "6#1%\"pG)\"#5%\"nG" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 1 " " }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 14 "Random Numbers" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "Here we use the term " }{TEXT 349 13 "ran dom number" }{TEXT -1 66 ". Actually the numbers we shall generate are more properly called " }{TEXT 350 21 "pseudo-random numbers" }{TEXT -1 151 ". Since they are generated by a computer they are not random i n the true sense of the word. To read more about this subject see, for example, the book " }{TEXT 347 40 "The Art of Computer Programming Vo l. 2, " }{TEXT 348 9 "Chapter 2" }{TEXT -1 18 ", by Donald Knuth." }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "No te that the smallest n digit positive integer is " }{XPPEDIT 18 0 "10^ (n-1);" "6#)\"#5,&%\"nG\"\"\"F'!\"\"" }{TEXT -1 45 " and the largest n digit positive integer is " }{XPPEDIT 18 0 "10^n-1;" "6#,&)\"#5%\"nG \"\"\"F'!\"\"" }{TEXT -1 25 ". For example, for n = 3:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "10^3;10^4-1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 11 "For n = 40:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "10^39;10^40 - 1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 6 "Using " }{TEXT 357 6 "length" }{TEXT -1 55 "(x) we can obtain the number of di gits in the number x." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "2^ 50;\nlength(2^50);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 32 "To create a procedure, call it " }{TEXT 346 4 "roll" }{TEXT -1 86 ", that will g enerate a random number (integer) between a and b use the following li ne:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "roll:=rand(a..b);" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 97 "We could call the procedure anyt hing we want. I just call it roll to suggest a roll of the dice. " }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "For example " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "roll_1:=rand(0..9):" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 45 "This procedure is used with just () as input:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "roll_1();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "roll_1();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "for i from 1 to 4 do\nprint(roll_1());\nod;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 65 "To make a procedure to generate ra ndom 40 digit numbers we write:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "roll_40:=rand(10^39..10^40 - 1):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "for i from 1 to 5 do\nroll_40();\nod;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 21 "Random n-Digit Primes" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 79 "We may use the following method to generate two random 100-digit prime numbers." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "roll:=rand(10^99..10^100-1):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "p:=nextprime(roll());\n\nq:=nextprime(roll( ));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 40 "Now we generate random 200 digit primes:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "roll:=ran d(10^199..10^200-1):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "p:=nextprim e(roll());\nq:=nextprime(roll());" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 101 "Notice that it takes a while to generate these. We first generate a random 200 digit number and then " }{TEXT 352 9 "nextprime" }{TEXT -1 112 " searches through all number greater than that number, one at \+ a time, till a prime is found using the procedure " }{TEXT 351 7 "ispr ime" }{TEXT -1 1 "." }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 25 "Timing M aple Computations" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 163 "The function time returns the total CPU time used since the start of the Maple ses sion. The units are in seconds and the value returned is a floating-po int number." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "t1:=time(); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "t2:=time();" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 118 "Here's how one may time a computation. I n this case we time how long it takes to find the next prime following 10^100:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "starting_time:= time();\nnextprime(10^100);\ntime_required:=time() - starting_time;" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 109 "Let's factor as many Mersenne p rimes as we can find in 1 second. We will stop when we have exceeded 1 second." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 159 "st:=time():\nf or n from 1 to 100 do\nif time() - st > 1 then break; fi:\np:=ithprime (n):\nq:=2^p-1:\nif isprime(q) then print(p); fi;\nod:\nelapsedtime:=t ime() - st;\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 22 "Computing powers mod m" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 32 "The map le command for computing " }{XPPEDIT 18 0 "`mod`(a^n,m);" "6#-%$modG6$ )%\"aG%\"nG%\"mG" }{TEXT -1 46 " using the binary method of exponentia tion is " }{TEXT 353 16 "Power(a,n) mod m" }{TEXT -1 33 ". We compare \+ the time to compute " }{XPPEDIT 18 0 "`mod`(a^n,m)" "6#-%$modG6$)%\"aG %\"nG%\"mG" }{TEXT -1 56 " using the naive method as opposed to the bi nary method." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 81 "st:=time(): \nn:=10^100:\nm:=10^100 - 5:\nPower(2,n) mod m;\nelapsedtime:=time() - st;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "restart:\nst:=time( ):\nn:=10^6:\nm:=10^6-5:\n2^n mod m;\nelapsedtime:=time() - st;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 46 "Converting Text to Numbers and Numbers to Text" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 7 "We can " }{TEXT 354 7 "convert" }{TEXT -1 50 " text to a list of numbers by using the \+ procedure " }{TEXT 355 13 "convert/bytes" }{TEXT -1 256 " as in the fo llowing examples. Each symbol (letters of the alphabet, punctuation m ark, etc) corresponds to a number from 1 to 255. Although the document ation does not say, this appears to be essentially the so-called ASCII (ask-key) code in decimal form. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "convert(\"a\",bytes);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "convert([97],bytes);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 124 "Note that double quotes, \", within a string w ill cause confusion unless you repeat them twice, as in the following \+ example. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "Text:=\"Genera l Washington said, \"\"Attack at dawn!\"\", before he went to sleep.\" ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 29 "Numbers:=convert(Text,bytes);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "convert(Numbers,bytes);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 215 "We can get a list of all symbols as follows. Note that there are many squares in the list. Apparently these are symbols not printable by Maple's interface, yet they are still considered as \+ distinct, as we shall see." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "L:=[seq(i, i=1..255)];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "L2:=convert(L,bytes);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 31 "Now \+ we convert back to numbers." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "convert(L2,bytes);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 221 "Note t hat there is a one-to-one correspondence between numbers between 1 and 255 and symbols (except for the numbers 10 and 13 on some computersbo th of which correspond to the symbol \\n which is the \"new line\" cha racter)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 3 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 90 "Converting \+ to and from decimal, binary, octal and hexadecimal representations of \+ integers." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 356 15 "convert(n, hex)" }{TEXT -1 196 " will convert the decima l number n to hexadecimal (that is, base 16). Similarly we can replace hex by binary or octal to convert to binary (base 2) or octal (base 8 ). Let's consider some examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "for n from 0 to 20 do \nn, convert(n,binary), conver t(n,octal), convert(n,hex);\nod;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 358 22 "convert(n,decimal,hex)" }{TEXT -1 227 " will convert n from hexade cimal to decimal. Similarly we can replace hex by binary or octal. Her e are some examples: Note that in the case of hexadecimal we need to p lace backquotes about the number if it begins with a number." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "convert(A01234,decimal,hex); " }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 4 "But:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "convert(`0123456789ABCDEF`,d ecimal,hex);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "convert(012 34567,decimal,octal);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "co nvert(1111111110000001111100000111,decimal,binary);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 22 "Homework Assignment #3" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 366 10 "problem 0." }{TEXT -1 42 " Open a new Ma ple worksheet. Click on the " }{TEXT 359 1 "T" }{TEXT -1 156 " on the \+ menu bar. This will allow you to insert text. Next go to the pull down menu on the left side where it says P Normal. Pull this down till you get to " }{TEXT 360 7 "Title. " }{TEXT -1 9 "Now type " }{TEXT 361 25 "Homework Assignment # 2. " }{TEXT -1 72 " Then hit return and type your name. Then click on the button that says " }{TEXT 362 2 "[>" } {TEXT -1 32 " on the menu bar. Next click on " }{TEXT 363 1 "T" } {TEXT -1 16 " again and type " }{TEXT 364 9 "problem 1" }{TEXT -1 16 " . Now click on " }{TEXT 365 3 "[> " }{TEXT -1 19 " again. Then solve \+ " }{TEXT 367 9 "problem 1" }{TEXT -1 60 " the next problem. Similarly \+ label each problem in this way." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT 368 10 "problem 1." }{TEXT -1 48 " Say that a n umber whose binary representation " }{TEXT 377 9 "to base b" }{TEXT -1 23 " is [1,1,1,...,1] is a " }{TEXT 369 16 "base-b repunit. " } {TEXT -1 46 "Thus a base-b repunit is a number of the form " } {XPPEDIT 18 0 "(b^n-1)/(b-1);" "6#*&,&)%\"bG%\"nG\"\"\"F(!\"\"F(,&F&F( F(F)F)" }{TEXT -1 118 ". For each of the bases b = 2, 3, 4, 5, 10 fin d the number of base-b repunits that are primes less than 1 google ( = " }{XPPEDIT 18 0 "10^100;" "6#*$\"#5\"$+\"" }{TEXT -1 2 ")." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 370 10 "problem 2." } {TEXT -1 152 " The ISBN number for a book has 10 digits. The last is a check digit. It is obtained by the formula \n (digit1*1 + digit2* 2 +....+ digit9*9) mod 11. " }}{PARA 0 "" 0 "" {TEXT -1 51 "where digi t1 is the left most digit of the number. " }{TEXT 378 3 "And" }{TEXT -1 191 " if the check digit is 10 it is replaced by X. Look up the ISB N for two different books and use Maple to see that the check digits a re correct. You might use the techniques in the section on " }{TEXT 371 27 "Addition Using for..do..od." }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 259 "" 0 "" {TEXT -1 11 "problem 3. " }{TEXT 372 26 "Find all p rimes less than " }{XPPEDIT 18 0 "10^4;" "6#*$\"#5\"\"%" }{TEXT -1 0 " " }{TEXT 379 11 " which are " }{TEXT 375 11 "palindromic" }{TEXT 376 50 ", i. e., they read the same forward as backwards. " }{TEXT -1 5 "H int:" }{TEXT 381 106 " You may check whether a number n is palindromic by the following program: \n\nFirst we define the function " }{TEXT -1 3 "rev" }{TEXT 382 28 " which will reverse a list:\n" }}{PARA 259 " > " 0 "" {MPLTEXT 1 0 35 "rev:=L->[seq(L[-i],i=1..nops(L))]:\n" }} {PARA 259 "" 0 "" {TEXT 373 88 "Next you may use the following as a pa rt of your program. I will leave the rest to you.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "L1:=convert(n,base,10);\nif L1 = rev(L1) then prin t(n); fi;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 374 10 "problem 4." }{TEXT -1 10 " Find the " }{TEXT 380 19 "hex adecimal, binary" }{TEXT -1 5 " and " }{TEXT 383 5 "octal" }{TEXT -1 62 " representations of the palindromic primes found in problem 3." }} }}}{MARK "19" 0 }{VIEWOPTS 0 0 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 1 0 2 33 157 1 }