{VERSION 5 0 "IBM INTEL NT" "5.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 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 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 1 0 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 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 272 "" 0 1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 257 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 257 "" 0 "" {TEXT -1 18 "Maple Worksheet #3" }}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 14 "Random Numbers" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "Here we use the term " }{TEXT 259 13 "random numb er" }{TEXT -1 70 ", but actually the numbers we shall generate are mor e properly called " }{TEXT 260 21 "pseudo-random numbers" }{TEXT -1 151 ". Since they are generated by a computer they are not random in t he true sense of the word. To read more about this subject see, for ex ample, the book " }{TEXT 257 40 "The Art of Computer Programming Vol. \+ 2, " }{TEXT 258 9 "Chapter 2" }{TEXT -1 18 ", by Donald Knuth." }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 41 "Th e smallest n digit positive integer is " }{XPPEDIT 18 0 "10^(n-1);" "6 #)\"#5,&%\"nG\"\"\"F'!\"\"" }{TEXT -1 45 " and the largest n digit pos itive 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 267 6 " length" }{TEXT -1 68 "(x) we can obtain the number of digits in the nu mber x. For example:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "2^5 0;\nlength(2^50);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 32 "To create a \+ procedure, call it " }{TEXT 256 4 "roll" }{TEXT -1 80 ", that will ge nerate a random number (integer) between a and b use the command: " } {TEXT 296 17 "roll:=rand(a..b);" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "We could call the procedure anythi ng we want. I just call it " }{TEXT 295 4 "roll" }{TEXT -1 32 " to sug gest a roll of the dice. " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "For \+ example " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "roll:=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 7 "roll() ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "roll();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "for i from 1 to 4 do\nprint(roll()) ;\nend do;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 65 "To make a procedure to generate random 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 39 "for i from 1 to 5 do\nroll_40();\ne nd do;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 55 "Of course one could rep lace 40 by any positive integer." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 21 "Random n-Di git Primes" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "We may use the following method to generate two random 10 0-digit primes." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "roll:=ra nd(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:=rand(10^199..10^200-1):" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "p:=nextprime(roll());" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "q:=nextprime(roll());" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 105 "Notice that it takes a while to g enerate these. Maple first generates a random 200 digit number and the n " }{TEXT 262 9 "nextprime" }{TEXT -1 113 " searches through all numb ers greater than that number, one at a time, till a prime is found usi ng the procedure " }{TEXT 261 7 "isprime" }{TEXT -1 1 "." }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 25 "Timing Maple Computations" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "The command " }{TEXT 294 6 "time()" } {TEXT -1 146 " returns the total CPU time used since the start of the \+ Maple session. The units are in seconds and the value returned is a fl oating-point 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 111 "Here's how one may time a comput ation. In this case we time how long it takes to find the next prime f ollowing " }{XPPEDIT 18 0 "10^100;" "6#*$\"#5\"$+\"" }{TEXT -1 1 "." } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "starting_time:=time();\nne xtprime(10^100);\ntime_required:=time() - starting_time;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 109 "Let's factor as many Mersenne primes as \+ we can find in 1 second. We will stop when we have exceeded 1 second. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 205 "starting_time:=time(): \nfor n from 1 to 100 do\nif time() - starting_time > 1 then break; en d if:\np:=ithprime(n):\nq:=2^p-1:\nif isprime(q) then print(p); end if ;\nend do:\nelapsed_time:=time() - starting_time;\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 maple command for computing " }{XPPEDIT 18 0 "`mod`(a^n,m);" "6#-%$modG6$)%\"aG%\"nG%\"mG" }{TEXT -1 46 " using the binary method of exponentiation is " }{TEXT 263 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 70 " using the naive method as opposed to the binary method. First we \+ use " }{TEXT 297 16 "Power(2,n) mod m" }{TEXT -1 5 " for " }{XPPEDIT 298 0 "n = 10^100;" "6#/%\"nG*$\"#5\"$+\"" }{TEXT -1 4 "and " } {XPPEDIT 299 0 "m = 10^100-5;" "6#/%\"mG,&*$\"#5\"$+\"\"\"\"\"\"&!\"\" " }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 96 "st:=tim e():\nn:=10^100;\nm:=10^100 - 5;\n`2^n mod n` = Power(2,n) mod m;\nela psed_time:=time() - st;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "Now we compute using " }{TEXT 300 9 "2^n mod m" }{TEXT -1 10 " for just " } {TEXT 301 4 "n = " }{XPPEDIT 302 0 "10^6;" "6#*$\"#5\"\"'" }{TEXT -1 5 " and " }{XPPEDIT 303 0 "m = 10^6-5;" "6#/%\"mG,&*$\"#5\"\"'\"\"\"\" \"&!\"\"" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 92 "restart:\nst:=time():\nn:=10^6;\nm:=10^6-5;\n`2^n mod m` = 2^n mod m; \nelapsed_time:=time() - st;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 159 " You can see that the second method takes much longer even though the n umbers involved are much smaller. In fact the second method would fail if we try it for " }{XPPEDIT 18 0 "n = 10^100;" "6#/%\"nG*$\"#5\"$+ \"" }{TEXT -1 4 "and " }{XPPEDIT 18 0 "m = 10^100-5;" "6#/%\"mG,&*$\"# 5\"$+\"\"\"\"\"\"&!\"\"" }{TEXT -1 19 ", since the number " }{XPPEDIT 18 0 "2^n;" "6#)\"\"#%\"nG" }{TEXT -1 64 " would be too large . It wou ld have over 300,000 decimal places." }}}{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 "" {TEXT -1 112 "We need to be able to convert text to numbers and numbers back to text to perform the RSA cryptographic scheme.\n" }}}{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 264 7 "convert " }{TEXT -1 50 " text to a list of numbers by using the procedure " } {TEXT 265 13 "convert/bytes" }{TEXT -1 270 " as in the following examp les. Each symbol (letters of the alphabet, punctuation mark, etc) cor responds to a number from 1 to 255. Although the documentation does no t say, this appears to be essentially the so-called ASCII (pronounced, \"ask-key\") code in decimal form. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{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 204 "\nText should be enclosed in quotes \" \" . But note that \" within a text string will cause confusion unless you replace each \" by \\\", as in the followi ng example. First we show that the natural way fails.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "Text:=\"General Washington said, \" Attack at dawn!\", before he went to sleep.\";" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 53 "Now we replace each \" inside the text string by \\ \" :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "Text:=\"General Was hington said, \\\"Attack at dawn!\\\", before he went to sleep.\";" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 46 "We now convert this text to a list of numbers:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "Numbers:=convert(Text,bytes);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 41 "Next we convert the numbers back t o text:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "convert(Numbers, bytes);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 123 "We can get a list of all symbols as follows. We start w ith a Maple command to obtain a list of the integers from 1 to 255." } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "L:=[seq(i, i=1..255)];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "N ow we convert this list to symbols:" }}}{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 "" {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 266 15 "convert(n, hex)" }{TEXT -1 95 " will convert the decimal number n to hexadecimal (that is, bas e 16). Similarly we can replace " }{TEXT 304 4 "hex " }{TEXT -1 2 "by " }{TEXT 305 7 " binary" }{TEXT -1 4 " or " }{TEXT 306 5 "octal" } {TEXT -1 79 " to convert to binary (base 2) or octal (base 8). Let's c onsider some examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 87 "f or n from 0 to 20 do \nn, convert(n,binary), convert(n,octal), conver t(n,hex);\nend do;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 268 22 "convert(n, decimal,hex)" }{TEXT -1 227 " will convert n from hexadecimal to decim al. Similarly we can replace hex by binary or octal. Here are some exa mples: Note that in the case of hexadecimal we need to place backquote s about the number if it begins with a number." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 28 "convert(A01234,decimal,hex);" }{TEXT -1 0 "" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 4 "B ut:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "convert(`123456789AB CDEF`,decimal,hex);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "conv ert(1234567,decimal,octal);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "convert(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 276 21 "Format the worksheet:" }{TEXT -1 42 " Open a new Maple worksheet. Click on the " }{TEXT 269 1 "T" } {TEXT -1 156 " on the menu bar. This will allow you to insert text. Ne xt go to the pull down menu on the left side where it says P Normal. P ull this down till you get to " }{TEXT 270 7 "Title. " }{TEXT -1 9 "No w type " }{TEXT 271 25 "Homework Assignment # 3. " }{TEXT -1 72 " Then hit return and type your name. Then click on the button that says " } {TEXT 272 2 "[>" }{TEXT -1 32 " on the menu bar. Next click on " } {TEXT 273 1 "T" }{TEXT -1 16 " again and type " }{TEXT 274 9 "problem \+ 1" }{TEXT -1 16 ". Now click on " }{TEXT 275 3 "[> " }{TEXT -1 19 " a gain. Then solve " }{TEXT 277 9 "problem 1" }{TEXT -1 43 ". Similarly \+ label each problem in this way." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT 278 10 "problem 1." }{TEXT -1 48 " Say that a n umber whose binary representation " }{TEXT 287 9 "to base b" }{TEXT -1 23 " is [1,1,1,...,1] is a " }{TEXT 279 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 280 10 "problem 2." } {TEXT -1 162 " 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 digit1 is the left most digit of the number. " }{TEXT 288 3 "And " }{TEXT -1 191 " if the check digit is 10 it is replaced by X. Look u p the ISBN for two different books and use Maple to see that the check digits are correct. You might use the techniques in the section on " }{TEXT 281 31 "Addition Using for..do..end do." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 256 "" 0 "" {TEXT -1 11 "problem 3. " }{TEXT 282 26 "Find all primes less than " }{XPPEDIT 18 0 "10^4;" "6#*$\"#5\" \"%" }{TEXT -1 0 "" }{TEXT 289 11 " which are " }{TEXT 285 11 "palindr omic" }{TEXT 286 50 ", i. e., they read the same forward as backwards. " }{TEXT -1 5 "Hint:" }{TEXT 291 106 " You may check whether a number n is palindromic by the following program: \n\nFirst we define the fu nction " }{TEXT -1 3 "rev" }{TEXT 292 28 " which will reverse a list: \n" }}{PARA 256 "> " 0 "" {MPLTEXT 1 0 35 "rev:=L->[seq(L[-i],i=1..nop s(L))]:\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "Here's how to use it ." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "rev([1,2,3,4]);" }}} {EXCHG {PARA 256 "" 0 "" {TEXT 283 89 "Next you may use the following \+ idea to check whether or not an integer n is a palindrome:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "n:=10109890101:\nL1:=convert(n,base,10);\ni f L1 = rev(L1) then \n print(n); \nend if;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "n:=10109880101:\nL1:=convert(n,base,10);\nif L1 \+ = rev(L1) then \n print(n); \nend if;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT 284 10 "problem 4." }{TEXT -1 10 " Find the " }{TEXT 290 19 "hexadecimal, binary" }{TEXT -1 5 " and " }{TEXT 293 5 "octal" } {TEXT -1 62 " representations of the palindromic primes found in probl em 3." }}}}}{MARK "7" 0 }{VIEWOPTS 0 0 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 0 1 2 33 1 1 }