{VERSION 5 0 "IBM INTEL LINUX" "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 "" -1 256 "" 1 24 0 0 0 0 0 0 0 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 1 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 1 }{CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 268 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 271 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 272 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{PSTYLE "Normal " -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 256 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 257 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 258 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 259 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 260 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 256 86 "Computer a lgebra, week 1, lecture 1:\nAssignments in Maple, sequences, lists, an d sets." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 60 "Assigning a value to a variable in Maple can be done with :=" }} {PARA 0 "" 0 "" {TEXT -1 101 "An assignment is a Maple command, and an y Maple command ends with a colon or a semicolon, with : or ;" }} {PARA 0 "" 0 "" {TEXT -1 108 "(the only difference is that if you end \+ a command with a colon, then nothing will be printed to the screen)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 25 "Example s of assignments: " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "A:=3;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "B:=4;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 102 "To view the value of a variable in Maple, just type the name of the variable, and end with a semicolon" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "B;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "You can assign two ( or more) variables at the same time:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "(A, B) := (5, 7);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "Spaces have no meaning, so this command was the same as:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "(A,B):= ( 5,7) ;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "B;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 118 "Simulta neously assigning several variables at the same time is convenient if \+ you want to switch the values of A and B:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 15 "(A,B) := (B,A);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "B;" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 77 "Variables can also be used even w hen they have not yet been assigned a value:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "y ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "P := x^3+x^5+12*x;" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 57 "When x is not assigned, you can s till use x. Here P is a " }{TEXT 258 11 "polynomial " }{TEXT -1 125 "i n x. If x had a value, say, an integer, then P wouldn't have become a \+ polynomial but it would have been an integer. You can " }{TEXT 269 4 " eval" }{TEXT -1 33 "uate P at x = 1, 2, 3 as follows:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "eval(P, x=1); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 71 "The above command substituted x=1 into P and then evaluated the result." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "e val(P, x=2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "eval(P, x=3 );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "or with the " }{TEXT 270 4 "subs" }{TEXT -1 177 " command (subs is short for substitution, and do es pretty much the same as the eval command. With subs, the x=.. come s at the beginning, and with eval, the x=.. is at the end)." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "subs(x=3, P); # This command substitutes x=1 into P:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 128 "Comm ents can be added to a line of Maple commands by using the symbol # ( Maple simply ignores everything that comes after a #)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 135 "We could do a seque nce of evaluations by the command seq (stands for sequence) as follows . Lets say we want to substitute i=1..6 for x:" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 27 "seq( eval(P, x=i) ,i=1..6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "seq(i, i=1..6);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 129 "The output of the seq command is a datastructure that' s called a sequence in Maple. In Maple a sequence is something of the \+ form:" }}{PARA 0 "" 0 "" {TEXT -1 42 " expression, expression, ..., \+ expression" }}{PARA 0 "" 0 "" {TEXT -1 3 "So " }{TEXT 259 58 "a sequen ce is a number of expressions seperated by commas." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 146 "Instead of computing the sequence eval(P, x=1), eval(P, x=2), .. we can also compute the sum: eval(P, x=1)+eval(P, x=2)+... with the add command:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "add( eval(P, x=i), i=1..6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "add(i, i=1..100);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 15 "Multiplication:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "mul(x-i, i=1..5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "mul(i, i=1..30);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "30! ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "if actor(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "The command " } {TEXT 260 7 "ifactor" }{TEXT -1 12 " stands for " }{TEXT 261 21 "integ er factorization" }{TEXT -1 266 ". Every Maple command must be ended w ith ; or with : and until now we've only used ; (you only end a co mmand with a colon : if you don't want to see the output of that comma nd. This is useful if the output is very large, filling up too much sp ace on the screen)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "A:=2; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "View the contents of variable A as follows:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "Now end the command with a colon i nstead of a semi-colon" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "A :=1234^1234:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 122 "You see that wit h a colon, Maple prints nothing. However, the command (in this case, a n assignment) did get executed, see:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "In Maple, e very command is followed by a colon : or by a semi-colon ;" }}{PARA 0 "" 0 "" {TEXT -1 154 "If you use : or ; that makes no difference for what Maple does, the only difference is that ; causes something to be written to the screen and : does not." }}{PARA 0 "" 0 "" {TEXT -1 85 "Lets look some more at sequences in Maple. The following is an exampl e of a sequence:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "A := 3, 4,5,2,3,3,3,1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 82 "Now you can ext end the sequence to the left, or to the right, or both, as follows:" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "A:=A,20,30;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "A:=hello,how,are,you,A,1000;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "A[1];" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 5 "A[2];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "A[3];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 101 "There is one speci al sequence in Maple, namely the empty sequence, denoted by NULL. See \+ what happens:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "A:=NULL,NU LL,A,NULL;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "Maple sequences are very handy. There is one problem with sequences though, and that is: " }}{PARA 256 "" 0 "" {TEXT -1 38 "You can't tell the difference betwe en:" }}{PARA 257 "" 0 "" {TEXT -1 21 " 1) An expression a." }}{PARA 258 "" 0 "" {TEXT -1 38 " 2) A sequence with just 1 element a." }} {PARA 0 "" 0 "" {TEXT -1 111 "Because of this problem, it is often mor e convenient to work with lists in Maple than with sequences. In Maple ," }}{PARA 0 "" 0 "" {TEXT 257 48 " a list is a sequence between squ are brackets." }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 7 "We can " } {TEXT 262 100 "turn a sequence into a list by putting square brackets \+ around the sequence and using an assignment, " }{TEXT -1 11 "as follow s:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "A:=[A];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 130 "We can again look at individual elements , A[1], A[2] and such. The following command tells you the number of e lements in the list:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "nops (A);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "A[15];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "A[nops(A)];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 170 "To get the last element, you can do A[nops(A)]; A \+ shorter syntax, which does exactly the same, is A[-1], which gives you the last element. A[-2] is the second last, etc." }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 21 "A[-1]; # last element" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 28 "A[-2]; # second last element" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "A[-3]; # third last element, etc." }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 127 "As already mentioned, everything \+ after # are considered comments (so everything after # will be ignored in Maple computations)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT 263 78 "The seq command is very useful for operations wit h: sequences, lists and sets." }}{PARA 0 "" 0 "" {TEXT -1 88 "If we wa nt to let i be all elements of a list or a set A we can do:\n seq( .. .. , i=A);" }}{PARA 0 "" 0 "" {TEXT -1 71 "and if we want to let i be all elements of a sequence S then we can do:" }}{PARA 0 "" 0 "" {TEXT -1 98 " seq( .... , i=[S]);\nFor example, compute the sequence of squares of the elements of the list A:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 14 "seq(i^2, i=A);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 23 "Or the list of squares:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "[seq(i^2, i=A)];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 22 "Or the se t of squares." }}{PARA 0 "" 0 "" {TEXT -1 2 " " }{TEXT 264 55 "A set \+ in Maple is a sequence between curly brackets \{\}." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 200 "Sets differ from lists in two ways: First, no element appears more than once (doubles will b e automatically removed, something that often comes in handy). Second, the ordering has no meaning for sets." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 253 "If S is a non-empty set, then S[1] i s an element of that set but you don't know in advance which element y ou will get (if you try it twice, then S[1] will be the same both time s, but your neighbor typing the same commands might get a different el ement)." }}{PARA 0 "" 0 "" {TEXT -1 196 "This is the reason that redoi ng the same computation in Maple can lead to a different (but mathemat ically equivalent) result. Say for example you solve a system of line ar equations (with Maple's " }{TEXT 271 5 "solve" }{TEXT -1 140 " comm and), and that the end result you get is \{x = 1, y = -z\}. Your neigh bor might find \{x = 1, z = -y\} even if she types the same commands. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "\{seq(i^2, i=A)\};" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "We can use the A[-1], A[-2], const ruction to reverse the list:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "[ seq(A[-i], i=1..nops(A)) ];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 258 "We have seen how you can convert a sequence to a list, with [ \+ ], or to a set, with \{\}. The converse is also possible. You can remo ve the [ ] or the \{ \} brackets by the op command. This is also usefu l if you want to convert a list to a set or a set to a list." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "B:=op(A);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "C:=\{op(A)\};" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "nops (A), nops(C); # C has fewer elements because multiple elements are rem oved." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 68 "nops(B); # The nop s command allows a list or set but not a sequence:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "nops([B]); # Now the input of nops is [B] w hich is a list. " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 444 "As you ca n see, we converted list A to a sequence B, and to a set C. Since C ha d fewer elements than A, we can see that A must have elements that app ear more than once. Note that nops does not work for a sequence, but i t does work for lists and sets. So, to count the number of elements in a sequence, we have to put brackets [ ] around it before we can count with nops. Given a list, we can compute sublists as follows, using th e double dot .." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "A[1..1]; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "A[1..4];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "A[1..-1];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "A[-3..-1];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 232 "The -1'th element refers to the last elements. So elements number s 1..-1 gives all elements. Likewise, the -3'rd element is the third \+ last elements. So A[-3..-1] is the third last to the last element (i.e . the last three elements)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "A[13..15];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "A[13..-1] ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "A[-3..15];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "C;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "C[1..4];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "C minus C[1..4];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 55 "The commands minus and union can only be used for sets." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "B;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "B[4 ..6];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 182 "We have seen before tha t if you have an expression involving a variable x, you can replace x \+ by something else with an eval command (or a subs command). How to do \+ that for sequences?" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "P;" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "subs(x=0,P);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "subs(x=1,P);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 2 "A;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "subsop(1=Hi,A);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 111 "Note that this subsop command d oesn't actually change A, it just returns A with its first entry repla ced by Hi." }}{PARA 0 "" 0 "" {TEXT -1 2 " " }{TEXT 265 39 "To change A we have to do an assignment" }{TEXT -1 1 ":" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 20 "A := subsop(1=Hi,A);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "A := subsop(2=there, A);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 22 "A := subsop(3=fox, A);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 21 "A:=subsop(4=NULL, A);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "nops(A);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 74 " Here I replaced entry A[4] by the empty sequence NULL, so this is the \+ way " }{TEXT 266 35 "you can remove an entry from a list" }{TEXT -1 45 ". For sets there are different ways to do it." }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 2 "C;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "subs(hello=NULL,C);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 " C; # the previous line didn't change C because there was no :=" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "C minus \{hello\};" }}} {EXCHG {PARA 259 "" 0 "" {TEXT -1 61 "The best way to remove an elemen t e from a set S is by doing:" }}{PARA 260 "" 0 "" {TEXT -1 19 " S := S minus \{e\};" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 118 "Note that if A,B are sets then in \"A minus B\" the set \+ B can be any set, it does not need to be a subset of A. Example:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "\{hello,Hello\} minus C;" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 103 "In Maple, the variable Hello is \+ different from hello because lower case and upper case is not the same ." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 267 25 "Ano ther example with sets" }{TEXT -1 125 ": Compute all numbers that are \+ a square of a positive integer <= 100, and that are also a sum of two \+ squares. How to do that?" }}{PARA 0 "" 0 "" {TEXT -1 41 "Well, first t ake all squares of i=1..100." }}{PARA 0 "" 0 "" {TEXT -1 48 "Then let \+ i = all elements of that set of squares" }}{PARA 0 "" 0 "" {TEXT -1 48 "and let j = all elements of that set of squares," }}{PARA 0 "" 0 " " {TEXT -1 115 "and for all of those, take i+j, and then take the set \+ of all of that.\nThen take the intersection of these two sets." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "squares:=\{seq(i^2,i=1..100) \}:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "sum_squares := \{ se q(seq( i+j ,i=squares),j=squares) \}:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 200 "I used a colon instead of semi-colon to end the command, to prevent Maple from printing lots of numbers. To find the answer to the question, we will have to compute the intersection of those two s ets:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "squares intersect s um_squares;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 149 "In case the resul t is not sorted (it need not be, because sets don't have an order) we \+ can sort it by first turning it into a list, and then sorting:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "L := [op(squares intersect s um_squares)]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "L := sort( L );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 268 56 "Recalling previous expr essions with the percentage sign." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 154 "The percentage sign % in Maple refers to the last thing Maple evaluated. And %% means the one before that, and %%% the one before that (there is no %%%%)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "a := 1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "b:=2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "c:=3;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "d:=4;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 3 "%%;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 80 "At \+ this point, the last one is 3, and so the second last is no longer 3, \+ it's 4." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "%%;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "a;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "b;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "c;" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "%%%;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 4 "%%%;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "%%%;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "a;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "b;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "c;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "%;" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "%%%;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 121 "If you end a command with a colon, it still counts \+ as an expression, even if you don't see it on the screen. For example, " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "int( ln(x), x):" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 41 "Now the last thing evaluated will \+ be the " }{TEXT 272 3 "int" }{TEXT -1 121 "egral of ln(x), so if I typ e % the result won't be 2 (the last thing visible on the screen) but i t will be that integral:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 " %;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "0 6 0" 25 }{VIEWOPTS 1 1 0 3 2 1804 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }