{VERSION 3 0 "SGI MIPS UNIX" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 256 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 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 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 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 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 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 }{CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 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 }{CSTYLE "" -1 268 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }{PSTYLE "Norma l" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 3 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" 2 7 1 {CSTYLE "" -1 -1 "" 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Error" 7 8 1 {CSTYLE "" -1 -1 "" 0 1 255 0 255 1 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 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 }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 }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 }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 }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 }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 0 "" }}{PARA 0 "" 0 "" {TEXT -1 24 "Examples \+ of assignments:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "A:=3;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG\"\"$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "B:=4;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"BG\"\"%" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 102 "To view the value of a variabl e in Maple, just type the name of the variable, and end with a semicol on" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#\"\"$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "B; " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"%" }}}{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);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>6$%\"AG%\"BG6$\"\"&\"\"(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "Spaces have no meaning, so this command w as the same as:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "(A,B):= \+ ( 5,7) ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>6$%\"AG%\"BG6$\"\" &\"\"(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "B;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"(" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 118 "Simultaneously 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);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>6$%\"AG%\"BG6$\"\"(\"\"&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"(" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "B;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"&" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 77 "Variables can also be used even when they have not yet been assigned a value:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%\"xG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "y;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%\"yG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "P:=x^3+x^5+12*x;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#> %\"PG,(*$)%\"xG\"\"$\"\"\"\"\"\"*$)F(\"\"&F*F+F(\"#7" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 57 "When x is not assigned, you can still use x. He re P is a " }{TEXT 258 11 "polynomial " }{TEXT -1 176 "in 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 compute values of P at x = 1, \+ 2, 3 by substitution:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "su bs(x=1,P);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#9" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "subs(x=2,P);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#k" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "subs(x=3,P); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"$1$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "or with the eval command (eval is short for: evaluation) " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "eval(P, x=3);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"$1$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 137 "We could do a sequence of substitutions by the command seq (stand s for sequence) as follows. Lets say we want to substitute i=1..6 for \+ x:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "seq( subs(x=i,P) ,i=1 ..6);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6(\"#9\"#k\"$1$\"%O6\"%5L\"%k!) " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "seq(i, i=1..6);" }} {PARA 11 "" 1 "" {XPPMATH 20 "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 " expressi on, expression, ..., expression" }}{PARA 0 "" 0 "" {TEXT -1 3 "So " } {TEXT 259 58 "a sequence is a number of expressions seperated by comma s." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 142 "In stead of computing the sequence subs(x=1,P), subs(x=2,P), .. we can a lso compute the sum: subs(x=1,P)+subs(x=2,P)+... with the add command: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "add( subs(x=i,P), i=1.. 6);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"&%*G\"" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 17 "add(i, i=1..100);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"%]]" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 15 "Multiplic ation:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "mul(x-i, i=1..5); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#*,,&%\"xG\"\"\"!\"\"F&F&,&F%F&!\"# F&F&,&F%F&!\"$F&F&,&F%F&!\"%F&F&,&F%F&!\"&F&F&" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 16 "mul(i, i=1..30);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"B+++![3jje5>7)fGDl#" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "30! ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"B+++![3jje5>7)fGDl#" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "ifactor(%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#*6)-%!G6#\"\"#\"#E\"\"\")-F&6#\"\"$\"#9F*)-F&6#\" \"&\"\"(F*)-F&6#F4\"\"%F*)-F&6#\"#6F(F*)-F&6#\"#8F(F*-F&6#\"#<\"\"\"-F &6#\"#>FD-F&6#\"#BFD-F&6#\"#HFD" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "The command " }{TEXT 260 7 "ifactor" }{TEXT -1 12 " stands for " } {TEXT 261 21 "integer factorization" }{TEXT -1 131 ". Every Maple comm and must be ended with ; or with : and until now we've only used ; L et's look at the difference between ; and :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "A:=2;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG\"\" #" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "View the contents of variabl e A as follows:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"#" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "Now end the command with a colon instead of a semi-colon " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "A:=12^12:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 122 "You see that with a colon, Maple prints \+ nothing. However, the command (in this case, an assignment) did get ex ecuted, see:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\".c#[/5;*)" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "In Maple, every 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 example of a sequence:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "A := 3,4,5,2,3,3,3,1;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG6*\"\"$\"\"%\"\"&\"\"#F&F&F&\"\"\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 82 "Now you can extend the sequence to the le ft, or to the right, or both, as follows:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 11 "A:=A,20,30;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\" AG6,\"\"$\"\"%\"\"&\"\"#F&F&F&\"\"\"\"#?\"#I" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "A:=hello,how,are,you,A,1000;" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%\"AG61%&helloG%$howG%$areG%$youG\"\"$\"\"%\"\"&\"\" #F*F*F*\"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "A[1];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%&helloG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "A[2];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#% $howG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "A[3];" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#%$areG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 101 " There is one special sequence in Maple, namely the empty sequence, den oted by NULL. See what happens:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "A:=NULL,NULL,A,NULL;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG 61%&helloG%$howG%$areG%$youG\"\"$\"\"%\"\"&\"\"#F*F*F*\"\"\"\"#?\"#I\" %+5" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "Maple sequences are very h andy. There is one problem with sequences though, and that is:" }} {PARA 256 "" 0 "" {TEXT -1 38 "You can't tell the difference between: " }}{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 more conv enient to work with lists in Maple than with sequences. In Maple," }} {PARA 0 "" 0 "" {TEXT 257 48 " a list is a sequence between square b rackets." }{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];" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>%\"AG71%&helloG%$howG%$areG%$youG\"\"$\"\"%\"\" &\"\"#F*F*F*\"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 130 "We can again look at individual elements, A[1], A[2] and such. Th e following command tells you the number of elements in the list:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "nops(A);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "A[15] ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"%+5" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 11 "A[nops(A)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"%+ 5" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 170 "To get the last element, yo u can do A[nops(A)]; A shorter syntax, which does exactly the same, i s A[-1], which gives you the last element. A[-2] is the second last, e tc." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "A[-1]; # last elemen t" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"%+5" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 28 "A[-2]; # second last element" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#I" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "A[-3 ]; # third last element, etc." }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#? " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 115 "Note that everything after # are considered comments (so everything after # will be ignored in Map le computations)." }}{PARA 0 "" 0 "" {TEXT 263 78 "The seq command is \+ very useful for operations with: sequences, lists and sets." }}{PARA 0 "" 0 "" {TEXT -1 88 "If we want to let i be all elements of a list o r 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 e xample, 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);" }} {PARA 11 "" 1 "" {XPPMATH 20 "61*$)%&helloG\"\"#\"\"\"*$)%$howGF&F'*$) %$areGF&F'*$)%$youGF&F'\"\"*\"#;\"#D\"\"%F1F1F1\"\"\"\"$+%\"$+*\"(+++ \"" }}}{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)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#71*$)%&helloG\"\"#\"\"\"*$)%$howGF'F(*$)%$ar eGF'F(*$)%$youGF'F(\"\"*\"#;\"#D\"\"%F2F2F2\"\"\"\"$+%\"$+*\"(+++\"" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 22 "Or the set 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 389 "Of cours e, if you have elements that appear more than once, the extra ones wil l be removed. Furthermore, the order has no meaning for sets. If S is \+ a non-empty set, then S[1] is an element of that set but you can not p redict in advance which element you will get. This is the reason that \+ redoing the same computation in Maple can lead to a different (but mat hematically equivalent) result." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "\{seq(i^2, i=A)\};" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<.\"\"\" \"\"%\"\"*\"#;\"#D\"$+**$)%&helloG\"\"#\"\"\"*$)%$howGF-F.*$)%$areGF-F .*$)%$youGF-F.\"$+%\"(+++\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "We can use the A[-1], A[-2], construction to reverse the list:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "[ seq(A[-i], i=1..nops(A)) ] ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#71\"%+5\"#I\"#?\"\"\"\"\"$F(F(\" \"#\"\"&\"\"%F(%$youG%$areG%$howG%&helloG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 258 "We have seen how you can convert a sequence to a list, w ith [ ], or to a set, with \{\}. The converse is also possible. You ca n remove the [ ] or the \{ \} brackets by the op command. This is also useful 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;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#71%&helloG%$howG%$areG%$youG\"\"$\"\"%\"\"&\"\"#F(F(F( \"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "B:=op (A);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"BG61%&helloG%$howG%$areG%$ youG\"\"$\"\"%\"\"&\"\"#F*F*F*\"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 11 "C:=\{op(A)\};" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"CG<.\"\"\"\"\"#\"\"$\"\"%\"\"&\"#?\"#I%$areG%$howG%$youG\"%+ 5%&helloG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "nops(A), nops( C); # C has fewer elements because multiple elements are removed." }} {PARA 11 "" 1 "" {XPPMATH 20 "6$\"#:\"#7" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 68 "nops(B); # The nops command allows a list or set but \+ not a sequence:" }}{PARA 8 "" 1 "" {TEXT -1 60 "Error, wrong number (o r type) of parameters in function nops" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "nops([B]); # Now the input of nops is [B] which is a \+ list. " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#:" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 444 "As you can see, we converted list A to a sequence B, and to a set C. Since C had fewer elements than A, we can see that A must have elements that appear more than once. Note that nops does \+ not work for a sequence, but it does work for lists and sets. So, to c ount 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 the double dot .." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "A[1..1];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7#%&h elloG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "A[1..4];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7&%&helloG%$howG%$areG%$youG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "A[1..-1];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#71%&helloG%$howG%$areG%$youG\"\"$\"\"%\"\"&\"\"#F(F(F( \"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "A[-3 ..-1];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "A[13..15];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "A[13..-1];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%\"#?\"#I\"%+5 " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "A[-3..15];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "C;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<.\"\"\"\"\"#\" \"$\"\"%\"\"&\"#?\"#I%$areG%$howG%$youG\"%+5%&helloG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "C[1..4];" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#<&\"\"\"\"\"#\"\"$\"\"%" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "C minus C[1..4];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<*\"\"&\"#?\"# I%$areG%$howG%$youG\"%+5%&helloG" }}}{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;" }}{PARA 11 "" 1 "" {XPPMATH 20 "61%&helloG%$howG%$areG%$youG\"\"$\"\"%\"\"&\"\"#F'F'F'\" \"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "B[4..6] ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%%$youG\"\"$\"\"%" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 153 "We have seen before that if you have an \+ expression involving a variable x, you can replace x by something else with a subs. How to do that for sequences?" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "P;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,(*$)%\"xG\" \"$\"\"\"\"\"\"*$)F&\"\"&F(F)F&\"#7" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "subs(x=0,P);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"! " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "subs(x=1,P);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#9" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#71%&helloG%$howG%$areG%$y ouG\"\"$\"\"%\"\"&\"\"#F(F(F(\"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "subsop(1=Hi,A);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#71%#HiG%$howG%$areG%$youG\"\"$\"\"%\"\"&\"\"#F(F(F(\"\"\"\"#?\"# I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#71%&helloG%$howG%$areG%$youG\"\"$\"\"%\"\"&\"\"#F( F(F(\"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 111 "Note \+ that this subsop command doesn't actually change A, it just returns A \+ with its first entry replaced 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); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG71%#HiG%$howG%$areG%$youG\" \"$\"\"%\"\"&\"\"#F*F*F*\"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "A := subsop(2=there, A);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG71%#HiG%&thereG%$areG%$youG\"\"$\"\"%\"\"&\"\"#F* F*F*\"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 " A := subsop(3=fox, A);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG71%#Hi G%&thereG%$foxG%$youG\"\"$\"\"%\"\"&\"\"#F*F*F*\"\"\"\"#?\"#I\"%+5" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "A:=subsop(4=NULL, A);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG70%#HiG%&thereG%$foxG\"\"$\"\"% \"\"&\"\"#F)F)F)\"\"\"\"#?\"#I\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "nops(A);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#9" }}} {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 remov e an entry from a list" }{TEXT -1 45 ". For sets there are different w ays to do it." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "C;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#<.\"\"\"\"\"#\"\"$\"\"%\"\"&\"#?\"#I%$ areG%$howG%$youG\"%+5%&helloG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "subs(hello=NULL,C);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<-\"\"\" \"\"#\"\"$\"\"%\"\"&\"#?\"#I%$areG%$howG%$youG\"%+5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "C;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<.\" \"\"\"\"#\"\"$\"\"%\"\"&\"#?\"#I%$areG%$howG%$youG\"%+5%&helloG" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "C minus \{hello\};" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<-\"\"\"\"\"#\"\"$\"\"%\"\"&\"#?\"#I%$areG%$ howG%$youG\"%+5" }}}{EXCHG {PARA 259 "" 0 "" {TEXT -1 61 "The best way to remove an element 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,Hel lo\} minus C;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<#%&HelloG" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 103 "In Maple, the variable Hello is d ifferent from hello because lower case and upper case is not the same. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 267 25 "Anot her 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 s quares. How to do that?" }}{PARA 0 "" 0 "" {TEXT -1 41 "Well, first ta ke all squares of i=1..100." }}{PARA 0 "" 0 "" {TEXT -1 213 "Then let \+ i = all elements of that set of squares and let j = all elements of th at set of squares, and for all of those, take i+j, and then take the s et 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;" }}{PARA 12 "" 1 "" {XPPMATH 20 "6# " 0 "" {MPLTEXT 1 0 41 "L := [ op(squares intersect sum_squares)]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "L := sort( L );" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>% \"LG7L\"#D\"$+\"\"$p\"\"$D#\"$*G\"$+%\"$D'\"$w'\"$T)\"$+*\"%c6\"%D7\"% p8\"%@:\"%+;\"%\"o\"\"%D?\"%+D\"%,E\"%/F\"%4G\"%DI\"%kL\"%+O\"%@P\"%DU \"%CY\"%+\\\"%H`\"%wa\"%Dc\"%%3'\"%+k\"%Cn\"%Ds\"%pv\"%@z\"%+\")\"%\"G )\"%D!*\"%4%*\"&++\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 268 56 "Recallin g previous expressions 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 5 "a:=1;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG\"\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "b:=2;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG\"\"#" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "c:=3;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"cG\"\"$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "d:=4;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"dG\"\"%" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "%%;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"$" }}} {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 "%%;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"%" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "a;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "b; " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"#" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 2 "c;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"$" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "%%%;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "%%% ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"#" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 4 "%%%;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"$" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "a;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "b; " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"#" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 2 "c;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"$" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "%;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "%%%; " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"#" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}}{MARK "139 1" 0 }{VIEWOPTS 1 1 0 1 1 1803 }