{VERSION 6 0 "IBM INTEL LINUX" "6.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 "" -1 256 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 257 "" 1 18 0 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 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 0 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 } {PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "Author" 0 19 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT -1 39 "Introduction to Maple for Number Theory" }}}{EXCHG {PARA 19 "" 0 "" {TEXT -1 57 "Mike O'Sulliva n\nSan Diego State University\nSeptember 2004" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }{TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 25 "Sets, Lists, some basics." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "A set is denoted by \{\} an d a list by []. Both may be empty." }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "S1:= \{\}; S2 := \{1, 23 \}; S3 := \{23,4,5\};" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 157 "Union, \+ intersection and minus (set difference) can be accomplished two ways. \+ Notice the back quote. The second form is more compact for more than two sets." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 49 "T1 := S2 union S3; T2 := `intersect`(S2, S3,T1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "You can test for membership and the result is of type boolean." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "b := member(1, S1); c := member(1, S2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "type(b,boolean);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "b and c;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 5 "Lists " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "L1 := [2,3,5,2,3,6,2,3] ; L2 := [3,4,8,9];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "nops( L1); op(3,L1); [op(1..6,L1)]; \{op(1..6,L1)\};" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 16 "convert(L1,set);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "L3 := [op(L1),op(L2)];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "L3 := map(x -> x^2, L2);" }}}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 12 "Divisibili ty" }}{PARA 0 "" 0 "" {TEXT -1 73 "Maple has two functions to compute \+ quotients and remainders of integers, " }}{PARA 0 "" 0 "" {TEXT -1 18 "iquo() and irem()." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "q := \+ iquo(10, 3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "r := irem(1 0,3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "q*3 + r;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "You can also use iquo() to get the remainder (and irem() to get the quotient)." }}{PARA 0 "" 0 "" {TEXT -1 17 "Notice the quotes" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "r := irem(29,7,'q'); q ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "q*7 + r;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "The floor of a quotient of two integers i s the iquo of the two integers." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "floor(29/7);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 87 "While we're discussing divisibility, try the fu nction ifactor(). You might think about" }}{PARA 0 "" 0 "" {TEXT -1 43 "what this output is and why it makes sense." }}{PARA 0 "" 0 "" {TEXT -1 62 "Note: The output of ifactors() is in the form [prime, po wer]." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "ifactor(-60);ifactors(-60);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 182 "Using Maple Help you can search for \"divisors\". It \+ is one of the functions in the number theory package. You might want \+ to browse that package to see the other functions available." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "n umtheory[divisors](30);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 28 "Divisibility for Polynomials" }}{PARA 0 "" 0 "" {TEXT -1 91 "The functions used fo r quotient and remainder of polynomials are similar to those used for \+ " }}{PARA 0 "" 0 "" {TEXT -1 47 "integers, but you need to specify the variable." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "f := x^5+x+1; \+ g := x^2+1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "quo(f,g, x) ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 84 "Now try the remainder funct ion rem(), and check that the result you get is correct." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 34 "Primes and the Euclidean Algorithm" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 37 "There are several \+ ways to get primes." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "next prime(100);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "p := ithprim e(55);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "You can test for primal ity." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "isprime(p);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 175 "The Euclidean algeorithm is used \+ to find the greatest common divisor. You can get the quotient of each integer by the gcd. The two extra variables are set to these value s." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "gcd(27,18);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "gcd(27,18,'ap','bp');ap; bp; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "You can also get the linear c ombination that gives the gcd.." }}{PARA 0 "" 0 "" {TEXT -1 64 "Note \+ \"igcdex\" is the extended Euclidean algorithm for integers." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "igcdex(45,290,'s','t');" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "s; t; s*45 + t*290;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "The same can be done with polynomi als. You have to specify the variable, too." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "F := x^3-3*x-2; H := x^4-4*x^2-x+2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "gcdex (F, H, x, 's','t');" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "s; t ; s*F + t*H; simplify(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 42 "Try using the functions ilcm() a nd lcm()." }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 49 "Iterative and conditional statements (For and If)" }}{PARA 0 "" 0 "" {TEXT -1 82 "Two of the most useful things in programming are iterative loops and conditionals." }}{PARA 0 "" 0 "" {TEXT -1 30 "Here are a couple of examples." }}{PARA 0 "" 0 "" {TEXT -1 57 "The syntax can be fussy, so use indetation to keep track. " }}{PARA 0 "" 0 "" {TEXT -1 78 "Here are the basic templates. You ma y have one or more statements inside the " }}{PARA 0 "" 0 "" {TEXT -1 56 "for loop (or then clause). Separate them by semicolons." }}{PARA 0 "" 0 "" {TEXT -1 22 "for i from __ to __ do" }}{PARA 0 "" 0 "" {TEXT -1 13 " _______;" }}{PARA 0 "" 0 "" {TEXT -1 12 " _______ ;" }}{PARA 0 "" 0 "" {TEXT -1 7 "end do;" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 12 "if ___ then " }}{PARA 0 "" 0 "" {TEXT -1 9 " ___;" }}{PARA 0 "" 0 "" {TEXT -1 8 " ___;" }} {PARA 0 "" 0 "" {TEXT -1 7 "end if;" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "for i from 1 to 10 do\n i^2;\nend do;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "16;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "for i from 1 to 100 do\n if isprime(i) then print(i );\n end if;\nend do;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 11 " Exe rcises" }}{PARA 0 "" 0 "" {TEXT -1 53 "1. Make a list with the first 20 Fibonacci numbers." }}{PARA 0 "" 0 "" {TEXT -1 82 " Next, giv en a and b, and starting values g_0 and g_1, produce the sequence " } }{PARA 0 "" 0 "" {TEXT -1 48 " determined by g_n = a g_\{n-1\} + \+ b g_\{n-2\}." }}{PARA 0 "" 0 "" {TEXT -1 212 "2. Make a list of all t he Fibonacci numbers (less than some bound) which are also perfect squ ares. List also the index of the Fibonacci number. Try it by a brute force method and then try to be more efficient." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 60 "3. Which Fibonacci numbe rs are divisible by 7, by 8, etc. " }}{PARA 0 "" 0 "" {TEXT -1 31 " \+ Can you form a conjecture?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 256 0 "" }{TEXT 257 0 "" }{TEXT -1 54 "4. For several real values of \+ x compute [x] + [-x] " }}}}{MARK "1 0 0" 57 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }