{VERSION 3 0 "IBM INTEL LINUX" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "" -1 256 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 3 " " }{TEXT 256 38 "A MINI COURSE on MAPLE: Math 115A" }} {PARA 0 "" 0 "" {TEXT -1 48 "========================================= =======" }}{PARA 0 "" 0 "" {TEXT -1 56 "The first command computes t he QUOTIENT when the first" }}{PARA 0 "" 0 "" {TEXT -1 36 " number is divided by the second." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "iquo(1007,456);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 53 "The next command computes the REMAINDER of the same " }}{PARA 0 "" 0 "" {TEXT -1 10 " division." }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 15 "irem(1007,456);" }{TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "floor(x) c omputes the greatest integer less than or equal to x" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "floor(13/5);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 41 "isprime(x) tests whether x is a prime" }{TEXT -1 0 "" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "isprime(5);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 13 "isprime(3/4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "isprime(6);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "S imilarly, ithprime(n) calculates the nth prime number where" }{TEXT -1 26 " n is a positive integer.\000" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "ithprime(1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "ithpr ime(5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "ithprime(100);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "ifactor(n) finds the UNIQUE pri me power factorization of the integer n" }{TEXT -1 0 "" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 12 "ifactor(45);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "ifactor(2354888179495090113);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 42 "ifactor(77777777777777777777777777777347);" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 74 "Now before we can use the next co mmand we need to read a LIBRARY of maple." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 50 "ifactors(n) find the prime integer s that divide n:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "readlib(ifactor s):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "ifactors(45);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 38 "Something very useful to know is H ELP!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "help(ifactor);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 47 "To comput e the GCD of some numbers we use " }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "igcd(464,1782,1932,254);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "There is a small variation if \+ you wish to write the GCD as a linear" }}{PARA 0 "" 0 "" {TEXT -1 19 "combination of a,b:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "igcdex(464, 1782,'s','t'); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "s*464+t* (1782); print(the \"coefficients are\",s,t);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 44 "To compute the LCM we have related command:" }{TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "ilcm(464,1782);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 67 "Inside MAPLE there is a speci al purpose package that contains" }}{PARA 0 "" 0 "" {TEXT -1 69 "many interesting an useful commands in number theory, including" }} {PARA 0 "" 0 "" {TEXT -1 66 "many we will study in the future. \+ the name of the package " }}{PARA 0 "" 0 "" {TEXT -1 16 "is numberth eory" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "help(numbertheory);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "with(numtheory);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 65 " For ex ample, it has already inside capabilities to compute" }}{PARA 0 " " 0 "" {TEXT -1 22 "the nth Fermat number:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "fermat(4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "fermat(10);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "It also con tains a very nice function that tells you a list " }}{PARA 0 " " 0 "" {TEXT -1 32 "of all divisors of a number:" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "divisors(41157113 );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 0 {PARA 3 " " 0 "" {TEXT -1 42 " AN EXAMPLE of programming with MAPLE" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 71 "Here is a small MAPLE prog ram to perform Fermat factorization" }}{PARA 0 "" 0 "" {TEXT -1 18 " of an integer n:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 47 "n:=2052; # HI GUYS this is my favorite number." }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "ifactor(2052);" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 11 "counter:=0;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "while member(2,divisors(n)) do" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "counter:=counter+1; n:=iquo(n,2); print(burro);" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "od; print(counter,n); # removing h ighest power of 2 from n." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "for i from 1 to floor(sqrt(n)) do" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 " a:=n+i^2;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 " print(i,a);" } }{PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "if floor(sqrt(a))^2=a then break: fi" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "od: print(\"the factors are: \",sqrt(a)-i,sqrt(a)+i,2^counter):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 68 " Now one little program that applies the Euclidean Algorithm." }}{PARA 0 "" 0 "" {TEXT -1 63 "This time it is presente d as a PROCEDURE ( a self contained" }}{PARA 0 "" 0 "" {TEXT -1 47 " program that can be called by other programs)." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "euclidalg:=proc(m,n)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "local i, m1, n1, r, q:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "i:=0:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "r:=n:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "m1:=m:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "n1:=n:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "w hile r>0 do" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 " q:=iquo(m1,n1):" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 " r:=irem(m1,n1):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 " print(m1,\"=\",q,n1,\"+\",r):" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 15 " m1:=n1: n1:=r:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 " i:=i+1:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "od;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "print(\"steps=\",i):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "euc lidalg(22,32);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "euclidalg (995,335);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "3 5 13 0" 15 }{VIEWOPTS 1 1 0 2 1 1805 }