{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 "Hyperlink" -1 17 "" 0 1 0 128 128 1 2 0 1 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 0 2 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {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 1 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 270 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 0 0 0 0 0 0 0 }{CSTYLE "" -1 373 "" 0 1 0 0 0 0 0 1 0 0 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 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 376 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 377 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" 18 378 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 379 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" 18 380 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 381 "" 0 1 0 0 0 0 0 1 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 "Title" -1 18 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 }{PSTYLE "Author" -1 19 1 {CSTYLE "" -1 -1 "T imes" 1 12 0 0 0 1 2 2 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 256 1 {CSTYLE "" -1 -1 "Times" 1 14 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 "Normal" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 18 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 "Normal" -1 258 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 "Normal" -1 259 1 {CSTYLE "" -1 -1 "Times" 1 24 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 "Normal" -1 260 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 1 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT 256 10 "Lecture 10" }}{PARA 19 " " 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 257 "" 0 "" {TEXT 261 5 "evalb" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 13 " The function " }{TEXT 35 6 "evalb " }{TEXT -1 27 "evaluates an express ion to " }{TEXT 262 4 "true" }{TEXT -1 2 ", " }{TEXT 263 5 "false" } {TEXT -1 299 ", or if it cannot tell, it just returns the command as i s. But in some cases, see examples below it even return false when th e correct answer is true. In some cases this can be corrected by apply ing the appropriate simplification or evalustion first. This is best u nderstood by looking at examples:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 15 "" 0 "" {TEXT -1 6 "Since " }{TEXT 260 5 "evalb" }{TEXT -1 187 " does not simplify expressions, it may return false to a relation which is actually true. In such a case, appropriate simplification mu st be applied to the relation before evalb is used. " }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "x = x;" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "evalb(x = x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "evalb(1 < 2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "evalb(sqrt(2) < sin(3));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 220 "This means that the inequality cannot be deter mined. But the following does help. Of course, they may be cases where Digits would have to be set very high to get the correct answer. Neve rtheless this works in most cases." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "evalb(evalf(sqrt(2)) < evalf(sin(3)));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 302 5 "evalb" }{TEXT -1 42 " can also be used to test for equality of " }{TEXT 304 4 "sets" }{TEXT -1 5 " and " } {TEXT 305 5 "lists" }{TEXT -1 10 ". But for " }{TEXT 326 8 "Matrices" }{TEXT -1 15 " we need to us " }{TEXT 306 20 "LinearAlgebra[Equal]" } {TEXT -1 25 ". Here are some examples." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "evalb([1,2,3]=[1,2,3]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "evalb([2,2,3] = [2,3,3]);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 23 "evalb(\{2,2,3\}=\{2,3,3\});" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 60 "restart:\nA:=Matrix([[1,2],[3,4]]);\nB:=Matrix ([[1,2],[3,4]]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalb(A =B);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "LinearAlgebra[Equal ](A,B);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 4 "Or, " }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "evalb(LinearAlgebra[Equal]( A,B));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 3 "Or," }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 48 "evalb(convert(A,listlist)= convert(B,listlis t));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 33 "The above problem holds a lso for " }{TEXT 327 8 "matrices" }{TEXT -1 23 " and can be fixed with " }{TEXT 328 61 "linalg[equal], or convert(A,listlist) = convert(B,li stlist).\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 25 "Let's create a proc edure " }{TEXT 341 2 "le" }{TEXT -1 42 " that has as input two argumen ts x and y. " }{TEXT 342 7 "le(x,y)" }{TEXT -1 13 " will return " } {TEXT 339 4 "true" }{TEXT -1 4 " if " }{XPPEDIT 18 0 "x <= y;" "6#1%\" xG%\"yG" }{TEXT -1 5 " and " }{TEXT 340 5 "false" }{TEXT -1 26 " if x \+ is not less than y. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "le: =(x,y)->evalb(x <= y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "l e(1,1), le(1,3), le(3,1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Let' s now create a procedure " }{TEXT 343 3 "le2" }{TEXT -1 25 " whose inp ut will be two " }{TEXT 329 5 "lists" }{TEXT -1 18 " L and M. We want \+ " }{TEXT 330 8 "le2(L,M)" }{TEXT -1 7 " to be " }{TEXT 264 4 "true" } {TEXT -1 23 " if L[2] <= M[2] and " }{TEXT 265 5 "false" }{TEXT -1 11 " otherwise." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "le2:=(L, M)-> evalb(L[2] <= M[2]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 15 "Here we see if " }{TEXT 331 3 "le2" }{TEXT -1 7 " works:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "le2([1,2,3],[2,3,5]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "le2([1,2],[1,2]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "le2([1,4],[0,3]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 5 "sort " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 257 5 "so rt " }{TEXT -1 20 "can be applied to a " }{TEXT 332 4 "list" }{TEXT -1 6 " or a " }{TEXT 258 12 "polynomial. " }{TEXT -1 81 " You can spec ify how you want things to be sorted in some cases, as we shall see." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 10 "Lists are " }{TEXT 259 6 "sorted" }{TEXT -1 69 " into ascending order by default and the original list is left as is. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "L1:=[5,3,4,1,2];\nL2:=s ort(L1);\nL1:=L1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 146 "Polynomials are sorted into descending order of the term degrees: In the case of \+ polynomials they are sorted in place. The old order is destroyed." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "p1:= 1+3*x+5*x^3+49*x^2;" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "sort(p1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 2 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 " p1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 140 "In this case we did not h ave to give p1 a new name. Note that p1 itself has been changed. Thi s is a somewhat unusual situation in Maple. \n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 132 "Execute if the next command if you wish to see the some methods Maple provides to sort polynomials in several variables. Note that " }{TEXT 333 10 "???command" }{TEXT -1 50 " takes you direc tly to the examples of the use of " }{TEXT 334 7 "command" }{TEXT -1 3 ". \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "???sort" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 159 "One can sort lis ts in various ways by inserting an optional second parameter which is \+ a boolean function F of two variables: Such a F can be created by usi ng " }{TEXT 266 5 "evalb" }{TEXT -1 182 " as we did at the end of the \+ previous section. For example, the following gives a boolean function \+ GE(x,y) which is true if x >=y: Using this we can sort lists into desc ending order:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "restart:\n GE:=(x,y)->evalb(x >=y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "GE(1,2),GE(1,1),GE(2,1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "L1:=[1,5,2,4,3];\nL2:=sort(L1);\nL3:=sort(L1,GE);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "A simpler method for reversing the order \+ of " }{TEXT 335 7 "numbers" }{TEXT -1 243 " in a list is the following . But it is best to learn the more general method in case you are sort ing lists that are not entirely numerical. Notice the use of backquote s in `>`. This is not to be confused with single (forward) quotes as i n '>'." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "L4:=sort(L1,`>`); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 80 "It is often more convenient t o use unnamed functions for the second variable in " }{TEXT 267 4 "sor t" }{TEXT -1 178 " as we illustrate below. This avoids introducing a n ame for a function we will only use for sorting once. We first make a \+ list of length 10 which we call L1, and then we sort it:" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "resta rt:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "L1:=[seq(i^3 mod 10, i=1..10)];\nL2:=sort(L1, (x,y)->evalb(x>=y));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 53 "Or, more simply, in this case as above we could use: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "L3:=sort(L1,`>`);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 202 "Here's an example where we may mu st use the more general method. We want to sort a list of lists on the i-th coordinate of the lists in the big list, as follows: We first c reate a random list of lists:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "die:=rand(1..6):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "L 1:=[seq([die(),die(),die()],i=1..10)];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "We sort the small inner lists on their second coordinate s:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "L2:=sort(L1,(x,y)->ev alb(x[2]<=y[2]));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "Sort will so rt words into alphabetical (lexorder) order:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "restart:\nsort([ betty, carla,aaron, Betty, Aaro n,Carla ] );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 68 "But note that cap italized words come before all uncapitalized words." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 41 "select, remove, selectremove, member, has" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 " " {TEXT -1 20 "What the procedures " }{TEXT 270 36 "select, remove, se lectremove, member" }{TEXT -1 6 ", and " }{TEXT 271 3 "has" }{TEXT -1 43 " do is evident from the following examples:" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "L1:=[seq(i,i=1..20)];\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "L2:=select(isprime,L1);\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "L3:=remove(isprime,L1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "The commands select and remove can be accomplished in a s ingle pass by use of " }{TEXT 336 12 "selectremove" }{TEXT -1 1 "." }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "L4:=selectremove(isprime,L1 );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Consider a few more example s." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "die:=rand(1..4):" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "L4:=[seq([die(),die(),die()] ,i=1..15)];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "L5:=select(x ->evalb(1<=x[3] and x[3]<=2),L4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "L6:=remove(x->evalb(1<=x[3] and x[3]<=2),L4);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "L7:=selectremove(x->evalb(1< =x[3] and x[3]<=2),L4):\nL7[1];\nL7[2];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 269 6 "member" }{TEXT -1 52 "(x,S) is true if x is in \+ S where S is a set or list." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "S:=[seq(i^3 \+ mod 11, i=1..12)];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "membe r(1,S);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "member(5,S);" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 158 "If there is a third argument for member, it will store the position of the first x in S, as in the fol lowing example. Note that here we use 'x' and not `x`. \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "member(5,S,'x');\nx;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 268 3 "has" }{TEXT -1 15 " is similar to " } {TEXT 337 6 "member" }{TEXT -1 139 " but more powerful. It should not \+ be used when member will do as well, since it takes more time to retur n a value: Here are some examples: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "restart:\nL1:=[seq(i^5 mod 13, i=5..15)];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "has(L1,1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "has(L1, 10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "p:=x^3+b*x^3*z^5+2+ 1 +x^(y^(z^w))+ sin(x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "h as(p,w);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "has(p,3);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "has(p,z^w);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "has(p,sin);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 9 "has(p,q);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "expr1:=(1+x^5)*(sin(3))+(exp(y^2)+sin(1));\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "select(has,expr1,x);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 20 "This is the same as:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "select(u->has(u,x),expr1);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "remove(has, expr1,x);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 11 "We can use " }{TEXT 338 12 "select remove" }{TEXT -1 113 " to separate an expression into two parts, one \+ that contains x and the other that doesn't contain x. For example:" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "Part:=selectremove(has, exp r1,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "Part[1];\nPart[2] ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 " " 0 "" {TEXT -1 16 "nops, op, subsop" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 256 "" 0 "" {TEXT 272 12 "The command " }{TEXT 273 2 "o p" }{TEXT 274 34 " extracts the various components (" }{TEXT 275 8 "op erands" }{TEXT 277 33 ") of an expression, the function " }{TEXT 278 4 "nops" }{TEXT 279 39 " returns the number of components, and " } {TEXT 287 6 "subsop" }{TEXT 288 70 " is used to substitute things for \+ given components of the expression.\n" }}{PARA 256 "" 0 "" {TEXT 280 92 "Let's look at examples. Some of these we have already seen when de aling with sets and lists:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "L:=[1,2,3,4, 5,x,y,z];\nS:=\{6,7,8,9, x^2+1,matrix([[1,2],[3,4]])\};" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "nL:=nops(L);\nnS:=nops(S);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "op(L);\nop(S);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 82 "In the next few commands we see that ther e are two ways of obtaining some results." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 27 "op(1,L),op(2,L);\nL[1],L[2];" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 30 "op(1,S),op(2,S);\nop(2,S),S[2];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "seq(op(i,L),i=1..nops(L));\nop(L); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "op(1,L), op(-2,L),op(-1 ,L);\nL[1],L[-2],L[-1];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 " op(2..4,L);\nL[2..4];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 112 "Most Ma ple objects are composed of several operands, you may see what they ar e in a particular case by applying " }{TEXT 344 2 "op" }{TEXT -1 34 " \+ to the object. Here's an example:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "p:= (x^7+8*x^6)/(x^2-9);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 39 "We ask how many operands p consists of:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "nops(p);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 76 "We see that there are two operands. We can obtain them as a lis t as follows:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "op(p);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "To give names to the two operan ds:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "op(1,p);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "op(2,p);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 55 "How are these operands put together? We check the type:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "whattype(p);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "Now we can take apart each of the two ope rands op(1,p) and op(2,p) as follows:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "op(1,p);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "nops(op(1,p));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "op(op(1, p));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "whattype(op(1,p)); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 91 "This indicates that the two p arts of op(1,p) are added together. Let's try another example:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "e:=p^(x^2+x+1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "whattype(e);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 8 "nops(e);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "op(e);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "op(1,e), o p(2,e);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 26 "Now let's look at op(1 ,e):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "op(op(1,e));" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "whattype(op(1,e));" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "There are two ways to get the seco nd operand of the first operand of e. Either this way:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "op(2,op(1,e));" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 12 "Or this way:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "op([1,2],e);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 101 "Now suppose we want to take this apart. Let's first see what it's o perands are and what type it is:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "op(op([1,2],e));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "whattype(op([1,2],e));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 10 "Note that " }{XPPEDIT 18 0 "1/(x^2-9);" "6#*&\"\"\"F$,&*$ %\"xG\"\"#F$\"\"*!\"\"F*" }{TEXT -1 14 " is stored as " }{XPPEDIT 18 0 "(x^2-9)^(-1);" "6#),&*$%\"xG\"\"#\"\"\"\"\"*!\"\",$F(F*" }{TEXT -1 47 " and both have type ^. So the two operands are " }{XPPEDIT 18 0 "x ^2-9;" "6#,&*$%\"xG\"\"#\"\"\"\"\"*!\"\"" }{TEXT -1 9 " and -1. " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 " " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 121 "Various parts of parts of parts, etc, can be selected in a manner which should be clear from the the following examples:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "f:=(x^2+1)*sin(x^2+y^2)*ln(x ^2+1)*((1+z)/(3*z^5+w^4+t^5));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "op(f);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "nops(f);" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "op(4,f), op(5,f); " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "op(5,f);" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 14 "nops(op(5,f));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "op([5,1],f), op([5,2],f);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 18 "nops(op([5,1],f));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "op([5,1,1],f), op([5,1,2],f), op([5,1,3],f);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "op([5,1,1,1],f), op([5,1,1,2 ],f);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "op([5,1,1,2,2],f); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT 276 16 "op(0,expression)" }{TEXT -1 73 " has a special meaning: For example; For many expressions it retur ns the " }{TEXT 307 4 "type" }{TEXT -1 49 ", for \"functions\" it is t he name of the function:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "A:=matrix([[1,2],[3,4]]);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "op(0,eval(A));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "op(0,x^2+y+1);" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 68 "nops(igcd(x,y));\nop(0,igcd(x,y));\nop(1,igc d(x,y));\nop(2,igcd(x,y));\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "nops(sin(x)),op(0,sin(x));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 281 25 "subsop(i = expression, p)" }{TEXT -1 52 " will replace whatever is in the i-th part of p by " }{TEXT 345 10 "expression" }{TEXT -1 7 ". Like " }{TEXT 308 4 "subs" }{TEXT -1 54 " it does not change p itself . We illustrate that here:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "p;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "op(p);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "op([1,2],p);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 25 "p1:=subsop( [1,2]=W, p );" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 2 "p;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "op([2,1,2],p);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "subso p( [2,1,2]=0, p );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 8 "lhs, rhs" }}{PARA 0 "" 0 "" {TEXT -1 13 "The commands " } {TEXT 282 3 "lhs" }{TEXT -1 5 " and " }{TEXT 283 3 "rhs" }{TEXT -1 84 ": These commands pick out the left hand side and the right hand side \+ of an equation:" }{TEXT 284 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "equation 1:=sin(x)+x = cos(x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "a: =lhs(equation1);\nb:=rhs(equation1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 126 "If we have a set or list of equations we could extract the rig ht hand side or the left hand sides of the equations as follows:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "EqSet:=\{x^2+2*x+1 = 4*y^4+z , sin(x) = exp(x^2), tan(x) = cos(y)*sec(z)\};" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 15 "map(rhs,EqSet);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "map(lhs,EqSet);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 12 "numer, denom" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 13 "The commands " }{TEXT 285 5 "numer " }{TEXT -1 5 " and " }{TEXT 286 5 "denom" }{TEXT -1 72 " allow one to give names to the numerator and denominator of a fraction:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "numer(3/7);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "denom(3/7);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 47 "f:=(2*x^3+y*z+ exp(tan(x)))/(sin(x*y*z)+w*r+2) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "X1:=numer(f);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "X2:=denom(f);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "This is somewhat easier than using the eq uivalent op commands:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "op( 1,f);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "op([2,1],f);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 38 "different kinds of quo tes: \", ' and `" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "restart " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 57 "The following is taken mostly from the Maple online help:" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 15 "" 0 "" {TEXT -1 84 "Three different types of quotes a re used in Maple for three different purposes: \nas " }{TEXT 289 6 "st ring" }{TEXT -1 17 " delimiters; \nas " }{TEXT 290 6 "symbol" }{TEXT -1 32 " delimiters; and \nas a means of " }{TEXT 291 19 "delaying eval uation" }{TEXT -1 19 " of an expression. " }}{PARA 15 "" 0 "" {TEXT -1 4 "The " }{TEXT 292 12 "double-quote" }{TEXT -1 27 " symbol (\") is used as the " }{HYPERLNK 17 "string" 2 "string" "" }{TEXT -1 12 " del imiter. " }}{PARA 15 "" 0 "" {TEXT -1 4 "The " }{TEXT 293 10 "back-quo te" }{TEXT -1 30 " symbol (`) is used to form a " }{HYPERLNK 17 "symbo l" 2 "symbol" "" }{TEXT -1 2 ". " }}{PARA 15 "" 0 "" {TEXT -1 2 "A " } {TEXT 294 21 "pair of single quotes" }{TEXT -1 71 " (' ') is used to \+ delay evaluation of the enclosed expression --- see " }{HYPERLNK 17 "u neval" 2 "uneval" "" }{TEXT -1 1 " " }}{PARA 15 "" 0 "" {TEXT -1 70 "I n earlier versions of Maple, the double-quote symbol was used as the \+ " }{HYPERLNK 17 "ditto" 2 "ditto" "" }{TEXT -1 64 " operator. This fac ility is now provided by the percent symbol. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 44 "We now discuss each of th ese in more detail:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 2 "A " }{TEXT 295 6 "string" }{TEXT -1 246 " is a sequence \+ of characters that has no value other than itself. It cannot be assign ed to, and will always evaluate to itself. Strings are usually used fo r processing text. We shall give examples later when we discuss some c ryptographic schemes." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "s: =\"This is a string\";" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "w hattype(s);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 2 "A " }{TEXT 35 4 "name" }{TEXT -1 300 " is usually a symb ol, which in its simplest form is a letter followed by zero or more le tters, digits, and underscores, with lowercase and uppercase letters d istinct. A name may also be formed by enclosing any sequence of charac ters in a pair of backquotes. What we usually thing of as variables ar e " }{TEXT 296 5 "names" }{TEXT -1 30 ".\n A key difference between a \+ " }{TEXT 297 4 "name" }{TEXT -1 7 " and a " }{TEXT 298 6 "string" } {TEXT -1 9 " is that " }{TEXT 299 58 "any value may be assigned to a n ame, but not to a string. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "`this is a variable with a long name`:=2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "`this is a variable with a long name`*3;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "\"this is a string and canno t be used as a name\":=2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 203 "A n ame need not be enclosed by back-quotes if it begins with a letter and contains no spaces. In this case the name is the same whether or not \+ the back-quotes are included as the following example shows:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "this_is_a_name:=2;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "`this_is_a_name` - this_is_a _name;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "We have seen the use of a pair of single quotes before. I will recall some of those uses her e:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "x:=2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "x:='x':" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 2 "x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "sum ('i^2','i'=1..n);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "f:=pro c(x) if x < 0 then RETURN(-x); else RETURN(x); fi; end:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "Note that we get an error here if we don' t use quotes:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "plot(f(x), x=-1..1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 18 "But this is works:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "plot('f(x)',x=-1..1, titl e=\"absolute value of x\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 103 "B ut note that in the title ` `will also sometimes work but as we see be low can sometimes lead to error:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "plot('f(x)',x=-1..1, title=`absolute value of x`);" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "`constant1`:=5:\nplot(sin( `constant1`*x),x=0..1, title = `constant1`);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "`constant1`:=5:\nplot(sin(`constant1`*x),x=0..1, title = \"constant1\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "Somet imes it is convenient to use " }{TEXT 309 14 "convert/string" }{TEXT -1 14 ". For example:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "a: =5:\nplot(sin(a*x),x=0..2*Pi,title = convert(sin(a*x),string));" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "Recall also the use of \" \" in th e formating part of a " }{TEXT 310 6 "printf" }{TEXT -1 11 " statement :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "printf(\"The result is x = %d \\n\", 987);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 49 "Recall al so the use of ' ' in the use of member:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "member(3, [1,1,1,3,5], 'position3');" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "position3;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 46 "converting text to numbers and nu mbers to text" }}{PARA 0 "" 0 "" {TEXT -1 7 "We can " }{TEXT 300 7 "co nvert" }{TEXT -1 66 " strings (i.e., text) to a list of numbers by usi ng the procedure " }{TEXT 301 13 "convert/bytes" }{TEXT -1 257 " as in the following examples. Each symbol (letters of the alphabet, punctu ation mark, etc) corresponds to a number from 0 to 255. Although the d ocumentation does not say, this appears to be essentially the so-call ed 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);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "convert(\"Hello world\",bytes);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "convert([72, 101, 108, 108, 111, 32, 119, 111 , 114, 108, 100],bytes);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 18 "As we see above, " }{TEXT 347 21 "convert(string,bytes)" }{TEXT -1 16 " al ways gives a " }{TEXT 346 4 "list" }{TEXT -1 44 " of integers from 1 t o 255. And, if L is a " }{TEXT 350 4 "list" }{TEXT -1 50 " of integer s each in the range from 1 to 255 then " }{TEXT 348 16 "convert(L,byte s)" }{TEXT -1 11 " returns a " }{TEXT 349 6 "string" }{TEXT -1 13 " (i n quotes)." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 167 "Note that double quotes, \", within a string wil l cause confusion unless you replace each \" by \"\" or by \\\" as in \+ the following examples. Note the first gives an error:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "Text:= \"General Washington said, \"Attack at dawn!\", before he went to slee p.\";" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "Text:=\"General Wa shington said, \"\"Attack at dawn!\"\", before he went to sleep.\";" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "Text:=\"General Washington said, \\\"Attack at dawn!\\\", before he went to sleep.\";" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 87 "No w we convert this string to a list of number and then convert back to \+ to the string: " }}}{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 30 "We can also convert text to a " } {TEXT 351 19 "list of the symbols" }{TEXT -1 70 " in the text, for var ious types of word processing. Here's an example:" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 25 "List:=convert(Text,list);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "nops(List);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 32 "We get the same value by use of " }{TEXT 303 6 "length" } {TEXT -1 1 ":" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "length(Tex t);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 14 "The procedure " }{TEXT 352 3 "cat" }{TEXT -1 115 " may be used to concatenate several strings , that is, put them together to form a single string. Here's an exampl e:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "s1:=\"The\";\ns2:=\" \+ \";\ns3:=\"sky\";\ns4:=\"is\";\ns5:=\"beautiful\";\ns6:=\"today\";\ns7 :=\".\";" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "cat(s1,s2,s3,s2 ,s4,s2,s5,s2,s6,s7);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 301 "We can g et 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 int erface, yet they are still considered as distinct, as we shall see. Th e conversion seems to depend to some degree on what type of computer i s being used." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "L:=[seq(co nvert([i],bytes),i=0..255)];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "nops(convert(L,set));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "LL:=cat(op(L));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "conv ert(LL,bytes);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "S:=conver t(%,set):\nnops(S);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "\{se q(i,i=0..255)\} minus S;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 85 "On my Mac both 10 and 13 convert to \"\\n\". This may not be the case on al l platforms. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "convert([1 0,13],bytes);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "convert(%, bytes);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "Note that 0 and 256 an d any numbers not in the range 1 to 255 convert to \"\" (the empty str ing)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "seq(convert([x],by tes), x=[-100,-1,0,256,257,1000]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 37 "substring, \+ SearchText, and searchtext" }}{PARA 0 "" 0 "" {TEXT 311 23 "substring( string, a..b)" }{TEXT -1 121 " extracts from the substring starting wi th the a-th character and ending with the b-th character. Here are som e examples:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "restart:\ntex t:=\"abcdefghijk\";" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "subs tring(text, 1...3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "subs tring(text,-3..-1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "subs tring(text, 4..7);" }}}{EXCHG {PARA 15 "" 0 "" {TEXT 312 10 "SearchTex t" }{TEXT -1 5 " and " }{TEXT 313 10 "searchtext" }{TEXT -1 20 " are v ery similar. " }{TEXT 314 10 "SearchText" }{TEXT -1 71 " searches for the pattern in the string looking for exact matches. The " }{TEXT 315 11 "searchtext " }{TEXT -1 112 "function does the same searching, \+ but it is case insensitive; that is, upper/lower case differences are \+ ignored." }}{PARA 15 "" 0 "" {TEXT -1 192 "If the pattern is found, bo th functions return an integer which indicates the position of the fir st character that matched. If the pattern is not found in the string, \+ these functions return 0." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "searchtext(\"cde\", \"ABCDEFcde567x yz\");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "SearchText(\"cde \", \"ABCDEFcde567xyz\");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "SearchText(\"cab\", \"ABCDEFcde567xyz\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 7 "In the " }{TEXT 353 11 "StringTools" }{TEXT -1 46 " pac kage you will find lots more sophisticated" }}{PARA 0 "" 0 "" {TEXT -1 34 " commands for string manipulation." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 18 "with(StringTools):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 139 "To checkout the commands available, execute the followin g command and you will find clickable links to the various commands in StringTools." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "?StringToo ls" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Here are just a few example s:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "Map(Capitalize,\"This is a sample string.\");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "UpperCase(\"This is a sample string.\");" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 38 "LowerCase(\"THIS IS A SAMPLE STRING.\");" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 137 "Remove( x->evalb( member(x, \{ \"a\", \"e\", \"i\", \"o\", \"u\" \} )), \"Some people contend tha t in the English language vowels are superfluous.\" );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 39 "Assignment \+ 10, Due Wednesday, April 10" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "" 0 "" {TEXT 361 10 "Problem 1." }{TEXT -1 5 " Let " } {XPPEDIT 18 0 "Z[256];" "6#&%\"ZG6#\"$c#" }{TEXT -1 97 " = \{0,1,2,. . ., 255\} denote the set of integers from 0 to 255. Consider for each element a in " }{XPPEDIT 18 0 "Z[256];" "6#&%\"ZG6#\"$c#" }{TEXT -1 19 " the function f : " }{XPPEDIT 18 0 "Z[256]" "6#&%\"ZG6#\"$c#" } {TEXT -1 4 " ->" }{XPPEDIT 18 0 "Z[256];" "6#&%\"ZG6#\"$c#" }{TEXT -1 56 " defined by the rule f(x) = a*x mod 256 for all x in " } {XPPEDIT 18 0 "Z[256];" "6#&%\"ZG6#\"$c#" }{TEXT -1 117 " . Note that \+ since n mod 256 is the remainder when n is divided by 256 each such f \+ is a well defined function from " }{XPPEDIT 18 0 "Z[256];" "6#&%\"ZG 6#\"$c#" }{TEXT -1 65 " to itself. Note that there is one such functi on for each a in " }{XPPEDIT 18 0 "Z[256];" "6#&%\"ZG6#\"$c#" }{TEXT -1 57 " , Note that since f depends on a we should write it as " } {XPPEDIT 18 0 "f[a];" "6#&%\"fG6#%\"aG" }{TEXT -1 2 " :" }{XPPEDIT 18 0 "Z[256]" "6#&%\"ZG6#\"$c#" }{TEXT -1 4 " ->" }{XPPEDIT 18 0 "Z[256] ;" "6#&%\"ZG6#\"$c#" }{TEXT -1 50 " and we could try to define using t he Maple code: " }{MPLTEXT 1 0 21 "f[a]:=x->a*x mod 256;" }{TEXT -1 105 " Unfortunately this doesn't work. However the following method do es work. This procedure if given input " }{TEXT 374 1 "a" }{TEXT -1 46 " will output a function (really a procedure) " }{TEXT 375 5 "f (a )" }{TEXT -1 11 " such that " }{TEXT 376 24 "f(a)(x) = a*x mod 256. \+ " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "f:=proc(a) x->a*x mod 256; end proc:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "\nHere are examples of how it can be used : Note that " }{TEXT 377 7 "f(a) : " }{XPPEDIT 378 0 "Z[256]" "6#&%\"Z G6#\"$c#" }{TEXT 379 4 " ->" }{XPPEDIT 380 0 "Z[256.];" "6#&%\"ZG6#-% &FloatG6$\"$c#\"\"!" }{TEXT -1 5 ". So " }{TEXT 381 20 "f(a)(x) =a*x m od 256" }{TEXT -1 41 "; For example if we take a = 13, we have:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "f(13);\n" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 31 "f(13)(1), f(13)(2), f(13)(200);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 90 "Note that we can use map to obtain the im age of the set \{1,2,200\} under the mapping f(13)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "map(f(13),\{1,2,200\});" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 40 "( a) Determine for which values of a in " }{XPPEDIT 18 0 "Z[256];" "6#& %\"ZG6#\"$c#" }{TEXT -1 15 " the functions " }{TEXT 354 4 "f(a)" } {TEXT -1 182 " are onto? Use Maple to determine this even if you might be able to figure it out using some theory. Hints available on reques t. The answer should be a list containing 128 integers.\n" }}{PARA 0 " " 0 "" {TEXT -1 39 "(b) Determine for which values of a in " } {XPPEDIT 18 0 "Z[256]" "6#&%\"ZG6#\"$c#" }{TEXT -1 14 " the function \+ " }{TEXT 355 4 "f(a)" }{TEXT -1 185 " is 1-1. You may use the fact tha t a mapping from a finite set with n elements to a finite set with n e lements is 1-1 if and only if it is onto.\n\n(c) It is a fact that if \+ the function " }{TEXT 356 4 "f(a)" }{TEXT -1 46 " has an inverse then its inverse has the form " }{TEXT 371 4 "f(b)" }{TEXT -1 16 " for som e b in " }{XPPEDIT 18 0 "Z[256]" "6#&%\"ZG6#\"$c#" }{TEXT -1 28 " . \+ Note for example, that " }{TEXT 357 5 "f(13)" }{TEXT -1 5 " and " } {TEXT 358 6 "f(197)" }{TEXT -1 95 " are inverses since their compositi on returns x in the following in the following computations:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "f(13)(f(197)(x));" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "f(197)(f(13)(x));" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 9 "Find the " }{TEXT 372 3 "set" }{TEXT -1 107 " of all pairs \{a,b\} such that f(a) and f(b) are inverses of each othere. So your \+ answer to (c) should be a " }{TEXT 373 3 "set" }{TEXT -1 274 " of pair s including the pair \{13,197\}. Note that this way we don't count \{1 3,197\} as different from \{197,13\}. You should have 66 \"pairs\". A few are inverses of themselves so these pairs will be \"degenerate\", that is, in some cases we have f(a) is its own inverse.\n\n(d) Use " }{TEXT 362 6 "select" }{TEXT -1 80 " to pick out the \"degenerate pair s\" in the output to (c). Note that you can use " }{TEXT 363 21 "x->ev alb(nops(x) = 1)" }{TEXT -1 48 " to pick out the \"pairs\" with only o ne element.\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 316 9 "Problem 2" } {TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 74 "I used the following me thod to encrypt a message: I chose at random some " }{TEXT 323 1 "a" }{TEXT -1 36 " in the set \{0,2,...,255\} such that " }{TEXT 364 4 "f( a)" }{TEXT -1 79 " is both 1-1 and onto. I next converted the message \+ to a list of numbers using " }{TEXT 318 7 "convert" }{TEXT -1 13 ". Th en using " }{TEXT 319 3 "map" }{TEXT -1 12 ", I applied " }{TEXT 359 4 "f(a)" }{TEXT -1 59 " to each element in the list to obtain the list of numbers:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 193 "[49, 85, 218, 125, 198, 155, 188, 55, 228, 155, 188, 115, 85, \+ 218, 65, 219, 96, 195, 85, 55, 96, 248, 155, 178, 135, 96, 22, 198, 85 , 105, 135, 218, 96, 188, 248, 135, 96, 145, 85, 12, 135, 26]" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 365 25 "Find my \+ original message." }{TEXT -1 2 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT 321 4 "Hint" }{TEXT -1 48 ". The message contain s the word \"the\". So using " }{TEXT 322 10 "searchtext" }{TEXT -1 86 " can help you pick out the correctly decrypted message as you appl y all possible b's. " }{TEXT 360 53 "Whatever you do don't print out m ore than one message" }{TEXT -1 94 ". You may experiment, but your fin al answer should just be a one line message. If you use the " }{TEXT 366 10 "searchtext" }{TEXT -1 24 " hint it will be easier." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 320 21 "[COPYING AND PAS TING:" }{TEXT -1 411 " I have found that when attempting to copy and p aste text such as the list of numbers above into an input field of Map le, sometimes I can make it work by copying and pasting first into a w ord processor. Then, from there, copy and paste into a Maple input reg ion. On some platforms you may be able to do it directly. On others, \+ when you paste into a Maple input region the material is converted to Maple text.]" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 317 17 "Problems 3 and 4." } {TEXT -1 2 " (" }{TEXT 325 27 "This counts as two problems" }{TEXT -1 196 ".) If you cannot do part (1) send me an email and I will send a p rogram to do it. This will cost you 1/2 out of a possible 2 points for this problem, but should allow you to do the other parts. ) " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 76 "Of course , all of this should be done using Maple and not counted by sight. " } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 171 "(1) Ma ke a list of the distinct words in the following text (which is the se cond paragraph of the Declaration of Independence). [If you put the te xt in a variable called " }{TEXT 324 5 "text " }{TEXT -1 76 "then you \+ can remove all comma, periods, etc, by use of the following code. ]" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 258 "" 0 "" {TEXT -1 99 "> T1:= convert(text,list):\n> T2:=remove(x->evalb(member(x,\{\".\",\",\",\"; \",\":\"\})),T1):\n> T:=cat(op(T2));" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 77 "Then you will need to find a way to mak e a list the contains only the words. " }{TEXT 367 5 "Hints" }{TEXT -1 428 ": Note that all words except the first and last are surrounded by blank spaces. You can use searchtext to find the first location of the first blank space. What precedes that will be a word. Remove that word, put it in your list, then replace the original text with the pr evious text with the word found just removed. Continue until you have \+ removed all the words.\n\n(2) Sort the list of words in order of incre asing word length." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 48 "(3) Find the total number of words in the text. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 37 " ( a) counting repetitions, and" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 37 " (b) not counting repetitions." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 390 "(4) Find the n umber of words in the text of each length from 1 to the maximum length word. If a word occurrs k times it should add k to the count. For ex ample, since \"a\" occurrs 4 times and it is the only word of length 1 , the first line of your output should say, \"There are 4 words of le ngth 1.\", The next line should say, \"There are 49 words of length 2. \", and so forth. One way is to " }{TEXT 368 3 "map" }{TEXT -1 1 " " } {TEXT 369 6 "length" }{TEXT -1 79 " onto the list of words. Then you w ill have a list of the lengths of the words." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 237 "(5). For each letter of the al phabet a through z determine the number of words (counting repetitions ) in the text containing the letter. Do not distinguish between upper \+ and lower case letters. Note that a word W contains letter \"x\" if \+ " }{TEXT 370 21 "searchtext(\"x\",W) > 0" }{TEXT -1 185 ". You may sel ect the words that contain \"x\" and then count them. A suitable outpu t would be 26 lines. The first being, \"Letter a is in 85 words.\" The last being, \"Letter z is in 1 word." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 258 "" 0 "" {TEXT -1 16 "Here's the text:" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 1624 "We hold these truths \+ to be self-evident, that all men are created equal, that they are endo wed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness. That to secure these \+ rights, Governments are instituted among Men, deriving their just powe rs from the consent of the governed, That whenever any Form of Governm ent becomes destructive of these ends, it is the Right of the People t o alter or to abolish it, and to institute new Government, laying its \+ foundation on such principles and organizing its powers in such form, \+ as to them shall seem most likely to effect their Safety and Happiness . Prudence, indeed, will dictate that Governments long established sho uld not be changed for light and transient causes; and accordingly all experience hath shewn, that mankind are more disposed to suffer, whil e evils are sufferable, than to right themselves by abolishing the for ms to which they are accustomed. But when a long train of abuses and u surpations, pursuing invariably the same Object evinces a design to re duce them under absolute Despotism, it is their right, it is their dut y, to throw off such Government, and to provide new Guards for their f uture security. Such has been the patient sufferance of these Colonies ; and such is now the necessity which constrains them to alter their f ormer Systems of Government. The history of the present King of Great \+ Britain is a history of repeated injuries and usurpations, all having \+ in direct object the establishment of an absolute Tyranny over these S tates. To prove this, let Facts be submitted to a candid world." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{MARK "10" 0 }{VIEWOPTS 0 0 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 1 1 1 33 1 1 }