{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 "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" 0 21 "" 0 1 0 0 0 1 0 0 0 0 2 0 0 0 0 1 }{CSTYLE "" -1 23 " Courier" 1 10 0 0 0 0 0 0 0 0 0 0 3 0 0 1 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 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 "" 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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STYLE "Bullet Item" -1 15 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 3 3 1 0 1 0 2 2 15 2 }{PSTYLE "Title" -1 18 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 }{PSTYLE "Title" -1 256 1 {CSTYLE "" -1 -1 "T imes" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 }{PSTYLE "Normal" -1 257 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 }} {SECT 0 {EXCHG {PARA 256 "" 0 "" {TEXT -1 9 "Lecture 7" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 8 "unapply " }{TEXT 441 6 "versus" }{TEXT -1 16 " arrow notation " }}{PARA 0 "" 0 "" {TEXT -1 10 "Sometimes " } {TEXT 442 7 "unapply" }{TEXT -1 61 " can be used to convert an express ion to a function when the " }{TEXT 443 5 "arrow" }{TEXT -1 18 " appro ach fails. \n" }}{PARA 0 "" 0 "" {TEXT -1 61 "Note that the following \+ fails to create the desired function:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "restart:\np:=sin(x) + cos(x):\nf:=x->p;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "We try to compute f(0) and f(t). This sho uld yield " }{TEXT 444 19 "sin(0) + cos(0) = 1" }{TEXT -1 6 ", and " } {TEXT 445 15 "cos(t) + sin(t)" }{TEXT -1 44 ", respectively. But as y ou see, it doesn't:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "f(0) ,f(t);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 38 "On the other hand the f ollowing works:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "restart: \np:=sin(x) + cos(x):\nf:=unapply(p,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "f(0), f(t);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "O ne can however use the following to create this function:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "restart:\nf:=x->sin(x) + cos(x):\nf (0),f(t);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 47 "As you can see this \+ requires typing or pasting " }{TEXT 446 16 "sin(x) + cos(x) " }{TEXT -1 171 "rather than using a variable that this expression has been ass igned to. In this case it's not much trouble. In some situations this \+ may be a bother. But, as we see above, " }{TEXT 440 7 "unapply" } {TEXT -1 15 " saves the day!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 36 "Elementary manipulatio n of Equations" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "Recall that " } {TEXT 447 5 "A = B" }{TEXT -1 15 " represents an " }{TEXT 305 8 "equat ion" }{TEXT -1 9 " whereas " }{TEXT 303 5 "A:= B" }{TEXT -1 7 " is an \+ " }{TEXT 306 20 "assignment statement" }{TEXT -1 2 ". " }{TEXT 304 4 " A:=B" }{TEXT -1 55 " means, as we have seen, \"assign to A the value \+ of B\"." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 26 "We assign to the variable " } {TEXT 288 3 "eq1" }{TEXT -1 14 " the equation " }{TEXT 289 11 "x^2 + x = 1" }{TEXT -1 1 ":" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "eq1 :=x^2+x = 2*x + 1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 77 "There are s everal things one can do with an equation: Here are some examples:" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "a:=lhs(eq1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "b:=rhs(eq1);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 13 "solve(eq1,x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "Note that Maple like the best mathematicians cannot " } {TEXT 409 5 "solve" }{TEXT -1 80 " every equation. However, sometimes \+ it can obtain an approximate solution using " }{TEXT 407 6 "fsolve" } {TEXT -1 12 " instead of " }{TEXT 408 5 "solve" }{TEXT -1 39 ". We dis cuss these commands more later." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "fsolve(eq1,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "w hattype(eq1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "type(eq1,e quation);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "type(q*g=r*t,e quation);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "type(x:=y,equa tion);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "isolate(4*x*sin(x )=3,sin(x));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "isolate(x^2 -3*x-5 = 0,x^2);" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 63 "Int , int, Diff, diff, Sum, sum, Product, product, Limit, limit." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 154 "Sometim es when Maple has two procedures of the same name where one begins wit h a capital letter and one with lower case, the capitalized procedure is an " }{TEXT 258 10 "inert form" }{TEXT -1 42 " of the lower case p rocedure. The command " }{TEXT 290 5 "value" }{TEXT -1 15 " forces th ese " }{TEXT 291 16 "inert procedures" }{TEXT -1 9 " such as " }{TEXT 292 15 "Int, Limit, Sum" }{TEXT -1 6 ", and " }{TEXT 259 4 "Diff" } {TEXT -1 78 " to be evaluated by their corresponding Maple (lower case ) procedure, such as " }{TEXT 260 17 "int, limit, sum, " }{TEXT -1 2 " or" }{TEXT 262 6 " diff." }{TEXT -1 48 " This is best understood by lo oking at examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restar t:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 87 "I tend to use the inert for ms when I want to check that I typed something in correctly." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "z1:=Int(x^2,x=a..b);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "value(z1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 10 "Note that " }{TEXT 256 21 "value(Int(x^2,x=a..b )" }{TEXT -1 16 " is the same as " }{TEXT 257 16 "int(x^2,x=a..b):" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "int(x^2,x=a..b);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "One can get a nice formula in the \+ following manner: (Note that we use " }{TEXT 261 13 "z1 = value(z)" } {TEXT -1 5 " not " }{TEXT 263 14 "z1:=value(z1)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "z1=value(z1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "z2:=Diff(sin(x)*exp(x),x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "z2=value(z2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "diff(sin(x)*exp(x),x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "z3:=Sum(1/n^2,n=1..infinity);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 13 "z3=value(z3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "sum(1/n^2,n=1..infinity);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 25 "z4:=Product(x-i,i=1..10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "z4=value(z4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "product(x-i,i=1..10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "z4=expand(value(z4));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "z5:=Limit(sqrt(x^2)/x,x=0,right);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "z5=value(z5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "limit(sqrt(x^2)/x,x=0,right);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 28 "limit(sqrt(x^2)/x,x=0,left);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 49 "sum('f(i)','i'=m..n) and product( 'f(i)','i'=m..n)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 13 "The commands " }}{PARA 0 "" 0 "" {TEXT -1 5 " " }} {PARA 0 "" 0 "" {TEXT 293 19 "sum(f(i), i = a..b)" }{TEXT -1 4 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 4 "and " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 294 20 "product( f(i),i=a..b)" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 48 "will work if i has not been previously assigned " }{TEXT 410 122 "but it is recommended (and often necessary) that bo th f and i be enclosed in single quotes to prevent premature evaluatio n" }{TEXT -1 79 ". (For example, i may have a previous value.) Thus th e preferred commands are " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 264 21 "sum('f(i)', 'i'=m..n)" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 4 "and " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 265 27 "product('f(i)', \+ 'i'=m..n). " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 32 "Consider the following examples:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "for i from 1 to 2 do i^2; od;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "i;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "sum(i^2,i=1..n);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "sum('i^2','i'=1..n);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "simplify(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 4 "T he " }{TEXT 411 20 "binomial coefficient" }{TEXT -1 37 " \" n choose k \" is given in Maple by " }{TEXT 448 13 "binomial(n,k)" }{TEXT -1 105 ". Recall that this is the number of k element subsets of an n ele ment set. Also it is the coefficient of " }{XPPEDIT 18 0 "x^k*y^(n-k); " "6#*&)%\"xG%\"kG\"\"\")%\"yG,&%\"nGF'F&!\"\"F'" }{TEXT -1 21 " in th e expansion of " }{XPPEDIT 18 0 "(x+y)^n;" "6#),&%\"xG\"\"\"%\"yGF&%\" nG" }{TEXT -1 144 ". There are many formulas involving sums and binom ial coefficients. Maple knows many of these formulas. The following s hows the definition of " }{TEXT 449 13 "binomial(n,k)" }{TEXT -1 24 " \+ in terms of factorials:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 " binomial(n,k) = convert(binomial(n,k),factorial);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 66 "Here's an identity about binomial coefficients tha t Maple \"knows\"." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "s:=Su m('k^2*binomial(n,k)', 'k'=0..n);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "s = value(s);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Again we have an error using " }{TEXT 450 7 "product" }{TEXT -1 43 " \+ if the index has been previously assigned:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 20 "product(i^2,i=1..n);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 14 "As before for " }{TEXT 451 3 "sum" }{TEXT -1 30 " this ca n be fixed as follows:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "p roduct('i^2','i'=1..n);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 30 "The an swer is in terms of the " }{TEXT 452 14 "gamma function" }{TEXT -1 1 " " }{XPPEDIT 18 0 "GAMMA;" "6#%&GAMMAG" }{TEXT -1 37 " which in Maple input is denoted by " }{TEXT 453 5 "GAMMA" }{TEXT -1 2 ". " } {XPPEDIT 18 0 "Gamma;" "6#%&GammaG" }{TEXT -1 124 " is a continuous an alogue of the factorial function. We can convert the answer to factori al notation by the following means." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "convert(%,factorial);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "expand(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "(I f you think about it a bit this is not very surprising.)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 12 "add and mul " }{TEXT 412 6 "versus" }{TEXT -1 16 " sum and prod uct" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{PARA 15 "" 0 "" {TEXT -1 4 "The " }{TEXT 266 3 "add" }{TEXT -1 32 " procedure is used to add up an " }{TEXT 454 27 "explicit sequence of values" }{TEXT -1 6 ". Th e " }{TEXT 267 3 "mul" }{TEXT -1 37 " procedure computes a product of \+ an e" }{TEXT 455 26 "xplicit sequence of values" }{TEXT -1 24 ". A typ ical call to the " }{TEXT 456 3 "add" }{TEXT -1 14 " procedure is " } {TEXT 268 17 "add(f(i), i=1..n)" }{TEXT -1 2 ". " }{TEXT 307 47 "Here \+ n must be a specific number not a variable" }{TEXT -1 58 ". This compu tes f(1) + f(2) + ... + f(n). More generally, " }{TEXT 269 18 "add(f(i ), i=m..n) " }{TEXT -1 48 "computes f(m) + f(m+1) + ... + f(n). Simila rly, " }{TEXT 270 17 "mul(f(i), i=m..n)" }{TEXT -1 38 " computes f(m) \+ * f(m+1) * ... * f(n). " }}{PARA 15 "" 0 "" {TEXT -1 5 "Both " }{TEXT 271 3 "add" }{TEXT -1 5 " and " }{TEXT 272 3 "mul" }{TEXT -1 162 " are considered to be more efficient that the corresponding do-loop constr uctions. Also you do not have to put quotes around the arguments as yo u need to do with " }{TEXT 273 3 "sum" }{TEXT -1 5 " and " }{TEXT 274 7 "product" }{TEXT -1 131 ". Note also that unlike the for loop constr uction, the value of the index i is unchanged by add and mul, as we se e in our examples:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "i:=120 000;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "add(i^2,i=1..10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "i;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 16 "add(i^2,i=1..n);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "mul(i^2,i=1..10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "i; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 15 "The pro cedures " }{TEXT 457 3 "add" }{TEXT -1 5 " and " }{TEXT 458 3 "mul" } {TEXT -1 87 " are builtin. Generally builtin procedures are much faste r than non-builtin procedures." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "interface(verboseproc=2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "eval(add);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 212 "N ote that the index, say i, in a for..do od; looping construction may h ave a value before the loop is entered. But it will have a possibly di fferent values when the loop is finished executing. Here's an example :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "i:=999;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "for i from 1 to 2 do print(sin(i)); od;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "i;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 15 "The procedures " }{TEXT 295 3 "sum" }{TEXT -1 5 " and " }{TEXT 296 7 "product" }{TEXT -1 12 " unlike the " }{TEXT 297 3 "add" }{TEXT -1 5 " and " }{TEXT 298 3 "mul" }{TEXT -1 116 " pro cedures compute symbolic sums and products as we have seen already in \+ previous examples. That is, the limits in " }{TEXT 299 8 "i = m..n" } {TEXT -1 296 " do not have to be specific values, they can be variable s. Note that sum is a very complicated procedure since it not only doe s simple addition, but also has a lot of theory about infinite series \+ and closed forms for other finite series built into the procedure. Le t's look at the definition of " }{TEXT 308 3 "sum" }{TEXT -1 141 ": (A fter you view it, replace the semicolon by a colon and execute the com mand again to remove the program. This will help save a few trees.)" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "eval(sum):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 7 "printf " }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "The command " } {TEXT 459 6 "printf" }{TEXT -1 78 " can be used to gain more control o ver the output. You will have noticed that " }{TEXT 413 5 "print" } {TEXT -1 5 " and " }{TEXT 414 6 "lprint" }{TEXT -1 74 " are limited in this respect. First I give a simple example of the use of " }{TEXT 280 6 "printf" }{TEXT -1 1 ":" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "restart:\nN:=10:\nA:=evalf(1000*sin(N));" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 59 "printf(\"The value of 1000*sin(%d) is %E or %f . \\n\", N,A,A);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 34 "What does all this mean? Briefly, " }{MPLTEXT 1 0 44 "\"The value of 1000*sin(%d) is %E or %f. \\n\" " }{TEXT -1 14 "is \+ called the " }{TEXT 460 13 "format string" }{TEXT -1 46 ". The values \+ input into the format string are " }{MPLTEXT 1 0 6 "N,A,A " }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 124 " You may wish to skim the following explanation and look at more exampl e. Then come back and read the details more carefully." }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 309 2 "%d" }{TEXT -1 43 " indicates an integer of unspecified size.\n" }}{PARA 0 "" 0 " " {TEXT 310 2 "%f" }{TEXT -1 56 " indicates a floating point number of unspecified size.\n" }}{PARA 0 "" 0 "" {TEXT 311 2 "%E" }{TEXT -1 91 " indicates a floating point number in scientific notation of unspecif ied size will go here." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 361 2 "%s" }{TEXT -1 73 " indicate a string, that is, a seq uence of characters enclosed by quotes." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 312 2 "\\n" }{TEXT -1 67 " is a new line ch aracter -- when encountered it causes a new line. " }}{PARA 0 "" 0 "" {TEXT -1 157 "\nNumbers can be added between the % and d,f,E, or s to \+ indicate the numbers of places allocated for the number being printed . See the following examples. \n" }}{PARA 0 "" 0 "" {TEXT -1 167 "Num bers are right justified unless one places a minus sign, - , just afte r the % sign. in which case they are left justified. Examine carefully the following examples." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 257 "" 0 "" {TEXT -1 166 "Note that the vertical lines | are put in mostly to make it easier to see the spacing determined by the numbers betwee n % and d, f, E and the effect of the - after %." }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 4 "See " }{TEXT 276 8 "?printf " }{TEXT -1 63 "for more details and the use of many more cod es in addition to " }{TEXT 313 1 "d" }{TEXT -1 2 ", " }{TEXT 314 1 "f " }{TEXT -1 5 " and " }{TEXT 315 1 "E" }{TEXT -1 45 " for printing in \+ other styles, for example, " }{TEXT 316 1 "o" }{TEXT -1 12 " for octa l, " }{TEXT 317 1 "x" }{TEXT -1 18 " for hexadecimal, " }{TEXT 318 1 " s" }{TEXT -1 19 " for strings, etc. " }{TEXT 275 55 "But for now just \+ concentrate on use of d, f , s, and E." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 279 128 "Note that everything between the two quotation marks \" \" i s printed verbatim --even spaces --unless it is preceded by a % sign. " }{TEXT -1 2 " \n" }}{PARA 0 "" 0 "" {TEXT -1 41 "The stuff between t he \" \" is called the " }{TEXT 278 13 "format string" }{TEXT -1 67 " The numbers after the format code are printed in the place of the " } {TEXT 319 2 "%d" }{TEXT -1 2 ", " }{TEXT 320 2 "%f" }{TEXT -1 5 " and \+ " }{TEXT 321 2 "%E" }{TEXT -1 7 " codes " }{TEXT 277 26 "in the order \+ they appear. " }{TEXT 323 39 "The following was copied from help for \+ " }{TEXT 324 6 "printf" }{TEXT 325 10 ". Execute " }{TEXT 326 7 "?prin tf" }{TEXT 327 27 " for the entire help file. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT -1 19 "The format string, " }{TEXT 322 3 "fmt" }{TEXT -1 178 ", \+ is a Maple symbol or string made up of a sequence of formatting specif ications, possibly separated by other characters. Each formatting spec ification has the following format: " }}{PARA 0 "" 0 "" {TEXT -1 1 "\n " }{TEXT 23 39 " %[flags][width][.precision]code" }}{PARA 15 " " 0 "" {TEXT -1 117 "The % symbol begins the format specification. One or more of the following flags can optionally follow the % symbol: " }}{PARA 14 "" 0 "" {TEXT -1 2 "+ " }}{PARA 14 "" 0 "" {TEXT -1 99 "A s igned numeric value is output with a leading positive or negative sign (+ or -) as appropriate. " }}{PARA 14 "" 0 "" {TEXT -1 2 "- " }} {PARA 14 "" 0 "" {TEXT -1 57 "The output is left justified instead of \+ right justified. " }}{PARA 14 "" 0 "" {TEXT -1 6 "blank " }}{PARA 14 " " 0 "" {TEXT -1 153 "A signed numeric value is output with either a le ading negative sign (-) or a leading blank, depending on whether the v alue is negative or non-negative. " }}{PARA 14 "" 0 "" {TEXT -1 2 "0 \+ " }}{PARA 14 "" 0 "" {TEXT -1 123 "The output is padded on the left (b etween the sign and the first digit) with zeroes. If - is also specifi ed, 0 is ignored. " }}{PARA 15 "" 0 "" {TEXT -1 201 "The optional widt h indicates the minimum number of characters to output for this field. If the formatted value has fewer characters, it is padded on the left (or right if - was specified) with blanks. " }}{PARA 15 "" 0 "" {TEXT -1 165 "The optional precision specifies the number of digits th at appear after the decimal point for floating point formats, or the m aximum field width for string formats. " }}{PARA 15 "" 0 "" {TEXT -1 25 "Here are a few examples: " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 152 "In the first example below the width assigned for the floating point \+ number is 13 -- this includes the decimal point. The 5 after the deci mal point in " }{TEXT 301 6 "%13.5f" }{TEXT -1 194 " indicates that w e want 5 digits after the decimal point. In the case of the E formats the standard is one digit to the left of the decimal point and the nu mber 5 indicated in the format code " }{TEXT 302 6 "%13.5E" }{TEXT -1 292 " indicates that there will be 5 digits after the decimal point. \+ You can see the effect of the blank, - or + added after the % signs in the following examples: To count the blanks more easily click on the paragraph icon at the right end of the menu bar. Clicking again will \+ undo the effect. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "printf (\"example: |%13.5f| \\n\",evalf(10*Pi));" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 45 "printf(\"example: |%-13.5f| \\n\",evalf(10*Pi));" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "printf(\"example: |%+13.5f | \\n\",evalf(10*Pi));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "p rintf(\"example: |%13d| \\n\",123456789012);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "printf(\"example: |%13d| \\n\",123456789012.);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "printf(\"example: |%-13d| \\n\",123456789012);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "pr intf(\"example: |%+13d| \\n\",123456789012);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "printf(\"example: |%13.5E| \\n\",evalf(10*Pi)); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "printf(\"example: |%-13 .5E| \\n\",evalf(10*Pi));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "printf(\"example: |%+13.5E| \\n\",evalf(10*Pi));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "printf(\"example: |%s| \\n\", \"Some Word \");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "printf(\"example: | %-13s| \\n\", \"Some Word\");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "printf(\"example: |%13s| \\n\", \"Some Word\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 42 "Here we use printf to make a little table :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 260 "printf(\"%3s | %6s | %6s | %6s \\n\", \"x\", \"sin(x)\", \"cos(x)\", \"tan(x)\");\nprint f(\"-----------------------------------\\n\");\nfor x from 90 to 100 \+ do\na:=evalf(sin(x)):\nb:=evalf(cos(x)):\nc:=evalf(tan(x)):\nprintf(\" %3d | % 6.5f | % 6.5f | % 6.5f \\n\", x, a,b,c);\nod:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 257 "" 0 "" {TEXT 328 14 "The effect of " }{TEXT -1 3 "\\n " }{TEXT 329 70 "in the format is to cause a new line. Note that if one repeatedly uses" }{TEXT -1 8 " \+ printf " }{TEXT 330 7 "without" }{TEXT -1 4 " \\n " }{TEXT 331 96 "no \+ new line is produced. In the following two examples we print every 5t h number on a new line:" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "L:=[seq(i,i=1..20)];\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 96 "for i from 1 to 20 do \n printf(\"%3d \",L[i]); \n if i mod 5 = 0 then printf(\"\\n\"); fi;\nod: " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "\nHere are more examples illustrating use of " }{TEXT 332 2 "\\n" }{TEXT -1 20 " to control printing" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "with(lin alg):\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 103 "Note that the rows of the next matrix are too long to get on one line so the matrix doesn' t look good." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "M:=randmatr ix(5,50, entries=rand(0..1));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 97 " Here's a way to get it printed out nicely: (Note carefully the locatio n of the newline statement " }{TEXT 415 12 "printf(\"\\n\")" }{TEXT -1 175 ".) Since it is just 0's and 1's we leave no spaces between the entries to save space. For it to look good you need to use select the smallest magnifying glass on the menu bar." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 96 "for i from 1 to 5 do\n for j from 1 to 50 do\n \+ printf(\"%1d\",M[i,j]);\n od;\n printf(\"\\n\");\nod;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "\nAn example using the string format:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 74 "L:=[\"Bill Jones\", \"Ann Smith\", \"Kimiko Suzuki\",\"Juan Gonz alez\",\"Xin Lee\"];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "for i from 1 to nops(L) do\nprintf(\"Student number %d is %s. \\n\",i,L[i ]);\nend do;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 35 "Note the effect o f leaving out the " }{TEXT 416 2 "\\n" }{TEXT -1 22 " in the above pro gram:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 78 "for i from 1 to no ps(L) do\nprintf(\"Student number %d is %s. \",i,L[i]);\nend do;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 3 "map" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 " " 0 "" {TEXT 281 3 "map" }{TEXT -1 96 " is a very useful procedure whe n you want to apply the same procedure to \nall the elements of a " } {TEXT 282 11 "set, list, " }{TEXT -1 2 "or" }{TEXT 283 7 " matrix" } {TEXT -1 25 ". Here are some examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "X0:=\{seq(i,i=1..8)\};" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 " X1:=map(sin,X0);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 38 "Note that the following does NOT work:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "X2:=sin(\{1,2,3,4,5,6,7,8\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 77 "Now we want to evaluate each of the elements of X1 as floating poi nt numbers:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "XX1:=map(eva lf,X1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "We could have done thi s in one step:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "map(evalf @sin, X0);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 7 "Unlike " }{TEXT 461 3 "sin" }{TEXT -1 2 ", " }{TEXT 333 5 "evalf" }{TEXT -1 53 " is one of the few functions that do not require map:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "XX2:=evalf(X1); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "(" }{TEXT 417 8 "simplify" }{TEXT -1 95 " is another command tha t doesn't need map.)---but it won't hurt to use it , in case you forge t." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "simplify([(x-y)^2/(x-y), (z^2-w^2)/(z-w)]); \n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "map(simplify, [(x-y)^2/(x-y) , (z^2-w^2)/(z-w)]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "map can a lso take \"unnamed\" functions. Here are some examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "Y1:=[seq(i,i=1..5),a,b,c];" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "map(unapply(x^2,x),Y1);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "map(x->x^2,Y1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "map(proc(x) x^2; end, Y1);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 110 "Recall that if U is a list of len gth two then U[1]+U[2] is the sum of the two elements in the list. So \+ we have" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "map(U->U[1]+U[2],[[a,b],[c,d],[e,f]]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "M:=Matrix([[1,2,3],[4,5,6],[7,8,9]] );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "map(sin,M);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "map(evalf@sin,M); " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "5 mod 2, modp(5,2); " } {TEXT -1 58 "(Both of these give the remainder when 5 is divided by 2. )" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 42 "Now suppose we want to apply the function " }{TEXT 418 15 "x->modp( x , 2)" }{TEXT -1 22 " to each element of M." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "M;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "map(modp,M,2); " }{TEXT -1 61 "(Note the second argument for `mod` goes after the matrix M)." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "map(modp,M,3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "Another way to accomplish this is as foll ows." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "map(x->modp(x,3),M) ;\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 53 "A similar example would be the following: (Note that " }{TEXT 419 12 "igcd(a,b,c) " }{TEXT -1 14 "is the gcd of " }{TEXT 420 8 "integers" }{TEXT -1 11 " a,b and c. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "L:=[seq(i,i=1001..1021) ];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 81 "The goal is to take the igc d of each element of L with 30 and 42. Here's one way:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "map(igcd, L,30,42);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 20 "Another way is this:" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 24 "map(x->igcd(x,30,42),L);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 3 "zi p" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 33 "The following examples show w hat " }{TEXT 334 3 "zip" }{TEXT -1 8 " can do:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "zip(f, [a,b ,c,d],[1,2,3,4]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "zip((x ,i)->x[i],[a,b,c,d],[1,2,3,4]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "zip((x,y)->x*y,[a,b,c,d],[x,y,z,w]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "zip((x,y)->x+y,[a,b,c,d],[x,y,z,w]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "A:=matrix(2,2,[seq(x[1],x=[a,b,c,d] )]);\nB:=matrix(2,2,[seq(x[2],x=[a,b,c,d])]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "zip(igcd,A,B);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "zip((x,y)->x*y,A,B);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 51 "evalb, Lin earAlgebra[Equal], and convert/listlist" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 19 "The purpose of the " } {TEXT 335 5 "evalb" }{TEXT -1 131 " function is to force evaluation of expressions involving relational operators, using a three-valued logi c system. The returns are " }{TEXT 347 4 "true" }{TEXT -1 2 ", " } {TEXT 348 5 "false" }{TEXT -1 6 ", and " }{TEXT 349 4 "FAIL" }{TEXT -1 71 ". If evaluation is not possible, an unevaluated expression is r eturned." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 6 "Since " }{TEXT 350 5 "evalb" }{TEXT -1 46 " does not simplify expre ssions, it may return " }{TEXT 351 5 "false" }{TEXT -1 121 " to a rela tion which is actually true. In such a case, appropriate simplificatio n must be applied to the relation before " }{TEXT 352 5 "evalb" } {TEXT -1 42 " is used. Consider the following examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "evalb(1 = 2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "evalb(2 <= 3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "evalb(x <= x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "evalb(x <=y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "gt :=(u,v)->evalb(u > v);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "gt (1,3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "gt(3,1);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "A:=[1,2,3]:\nB:=[1,2,3]:\nev alb(A=B);\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "S1:=\{1,2,3 \}:\nS2:=\{1,2,3\}:\nevalb(S1=S2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "sin(Pi/12);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "theta=convert(sin(Pi/12),radical);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "evalb(sin(Pi/12) = theta);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 78 "This shows that even though the equation is true, Maple does not recognize it." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 " A:=Matrix([[1,2],[3,4]]);\nB:=Matrix([[1,2],[3,4]]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "Clearly these matrices are equal, but the follo wing command says they are not!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalb(A=B);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 11 "We may use " }{TEXT 353 10 "equal(A,B)" }{TEXT -1 68 " in the linear algebra pac kage to test equality of matrices A and B." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 20 "with(LinearAlgebra):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "Equal(A,B);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 73 "A nother way to deal with equality of matrices is to convert them to typ e " }{TEXT 362 9 "listlist:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "LA:=convert(A,listlist);\nLB:=convert(B,listlist);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "evalb(LA = LB);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 11 "What about " }{TEXT 354 6 "tables" }{TEXT -1 14 " . We see that " }{TEXT 355 5 "evalb" }{TEXT -1 52 " doesn't work, but \+ below is a method that does work." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 93 "We construct tables T and S that are clea rly equal, but the command evalb(T=S) returns false." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "T[1]:=1;\nT[red]:=green;\nS[1]:=1;\nS[red ]:=green;\nevalb(T = S);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "Howev er, we can \"look inside\" the tables as follows." }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 6 "op(T);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "op(op(T));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 17 "This reduce s the " }{TEXT 462 5 "table" }{TEXT -1 6 " to a " }{TEXT 463 4 "list" }{TEXT -1 77 ". We can do the same for S and then Maple will recognize that they are equal." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "ev alb(op(op(T)) = op(op(S)));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 6 "testeq" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{EXCHG {PARA 15 "" 0 "" {TEXT -1 13 "The function " }{TEXT 338 6 "testeq" }{TEXT -1 23 " tests for equivalence " }{TEXT 336 17 "probabilistically" }{TEXT -1 13 ". It returns " }{TEXT 337 5 " false" }{TEXT -1 58 " if the expressions are not equal (or not equal t o 0) and " }{TEXT 339 4 "true" }{TEXT -1 10 " otherwise" }{TEXT 422 35 " for the class of expressions that " }{TEXT 340 6 "testeq" }{TEXT 464 13 " understands." }{TEXT 421 1 " " }{TEXT -1 11 "The result " } {TEXT 341 5 "false" }{TEXT -1 4 " is " }{TEXT 342 15 "always correct; " }{TEXT -1 12 " the result " }{TEXT 343 4 "true" }{TEXT -1 1 " " } {TEXT 465 43 "may be incorrect with very low probability." }{TEXT 344 1 " " }}{PARA 15 "" 0 "" {TEXT -1 68 "It will return FAIL if the proce dures fail to produce an answer see " }{TEXT 423 7 "?testeq" }{TEXT -1 69 " for a few more details and a reference to the mathematics invo lved. " }}{PARA 0 "" 0 "" {TEXT -1 32 "Consider the following examples :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "a := (sin(x)^2 - cos(x)*tan(x)) * ( sin(x)^2 + cos(x)*tan(x))^2;\nb:=expand(a);\n\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 87 "Clearly a and b should be equal, since b is just an \+ expanded version of a, yet we have:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalb(a=b);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 37 "B ut testeq recognizes their equality:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "testeq(a=b);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 54 " Here's another example: Consider the following number:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "c:=surd(2+sqrt(5),3) + surd(2-sqrt( 5),3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "According to an article in the February 2001 issue of " }{TEXT 345 20 "Mathematics Magazine" }{TEXT -1 43 " the number c is actually 1. But note that " }{TEXT 346 11 "testeq(c=1)" }{TEXT -1 23 " doesn't tell us this. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "testeq(c=1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "However, the Maple simplify does show that c = 1. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "simplify(c);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 32 "Palindromes and Makin g your own " }{TEXT 424 7 "convert" }{TEXT -1 11 " procedures" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "Here we show how to determine whet her or not a number is a " }{TEXT 287 5 "palin" }{TEXT -1 0 "" }{TEXT 286 5 "drome" }{TEXT -1 85 ", that is whether or not its digits read t he same forward as backwards. For example, " }{TEXT 300 9 "113343311" }{TEXT -1 17 " is a palindrome." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 100 "Recall that t he following command converts an integer to a list of its digits --- i n reversed order." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "L:=con vert(1234,base,10);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT -1 49 "A user can make her own conversions known to t he " }{TEXT 357 7 "convert" }{TEXT -1 79 " function by defining a Mapl e procedure in the following way. If the procedure " }{TEXT 356 11 "`c onvert/f`" }{TEXT -1 36 " is defined, then the function call " }{TEXT 358 20 "convert(a,f,x,y,...)" }{TEXT -1 13 " will invoke " }{TEXT 359 22 "`convert/f`(a,x,y,...)" }{TEXT -1 67 "; Here we create a procedur e to convert a list back to an integer." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 91 "`convert/number`:=proc(L)\n local i,n;\n n:=nops(L) ;\n add(L[i]*10^(i-1),i=1..n);\nend proc:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 18 "convert(L,number);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "Here's another example to see how it works:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "n:=123456789101112131415;\nL:=conve rt(n,base,10);\nconvert(L,number);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 26 "We now define a procedu re " }{TEXT 284 3 "REV" }{TEXT -1 93 " whose input is a list L and who se output is the list obtained by reversing the entries in L." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "REV:=proc(L)\n local i;\n \+ [seq(L[-i],i=1..nops(L))];\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "REV([0,1,2,3,4,5,6,7,8,9]);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 42 "Using the above we can define a procedure " }{TEXT 360 3 "rev" }{TEXT -1 119 " which, given as input a positive integer n, re turns the integer obtained by writing the digits of n in reversed orde r:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 91 "rev:=proc(n)\n local i,L,k;\n L:=convert(n,base,10);\n L:=REV(L);\n convert(L,number); \nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "rev(123456789);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 17 "A number n is a " }{TEXT 285 12 "palindrome " }{TEXT -1 91 "if rev(n) = n. Using the above we can easily test whether or not a number is a palindrome:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "ispalindrome:=proc(n)\n evalb(n = \+ rev(n));\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "ispalindr ome(12321);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "ispalindrome (1121);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "Let's find some primes which are palindromes:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 107 "L:=NULL:\nfor i from 1 to 1000 do \n p:=ithprime(i);\n if ispal indrome(p) then L:=L,p; end if; \nend do:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 2 "L;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "nop s([L]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 20 "So there are twenty " }{TEXT 466 18 "palindromic primes" }{TEXT -1 16 " less than 1000." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 18 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 21 "Can Maple be trusted? " }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "From Robert Israel's " }{TEXT 364 24 "Maple Advisor Datatbase:" }}{PARA 0 "" 0 "" {TEXT -1 543 "\nAn y very large software project has bugs, and Maple has plenty of them. \+ You should not have blind faith in Maple, or any other computer algeb ra system, or a human for that matter. Use the same general guideline s that you might apply to something one of your colleagues might have \+ come up with (after a long and complicated calculation): first ask you rself if the answer appears to be reasonable, and then check it if pos sible. Try some special cases, a different method of calculating the \+ answer, or verify some consequences of the answer." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 167 "In a situation where an \+ error might have serious consequences, be especially diligent in check ing the answer. You might even try it on another computer algebra syst em." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 201 "I t's not unlikely that after using Maple for a while you will discover \+ some bugs. If you find what appears to be a bug, first make sure that \+ it really is a bug rather than your own mistake. Check the " }{TEXT 363 22 "Maple Advisor Database" }{TEXT -1 305 " and the help pages on \+ the functions you are using, to be sure that you are using them correc tly. Perhaps try some simpler examples, to determine the nature of th e problem and under what conditions it appears. If possible, consult \+ a more experienced Maple user (your instructor, if you are a student). " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 87 "If \+ you still think it is a bug, you can report it by e-mail to the Maple \+ developers at " }{MPLTEXT 0 21 21 "support@maplesoft.com" }{TEXT -1 47 ", to the Maple User Group, or to the newsgroup " }{MPLTEXT 0 21 24 "comp.soft-sys.math.maple" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 36 "solve and fsolve: a f ew more details" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 14 "The procedure \+ " }{TEXT 369 5 "solve" }{TEXT -1 102 " attempts to find an exact solut ion to an equation. It often fails to do this for theoretical reasons: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "poly:=x^4+x^2+1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 187 "Note carefully the difference in the following two commands and the difference in the output. This is sometimes an i mportant distinction as we shall see later. In the first case we get a " }{TEXT 467 15 "list of numbers" }{TEXT -1 33 " and in the second ca se we get a " }{TEXT 468 44 "list of sets each set containing an equat ion" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "sol1 :=solve(poly,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "sol2:=s olve(poly,\{x\});" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "Y:=eva lf(sol1); \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "Z:=evalf(so l2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "pol:=x^5-x^4+x^3+2* x-1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "S:=solve(pol=0,x); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 239 "This indicates that Maple is unable to find a solution--it has been proved that in general there a re no formulas for polynomials of degree greater than 4. We can, howe ver, obtain the numerical approximations for these 5 roots as follows :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evalf(S);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 108 " We can, also, direct Maple to find floa ting point approximations to the solutions to an equations by using " }{TEXT 374 8 "fsolve. " }{TEXT -1 11 "For example" }{TEXT 376 1 ":" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "fsolve(pol,x);" }}}{EXCHG {PARA 15 "" 0 "" {TEXT -1 24 "For a general equation, " }{TEXT 365 46 "fsolve attempts to compute a single real root." }{TEXT -1 144 " Howev er, for polynomials it will compute (approximations to) all real (non- complex) roots, although exceptionally ill-conditioned polynomials " }{TEXT 366 36 "may cause fsolve to miss some roots" }{TEXT -1 2 ". " }}{PARA 15 "" 0 "" {TEXT -1 39 "To compute numerical approximations to " }{TEXT 367 25 "all roots of a polynomial" }{TEXT -1 51 " over the f ield of complex numbers, use the option " }{TEXT 368 7 "complex" } {TEXT -1 13 " as follows: " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "Sol:=fsolve(pol=0,x,complex);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "Note that this gives the same resu lt as found above:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "evalb (\{evalf(S)\} = \{Sol\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "If you want to do something with t he roots use the following approach:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "Sol:=fsolve(pol=0,x,complex);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 158 "Now Sol[i] is the ith-solution. Note that the solut ions are returned as a sequence -- not a list or set. To see how many \+ convert Sol to a list and apply nops:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "nops([Sol]);\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 73 "We can spread them out a little for better viewing with a simple d o loop:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "for i from 1 to \+ nops([Sol]) do\nprint(Sol[i]);\nod;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 131 "Some solutions may be lost when the equation contains \"trans cendental\" functions (sin,cos, exp, ln, etc..). Consider the example " }{XPPEDIT 425 0 "sin(x)-x^2 = 0;" "6#/,&-%$sinG6#%\"xG\"\"\"*$F(\" \"#!\"\"\"\"!" }{TEXT -1 65 ". From the graph we see clearly that ther e are two points where " }{XPPEDIT 426 0 "sin(x) = x^2;" "6#/-%$sinG6 #%\"xG*$F'\"\"#" }{TEXT -1 2 " :" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "plot(\{sin(x),x^2\} ,x=-Pi..Pi,color=BLACK); " }{TEXT -1 132 "(Click on the plot and use t he cursor to shrink the size so you can see it better and so printing \+ it doesn't require so much paper.)" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 38 "But see what happens when we try both " }{TEXT 372 5 "solve" } {TEXT -1 5 " and " }{TEXT 373 5 "fsolv" }{TEXT -1 32 "e. Neither gives both solution. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "solve(s in(x) = x^2,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evalf(%); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "fsolve(sin(x) = x^2,x); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "Even specifying that we want \+ a root in the interval -2..2 gives only one root:" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 29 "fsolve(sin(x) = x^2,x,-2..2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 427 44 "But if we say we want a root in the inte rval" }{TEXT -1 8 " .5..1, " }{TEXT 428 26 "we do find the other root. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "fsolve(sin(x) = x^2,x,. 5..1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 71 "So the best advice is when seeking roots of tra nscendental equations: " }{TEXT 375 77 "look at the graph and try to \+ determine an interval containing a desired root." }{TEXT -1 10 " Then \+ use " }{TEXT 370 6 "fsolve" }{TEXT -1 51 " specifying the interval as \+ in the above examples. " }{TEXT 377 18 "Keep in mind that " }{TEXT 371 6 "fsolve" }{TEXT 378 48 " is happy to find just one root in any i nterval." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 14 "Basic plotting" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 380 16 "[Acknowledgement" } {TEXT -1 47 ": Some of the material below is from the book " }{TEXT 379 21 "Introduction to Maple" }{TEXT -1 91 " by Andre Heck. The book , however, is rather old now and uses an older version of Maple.] " }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 30 "N ote that one may plot either " }{TEXT 381 11 "expressions" }{TEXT -1 4 " or " }{TEXT 382 10 "procedures" }{TEXT -1 4 " or " }{TEXT 383 9 "f unctions" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 429 10 "Important:" }{TEXT -1 33 " Note that the calculus function " }{XPPEDIT 18 0 "e^x;" "6#)%\"eG%\"xG" }{TEXT -1 54 " is NOT denoted by e^x in Maple. One MUST use instead " }{TEXT 388 6 "exp(x)" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "h:=exp(-x^2)*cos(Pi*x^3 );\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 18 "Note that h is an " } {TEXT 386 10 "expression" }{TEXT -1 66 " in the variable x. Note h is \+ NOT a function and not a procedure. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "plot(h,x=-2..2); " }{TEXT -1 44 "Shrink this (and ALL plots) before printing." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "Or we may turn this expression into a procedure." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "f:=unapply(h,x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 79 "Here's a simple way to get a graph of the procedure f on the i nterval (-2..2):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "plot(f, -2..2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "The same result is obt ained as follows by plotting the Maple " }{TEXT 384 8 "function" } {TEXT -1 6 " f(t):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "plot( f(t),t=-2..2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "But here is a c ommon problem: If the procedure has an " }{TEXT 387 10 "if ...then" } {TEXT -1 65 " statement in it Maple will often be confused: Here's an \+ example:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "g:=proc(u) if u > 0 then u else -u; fi; end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "plot(g(u),u=-2..2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 35 "Here are three ways to remedy this:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "plot(g,-2..2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "p lot('g(u)',u=-2..2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 40 "The third way is by using the procedure " }{TEXT 385 9 "piecewise" }{TEXT -1 25 " to define the procedure:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "g:=piecewise(u<0,-u,u>=0,u);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "plot(g(u),u=-2..2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 96 "Two or more functions may be plotted on the same set of axes as in the next example: This plots " }{XPPEDIT 18 0 "x^3;" "6#*$%\"xG\" \"$" }{TEXT -1 180 " and its first and second derivative. Note that he re we use expressions and not functions or procedures. Since the defa ult colors are not easy to see, I have added a color option:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "plot([x^3, diff(x^3,x), diff (x^3,x$2)],x=-2..2, color=[red,blue,black]);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 59 "We can also do this with the operator notation, as foll ows:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "f:=x->x^3:\nplot([f ,D(f),(D@@2)(f)],-2..2, color=[red,blue,black]);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 188 "Recall that f@g is the composition of f with g an d g@@n is the composition of g with itself n times. So D(f) is the der ivative of f and (D@D)(f) or (D@@2)(f) is the second derivative of f. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "eval(f);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "D(f);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "(D@D)(f);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "(D@@2)(f);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "(D@@3)(f) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "(D@@4)(f);\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 38 "Finding Maxima and Minima via Calculus" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 284 "Here we show h ow to use some theory from calculus to find the maximum and minimum va lues of a function. Note that often it is more convenient to use expre ssions rather than procedures or functions. We can always use unapply to convert an expression to a function if we need to do so." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 69 "p := (6*x^4+312*x^2+10706-20*x^3-20*x)/(x^6- 197*x^4+10003*x^2+10201);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "plot(p,x=-20..20);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 129 "Note t he different scales on the x and y axes in the graph above. Let's plot the derivative to see where the critical points are:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "dp:=diff(p,x): \ndp:=simplify(dp); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "plot(dp,x=-20..20);" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 262 "Let's find the exact location of the critical points corresponding to the three peaks which we see in \+ the graph of p. We can see that the peaks occur approximately when x = -10, 0 and 10. But are these the exact values? We shall see that they are not. Let's use " }{TEXT 389 6 "fsolve" }{TEXT -1 1 ":" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "x1:=fsolve(dp=0,x,-11..-9);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "x2:=fsolve(dp=0,x,-(.1)..(.1 ));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "x3:=fsolve(dp=0,x,9. .11);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 98 "To find the value of p a t each of these values we convert p to a procedure which we shall call ff." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "ff:=unapply(p,x):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 47 "The three peaks have the follow ing coordinates:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "[x1,ff( x1)]; \n[x2,ff(x2)]; \n[x3,ff(x3)];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "Note that it looks as if dp has a root at x = 0, however as we \+ see below this is not the case. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "fdp:=unapply(dp,x):\nfdp(0);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 102 "We can also see this by plotting the derivative neare r the origin. We see that dp is not 0 when x = 0." }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 25 "plot(dp,x=-1/100..1/100);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 44 "Assignment 7 --Due Tue sday, October 29, 2002" }}{EXCHG {PARA 0 "" 0 "" {TEXT 391 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT 390 10 "Problem 1." }{TEXT -1 2 " " }} {PARA 0 "" 0 "" {TEXT -1 23 "(a) Plot the graph of " }{XPPEDIT 18 0 " sin(x)*exp(-x^2)" "6#*&-%$sinG6#%\"xG\"\"\"-%$expG6#,$*$F'\"\"#!\"\"F( " }{TEXT -1 67 " for x in the interval [-2,2]. \n\n(b) Find to 10 deci mal digits the " }{TEXT 393 7 "maximum" }{TEXT -1 5 " and " }{TEXT 394 7 "minimum" }{TEXT -1 11 " values of " }{XPPEDIT 18 0 "sin(x)*exp( -x^2);" "6#*&-%$sinG6#%\"xG\"\"\"-%$expG6#,$*$F'\"\"#!\"\"F(" }{TEXT -1 17 " for x in [-2,2] " }{TEXT 392 3 "AND" }{TEXT -1 6 " find " } {TEXT 395 33 "the corresponding values of x. [ " }{TEXT -1 57 "So if t he maximum occurs at x=a, you should also compute " }{XPPEDIT 18 0 "si n(a)*exp(-a^2);" "6#*&-%$sinG6#%\"aG\"\"\"-%$expG6#,$*$F'\"\"#!\"\"F( " }{TEXT -1 123 " both to 10 digits. Similarly for the minimum. Using \+ unapply to make the expression into a function will be useful here.] \+ " }{TEXT 430 5 "Hint:" }{TEXT -1 164 " Look at the graph of the deriva tive to find intervals where the roots of the derivative are located, Use these with fsolve to obtain the zeros of the derivative. " }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 400 10 "Problem 2." }{TEXT -1 29 " (a) Find the exact value of " } {XPPEDIT 18 0 "Sum(`mod`(n,5),n = 1 .. 40000);" "6#-%$SumG6$-%$modG6$% \"nG\"\"&/F);\"\"\"\"&++%" }{TEXT -1 66 " using each of the following methods: Time each method by using " }{TEXT 431 17 "starttime:=time( )" }{TEXT -1 12 " before and " }{TEXT 432 32 "elapsed_time:=time() - s tarttime" }{TEXT -1 30 " after the command.\n(1) using " }{TEXT 396 3 "sum" }{TEXT -1 2 ", " }}{PARA 0 "" 0 "" {TEXT -1 10 "(2) using " } {TEXT 397 3 "add" }{TEXT -1 6 ", and " }}{PARA 0 "" 0 "" {TEXT -1 12 " (3) using a " }{TEXT 398 7 "do loop" }{TEXT -1 2 ". " }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 1 "[" }{TEXT 399 7 "Remark: " }{TEXT -1 106 " There was a bug in (1) in Maple 7, but it seems to h ave been fixed in Maple 8.]\n\n(b) Try to use each of " }{TEXT 433 3 "add" }{TEXT -1 5 " , a " }{TEXT 434 7 "do loop" }{TEXT -1 5 " and " } {TEXT 436 3 "sum" }{TEXT -1 22 " to find the value of " }{XPPEDIT 18 0 "sum((-1)^n/n,n = 1 .. infinity);" "6#-%$sumG6$*&),$\"\"\"!\"\"%\"nG F)F+F*/F+;F)%)infinityG" }{TEXT -1 2 " " }{TEXT 435 4 "HINT" }{TEXT -1 136 ". One command will work, another will give an error message an d one will run till you hit the stop button and interrupt the computat ion." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 401 7 "P roblem" }{TEXT -1 1 " " }{TEXT 402 1 "3" }{TEXT -1 127 ". The followin g program generates a 20x51 matrix M of 0's and 1's. (This is an exam ple of a 1-dimensional cellular automaton.)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 33 "(a) Print out the matrix M usin g " }{TEXT 403 6 "printf" }{TEXT -1 52 " with no spaces between the 0' s and 1's in each row." }}{PARA 0 "" 0 "" {TEXT -1 9 "\n(b) Use " } {TEXT 405 3 "map" }{TEXT -1 265 " to change each 0 in the matrix M to the blank string \" \" and, each 1 in the matrix to the string \"X\". [For this it will help to write a procedure which will output \" \" \+ upon input 0 and \"X\" upon input 1.] (The resulting picture should r esemble a Christmas tree.)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 9 "Then use " }{TEXT 404 6 "printf" }{TEXT -1 11 " w ith the " }{TEXT 406 2 "%s" }{TEXT -1 92 " format code to print the ma trix of blanks and X's with no spaces between them on each row. " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "L:=[seq(0,i=1..25),1,seq(0,i=1..25)]:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 107 "f:=proc(X)\nlocal i;\n[X[1]+X[2] mod 2, seq(X[i-1] +X[i]+X[i+1] mod 2, i=2..50), X[50]+X[51] mod 2];\nend proc:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "M:=matrix(20,51,[seq((f@@n)( L),n = 0..19)]):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 437 9 "Problem 4" }{TEXT -1 199 ". Use the following program to generate a set S of 2 x 2 Mat rices with random entries 0 and 1. By initializing the global variable _seed to 1 everyone will obtain exactly the same set of matrices." } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 147 "restart:\nwith(LinearAlge bra):\n_seed:=1:\ndie:=rand(0..1):\nS:=\{\}:\nfor i from 1 to 100 do\n S:=S union \{Matrix([[die(),die()],[die(),die()]])\}:\nend do:\n" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "Execute the command:\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "nops(S);\n" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 9 "\nUse the " } {TEXT 438 5 "Equal" }{TEXT -1 246 " command in the linear algebra pack age to determine how many times each of the 16 2x2 0-1 matrices appe ars in the set S.\n\nThe following can be used to find the sequence T \+ of all 16 2x2 matrices with entries 0 and 1. You may find this usefu l.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 128 "L:=[[0,0],[1,0],[0 ,1],[1,1]]:\nT:= NULL:\nfor i from 1 to 4 do\n for j from 1 to 4 do\n \+ T:= eval(T), Matrix([L[i],L[j]]);\n od;\nod;\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 154 "(a) For each i from 1 to 16 find the number c[i] of times that the matrix T[i] appears in the set S. Print out these values in a column of the form \n\n1, 2" } }{PARA 0 "" 0 "" {TEXT -1 4 "2, 8" }}{PARA 0 "" 0 "" {TEXT -1 4 "3, 4 " }}{PARA 0 "" 0 "" {TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 1 "." }} {PARA 0 "" 0 "" {TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 5 "16,10" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 99 "This mean s for example that matrix T[1] appears 2 times, matrix T[2] appears 8 \+ times, and so forth." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 74 "[Note that the c[i]'s depend on the initial value chose n for the variable " }{TEXT 439 5 "_seed" }{TEXT -1 224 " at the begin ning.]\n\n(b) Print out the matrix which occurs most frequently in S. \+ You may do this by visually inspecting the results from (a) to see the number i for which c[i] is largest. This will correspond to matrix T[ i]." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{MARK "16 0 0" 44 }{VIEWOPTS 0 0 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 1 1 2 33 1 1 }