{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 0 }{CSTYLE "" -1 414 "" 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 "Tim es" 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 "Times" 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 14 " The procedure " }{TEXT 35 6 "evalb " }{TEXT -1 27 "evaluates an expres sion to " }{TEXT 262 4 "true" }{TEXT -1 2 ", " }{TEXT 263 5 "false" } {TEXT -1 311 ", or, if it cannot tell, it just returns the input expre ssion as is. But in some cases (see examples below) it even returns f alse when the correct answer is true. In some cases this can be correc ted by applying the appropriate simplification or evaluation first. Th is is best understood by looking at examples:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT -1 6 "Since " }{TEXT 260 5 "eva lb" }{TEXT -1 172 " does not simplify expressions, it may return false to a relation which is actually true. In such a case, appropriate sim plification must be applied to the relation before " }{TEXT 398 5 "eva lb" }{TEXT -1 56 " is used. In the next section we see that the proced ure " }{TEXT 389 2 "is" }{TEXT -1 29 " will sometimes succeed when " } {TEXT 390 5 "evalb" }{TEXT -1 9 " doesn't." }}{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 117 "This means that the inequality cannot be determined. B ut the following does help. Of course, they may be cases where " } {TEXT 399 6 "Digits" }{TEXT -1 97 " would have to be set very high to \+ get the correct answer. Nevertheless this works in most cases." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "evalb(evalf(sqrt(2)) < evalf (sin(3)));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "evalf(sqrt(2) ), evalf(sin(5));" }}}{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 fo r " }{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 "" {TEXT -1 47 "See how evalb of A=B gives an incorrect answer:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalb(A=B);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "To check equality of Matrices we do the f ollowing?" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "LinearAlgebra[ Equal](A,B);" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {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,listlist));" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 33 "The above problem holds also for " }{TEXT 327 8 "m atrices" }{TEXT -1 23 " and can be fixed with " }{TEXT 328 61 "linalg[ equal], or convert(A,listlist) = convert(B,listlist).\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 25 "Let's create a procedure " }{TEXT 339 2 " le" }{TEXT -1 42 " that has as input two arguments x and y. " }{TEXT 340 7 "le(x,y)" }{TEXT -1 13 " will return " }{TEXT 337 4 "true" } {TEXT -1 4 " if " }{XPPEDIT 18 0 "x <= y;" "6#1%\"xG%\"yG" }{TEXT -1 5 " and " }{TEXT 338 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 "le(1,1), le(1,3), le (3,1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Let's now create a proc edure " }{TEXT 341 3 "le2" }{TEXT -1 25 " whose input will be two " } {TEXT 329 5 "lists" }{TEXT -1 18 " L and M. We want " }{TEXT 330 8 "le 2(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 28 "What the me aning of \"is\" is." }}{PARA 0 "" 0 "" {TEXT -1 12 "The command " } {TEXT 380 11 "is(x,prop) " }{TEXT -1 42 "returns true if Maple can det ermine that " }{TEXT 381 1 "x" }{TEXT -1 14 " has property " }{TEXT 382 6 "prop, " }{TEXT -1 50 "false if Maple can determine that it does not and " }{TEXT 383 5 "FAIL " }{TEXT -1 51 " if it cannot decide. On e may also use the command " }{TEXT 384 8 "is(rel) " }{TEXT -1 3 "if \+ " }{TEXT 385 3 "rel" }{TEXT -1 34 " is a relation and it will return \+ " }{TEXT 400 4 "true" }{TEXT -1 2 ", " }{TEXT 401 5 "false" }{TEXT -1 4 " or " }{TEXT 402 4 "FAIL" }{TEXT -1 29 " depending on whether or no t " }{TEXT 386 3 "rel" }{TEXT -1 85 " is true, false, or Maple cannot \+ decide. The following examples will also show that " }{TEXT 387 3 "is " }{TEXT -1 17 "may succeed when " }{TEXT 388 5 "evalb" }{TEXT -1 61 " will fail. Although in some cases they give the same result." }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "is(1/2,integer);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "is(2+3*I,real);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "is(x = x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "is(1 < 2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "is(sqrt(2) < sqrt(3));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "Rec all that " }{TEXT 393 5 "evalb" }{TEXT -1 41 " fails in the above case . Note that when " }{TEXT 392 5 "evalb" }{TEXT -1 55 " cannot decide i t return the relation entered, whereas " }{TEXT 391 2 "is" }{TEXT -1 14 " returns FAIL." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "evalb (sqrt(2) < sqrt(3));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "is( D,positive);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "assume(t,in teger);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "is(t+1,integer); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "is(t+1/2,integer);" }}} {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 "sort " }{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 specify 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 16 "L1:=[5,3,4,1,2];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "L 2:=sort(L1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "L1;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 102 "Polynomials are sorted into desce nding order of the term degrees: In the case of polynomials they are \+ " }{TEXT 403 15 "sorted in place" }{TEXT -1 29 ". The old order is des troyed." }}}{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 139 "In this c ase we did not have to give p1 a new name. Note that p1 itself has b een changed. This is a somewhat unusual situation in Maple. " }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 159 "One can sort lists in various ways by inserting an optional se cond parameter which is a Boolean function F of two variables: Such a F can be created by using " }{TEXT 266 5 "evalb" }{TEXT -1 133 " as w e did at the end of the previous section. For example, the following g ives a Boolean function GE(x,y) which is true if x >=y. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "restart:\nGE:=(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 "" {TEXT -1 51 "Using this we can sort lists into descending order:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 " L1:=[5,1,2,4,3];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "L2:=sor t(L1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "L3:=sort(L1,GE); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "A simpler method for reversin g the order of " }{TEXT 333 7 "numbers" }{TEXT -1 243 " in a list is t he following. But it is best to learn the more general method in case \+ you are sorting lists that are not entirely numerical. Notice the use \+ of backquotes in `>`. This is not to be confused with single (forward) quotes as in '>'." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "L4:=s ort(L1,`>`);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 35 "It is often more \+ convenient to use " }{TEXT 394 18 "unnamed procedures" }{TEXT -1 28 " \+ for the second variable in " }{TEXT 267 4 "sort" }{TEXT -1 179 " as we illustrate below. This avoids introducing a name for a procedure we w ill 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 "restart:" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 30 "L1:=[seq(i^3 mod 10,i=1..10)];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "L2:=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 "L 3:=sort(L1,`>`);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 202 "Here's an ex ample where we may must 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, a s follows: We first create 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 "L1:=[seq([die(),die(),die()],i=1..10)];" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "We sort the small inner lists on \+ their second coordinates:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "L2:=sort(L1,(x,y)->evalb(x[2]<=y[2]));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "Sort will sort words into alphabetical (lexorder) order: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "restart:\nsort([ betty, carla,aaron, Betty, Aaron,Carla ], lexorder );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 68 "But note that capitalized words come before all unca pitalized words." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 50 "select, remove, selectremove, member, has, hastype" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 20 "Wh at the procedures " }{TEXT 270 36 "select, remove, selectremove, membe r" }{TEXT -1 2 ", " }{TEXT 271 3 "has" }{TEXT -1 6 ", and " }{TEXT 395 7 "hastype" }{TEXT -1 39 " may be seen in 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 single pass by use of " }{TEXT 334 12 "selectrem ove" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "L4:= selectremove(isprime,L1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Cons ider a few more examples." }}}{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:=se lectremove(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 40 "( x,S) is true if x is in S where S is a " }{TEXT 396 3 "set" }{TEXT -1 4 " or " }{TEXT 397 4 "list" }{TEXT -1 1 "." }}}{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 "member(1,S);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "member(5,S);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 158 "If there i s a third argument for member, it will store the position of the first x in S, as in the following example. Note that here we use 'x' and no t `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 335 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 return 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 "has(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 336 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 28 "hastype(x^2+2*x-1,nega tive);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "selectremove(hast ype,[1,-2,x,-t,-sqrt(3)],negative);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "selectremove(hastype,[1,-2,x,-t,-sqrt(3)],numeric);" }}}{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 "op " }{TEXT 274 34 " extracts the various components (" }{TEXT 275 8 "ope rands" }{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 dealing w ith sets and lists:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "resta rt:" }}}{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 there are two ways o f 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 48 "L;\nop(1,L), op(-2,L),op(-1, L);\nL[1],L[-2],L[-1];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "L ;\nop(2..4,L);\nL[2..4];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 112 "Most Maple objects are composed of several operands, you may see what they are in a particular case by applying " }{TEXT 342 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 8 "op(0,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,igcd(x,y)); \nop(2,igcd(x,y));\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "nop s(sin(x)),op(0,sin(x));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 281 25 "subso p(i = expression, p)" }{TEXT -1 51 " will replace whatever is in the i -th part of p by " }{TEXT 343 10 "expression" }{TEXT -1 7 ". Like " } {TEXT 308 4 "subs" }{TEXT -1 54 " it does not change p itself. We illu strate 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 "subsop( [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 17 "lhs, rhs, isolate" }}{PARA 0 "" 0 "" {TEXT -1 13 "The com mands " }{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 righ t 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 "equation1:=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 right hand side or the left hand sides of the equat ions 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 "" {TEXT -1 12 "The command " }{TEXT 404 18 "isolate(eqn, expr)" }{TEXT -1 41 " attempts to isolate the second argument " } {TEXT 405 4 "expr" }{TEXT -1 23 " in the first argument " }{TEXT 406 3 "eqn" }{TEXT -1 31 " on one side of the equation. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "isolate(x^2*sin(x) = cos(x)*sin(x) \+ + 5 , sin(x)); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "isolate( cos(sin(x)^2) = exp(x), sin(x));" }}}{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 equivalent 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 quotes: \", ' and `" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "re start;" }}}{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 \+ are used in Maple for three different purposes: \nas " }{TEXT 289 6 "s tring" }{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 60 "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 15 "But this works:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "plot('f(x)',x=-1..1, title= \"absolute value of x\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 103 "But note that in the title ` `will also sometimes work but as we see belo w 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(`constant 1`*x),x=0..1, title = `constant1`);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "`constant1`:=5:\nplot(sin(`constant1`*x),x=0..1, titl e = \"constant1\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "Sometimes \+ 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:\np lot(sin(a*x),x=0..2*Pi,title = convert(sin(a*x),string));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 55 "Recall also the use of \" \" in the forma tting part of a " }{TEXT 310 6 "printf" }{TEXT -1 11 " statement:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "printf(\"The result is x = % d. \\n\", 987);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "Recall also th e 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 256 " as in the following examples. Each symbol (letter of the alphabet, punctua tion mark, etc) corresponds to a number from 0 to 255. Although the do cumentation does not say, this appears to be essentially the so-calle d 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 345 21 "convert(string,bytes)" }{TEXT -1 16 " al ways gives a " }{TEXT 344 4 "list" }{TEXT -1 44 " of integers from 1 t o 255. And, if L is a " }{TEXT 348 4 "list" }{TEXT -1 50 " of integer s each in the range from 1 to 255 then " }{TEXT 346 16 "convert(L,byte s)" }{TEXT -1 11 " returns a " }{TEXT 347 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 349 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 350 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 115 "We can g et a list of all symbols as follows. The conversion seems to depend on what type of computer is being used." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "L:=[seq(convert([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 "convert(LL,bytes);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "S:=convert(%,set):\nnops(S);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "\{seq(i,i=0..255)\} minus S;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "Note that 0 and 256 and any numbers not i n the range 1 to 255 convert to \"\" (the empty string)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "seq(convert([x],bytes), x=[-100,-1, 0,256,257,1000]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 48 "substring, SearchText, searchtext , and SearchAll" }}{PARA 0 "" 0 "" {TEXT 311 23 "substring(string, a.. b)" }{TEXT -1 15 " extracts from " }{TEXT 407 6 "string" }{TEXT -1 107 " the substring starting with the a-th character and ending with t he b-th character. Here are some examples:" }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 29 "restart:\ntext:=\"abcdefghijk\";" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "substring(text, 1...3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "substring(text,-3..-1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "substring(text, 4..7);" }}}{EXCHG {PARA 15 "" 0 "" {TEXT 312 10 "SearchText" }{TEXT -1 5 " and " }{TEXT 313 10 "searchtext" }{TEXT -1 20 " are very similar. " }{TEXT 314 10 "Sea rchText" }{TEXT -1 71 " searches for the pattern in the string looking for exact matches. The " }{TEXT 315 11 "searchtext " }{TEXT -1 113 "p rocedure 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, both functions return an integer whic h indicates the position of the first character that matched. If the p attern is not found in the string, these functions return 0." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "s earchtext(\"cde\", \"ABCDEFcde567xyz\");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "SearchText(\"cde\", \"ABCDEFcde567xyz\");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "SearchText(\"cab\", \"ABCDEFcde567x yz\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 7 "In the " }{TEXT 351 11 " StringTools" }{TEXT -1 61 " package you will find many commands for st ring manipulation." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "with( StringTools):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "To checkout the \+ commands available see help for StringTools. " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Here are just a few examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "SearchAll(\"Aba\", \"AbacccAbadddAbaba\");" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 106 "SearchAll is similar to SearchTex t except it finds all occurrence of the sought string in the given tex t. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "UpperCase(\"This is \+ a sample string.\");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "Low erCase(\"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 that 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 41 "Assignment 10, Due Tuesday, November 19. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 359 10 "Problem 1." }{TEXT -1 5 " Let " }{XPPEDIT 18 0 "Z[256];" "6#&%\"ZG 6#\"$c#" }{TEXT -1 97 " = \{0,1,2,. . ., 255\} denote the set of integ ers from 0 to 255. Consider for each element a in " }{XPPEDIT 18 0 " Z[256];" "6#&%\"ZG6#\"$c#" }{TEXT -1 22 " the function f(a) : " } {XPPEDIT 18 0 "Z[256]" "6#&%\"ZG6#\"$c#" }{TEXT -1 4 " ->" }{XPPEDIT 18 0 "Z[256];" "6#&%\"ZG6#\"$c#" }{TEXT -1 59 " defined by the rule f (a)(x) = a*x mod 256 for all x in " }{XPPEDIT 18 0 "Z[256];" "6#&%\" ZG6#\"$c#" }{TEXT -1 137 " . Note that since n mod 256 (or modp(n,256 ) is the remainder when n is divided by 256 each such f(a) is a well \+ defined function from " }{XPPEDIT 18 0 "Z[256];" "6#&%\"ZG6#\"$c#" } {TEXT -1 65 " to itself. Note that there is one such function for eac h a in " }{XPPEDIT 18 0 "Z[256];" "6#&%\"ZG6#\"$c#" }{TEXT -1 61 " , \+ Note that since f (a) 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 the Maple code: " }{MPLTEXT 1 0 23 "f[a]:=x->modp(a*x,256);" }{TEXT -1 105 " Un fortunately this doesn't work. However the following method does work. This procedure if given input " }{TEXT 372 1 "a" }{TEXT -1 46 " will output a function (really a procedure) " }{TEXT 373 5 "f (a)" } {TEXT -1 11 " such that " }{TEXT 374 24 "f(a)(x) = a*x mod 256. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "f:=proc(a) x->modp(a*x,256); end proc:" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 52 "\nHere are examples of how it can be used: Note that " }{TEXT 375 7 "f(a) : " }{XPPEDIT 376 0 "Z[256]" "6#&%\"ZG6#\"$c#" } {TEXT 377 4 " ->" }{XPPEDIT 378 0 "Z[256.];" "6#&%\"ZG6#-%&FloatG6$\" $c#\"\"!" }{TEXT -1 5 ". So " }{TEXT 379 20 "f(a)(x) =a*x mod 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 image of t he 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 " " {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 352 4 "f(a)" }{TEXT -1 182 " are onto? Use Maple to determine this eve n if you might be able to figure it out using some theory. Hints avail able on request. 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 fun ction " }{TEXT 353 4 "f(a)" }{TEXT -1 185 " is 1-1. You may use the fa ct that a mapping from a finite set with n elements to a finite set wi th n elements is 1-1 if and only if it is onto.\n\n(c) It is a fact th at if the function " }{TEXT 354 4 "f(a)" }{TEXT -1 46 " has an invers e then its inverse has the form " }{TEXT 369 4 "f(b)" }{TEXT -1 16 " f or some b in " }{XPPEDIT 18 0 "Z[256]" "6#&%\"ZG6#\"$c#" }{TEXT -1 28 " . Note for example, that " }{TEXT 355 5 "f(13)" }{TEXT -1 5 " a nd " }{TEXT 356 6 "f(197)" }{TEXT -1 121 " are inverses since their co mposition applied to x is x for all x from 0 to 255 as verified in the following computation:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 142 "inverse:=true:\nfor x from 0 to 255 do\nif (f(13)@f(197))(x)<> x or ( f(197)@f(13))(x) <> x then inverse:=false; break; \nend if;\nend do:\n inverse;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 9 "Find the " }{TEXT 370 3 "set" }{TEXT -1 106 " of all pairs \{a,b\} such that f(a) and f(b) are inverses of eac h other. So your answer to (c) should be a " }{TEXT 371 3 "set" } {TEXT -1 302 " of \"pairs\" including the pair \{13,197\}. Note that t his way we don't count \{13,197\} as different from \{197,13\}. You sh ould have 66 \"pairs\". A few are inverses of themselves so these pai rs will be \"degenerate\", that is, in some cases we have f(a) is its \+ own inverse. It might help to write a procedure " }{TEXT 409 12 "Inver seCheck" }{TEXT -1 31 " with input a and b and output " }{TEXT 410 4 " true" }{TEXT -1 49 " if f(a) and f(b) are inverses of each other and \+ " }{TEXT 411 5 "false" }{TEXT -1 83 " if not. Then you can go through \+ all possible a and b and find the pairs for which " }{TEXT 412 17 "Inv erseCheck(a,b)" }{TEXT -1 24 " returns true.\n\n(d) Use " }{TEXT 360 6 "select" }{TEXT -1 80 " to pick out the \"degenerate pairs\" in the \+ output to (c). Note that you can use " }{TEXT 361 21 "x->evalb(nops(x) = 1)" }{TEXT -1 48 " to pick out the \"pairs\" with only one element. \n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 316 9 "Problem 2" }{TEXT -1 2 ". \+ " }}{PARA 0 "" 0 "" {TEXT -1 74 "I used the following method to encryp t a message: I chose at random some " }{TEXT 323 1 "a" }{TEXT -1 36 " in the set \{0,2,...,255\} such that " }{TEXT 362 4 "f(a)" }{TEXT -1 79 " is both 1-1 and onto. I next converted the message to a list of n umbers using " }{TEXT 318 7 "convert" }{TEXT -1 13 ". Then using " } {TEXT 319 3 "map" }{TEXT -1 12 ", I applied " }{TEXT 357 4 "f(a)" } {TEXT -1 59 " to each element in the list to obtain the list of number s:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 193 "[4 9, 85, 218, 125, 198, 155, 188, 55, 228, 155, 188, 115, 85, 218, 65, 2 19, 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 363 25 "Find my original messa ge." }{TEXT -1 2 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT 321 4 "Hint" }{TEXT -1 48 ". The message contains the word \"t he\". So using " }{TEXT 322 10 "searchtext" }{TEXT -1 86 " can help yo u pick out the correctly decrypted message as you apply all possible b 's. " }{TEXT 358 53 "Whatever you do don't print out more than one mes sage" }{TEXT -1 94 ". You may experiment, but your final answer should just be a one line message. If you use the " }{TEXT 364 10 "searchtex t" }{TEXT -1 24 " hint it will be easier." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 320 21 "[COPYING AND PASTING:" }{TEXT -1 411 " I have found that when attempting to copy and paste text such as the list of numbers above into an input field of Maple, sometimes I c an make it work by copying and pasting first into a word processor. Th en, from there, copy and paste into a Maple input region. On some pla tforms you may be able to do it directly. On others, when you paste i nto 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 d o part (1) send me an email and I will send a program to do it. This w ill cost you 1/2 out of a possible 2 points for this problem, but shou ld 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 12 "(1) Make a " }{TEXT 413 4 "list" } {TEXT -1 155 " of the distinct words in the following text (which is t he second paragraph of the Declaration of Independence). [If you put t he text 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 102 " > T1:=convert(text,list):\n T2:=remove(x->evalb(member(x,\{\".\",\", \",\";\",\":\"\})),T1): T:=cat(op(T2));" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 43 "Then you will need to find a wa y to make a " }{TEXT 408 4 "list" }{TEXT -1 132 " of the words in the \+ text. For example if it is called Words. Then you should have Words:=[ \"We\", \"hold\", \"these\", . . . , \"world\"]. " }{TEXT 365 5 "Hints " }{TEXT -1 479 ": Note that all words except the first and last are s urrounded by blank spaces. You can use searchtext to find the first lo cation of the first blank space. What precedes that will be a word. Re move that word, put it in your list, then replace the original text wi th the previous text with the word that you just found just removed. C ontinue until you have removed all the words.\n\n(2) Sort the list of \+ words in order of increasing word length. The length of a string is g iven by " }{TEXT 414 15 "length(string)." }}{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 388 "(4) Find the number of words in the text of each length from 1 to the maximum length word. If a word occurs k times it should add k \+ to the count. For example, since \"a\" occurs 4 times and it is the o nly word of length 1, the first line of your output should say, \"The re are 4 words of length 1.\", The next line should say, \"There are 4 9 words of length 2.\", and so forth. One way is to " }{TEXT 366 3 "ma p" }{TEXT -1 1 " " }{TEXT 367 6 "length" }{TEXT -1 79 " onto the list \+ of words. Then you will 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 alphabet a through z determine the number of words (counting repetitions) in the text containing the letter. Do not dist inguish between upper and lower case letters. Note that a word W cont ains letter \"x\" if " }{TEXT 368 21 "searchtext(\"x\",W) > 0" }{TEXT -1 185 ". You may select the words that contain \"x\" and then count t hem. A suitable output 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 endowed by their Creator with certain unalienable Right s, that among these are Life, Liberty and the pursuit of Happiness. Th at to secure these rights, Governments are instituted among Men, deriv ing their just powers from the consent of the governed, That whenever \+ any Form of Government becomes destructive of these ends, it is the Ri ght of the People to alter or to abolish it, and to institute new Gove rnment, laying its foundation on such principles and organizing its po wers in such form, as to them shall seem most likely to effect their S afety and Happiness. Prudence, indeed, will dictate that Governments l ong established should not be changed for light and transient causes; \+ and accordingly all experience hath shewn, that mankind are more dispo sed to suffer, while evils are sufferable, than to right themselves by abolishing the forms to which they are accustomed. But when a long tr ain of abuses and usurpations, pursuing invariably the same Object evi nces a design to reduce them under absolute Despotism, it is their rig ht, it is their duty, to throw off such Government, and to provide new Guards for their future security. Such has been the patient sufferanc e of these Colonies; and such is now the necessity which constrains th em to alter their former Systems of Government. The history of the pre sent King of Great Britain is a history of repeated injuries and usurp ations, all having in direct object the establishment of an absolute T yranny over these States. To prove this, let Facts be submitted to a c andid world." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{MARK "12" 0 }{VIEWOPTS 0 0 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 1 1 1 33 1 1 }