{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 42 "Using Maple for Number Th eory and Algebra:" }}{PARA 18 "" 0 "" {TEXT -1 10 "The Basics" }} {PARA 19 "" 0 "" {TEXT -1 55 "Mike O'Sullivan\nSan Diego State Univers ity\nJanuary 2005" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 226 "This worksh eet has some fundamental examples of Maple commands and some exercises that will help you get started working with the integers and polynom ials. The last section shows how to write a for loop and an if state ment." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }{TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 25 "Sets, Lists, some basi cs." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "A set is denoted by \{\} and a list by []. Either may be empt y." }}{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 76 "Using the op() command, you get a \+ sequence of the elements of a list or set." }}{PARA 0 "" 0 "" {TEXT -1 54 "This can be used to extend a set as the example shows." }} {PARA 0 "" 0 "" {TEXT -1 46 "nops() tells the number of elements of a \+ list." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "op(S3);\nnops(S3); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "U1 := \{op(S3), 52\}; \+ \nnops(S4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 77 "You can create a s et (or list) with lots of elements using the seq() command." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "U 2 := \{seq(i^2, i=1..10)\};" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 157 "U nion, intersection and minus (set difference) can be accomplished two \+ ways. Notice the back quote. The second form is more compact for mor e 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 61 "You can test for membersh ip. 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 85 "Lists are handled similarly. But we don't take the union or intersection o f lists. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "L1 := [2,3,5, 2,3,6,2,3]; \nL2 := [3,4,8,9];\nL1 union L2;\n " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 164 "op() and nops() still work. In fact op() can be us ed to access a selection of elements of a list. \nWe can us op() to c onvert from a list to a set (or vice-versa)." }}}{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 "" {TEXT -1 74 "The convert() function is used to convert one type of object to another. " }}{PARA 0 "" 0 "" {TEXT -1 33 "For example from a list to a set." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 16 "convert(L1,set);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 16 "Another example." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "L3 := [op(L1),op(L2)];" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 9 "Functions" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 32 "A function is defined as follows" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "f := x -> 2^x + 1;\nf(3);" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 175 "Using map() a function can be a pplied to every element of a list. \nThe function can be defined ahea d of time, it can be a built in function, or it can be defined within \+ map()" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "L1;\nmap(f, L1);\n map(sqrt, L1);\nmap(x->x^2+1, L1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 12 "Divisibility" }}{PARA 0 "" 0 "" {TEXT -1 73 "Maple has two functions to compute quotients and remainde rs 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(10,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 quote s" }}}{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 is the iquo of the two int egers." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "floor(29/7);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 111 "W hile we're discussing divisibility, try the function ifactor(). \nThe function gives the unique factorization." }}{PARA 0 "" 0 "" {TEXT -1 88 "Note: The output of ifactors() is in the form [ unit, [[prime, po wer]...[prime,power]]." }}{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 f or \"divisors\". It is one of the functions in the number theory pack age. 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 "numtheory[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 92 "Th e procedures used for quotient and remainder of polynomials are simila r 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 17 "quo(f,g, x); " }{TEXT -1 0 "" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 87 "Try rem(), in the manner we used for irem().\nChe ck that the result you get is correct." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 71 "Factorization is more interesting. Over which field are \+ you factoring?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 48 "factors(x^2+3*x+3);\nfactors(x^2+3*x+3, comple x);" }}}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 34 "Primes and t he 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 "nextprime(100);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "p := ithprime(55);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "You can test for primality." }}}{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 greate st common divisor. You can get the quotient of each integer by the gc d. The two extra variables are set to these values." }}}{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 combination that gi ves 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 polynomials. You have to speci fy the variable, too." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "F := x^2+x+1;\nG := x^3-3*x-2; \nH \+ := x^4-4*x^2-x+2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "irredu c(F);\nirreduc(G);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "gcdex (G, H, x, 's','t');" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "s; t ; s*G + 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 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 107 "for i from 1 to 100 do\n if isprime(i) then \n \+ print(\"I found one!\");\n 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 " Exercises" }}{PARA 0 "" 0 "" {TEXT -1 53 "1. Make a list with the first 20 Fibonacci numbers." }} {PARA 0 "" 0 "" {TEXT -1 82 " Next, given a and b, and starting v alues 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 the Fibonacci numbers (les s than some bound) which are also perfect squares. List also the inde x of the Fibonacci number. Try it by a brute force method and then tr y to be more efficient." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 60 "3. Which Fibonacci numbers are divisible by 7, by \+ 8, etc. " }}{PARA 0 "" 0 "" {TEXT -1 31 " Can you form a conjectur e?" }}{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 "0 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }