{VERSION 4 0 "IBM INTEL NT" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "" -1 256 "Helvetica" 1 14 128 0 0 1 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 0 24 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 258 "Helvetica" 0 1 128 0 0 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 259 "Helvetica" 0 1 128 0 0 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 260 "" 1 14 0 0 0 0 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "" -1 261 "" 1 14 0 0 0 0 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "" -1 262 "" 1 14 0 0 0 0 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "" -1 264 "" 1 14 0 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 265 "" 1 14 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 266 "" 1 14 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 267 "" 1 14 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 268 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 269 "" 1 14 0 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 270 "" 1 14 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 271 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 1 1 1 }1 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 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 2 1 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 256 "" 0 "" {TEXT 257 13 "MLC Lab Visit" }}{PARA 0 "" 0 "" {TEXT 256 27 "Mth 351 May 18 2001 Maple 6" }}{PARA 0 "" 0 " " {TEXT 258 16 "Bent E. Petersen" }}{PARA 0 "" 0 "" {TEXT 259 32 "File name: 351s2001_lab_visit.mws" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 271 130 "Some of the commands below may not work corre ctly in Maple 5 and earlier. Usually there are other ways to achieve t he same effect." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 393 "The workstations in the MLC lab are PCs running Win dows NT 4.0. In order to use the machines you must have an ORST (a.k.a . myORST) account. When you logon to a machine in the MLC lab your ORS T directory on the ORST server will be visible as drive Z: This is whe re you should keep your personal files. Then they will be available fr om any PC in the MLC lab (and many other labs) when you login." }} {PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT 260 5 "Login" } }{PARA 0 "" 0 "" {TEXT -1 330 "The machines in the lab are normally le ft on, but the monitors may be turned off. If the monitor is off, then switch it on. Next press the Ctrl-Alt-Delete keys simultaneously. You should get a login prompt. Enter your ORST user name and press the Ta b key (not the Enter key). Then enter your ORST password and press the Enter key." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 93 "Next you may see a message about a slow network connection. Thi s message is bogus. Ignore it." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 164 "Next you may see a question about a defa ult Novell server. Just answer \"none\" unless you have a reason to an swer otherwise. This question should never appear again." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 269 "To start Maple (o r Matlab, or Mathematica, ... ) select the Start button (lower left co rner of the screen), then Programs from the menu, etc. If you don't kn ow the appropriate steps here ask for help. Writing all this out in de tail produces an incredibly dull document." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 261 6 "Logout" }}{PARA 0 "" 0 "" {TEXT -1 257 "When you are done with your session save your work, shut down the software you were using and should logout. To logout select t he Start button (this is a very strange Windows idiom), and then selec t \"Shut Down ...\" and finally select \"Logon as another user.\"" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 111 "Another \+ way to logout is to press Ctrl-Alt-Delete. A menu will appear. Select \+ logoff. That is the simplest way." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 329 "Do not select Restart or Shutdown unless you have a reason to do so and do not shut off the PC. There is no ha rm in shutting off the PC, but doing so causes the next user to have a long wait while the machine reboots. You may turn off the monitor if \+ you wish. That will save power and will reduce the load on the air-con ditioner." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 186 "Note: If you do not logout you leave your account open for the ne xt person to come along. That person will have access to your personal files on the ORST server. Do not forget to logout!" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 533 "If you plan to leave t he lab, even just for a few minutes, save your work and logoff. When y ou return and logon, even to a different machine, your work will be av ailable. Do not select \"Lock Workstation.\" If you do, someone else w ishing to use the workstation may power-cycle it in order to gain acce ss and some of your work may be lost as a result. The same comments ap ply to relying on a password protected screensaver. Don't do it. Save \+ your work and logoff. You have no claim on any workstation if you are \+ not physically present." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 262 13 "The Worksheet" }}{PARA 257 "" 0 "" {TEXT -1 470 "Wh en you are using Maple in a window environment it is possible to move \+ around on the worksheet by left-clicking the mouse. As a result, comma nds may end up being executed in a nonlinear order. This can cause som e confusion, since there is no visual clue. One way to fix a mess is t o have Maple re-execute the whole worksheet (look on the Edit menu). T his works best if old expressions are cleaned up first, so it is a goo d idea to start each worksheet with the command " }{TEXT 263 8 "restar t;" }{TEXT -1 40 " You do not need to do so of course ...." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "rest art;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 115 "Maple commands are executed by pressing the Enter key when the mouse cursor is in the line containing the commands." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 468 "Note each Maple comma nd must be terminated by a colon or a semicolon (except help commands \+ preceded by a question mark). You can spread the command over several \+ lines by postponing the terminating colon or semicolon. You simply mov e to a new line by pressing Enter. Maple will chatter at you when you \+ move to a new line in this manner if the previous command is untermina ted. Ignore it, but keep in mind a command will not be executed before it is properly terminated." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 299 "You can also stack up several commands on one \+ line by terminating them individually with colons or semicolons. The e ffect of the colon is to suppress output from the corresponding comman d, though the command is still carried out. All the commands on a line are executed when you press the Enter key." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 408 "Maple has two ditto operators, % and %%. The value of % is the previous evaluated expression, the \+ value of %% is the one before that. Since the Worksheet commands may be executed in any order, the ditto operators can cause a lot of conf usion. It is probably best to restrict them to the same line as the ex pressions they refer to. Here is a silly example, which also demonstra tes the assignment operator." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 222 "Here's a useful fact: You can open a new comma nd line below the current one by pressing Ctrl-J, or above the current line, by pressing Ctrl-K. This is pretty useful when you realize you \+ omitted something at a certain step." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "a:=5: b:=4: %%; %%; %;" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 137 "You can also unassign variables. Right now a is 5. That would caus e problems if we want to use a as a dummy variable of integration!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "unassign('a','b'); a; b;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 63 "You can pass any number of variabl es to the unassign() command." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 114 "A simpler way to unassign one variable i s to assign it its name extracted by single quotes (this is a Maple id iom)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "a:=5; a:='a': a;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 279 "This is quite convenient, but som etimes the single quotes are hard to find on the keyboard and even har der to see on the monitor. Thus, even though it is more typing you may prefer to use the evaluate to a name function evaln() since it does \+ not require the pesky single quotes." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "a:=5; b:=4;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "unassign(evaln(a),evaln(b)); a; b; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 92 "Unfortunately, you can pass only one expression to evaln(), since \+ it returns only one name. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 27 "Maple has builtin constants" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "Pi; evalf(Pi); I; I^2;" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 210 "Note the upper ca se letters. If you enter pi you will just get the Greek letter pi, not the real number pi. By the way, the evalf() function takes a second p arameter specifiying the precision in decimal digits." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "evalf(Pi ,40);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 224 "You can also set the precision by assigning a value to D igits (the default is 10). Maple usually does exact calculations, but \+ when floating point numbers are involved then Digits sets the precisio n. Here's an amusing example" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "Digits:=4: convert(evalf(Pi) ,`rational`);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 172 "The conversion to a rational number makes use of Digi ts, rather than any precision specified in the evalf() command. You ca n easily find other rational approximations to pi" }{MPLTEXT 1 0 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "Digits:=8: convert(evalf(Pi),rational);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 292 "Note this time I om itted the backticks on the word \"rational.\" Most of the time you do \+ not need them, but if you have a variable called \"rational\" you need the backticks to ensure that you pass a literal string to Maple's con vert() function, rather than the value of your variable \"rational.\" " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 37 "Let's set Digits back to its default." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "Digits:=10:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 139 "Let's lo ok a bit at symbolic manipulations now. Maple distinguishes between fu nctions and expressions. Here's one way to define a function:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "f:=x->sin(3*x+x^2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 33 "We can also define an expression:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "g:=sin(3*x+x^2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 261 "Both of the examples above assume that \+ x has not already been assigned a value. It needs to be an unassigned variable. In the definition of f the x is a dummy variable, a pla ce marker. In g however, it is part of the expression, and one can r efer to it." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 159 "To evaluate a function we use the usual function convention. T o evaluate an expression one generally uses the subs() command (though it has other subtle uses)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "f(1); subs(x=1,g);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 59 "No te the subs() command above does not assign a value to x." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 310 "An expression can also be evaluated by using the eval() command, but do check help to m ake sure you don't have any surprises in more complicated situations. \+ The commands eval() and subs() work in quite different ways. In the si mple case that we illustrated here eval() is actually the preferred co mmand to use." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "eval(g,x=1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 59 "Note the eval() command above d oes not assign a value to x." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 75 "We can convert an expression into a function by using the unapply() command" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "h:=unapply(g,x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 102 "You can \+ think of unapply() as turning the indicated variable(s) into dummy var iables or place markers." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 132 "Some Maple commands work on expressions, some wor k on functions, and some on both. For example, here are the derivative s of f and g." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "D(f); diff(g,x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 33 "Second derivatives are no problem" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "D(D(f)); diff(g,x,x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 124 "but this notation can ge t out hand. Fortunately there is an alternative! Here are the fourth d erivatives as an illustration:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "(D@@4)(f); diff(g,x$4);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 60 "Pa rtial derivatives of expressions are also easily computed:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "dif f(x/(x^2+y^2),x$3,y);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 395 "There is an inert version Diff() of diff (). An inert function returns unevaluated. That may seem strange, but \+ sometimes one can save time by postponing evaluation, or one can preve nt Maple from attempting a calculation that will fail in at present, b ut can be caried out later in special cases. Unevaluated expressions m ay be evaluated by using the command value(), thought there are other \+ ways." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 135 "Inert functions, together with the ditto operator can be used to get \+ nicely typeset expressions. See if you can sort out the following:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "Diff(x/(x^2+y^2),x$3,y): %=value(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 290 "As a final general examp le let's bring back some fond memories from calculus - the problem of \+ integration. Here's on example to get you started: Once again I use po stponed evaluation to get a nicely typeset equation. You don't need to do such trickery, of course, but it's nice to know how." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "Int( 1/(1+x^4),x): % = value(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 0 "" 0 "" {TEXT -1 41 "You can obtain the same effect by writin g" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "Int(1/(1+x^4),x) = int(1/(1+x^4),x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 157 "if you d on't mind writing the integrand twice. If you are just interested in e valuating the integral then you can dispense with all the typesetting \+ niceties:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 17 "int(1/(1+x^4),x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 46 "Naturally definite integrals ar e possible too." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 50 "Int(2*x^2*log(x)^3+x^3*log(x),x=1..2): %=value (%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 139 "If you want a floating point number you can simply use evalf() , but there is a subtle and important difference depending on how you \+ do it. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "a:=int(2*x^2*log(x)^3+x^3*log(x),x=1..2): evalf(a,16) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "evalf(Int(2*x^2*log(x) ^3+x^3*log(x),x=1..2),16);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 299 "In the first case we assign the symbolic expression for the integral to a and then evaluate that expression. In the second example, Maple detects that we want a numeric result an d evaluates the integral numerically without first trying to obtain a \+ symbolic solution. This is important. For example" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "int(arctan( x)/log(x),x=Pi/8..Pi/4); evalf(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "evalf(Int(arctan(x)/log(x),x=Pi/8..Pi/4));" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 476 "H ere, in the first case, Maple decided after a while that it can not re turn a symbolic value for the integral and so returned it unevaluated. Then evalf() called a numeric quadrature rule to get an answer. In th e second case however, Maple wasted no time trying to find a nonexiste nt symbolic solution, but instead used a numeric quadrature method. Th is is an important use of inert functions. You can grow noticably olde r waiting for a symbolic solution to a complex problem." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 137 "There are refinemen ts. For example, you can specify what quadrature method to use. Enter \+ the command ?int[numeric] for more information." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 258 "" 0 "" {TEXT -1 10 "Some Plots" }{TEXT 268 0 "" }{TEXT 269 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 124 "Functions and \+ expressions can be plotted. There are numerous plot variations. Check \+ the help facility, ?plot, for details." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "f:=x->sin(1/x); g:=s in(1/x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "plot(f,0..1,num points=200,title=\"Plotting a function\");" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 60 "plot(g,x=0..1,numpoints=200,title=\"Plotting an exp ression\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 88 "We can convert a function into an expression simply by \+ evaluating it, so one can also do" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 " plot(f(x),x=0..1):" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 92 "I \+ supressed the output, since you probably don't want to see a third cop y of the same graph." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 117 "You can also plot anonymous functions, or expressions, that is, plot them without first assigning them to a variable:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plot(x->x+sin(x),0..4*Pi);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "plot(x+sin(x),x=0..4*Pi);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 265 29 "Taylor Series and Polynomials" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 288 "We have studied Taylor and int erpolation polynomials in class. Maple supports both. Actually the Tay lor polynomial is a special case of interpolation, with all the nodes \+ equal. but Maple's interpolation routine requires distinct nodes (we c an get around that restriction by using limits)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 50 "Let's start with an examp le of Taylor polynomials:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "expr:=taylor(exp(2*sin(x)),x=0,10); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 166 "Note taylor() works on expressions. The second argument specifies the center. The third argument specifies the order of the terms omitt ed. Parameters may be included:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "a:=evaln(a);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "expr:=taylor(exp(a*sin(x)),x=0,5); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 174 "Note I unevaluated a first, because we left it assigned to some n umber above. If I had not unevaluated it then Maple would have substit uted the value of a in this expression." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 132 "The data type returned by taylor() \+ is a series, not a polynomial. If you want a polynomial to play with y ou need to do a conversion:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "taylor(tan(x),x=0,10): p:=co nvert(%,polynom);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 62 "You need backticks if you have used polynom as a v riable name." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 55 "You can specify a different center, even a symbolic one" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "taylor(exp(x),x=c,4): pc:=convert(%,polynom);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 264 25 "Interpolation \+ Polynomials" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 74 "Maple provides a builtin command for computing interpolation po lynomials. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "q1:=interp([1,3,4,2],[2,1,3,1],x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 193 "The firs t parameter we pass to interp() is the list of (distinct) abscissas, t he second is the list of ordinates and the third is a name, the name f or the variable to be used in the polynomial." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 110 "If you want a polynomial function rather than a polynomial expression in some variable, you ca n use unapply():" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "q2:=unapply(interp([1,3,4,2],[2,1,3,1],x),x); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 27 "Let's check that it worked:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "q2(1); q2(3); q2(4); q2(2); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 163 "If you have a list of points you want to interpolate you can extr act the abscissas and ordinates by using the op() command (it lists th e operands in its argument):" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "L:=[ [1,2], [2,-1], [3,-2], \+ [4,1], [5,7], [6,6], [7,5] ];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 108 "We start by declaring two empty list s, XX and YY, and then push the abscissas on XX and the ordinates on Y Y:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "XX:=[]: YY:=[]: for ptr in L do XX:=[op(XX),ptr[1]]; \+ YY:=[op(YY),ptr[2]]; od:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 59 "Before we use XX and YY let's check that they look alright" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "XX; YY;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "p3:=interp(XX,YY,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "plot(p3,x=1..7,title=\"p3\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 186 "A convenient way to construct an interpolation polynomial for a function is to use the ma p() command to evaluate the function at each abscissa. Let's consider \+ the sine function on [0,4]:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "XX:=[0,1/2,1,3/2,2,5/2,3,7/2 ,4];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "YY:=evalf(map(sin,X X));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 126 "Here we used evalf() to force (approximate) evaluation of the \+ sine. Otherwise we will get an (painfully) exact answer. Try it." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "ps:=interp(XX,YY,t);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 76 "plot([ps,sin(t)],t=0..6.5,title=\"Interpolation of sin(t)\",color= [red,blue]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 79 "Note the previous example shows one way of plotting two functions on one graph." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 266 20 "Interpol ating Spline" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 267 "Maple computes splines of all degrees - check the help. Here w e will look only at linear and (natural) cubic splines. A linear splin e is just a piecewise linear function. The parameters are much the sam e as for interp(), but the abscissas must be in increasing order." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "XX:=[1,2,5/2,3,13/4,15/4,5];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "YY:=[1,1,2,1,-1,-1,3];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "sp1:=spline(XX,YY,x,linear);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "sp3:=spline(XX,YY,x,cubic);" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 122 "plot([sp1,sp3],x=1..5,color=[red,blue],thic kness=2,numpoints=200,title=\"piecewise linear and cubic spline interp olation\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 230 "You can see how the cubic spline smoothens out the gra ph without introducing too much oscillation. If we compare the piecewi se linear spline and the interpolation polynomial we see unreasonable \+ oscillation unsupported by the data:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "pp:=interp(XX,YY,x);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 119 "plot([sp1,pp],x=1..5,color= [red,blue],thickness=2,numpoints=200,title=\"piecewise linear and poly nomial interpolation\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 203 "Note the vertical scales are different i n the two graphs. We can plot all three function in one graph for a mo re convincing demonstartion of how well the cubic spline follows the p iecewise interpolation." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 161 "plot([sp1,sp3,pp],x=1..5,-3..9,col or=[red,blue,black],thickness=2,numpoints=200,title=\"red=piecewise li near, blue=cubic spline, black=interpolation polynomial\");" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 164 "N ote how I restricted the vertical range so we would be able to see the details (otherwise the piecewise linear and the cubic spline just abo ut merge on the graph)." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT 267 30 "Trapezoidal and Simpson's Rule" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 229 "Maple has nume rous high-power quadrature methods built in, but if one simply wants t o experiment with the trapezoidal rule or Simpson's rule, these are av ailable in the student package, accessed through the command with(stud ent)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 179 "It is also fairly easy to roll your own, even to write high order New ton-Cotes methods, if you wish. There are some example on my web page. For now, let's use the student package." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "with(student):" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "trapezoid(f(x),x=a..b,6);" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "simpson(f(x),x=a..b,6);" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 48 " Let's try an actual function, say exp(x)*cos(x)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "trapezoid(e xp(x)*cos(x),x=0..3,12): test:=evalf(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "simpson(exp(x)*cos(x),x=0..3,12): sest:=evalf(%);" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "int(exp(x)*cos(x),x=0..3); \+ evalf(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 57 "As we expected, Simpson's rule performs much better here. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 270 15 "Closing Remarks" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 112 "We have barely scratch ed the surface. There are many other things Maple can do. Try explorin g the help facility!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "ifactor(111111111111111111);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "isprime(333667);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "isprime(333613);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "limit((exp(x)-1-x)/x^2,x=0);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "sum(k^4,k=1..n);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "sum(k^(-2),k=1..infinity);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 40 "fsolve(tan(x)=3*x,x,avoid=\{x=0\},0..1.4);" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "fsolve(tan(x)=3*x,x,1.4..5) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "solve(\{x+2*y=3,3*x-2* y=5\},\{x,y\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 11 "Experiment!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "0 2 0" 16 } {VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }