{VERSION 4 0 "APPLE_PPC_MAC" "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 "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 "" -1 256 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 261 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 265 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 266 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 271 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 272 "" 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" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 314 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 315 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 316 "" 0 1 0 0 0 0 1 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 "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Error" -1 8 1 {CSTYLE "" -1 -1 "Courier" 1 10 255 0 255 1 2 2 2 2 2 1 1 1 3 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{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 "Author" -1 19 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 8 8 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 18 "" 0 "" {TEXT -1 34 " Variables, Functions and Equations" }}{PARA 19 "" 0 "" {TEXT -1 28 "Dr . Saccone, Revised 1/18/01" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 9 "Variables" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 153 "In a worksheet you can define your own variables. One must use caution here. Haphaza rdly defined variables can lead to unexpected results in a worksheet. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 204 "Mapl e has some built-in variables. Note that variable names are case-sensi tive. To display a value that has been assigned to a variable name ent er the name of the variable on a command line and hit enter." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 256 9 " Examples." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "Pi;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "evalf(Pi,10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "infinity;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "gamma; " }{TEXT -1 16 "Euler's constant" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "evalf(gamma,10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 132 "Some variable names have no value assign ed to them. In this case Maple manipulates expressions involving that \+ variable symbolically." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 257 9 "Example. " }{TEXT -1 87 "In order to \+ be safe, execute the following command by clicking on it and hitting E nter." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 112 "The Maple environment should now be restored to t he way it was at startup time. At the moment the variable name " } {XPPEDIT 18 0 "x;" "6#%\"xG" }{TEXT -1 139 " should have no assigned v alue. If this is the case Maple will simply echo the name of the varia ble when it is entered into a command line." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalf(x,10);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 11 "x^2+3*x+10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 22 "Expressions involving " }{XPPEDIT 18 0 "x;" "6#%\"xG" } {TEXT -1 34 " will now be treated symbolically." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "(x+3)^3;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "expand((x+3)^3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 257 "" 0 "" {TEXT -1 4 "The " } {TEXT 302 4 "eval" }{TEXT 303 1 " " }{TEXT -1 8 "command." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 78 "We can evaluate ex pression for given values of the variable using the command " }{TEXT 301 6 "eval. " }{TEXT -1 47 "This will not assign any value to the var iable." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }{TEXT 304 8 "Example." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 " eval(x^2+3*x+10,x=1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 39 "We haved evaluated the expression with " }{XPPEDIT 18 0 " x = 1;" "6#/%\"xG\"\"\"" }{TEXT -1 22 " without changing the " }{TEXT 316 5 "value" }{TEXT -1 4 " of " }{XPPEDIT 18 0 "x;" "6#%\"xG" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 143 "We can now assign a value to this v ariable. When we do this the value we assign will be substituted for t hat variable whenever it is used. The " }{TEXT 258 20 "assignment oper ator " }{TEXT -1 86 "is the symbol \":=\". Be careful not to use \"=\" , this symbol is reserved other purposes." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "x:=5;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "x^2+3*x+10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "(x+3)^3;" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 16 "expand((x+3)^3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 214 "Thus, this object is no longer treated symbolically. One must be careful in assigning values to variables. If you lose track o f what variables have been assigned you may incur unexpected results i n your worksheets." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 259 8 "Example." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "plot(x^2,x=-1..1);" }}{PARA 8 "" 1 "" {TEXT -1 35 "Er ror, (in plot) invalid arguments\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 267 "The plot command does not respond well to our request. T he problem is that Maple now reads the second argument as \"5=-1..1\". The first argument is read as \"25\", but that's ok as can be seen fr om the next command (assuming you haven't assigned a value to the vari able " }{XPPEDIT 18 0 "t;" "6#%\"tG" }{TEXT -1 10 " somehow)." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "plot(25,t=-1..1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" } }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 111 "So, as signments can wreak havoc if they are not done carefully. The value of 5 is now assigned to the variable " }{XPPEDIT 18 0 "x;" "6#%\"xG" } {TEXT -1 171 ". This will be the case in any new worksheet you open. I t will also be the case if you try to go back to the beginning of this worksheet and re-execute the commands above." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 3 "To " }{TEXT 260 9 "unassig n " }{TEXT -1 54 "a variable you can restart Maple, you can execute th e " }{TEXT 261 8 "restart " }{TEXT -1 37 "command, or you can do the f ollowing." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "x := 'x';" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 53 "The first statement makes of use of something called " }{TEXT 262 16 "forward quotes, " }{TEXT -1 43 "a topic we need not go into at this moment." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 263 18 "Naming Co nventions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 105 "Variable names cannot begin with a number. They may only contain \+ alphanumeric characters and underscores." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 272 29 "Example of legal d efinitions." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "myName := 5; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "thisIs4You := 2/3 + Pi; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "the_Last_Name := sqrt(1 21);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 257 "" 0 "" {TEXT -1 0 "" }}{PARA 257 "" 0 "" {TEXT -1 31 "Example of illegal d efinitions." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "2theLastDrop \+ := 23;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "this&that := 0;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "Pi := -1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 13 "Functions or " }{TEXT 271 10 "Procedures" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 125 "Suppose we have some kin d of computation that we wish to repeatedly. For example, suppose we w ant to evaluate the expression " }{XPPEDIT 18 0 "x^2+2*x+2;" "6#,(*$% \"xG\"\"#\"\"\"*&F&F'F%F'F'F&F'" }{TEXT -1 23 " for various values of \+ " }{XPPEDIT 18 0 "x;" "6#%\"xG" }{TEXT -1 111 " throughout the workshe et. One method of doing so would be to assign a function, or, as Maple would call it, a " }{TEXT 264 10 "procedure " }{TEXT -1 61 "to a vari able name. Maple's syntax for defining a function is" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 256 "" 0 "" {TEXT -1 0 "" }{TEXT 265 24 "var - > expression in var" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 6 "where " }{TEXT 266 4 "var " }{TEXT -1 17 "is some variab le." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" } {TEXT 267 8 "Example." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "f : = x -> x^2+2*x+2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 268 7 "Caution" }{TEXT 305 106 ": the left hand side is simply \"f\", it is not \"f(x) \" the way we normally define functions in math classes." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 304 "If you click on t he blue output above you will see Maple's internal representation of t his function assignment, namely \"f := proc (x) options operator, arr ow; x^2+2*x+2 end proc\" where \"proc\" stands for \"procedure\". Fort unately we do not have to worry about this internal language, at least not for now." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 53 "We can now evaluate this function at various numbers." }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(1);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 6 "f(Pi);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evalf(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 306 90 "Note tha t in the above calculation we used the \"%\" symbol. This represents t he last output" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 20 "We can also graph f." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "plot(f(x), x=-1..1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 102 "Note that we do not have to use the same independen t variable in the plot as we did when we defined f." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "plot(f(t), t=-1..1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 269 14 "Mo re examples." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "f := x -> a* x^2+b*x+c; " }{TEXT -1 54 "A function definition with undefined parame ters a,b,c." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(2);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(x);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 11 "f(sin(x)); " }{TEXT -1 24 "Composition of func tions" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "f(f(x)); " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "g := (s,t) -> s^2 + t^2; " } {TEXT -1 27 "A function of two variables" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "g(x,y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "g(1,3);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 22 "h(x) := sin(x)*cos(x);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 5 "h(0);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 270 33 "Wha t happened in the last example" }{TEXT 307 53 "? This is related to th e caution given above. You do " }{TEXT -1 0 "" }{TEXT 308 0 "" }{TEXT 309 4 "not " }{TEXT 310 0 "" }{TEXT -1 0 "" }{TEXT 311 92 "define func tions using the notation \"(x)\" on the left hand side of the assignm ent operator." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 312 8 "Example." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "f(x):=x^2+3 *x+10;" }}}{PARA 0 "" 0 "" {TEXT -1 105 "All this does is define an ex pression whose name is \"f(x)\". The variable does not behave like a f unction." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "f;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(x); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(0);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 102 "The exp ression f(0) is unassigned. If we want to evaluate the expression f(x) when x=0 we can use the " }{TEXT 313 5 "eval " }{TEXT -1 8 "command. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "eval(f(x),x=0);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 23 "It i s probably best to " }{TEXT 314 6 "never " }{TEXT -1 30 "make assignme nts for the form " }{XPPEDIT 18 0 "f(x) := expr;" "6#>-%\"fG6#%\"xG%%e xprG" }{TEXT -1 35 ". The results can be unpredictable." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "f := x \+ -> x^3+20;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "f(x) := x^2+3 *x+10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(0);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" } }}{PARA 0 "" 0 "" {TEXT -1 172 "When we entered f(x) Maple did not eva luate the function at the unassigned variable x because there is a var iable name \"f(x)\", and that takes precedence. However, there is " } {TEXT 315 4 "not " }{TEXT -1 84 "a variable named f(y) so Maple evalua te the function f at the unassigned variable y." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 134 "If you option-click on the output of a function assignment you do not get a menu with many options. Compare the following two output s." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "x^2+3*x+10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "f := x -> x^2+3*x+10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 190 " If you option-click on the output from the first command you get lots \+ of options, such as graphing. However, the same procedure applied to s econd output yields very little, possibly nothing." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 9 "Equations" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 36 "The equal s sign \"=\" is reserved for " }{TEXT 273 11 "equations. " }{TEXT -1 76 "Equations differ from assignments in that no information is actual ly stored." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 274 8 "Example." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "x:=1; y:=2; " }{TEXT -1 53 "Note that we can do more than one op eration per line." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "x=y;" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "x; y;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 177 "The input \"x=y\" did not modify x or y. So what \+ did it do? Well, nothing. So what can we do with equations? We can ask if they are true and, in some instances, we can solve them." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "ev alb(x=y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 30 "The \"b\" in the M aple function " }{TEXT 275 6 "evalb " }{TEXT -1 104 "stands for Boolea n which refers to an object of a true/false natures. The function retu rns the value of " }{TEXT 276 5 "true " }{TEXT -1 28 "when the equatio n holds and " }{TEXT 277 6 "false " }{TEXT -1 17 "when it does not." } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "S uppose we unassign the variables " }{XPPEDIT 18 0 "x;" "6#%\"xG" } {TEXT -1 5 " and " }{XPPEDIT 18 0 "y;" "6#%\"yG" }{TEXT -1 17 " and st art over: " }{MPLTEXT 1 0 15 "x:='x'; y:='y';" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalb(x=y); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 59 "Still not true since thes e variables are undefined. Now try" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "x:=2; y:=2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalb(x=y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 278 18 "Solving Equations." } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 18 "The Mapl e command " }{TEXT 279 6 "solve " }{TEXT -1 48 "will solve an equation for a specified variable." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 280 8 "Example." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "First, let's reinitializ e the environment: " }{MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 17 "solve(x^2-4=0,x);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 49 "Maple returns the solutions as a list of numbers." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "solve(x^3-6*x^2+11*x-6=0,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "solve(x^3+1=2-x,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "solve(a*x+4=5,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 44 "Maple can work with complex numbers as well." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "solve (x^2+1=0,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "so lve(a*x^2+b*x+c=0,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" } }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 14 "Look fa miliar?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 300 115 "Try solving some of your own equations and see what happens. You way want to open a blank worksheet and work there." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 53 "If you om it \"=0\" Maple assumes this is what you want." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "solve(t^2+3*t+1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 33 "When the root of a polynomial is " }{TEXT 281 9 "repeated " }{TEXT -1 54 "Maple lists this root as many times as it is repeated ." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" } {TEXT 282 8 "Example." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "sol ve(x^2+2*x+1,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "solve(( x-2)^3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 75 "It is possible to wo rk with more than one equation. In this case we pass a " }{TEXT 283 4 "set " }{TEXT -1 112 "of equations to the solve command. A set is a li st of expressions with braces \"\{\}\" that are separated by commas." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "solve(\{x+y=0,y=1\},\{x,y\});" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 22 "There answer gives us " }{TEXT 284 4 "one " }{TEXT -1 38 "solution. What we have passed on is a " }{TEXT 285 7 "system " } {TEXT -1 16 "of equations. A " }{TEXT 286 9 "solution " }{TEXT -1 92 " to a system of equations is a list of values for the variables that so lve all the equations " }{TEXT 287 15 "simultaneously." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "solve( \{x^2+3*y=1,y=x+1\},\{x,y\});" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 70 "In this case we have found two solutions; the output is two pairs, or " }{TEXT 288 5 "sets," }{TEXT -1 12 " of numbers." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "solve(\{a*x+ b*y=A,c*x+d*y=B\},\{x,y\});" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 45 "T his solution of a linear system is known as " }{TEXT 289 14 "Cramer's \+ Rule." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }{TEXT 290 20 "Numerical solutions." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 13 "The function " }{TEXT 291 6 "solve " }{TEXT -1 56 "does not find a satisfactory symbolic answer every time. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "solve(cos(x)=x,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 58 "T his answer is mathematically sophisticated way of saying " }{TEXT 292 14 "I don't know. " }{TEXT -1 38 "However, you can ask Maple to find a n " }{TEXT 293 12 "approximate " }{TEXT -1 65 "solution, rather than a n exact. This is usually referred to as a " }{TEXT 294 10 "numerical \+ " }{TEXT -1 161 "solution. Maple has built-in procedures for find appr oximate solutions. You may have seen cruder, but similar, methods in y our calculus course. For example, the " }{TEXT 295 13 "tangent line " }{TEXT -1 17 "approximation or " }{TEXT 296 15 "Newton-Raphson " } {TEXT -1 7 "method." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 54 "The Maple function for finding numerical solutions is \+ " }{TEXT 297 8 "fsolve. " }{TEXT -1 61 "This function returns a floati ng point answer, hence the \"f\"." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "fsolve(cos(x)=x,x);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "cos(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 72 "Note that the last command verified that this is a pretty good solution." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 95 "The nice thing about fsolve is that you can specify \+ a place to look. For example, the equation " }{XPPEDIT 18 0 "sin(x) = \+ 0;" "6#/-%$sinG6#%\"xG\"\"!" }{TEXT -1 86 " has infintely many solutio ns. We can ask fsolve to find solutions in a certain range." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "fs olve(sin(x)=0,x,10..13);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 98 "The \+ function fsolve may find no solution (this will happen, for example, w hen no solution exists)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "fsolve(sin(x)=0,x,10..12);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 185 "Suppose we wish to increase th e accuracy. We can attempt to do this by increasing the number of sign ificant digits Maple uses in its computations. This number is stored i n the variable " }{TEXT 298 7 "Digits." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "Digits;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 133 "This is the number of digits Maple is cu rrently using. You should be able to verify this by looking at output \+ above. Digits is not a " }{TEXT 299 10 "protected " }{TEXT -1 30 "vari able, it can be redefined." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "Digits := 20;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "fsolve(cos(x)=x,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "cos(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 167 "Oops, it's just a little off. When you increase the number of sig nificant digits there will still be error, such as rounding error. How ever, you do get more accuracy. " }}}}{MARK "1 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }