{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "Hyperlink" -1 17 "" 0 1 0 128 128 1 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 1 14 0 0 2 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 248 0 0 0 1 2 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 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 263 "" 1 14 124 1 100 0 0 0 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 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 271 "" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 272 "" 1 12 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "TXT CMD" -1 273 "MS \+ Sans Serif" 0 0 128 0 0 1 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "Bookmark" -1 274 "" 0 0 0 128 0 1 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "word" -1 275 "" 0 0 128 0 0 1 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "bookmark" -1 276 "" 0 0 0 128 0 1 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 277 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 278 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 279 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "TXT CMD " 26 280 "" 0 0 128 0 0 1 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "index" -1 281 "" 0 0 0 128 0 1 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "paragraph" -1 282 " " 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 283 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 284 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 285 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 286 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 287 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 288 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{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 "Heading 1 " 0 3 1 {CSTYLE "" -1 -1 "" 1 18 255 255 0 0 0 1 0 0 0 0 0 0 0 1 }1 0 0 0 6 6 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 2" 3 4 1 {CSTYLE "" -1 -1 " " 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 4 4 0 0 0 0 0 0 -1 0 } {PSTYLE "Heading 3" 4 5 1 {CSTYLE "" -1 -1 "" 1 12 171 191 99 0 1 0 0 0 0 0 0 0 0 1 }0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 }{PSTYLE "Bullet Item" 0 15 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 3 3 0 0 0 0 0 0 15 2 }{PSTYLE "newpage" -1 256 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 1 0 -1 0 } {PSTYLE "vfill" -1 257 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 "Definition" -1 258 1 {CSTYLE "" -1 -1 "" 0 0 0 64 128 1 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 4 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Theorem" -1 259 1 {CSTYLE "" -1 -1 "" 0 0 219 36 36 1 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 4 4 0 0 0 0 0 0 -1 0 } {PSTYLE "Problem" -1 260 1 {CSTYLE "" -1 -1 "" 0 0 0 0 255 1 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 4 4 3 4 0 0 0 0 -1 0 }{PSTYLE "dblnorm" -1 261 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 2 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "code" 2 262 1 {CSTYLE "" -1 -1 "Comic Sans \+ MS" 0 0 128 0 128 1 0 1 0 0 0 0 3 0 0 1 }0 0 0 -1 -1 -1 3 12 0 0 0 0 -1 0 }{PSTYLE "asis" 0 263 1 {CSTYLE "" -1 -1 "Arial Narrow" 1 12 128 64 0 1 0 0 0 0 0 1 3 0 0 1 }0 0 0 -1 -1 -1 3 6 0 0 0 0 0 0 }{PSTYLE "s ubproblem" 0 264 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 "diagram" -1 265 1 {CSTYLE "" -1 -1 "" 0 0 239 239 239 1 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 "dblnorm.mws" -1 266 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 2 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Item" 0 267 1 {CSTYLE "" -1 -1 "Lucida Sans" 1 12 0 0 0 1 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 6 -1 3 0 0 0 0 0 -1 0 }{PSTYLE "" 0 268 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 269 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "rdiagra m" -1 270 1 {CSTYLE "" -1 -1 "" 0 0 239 239 239 1 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 "texcomment" -1 271 1 {CSTYLE "" -1 -1 "" 0 0 128 128 128 1 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 "paragraph" -1 272 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 4 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {SECT 0 {PARA 3 "" 0 "" {TEXT 256 44 " A Short Introduction t o the Maple Language" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 293 "This sect ion contains an introduction to some of the Maple vocabulary used for \+ solving problems. It is not meant to cover everything, just some of the basics. Read it through quickly, to get an overview of the lang uage. Then you can come back and read with more understanding late r. " }}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 12 " Arithmetic" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 292 "First, there is arithmetic: addition, su btraction, multiplication, division and exponentiation. These can be c ombined, just as on a calculator. The order of precedence is the the \+ usual one: exponentiation first, then multiplication and division, th en addition and subtraction. So entering " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 " 2-3+4/5*6^7;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 25 " is the s ame as entering " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "(2-3)+(4/5)*(6^7);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 160 "You will notice that Maple wor ks with fractions whenever possible, changing to decimal numbers only \+ on demand. So typing and entering (pressing the enter key)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "1/3 + 1/2 ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 125 "will get a return of 5/6. \+ If you put a decimal point in one of the numbers, that forces Maple \+ to return a decimal answer. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "1/3. + 1/2;" }}}{EXCHG {PARA 0 "" 0 "evalf" {TEXT -1 54 "Another way to get decimals is to use the maple word " }{TEXT 273 5 "evalf" }{TEXT -1 41 " to convert a result to decimal form." }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 15 "evalf(1/2+1/3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 88 "Maple does arithmetic with complex numbers too. I is a Maple constant standing for " }{XPPEDIT 18 0 "sqrt(-1)" "6#-%%sqrtG6#,$\" \"\"!\"\"" }{TEXT -1 16 " . So entering " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "(3+2*I)*(2-I);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 35 "will produce an output of 8+I . " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "Maplese" {TEXT -1 57 "The name for pi, the area of the circle of radius 1, in " } {TEXT 275 7 "Maplese" }{TEXT -1 79 " is Pi. So to calculate the \+ area of a circle of radius 3, you would enter" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "Pi*3^2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 50 " Expressions, Names, Statements, and Assignments" }}{PARA 0 " " 0 "expressions" {TEXT -1 51 "Quantities to be computed like 1/2+1/3 \+ are called " }{TEXT 275 11 "expressions" }{TEXT -1 4 ". " }}{PARA 0 "" 0 "name" {TEXT -1 4 " A " }{TEXT 275 4 "name" }{TEXT -1 85 " is a string of characters which can be used to store the result of a com putation. " }}{PARA 0 "" 0 "statement" {TEXT -1 3 "A " }{TEXT 275 9 "statement" }{TEXT -1 173 " in Maple is a string of names and express ions terminated with a semicolon, or a colon if you don't want to se e the output, which when entered will produce some action. " }}{PARA 0 "" 0 "assignment" {TEXT -1 5 "The " }{TEXT 275 10 "assignment" } {TEXT -1 68 " statement is one of the most common statements. It is \+ of the form" }}{PARA 0 "" 0 "" {TEXT -1 51 " name := expression; For example, the assignment " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "area := Pi*3^2;" }}}{PARA 0 "" 0 "" {TEXT -1 53 "stores 9*Pi in a \+ location marked by the name area." }}{PARA 0 "" 0 "" {TEXT -1 53 "A mo re useful assignment for the area of a circle is " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "area := Pi*r ^2;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "subs" {TEXT -1 161 "In this case, the expression Pi*r^2 is stored in area and with this assignment, the area of a circle of any given radius can be comp uted using the Maple word " }{TEXT 273 4 "subs" }{TEXT -1 53 ". So to calculate the area when r is 3, we enter " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "subs(r=3,are a);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 80 "H ere, it is convenient to think of the assignment as defining area as a function" }}{PARA 0 "" 0 "" {TEXT -1 17 " of the radius r." }}}{SECT 0 {PARA 4 "" 0 "" {TEXT 259 2 " " }{TEXT -1 10 "Functions " }}{PARA 0 "" 0 "function" {TEXT -1 3 "A " }{TEXT 275 8 "function" }{TEXT -1 261 " is a rule f (possibly very complicated) for assigning to each argument x in a given set, a unique value f(x) in a set. In calculus the arguments and values of a function are always real numbers, but the notion of function is much more flexible than that." }}{PARA 0 " " 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 58 " Functions can be defined in several useful ways in Maple." }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }{TEXT 257 17 "As an expression :" }{TEXT -1 17 " The assignment " }}{PARA 5 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "area := Pi*r^2;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 265 "defines the area of a circle as a function of it's radius. The area function defined a s an expression is evaluated with subs. Since this function assigns r eal numbers to real numbers, its values can be plotted on a graph with the Maple word plot. So the statement" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "plot(area,r=0..4);" }}}{PARA 0 "" 0 "" {TEXT -1 109 " will produce in a separate plot window, the graph of the area function over the interval from r=0 to r=4 ." }}{PARA 0 "" 0 "arrow operato r" {TEXT -1 1 " " }{TEXT 282 39 "With the arrow operator the assignmen t:" }{TEXT -1 56 " If you have a simple function, you can often use \+ the " }{TEXT 275 14 "arrow operator" }{TEXT -1 18 ". For example, " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "area := r -> Pi*r^2;" }}}{PARA 0 "" 0 "" {TEXT -1 108 "defines the area function also. Now to find the area of a circle of radius 3 , we simply enter the statement" }}{EXCHG {PARA 4 "> " 0 "" {MPLTEXT 1 0 9 " area(3);" }}}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 55 "To plot this function over the domain r=0..4 , type " }}{PARA 5 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "plot(area,0..4);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 43 "Note that the variable r is omitted here. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "unapply" {TEXT 258 11 "U se unapply" }{TEXT -1 26 " . The ugly little word " }{TEXT 281 8 "un apply " }{TEXT 273 1 " " }{TEXT -1 154 "transforms expressions of one \+ or more variables into fuctions defined by an arrow operator. For exa mple, if we had a polynomial defined by the assignment" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "pol := x^2 + 4*x -1;" }}}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 19 "then the assignmen t" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "pol := unapply(pol,x); " }}}{PARA 0 "" 0 "" {TEXT -1 59 "turns pol into a function defined \+ by an arrow operator. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "proc" {TEXT 260 14 "As a procedure" }{TEXT -1 18 ": The Maple word " }{TEXT 281 4 "proc" }{TEXT -1 49 " can be used to define functions . For example, " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 " area := proc(r) Pi*r^2 end;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "ERROR" {TEXT -1 340 "defines the area function too. It is evaluated \+ and plotted as in the arrow operator definition. One advantage of \+ this way of defining a function is that the domain can be specified. \+ For example, the domain of the area function for a circle is all posit ive real numbers. This can be inserted into the procedure, with the M aple word " }{TEXT 281 5 "ERROR" }{TEXT -1 6 " . " }}{PARA 0 "" 0 "" {TEXT -1 80 "The message must be enclosed in backquotes '`', w hich is on the key with the " }{TEXT 281 5 "tilde" }{TEXT -1 6 ". \+ " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "area := proc(r) " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 55 " if r <= 0 then ERROR(`radius must be positive`) else " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "Pi*r^2 fi end;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "area(3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 " area(-3);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "if..then.. fi" {TEXT -1 10 "Note the " }{TEXT 281 13 "if..then..fi " }{TEXT 273 2 " " }{TEXT -1 24 "control statement here. " }}{PARA 0 "" 0 "?if" {TEXT -1 47 "You can learn more about the word if by typing " }{TEXT 281 4 "?if " }{TEXT -1 34 " in an input cell and entering it." }} {PARA 0 "" 0 "" {TEXT -1 190 " Functions of two variables can be defi ned and plotted just as easily in Maple as functions of one variable. \+ For example, the volume V of a cylinder of height h and radius r is \+ defined by" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "V := (r,h) -> \+ Pi*r^2*h;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "plot3d" {TEXT -1 44 "To see what the graph of V looks like, use " }{TEXT 281 6 "plot3d" }{TEXT 273 5 ". " }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "plot3d(V,0.. 4,0..4,axes=boxed);" }}}{PARA 0 "" 0 "" {TEXT -1 342 "Which way of def ining a function is the preferred way? That really depends on the sit uation. The expression method works well for functions which have onl y one rule of evaluation, but eventually you cannot avoid using an - > or proc definition. You will find yourself using arrow or p roc definitions more and more as time goes by." }}{EXCHG {PARA 0 "" 0 "" {TEXT 282 28 "Piecewise defined functions:" }}{PARA 0 "" 0 "piecewi se" {TEXT -1 111 "Many functions can only be described by stating vari ous rules for various parts of the domain. The Maple word " }{TEXT 281 10 "piecewise " }{TEXT -1 41 " will help with defining such funct ions." }}{PARA 0 "" 0 "" {TEXT -1 33 "Here is an example to show usage ." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "f(x) :=piecewise(x <= \+ -1,x^3+8, x <= 2,7+ 2*x, x <= 4, 11 - cos(x),3*x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 92 "As it stands, f is not really a function. We need to use unapply \+ to make it into a funtion." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "g :=unapply(f(x),x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 " g(2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 77 "When plotting piecewise \+ defined functions, sometimes style = point is better." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "plot(g, -3..6,style= point);" }}}} {SECT 0 {PARA 4 "" 0 "" {TEXT 262 56 " Built in Maple functions and O perations with Functions" }}{PARA 0 "" 0 "sqrt" {TEXT -1 78 " All of t he standard scientific functions are built into Maple. For example, \+ " }{TEXT 275 4 "sqrt" }{TEXT 273 2 " " }{TEXT -1 259 "is the square r oot function, abs is the absolute value function, the trig and inve rse trig functions are sin , arcsin , cos , etc., the natural log arithm and exponential functions are ln and exp . For a complete list of built in functions, type " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "?inifcns; " }}}{PARA 0 "" 0 "@" {TEXT -1 206 "New fun ctions can be obtained from old functions by use of the arithmetic ope rations of addition, subtraction, multiplication, and division togethe r with the operation of composition, which is denoted by " }{TEXT 281 1 "@" }{TEXT 273 6 ". " }{TEXT -1 44 "Thus the function define d by the assignment " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "y := sin(cos(x^2+3));" }}}{PARA 0 "" 0 " " {TEXT -1 28 " and evaluated at x=3 by " }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 13 "subs(x=3.,y);" }}}{PARA 0 "" 0 "" {TEXT -1 39 "coul d also be defined by the assignment" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "y := sin@cos@(x->x^2+3);" }}}{PARA 0 "" 0 "" {TEXT -1 28 " and evaluated at x=3 by" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "y(3.);" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 45 " Usi ng Maple as a fancy graphing calculator." }}{PARA 0 "" 0 "" {TEXT -1 162 " It is convenient to think of Maple as a fancy graphing calculato r for many purposes. For example, suppose you want to find the real s olutions of the equation " }{XPPEDIT 18 0 "x^5 - 30*x - 2 = 0" "6#/, (*$%\"xG\"\"&\"\"\"*&\"#IF(F&F(!\"\"\"\"#F+\"\"!" }{TEXT -1 20 " in t he interval " }{XPPEDIT 18 0 "-3..3" "6#;,$\"\"$!\"\"F%" }{TEXT -1 113 " . Then we can just plot the right hand side of the equation \+ and look for where the graph crosses the x-axis." }}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 30 " f := x -> 10*x^5 - 30*x +10 ;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 " plot(f ,-3..3);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 61 "By inspection, the graph crosses near 0. We can look closer." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "plot(f,-1.5..1.5); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{PARA 0 "" 0 "fsolve" {TEXT -1 154 " We see that the graph crosse s 3 times, the largest solution being between 1 and 1.5. If we wante d the largest solution more accurately, we could use " }{TEXT 273 6 "fsolve" }{TEXT -1 152 ". Note the syntax. There are three argumen ts, the equation to solve, the variable to solve for, and the interval in which to search for a solution." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 " fsolve(f(x)=0,x,1..1.5);" }}}}{SECT 0 {PARA 4 "" 0 " " {TEXT -1 66 " Data types, Expression Sequences, Lists, Sets, Arrays , Tables: " }}{EXCHG {PARA 0 "" 0 "types" {TEXT -1 138 "Maple express ions are classified into various data types . For example, arithmeti c expressions are classified by whether they are sums " }{TEXT 275 8 "type '+'" }{TEXT -1 13 ", products " }{TEXT 275 8 "type '*'" } {TEXT -1 7 " , etc." }}{PARA 0 "" 0 "whattype" {TEXT -1 19 " The Mapl e word " }{TEXT 281 8 "whattype" }{TEXT -1 49 " will tell what type a particular expression is." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "whattype(1/2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "whattype(a + b);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "whattype(x^2 + x = 2*x - 1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "whattype(a,b,3);" }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 " " }{TEXT 282 20 "Expression \+ Sequence." }{TEXT -1 2 " " }}{PARA 0 "" 0 "exprseq" {TEXT -1 5 "An \+ " }{TEXT 281 7 "exprseq" }{TEXT -1 90 ", expression sequence, is any \+ sequence of expressions separated by commas. For example, " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "viola := \+ 1,2, w*r+m, a=b+c, 1/2, (x+y)/z,`hello`;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 160 "is an assignment to vi ola of an expression sequence of 7 expressions. To refer to the si xth expression in this sequence, use the expression viola[6]; " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "vio la[6]; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }{TEXT 261 4 "List" } {TEXT -1 3 ". " }}{PARA 0 "" 0 "list" {TEXT -1 3 "A " }{TEXT 275 4 " list" }{TEXT -1 61 " is an expression sequence enclosed by square bra ckets. So " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "explist:= [viola];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 264 "makes a list whose terms are t hose in viola . As with expression sequences, we can refer to part icular terms of a list by appending to its name the number of the term enclosed in square brackets. Thus to get the fifth term of explis t , type the expression" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "explist [3];" }}}{EXCHG {PARA 0 "" 0 "op" {TEXT -1 78 "You can also reference \+ the fifth term in this list by by using the Maple word " }{TEXT 281 2 "op" }{TEXT -1 5 ". " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "op(3,explist);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 74 "In general, op(n,explist); returns the nth term in the list explist ." }}{PARA 0 "" 0 "nops" {TEXT -1 53 "To count how man y terms are in a list, use the word " }{TEXT 281 5 " nops" }{TEXT -1 19 ". So for example," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 " nops(ex plist);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "tells us that there ar e 7 terms in the list explist . nops comes in handy when you" }} {PARA 0 "" 0 "" {TEXT -1 69 "don't want to (or aren't able to) count t he terms in a list by hand. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 242 "You can't directly use the word nops to cou nt the number of terms in an expression sequence. But you can put sq uare brackets around the expression sequence and count the terms in t he resulting list. This device is used again and again." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 " nops(3,4,a);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "nops([3,4,a]);" }}}{EXCHG {PARA 0 "" 0 "point in the \+ plane" {TEXT -1 4 "A " }{TEXT 275 18 "point in the plane" }{TEXT -1 95 " is a list of two numbers. Points can be added and subtracted \+ and multiplied by a number. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "p := [1,2]; q := [-3,1]; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "w := 3*p + 2*q - p;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 180 "One important use of lists is to make lists of points to plot. For example, to draw a picture of the square with vertices (1,1), (3 ,1), (3,3), (1,3), make a list and then plot it." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "ab := [[1,1],[3,1],[3,3],[1,3],[1,1]];" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "plot(ab);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 135 "Notice in the gr aph that the origin is not included in the field of view. We can speci fy that by restricting the x and y coordinates. " }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 23 "plot(ab,x=0..4,y=0..4);" }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}}{EXCHG {PARA 0 "" 0 "parametric plot" {TEXT -1 32 "A nother use of lists is with " }{TEXT 275 16 "parametric plots" } {TEXT -1 31 ". If you have a curve in the" }}{PARA 0 "" 0 "" {TEXT -1 40 "plane described parametrically with " }{XPPEDIT 18 0 "x = f (t) " "6#/%\"xG-%\"fG6#%\"tG" }{TEXT -1 4 ", " }{XPPEDIT 18 0 "y = g (t)" "6#/%\"yG-%\"gG6#%\"tG" }{TEXT -1 322 " , as the parameter t run s from a to b, then you can draw it by making up a 3 term list to giv e to plot. Say you wanted to draw the upper half of the circle of ra dius 4 centered at (1,5). Then the list consists of the expressions \+ for the x and y coordinates followed by an equation giving the range o f the parameter." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "plot([1 +4*cos(t),5+4*sin(t),t=0..Pi],\nscaling=constrained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 151 "If you had to draw several pieces of cir cles, you might define a function to simplify things. You can call \+ the function whatever you want, say circ." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 55 " circ := (h,k,r,f,l) -> [h+r*cos(t),k+r*sin(t),t=f..l ];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 121 " So if we wanted circles of radius 1/2 centered at the corners of the square ab we can construct the sequence of lists" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 50 " circs := seq(circ(op(ab[i]), 1/2,0,2*Pi) ,i=1..4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 174 "In order to plot th ese circles, you need to enclose them in curly brackets to make a set \+ of the sequence before you give them to plot . See below for a disc ussion of sets." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "plot(\{circs,ab\},scaling=constrained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "seq" {TEXT -1 139 "Somet ime you might want to split a list of points to plot into a list of x- coordinates and another list of ycoordinates. The Maple word " } {TEXT 281 4 "seq " }{TEXT -1 101 " is very handy for this and many ot her operations. So to split off from ab the odd and even terms--" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "xdat := [ seq(ab[i][1],i=1..nops(ab) )];" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 39 "ydat := [seq(ab[i][2],i=1..nops(ab) )];" }} {PARA 0 "" 0 "" {TEXT -1 1 " " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 163 "What about the converse problem? Building up a list of points to plo t from two lists can also be done. The first thing you might think o f doesn't work, however." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 40 " seq([x dat[i],ydat[i]],i=1..nops(xdat));" }}{PARA 0 "" 0 "" {TEXT -1 1 " " }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 130 " Seq doesn't work well with a p ure expression sequence as input. However, with some coaxing we can \+ get it to do what we want. " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 50 " ne wab :=[seq([xdat[i],ydat[i]],i=1..nops(xdat))];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 298 "What did we do to change the input to seq ? We enc losed it in square brackets. If you feed such a list of points to plot , it knows what to do. If you wanted to strip out the inside brackets , that can be done too, but in release 4 of Maple, plot would treat it as a sequence of constant functions." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "newab := [seq(op([xdat[i],ydat[i]]),i=1..nops(xdat))];" }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 " plot(newab,color=black);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{EXCHG {PARA 0 "" 0 "" {TEXT 282 4 "Sets" }}{PARA 0 "" 0 "set" {TEXT -1 5 " A " }{TEXT 275 3 "set" }{TEXT -1 298 " is an expressi on sequence enclosed by curly brackets. This is much different from \+ a list. For one thing, the order in which you specify the members of a set may not be the order in which they are stored. Also each membe r of the set is only stored once, no matter how many times you list it ." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "Aset := \{y+x+1,1,2,1, 4,`bill`,x+y+1,`bill`\};" }}}{EXCHG {PARA 0 "" 0 "union" {TEXT -1 22 " The set operations of " }{TEXT 273 5 "union" }{TEXT -1 4 ", " } {TEXT 275 12 "intersection" }{TEXT -1 7 ", and " }{TEXT 275 5 "minus " }{TEXT -1 27 " are at your beck and call." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "Anotherset := Aset union \{4,3,a,7\} ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "Anotherset minus Aset, Anotherset i ntersect Aset;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 99 "Sets are import ant when plotting more than one function at at time, to plot the quadr atic function " }{XPPEDIT 18 0 "x^2-2" "6#,&*$%\"xG\"\"#\"\"\"F&!\"\" " }{TEXT -1 25 " and the linear function " }{XPPEDIT 18 0 "2*x+5" "6#, &*&\"\"#\"\"\"%\"xGF&F&\"\"&F&" }{TEXT -1 18 " on the same axes," }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "plot(\{x^2-2,2*x+5\},x=-5..5 );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " " 0 "plots[display]" {TEXT -1 20 "plots the parabola " }{XPPEDIT 18 0 " y=x^2-2" "6#/%\"yG,&*$%\"xG\"\"#\"\"\"F(!\"\"" }{TEXT -1 15 " and the line " }{XPPEDIT 18 0 " y=2x+5 " "6#/%\"yG,&*&\"\"#\"\"\"%\"xGF( F(\"\"&F(" }{TEXT -1 20 " over the domain " }{XPPEDIT 18 0 "x=-5..5 " "6#/%\"xG;,$\"\"&!\"\"F'" }{TEXT -1 82 " on the same graph. If yo u have a very complicated drawing to make, you can use " }{TEXT 281 16 " plots[display] " }{TEXT -1 125 " from the plots package. Just gi ve names to the plots you want to display and then display the list of plots you have named." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "p l1 := plot(\{x^2-2,2*x+5\},x=-5..5):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "pl2 := plot([[2,1],[3,20],[0,0],[2,1]]):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plots[display]([pl1,pl2]);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 282 17 "Tables and Arrays" }}{PARA 0 "" 0 "table" {TEXT -1 5 " A " }{TEXT 275 5 "table" }{TEXT -1 303 " is a special kind of data \+ structure which is very flexible. The packages of special vocabularie s are really tables whose indices of the package are the names of the \+ procedures and whose entries are the bodies of the procedures. We do \+ not make much use of tables in this handbook, except for arrays." }} {PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "array" {TEXT -1 5 " An \+ " }{TEXT 275 5 "array" }{TEXT -1 151 " is a special kind of table wh ose indices are numerical. Somet useful arrays are matrices (2 dimensi onal arrays) and vectors (1 dimensional arrays). " }}{PARA 0 "" 0 "ev alm" {TEXT -1 46 "Matrix operations are made using Maple word " } {TEXT 281 6 "evalm " }{TEXT -1 63 " together with the symbol for mat rix multiplication &* . " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "a : = array(1..2,1..2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 73 " creates a 2 by 2 matrix, whose en tries are accessed as a[1,1] etc. " }}{PARA 0 "" 0 "" {TEXT -1 28 " So to rotate the square " }{XPPEDIT 18 0 "ab := [[1,1],[3,1],[ 3,3],[1,3],[1,1]];" "6#>%#abG7'7$\"\"\"F'7$\"\"$F'7$F)F)7$F'F)7$F'F'" }{TEXT -1 114 " through an angle of 31 degrees counter clockwise ab out the origin and display it, we could proceed as follows." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "rot := array([[cos,-sin],[si n,cos]]); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "ang := eval f(Pi/180*31);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "ab := [[1, 1],[3,1],[3,3],[1,3],[1,1]];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 70 "rotab := [seq(convert( evalm(rot(ang)&*ab[i]),list) ,i=1..nops(a b) )];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "plot(\{ [[0,0]], ab,rotab\} );" }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT 263 27 " Maple con trol statements " }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "There are two \+ especially important control statements . One is the " }{TEXT 275 15 "repetition loop" }{TEXT -1 85 ", and the other is the conditio nal execution statement. The repetition loop is " }}{PARA 268 "" 0 " " {TEXT 281 45 "for .. from .. by .. to .. while .. do .. od;" }{TEXT 283 1 " " }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 121 "This stateme nt can be used interactively or in a procedure to perform repetitive t asks or to do an iterative algorithm. " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 260 "" 0 "" {TEXT 284 8 "Example:" }{TEXT -1 32 " Add up the first 100 numbers." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 " s := 0: for i from 1 to 100 do s := s+i od:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 " s;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 260 "" 0 "" {TEXT 285 8 " Example:" }{TEXT -1 127 " Compute the cubes of the first five positiv e integers and store them in a list. Then do it again, storing them i n an array. " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 20 "Solution with lists:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 151 "locube := NULL: # start with the empty exprseq\n fo r i from 1 to 5 do \n locube := locube ,i^3 od: \nlocube := [ locube]; # make locube a list.;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "Note the way \+ the list is built up from an empty exprseq " }{TEXT 281 4 "NULL" } {TEXT -1 197 ". Each time through the loop, one more term is added o nto the end of the sequence. At the end, square brackets are put arou nd the sequence, making it a list. With arrays, one can be more direct ." }}{PARA 0 "" 0 "" {TEXT -1 21 "Solution with arrays:" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 47 "aocube := array(1..5): # initialize the array ." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "for i from 1 to 5 do \+ aocube[i]:= i^3 od; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 " o p(aocube); # to see the array " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 344 "Now the array aocub e has the numbers stored in it. To refer to the third element of a ocube , we would enter aocube[3] just as if it were a list, rather \+ than an array. Why have arrays at all? Well, for one thing, the term s in an array can be more easily modified. For example, to change the third term in aocube to 0 just enter " }{XPPEDIT 18 0 "aocube[3] := 0" "6#>&%'aocubeG6#\"\"$\"\"!" }{TEXT -1 154 "; . To change the \+ third term in locube to 0, you have to make an entirely new list who se terms are all the same as locube except for the third one." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "aoc ube[3]:=0;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "print(aocube) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "locube := [locube[1],l ocube[2],0,locube[4],locube[5]];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 282 22 "Conditional \+ execution " }{TEXT 286 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 269 "" 0 "" {TEXT -1 35 " if .. then .. elif .. else .. fi; " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "elif" {TEXT -1 95 "There are l ots of times when you need to consider cases, and they can all be hand led with the " }{TEXT 281 36 " if .. then .. elif .. else .. fi;" } {TEXT -1 126 " statement. For example, many functions are defined \+ piecewise. The absolute value function abs is such a function. \n \+ " }}{PARA 260 "" 0 "" {TEXT 287 8 "Problem:" }{TEXT -1 57 " Define y our own version of the absolute value function." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 11 "A solution:" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "myabs := pro c(x) if x > 0 then x else -x fi end;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "myabs(-23);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "plot(myabs,-2..2,scaling=constrained,title=`my absolute value`); # to see what it looks like." }}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 36 " A Brief Vocabulary of Maple Words " }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 199 "Here are some Maple words useful in calculus problem so lving, together with examples of their usage. For more information on these words and others, look at the helpsheets and use the help brows er." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "y := (x+3)/tan(x^2-1 ); # use 'colon-equal' to make assignments. " }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 51 "collect(x*2 + 4*x,x); # collects like powers \+ of x." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "diff(cos(x),x); # calculates the derivative " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "D(cos); # the differential operator" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 " y := denom((a+b)/(e+f)); # assigns e+f to y. " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "y := 'y'; # makes y a vari able again. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "evalc((2+3* I)^3); # performs complex arithmetic " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "evalf(1/2^9); #evaluates 1/2^9 to a decimal number \+ " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "expand((x+b)^7); # exp ands the product " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "p := x ^2+5*x+6; # assigns the quadratic to p. " }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 37 "factor(p); # factors the polynomial " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "fsolve(x^5-3*x=1,x,0..2); # solve \+ eqn for x in 0..2" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "int(x* exp(x),x); # returns an antiderivative." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 44 "Int(x*exp(x),x=0..1); # A passive integral." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "map(x->x^2,[1,3,2,5]); # ret urns a list of squares." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 " nops([3,4,x,1]); # returns the number of terms in the list. " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "numer((a+b)/c); # gives num erator, here a+b " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "op([3, 4,1,x]); # strips the brackets off the list " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "plot(x^2+x, x=-3..3); # plots x^2+x as x goes \+ from -3 to 3. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "plot3d(x^ 2+y,x=-2..2,y=0..2); # plots a surface " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "f := x -> x^2; # defines the squaring function. " }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "f(3); # then returns 9. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "quo((x^4-4),(x^2-2),x); \+ # divides polynomials " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "i quo(23,2) ; # divides the integers" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "rem((x^4-4*x+3),(x^2-2),x); # gives the remainder" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "irem(23,2) ; # gives the i nteger remainder " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "restar t; # very handy. This word resets all assignments." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "eq1 := x^2 + 3*x -1 = a; # assigns the e quation" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 70 "rhs(eq1); # yie lds the righthand side of eq1. There is also an lhs. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "simplify(a/x+b/y); # sometimes sim plifies expr. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "solve(a*x +4*y=0,x); # solve the equation for x. " }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 66 "subs(x=5,x^2+x); # substitute 5 for x where it oc curs in x^2+x. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "i := 'i' ; # makes i a variable again" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "sum((i^2,i=2..9)); # add up the 2nd thru 9th squares \+ " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 0 {PARA 4 "" 0 "" {TEXT -1 24 " Trouble Shooting Notes" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 273 "Learning to use Maple can be an e xtremely frustrating experience, if you let it. There are some type s of errors which occur from the beginning that can be spotted and cor rected easily by a person fluent in Maple, so if you have access to su ch a person, use him or her. " }}{PARA 0 "" 0 "" {TEXT -1 115 "Here a re a few suggestions that may be of use when you're stuck with a works heet that's not working like it should." }}{PARA 15 "" 0 "" {TEXT 269 10 " Use help:" }{TEXT -1 232 " There is a help sheet with examples f or every Maple word. A quick read thru will often clear up syntax pr oblems. One very common early mistake is to leave out the parentheses around the inputs of a word. For example, typing " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "plot x^2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 66 "will get you a syntax error, because you left out the parentheses." } }{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 15 "" 0 "" {TEXT -1 1 " " }{TEXT 268 27 "The maple prompt is `>` " }{TEXT -1 117 ". \+ You can begin entering input after it. Make sure you are typing int o an input cell, if you are expecting output." }}{PARA 15 "" 0 "" {TEXT -1 1 " " }{TEXT 267 42 "End maple statements with a semicolon `; ` " }{TEXT -1 153 ". Maple does nothing until it finds a semicolo n. If you are getting no output when you should be, try feeding in a semicolon. This often works. " }}{PARA 15 "" 0 "" {TEXT 266 34 "Whe n in doubt, put in parentheses." }{TEXT -1 72 " For example, (x+3)/ (x-3) is very different from x+3 / x-3 ." }}{PARA 15 "" 0 "" {TEXT 264 37 "Make sure your variables are variable" }{TEXT -1 315 ". \+ You may have assigned a value, say 3, to x in a previous problem. \+ To make x a variable again, type x := 'x': . Use the forward quot e ' key, just below the double quote \" here. If you forget this, strange things can happen. One way to handle this is to keep a n input cell of variables used. " }}{PARA 15 "" 0 "" {TEXT -1 4 "Use " }{TEXT 278 8 "restart;" }{TEXT -1 195 " By typing restart; in an i nput cell and pressing enter, you clear all assignments, and start wit h a clean slate. This fixes a lot of problems fast, but you will need to re-execute input cells." }}{PARA 15 "" 0 "forward quote" {TEXT 265 39 "Are you using the correct quote symbol?" }{TEXT -1 18 " In M aple, the " }{TEXT 275 13 "forward quote" }{TEXT -1 160 " ' is used to suppress evaluation. The back quote ` is used to enclose asci i strings. The double quote \" is used to reference the last comput ation. " }}{PARA 15 "" 0 "" {TEXT 270 34 "Do not forget to end loops with od" }{TEXT -1 388 ", `if` statements with fi, and procedures wi th end. If you start a loop with do , Maple does not begin proc essing until it finds the end of the loop, which is signaled by the wo rd od; The same applies to the if .. then ... fi; and proc \+ ... end; contructions. If you are getting no output when you should \+ be, try feeding an od; , fi; , or end; This often works." }} {PARA 15 "" 0 "" {TEXT 272 17 "Unwanted output?:" }{TEXT 271 156 " Is there output you need but don't want to see? Use a colon `:` \+ instead of a semicolon to end the Maple statement which generates \+ the output." }}{PARA 15 "" 0 "printlevel" {TEXT 277 21 "Use printleve l := 10;" }{TEXT -1 117 " if you want to see what Maple is doing behin d the scenes when you give it a command. If you want to see more, us e " }{TEXT 281 10 "printlevel" }{TEXT -1 147 " := 50 or higher. Often by inspecting the output when printlevel is greater than 1 (the defa ult), you can discover what is ailing your worksheet." }}{PARA 15 "" 0 "debug" {TEXT 279 9 "Use debug" }{TEXT -1 124 ". If you have define d a word, say `something` and it does not do what you want, you can of ten discover the error by typing " }{TEXT 281 17 "debug(something);" } {TEXT 273 2 " " }{TEXT -1 146 " in an input cell and pressing the ent er key. When you use the word again, its behind the scene computation s are printed out for your inspection." }}{PARA 15 "" 0 "verboseproc" {TEXT 288 31 "Want to see a word definition? " }{TEXT -1 45 " Say you want to see how plot works. Type " }{TEXT 281 25 "interface(verbose proc=2);" }{TEXT -1 60 " in an input cell and press enter. Then type print(plot);" }}}}}{EXCHG {PARA 0 "" 0 "" {HYPERLNK 17 "" 1 "psol1.m ws" "" }{HYPERLNK 17 "" 1 "worksh.mws" "" }{HYPERLNK 17 "Table of Cont ents" 1 "hand0.mws" "" }}}}{MARK "2" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }