{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 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 "" 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 260 "" 0 1 255 0 0 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 271 "" 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 272 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 273 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 274 "" 0 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 275 "" 0 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 276 "" 0 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 277 "" 0 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 278 "" 1 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 279 "" 1 14 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 280 "" 1 14 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 281 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 282 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 283 "" 1 14 0 0 0 0 0 1 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 "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 14 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 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 256 "" 0 "" {TEXT 257 30 "MLC Lab Visit - Lab 02 \+ - Maple" }}{PARA 0 "" 0 "" {TEXT 256 46 "Mth 355 (a.k.a. Mth 399) Jan \+ 15, 2003 Maple 7" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 29 "Revis ed slightly Feb 11, 2003" }}{PARA 0 "" 0 "" {TEXT 258 16 "Bent E. Pete rsen" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 257 "" 0 "" {TEXT 260 181 "There are 3 problems below. Problem solutions are du e Jan 22, 2003. Email your solutions to me as Maple worksheet attachme nts. Your worksheet must execute correctly for full credit." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 62 "In this workshe et we investigate a few more features of Maple." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 259 276 "If you are viewing the \+ MWS version of this document you will note all the Maple output has be en removed. You will have to execute each command (by pressing Enter w hen the cursor is on the command line) to see the output. Take the opp ortunity to experiment! Change some things." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 123 "The static PDF version of this document shows all of the Maple output. It is useful to look at when \+ Maple is not available." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 6 "Digits" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 271 0 "" }} {PARA 0 "" 0 "" {TEXT -1 238 "You set the Maple's floating point preci sion by assigning a value to Digits (the default is 10). Maple usually does exact calculations, but when floating point numbers are involved then Digits sets the precision. Here's an amusing example" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "Dig its:=4: convert(evalf(Pi),rational);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 172 "The conversion to a rational n umber makes use of Digits, rather than any precision specified in the \+ evalf() command. You can 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),ration al);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 103 "The label \"rational\" is protected in Maple 6. You can not as sign a value to it (which is just as well)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 37 "Let's set Digits back to its de fault." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "Digits:=10:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 25 "Functions and Expressi ons" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 91 "Maple distinguishes between functions and expressions. Here's o ne 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 val ue. It needs to be an unassigned variable. In the definition of f th e x is a dummy variable, a place marker. In g however, it is part \+ of the expression, and one can refer to it." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 159 "To evaluate a function we use \+ the usual function convention. To 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 "Note the subs() command above does not assign a va lue 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 make sure you don't have any surprises in more co mplicated situations. The commands eval() and subs() work in quite dif ferent ways. In the simple case that we illustrated here eval() is act ually the preferred command 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 60 "Note the \+ eval() command above does not assign a value to x. " }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}}{EXCHG {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 226 "You can think of unapply() as turning the indicated variable(s) into dummy variables or place markers. Thus f(x) is the the function f evaluated at x and unapply(f(x),x) ought to return the function f. Let's check that:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "ff:=unapply(f(x),x); (ff-f )(w);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 12 "Sure enough!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 150 "If you have an inquisitive nature you probably wo nder if Maple has an apply() command. It does but the functional notat ion is usually more convenient." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "is(f(t) = apply(f,t));" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT 272 11 "Derivatives" }{TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 273 0 "" }{TEXT -1 150 "Some Maple commands work on expressions, some work on function s, and some on both. For example, here are the derivatives of f and \+ g (defined above)." }}{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 119 "P artial derivatives of expressions are also easily computed (here once \+ relative to y and three times relative to x):" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "diff(x/(x^2 +y^2),x$3,y);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 415 "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 prevent Maple from attempting a calculation that will fail at present, but can be carrie d out later in special cases or different contexts. Unevaluated expres sions may 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 followi ng:" }}{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 125 "In Maple we can label just about any expression. Thus we can achieve the effec t above in a manner that may seem more natural:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "expr01:=x/( x^2+y^2),x$3,y: Diff(expr01)=diff(expr01);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 74 "Note equals sign is just \+ part of the expression. It is not an assignment. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 11 "Integration" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 118 "Let's bring back some fo nd memories from calculus - the problem of integration. Here's an exam ple to get you started: " }}{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 76 "Again you can u se postponed evaluation to obtain a nicely typeset expression" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "Int(1/(1+x^4),x): %=value(%);" }{XPPMATH 20 "6#/-%$IntG6$*&\"\" \"F(,&F(F(*$)%\"xG\"\"%F(F(!\"\"F,,(*&-%%sqrtG6#\"\"#F(-%#lnG6#*&,(*$) F,F4F(F(*&F,F(F1F(F(F(F(F(,(F:F(F " 0 "" {MPLTEXT 1 0 23 "h:=t->t^3; int(h(u),u);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 72 "I bet you wish you had a tool like this when you were studying calculus!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 76 "Naturally definite integr als are possible too, even some improper integrals." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "exp(-t^2) ,t=0..infinity: Int(%)=int(%);" }}}{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 differ ence 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*lo g(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 c ase we assign the symbolic expression for the integral to a and then evaluate that expression. In the second example, Maple detects that w e want a numeric result and evaluates the integral numerically without first trying to obtain a symbolic solution. This is important. For ex ample" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "stime:=time():" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "int(arct an(x)/log(x),x=Pi/8..Pi/4); evalf(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "etime:=time()-stime: 'time'=etime;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "stime:=tim e():" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "evalf(Int(arctan(x) /log(x),x=Pi/8..Pi/4));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 " etime:=time()-stime: 'time'=etime;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 0 "" 0 "" {TEXT -1 500 "Here, in the first case, Maple decided \+ after a while (possibly a long while) that it can not return a symboli c value for the integral and so returned it unevaluated. Then evalf() \+ called a numeric quadrature rule to get an answer. In the second case \+ however, Maple wasted no time trying to find a nonexistent symbolic so lution, but instead used a numeric quadrature method. This is an impor tant use of inert functions. You can grow noticably older waiting for \+ a symbolic solution to a complex problem." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 135 "There are refinements. For exampl e, you can specify what quadrature method to use. Enter the command ?i nt[numeric] for more informatio" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 8 "Plotting" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 124 "Function s 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:=sin(1/x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "plot(f ,0..1,numpoints=200,title=\"Plotting a function\");" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "plot(g,x=0..1,numpoints=200,title=\"Plott ing an expression\"):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 130 "Replace the colon above by semicolons an d press Enter to generate the plot. Of course, it will look the same a s the previous plot." }}{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 77 "Re place the colon above by a semicolon and press Enter to generate the p lot. " }}{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+s in(x),0..4*Pi);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "plot(x+s in(x),x=0..4*Pi):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 75 "Replace the colon above by semicolons and press En ter to generate the plot." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 83 "Maple has many plot types. Explore Maple help to s ee if you can find what you want." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 25 "Here is a well-know plot." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "plot3d (sin(sqrt(x^2+y^2))/sqrt(x^2+y^2),x=-7..7,y=-7..7);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 206 "Note you can u se the mouse to grab the plot and rotate it to view the surface from d ifferent angles. You can also specify the initial default orientation \+ as part of the plot3d command. Check ?plot3d[option]" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 202 "We can also do paramet ric plots. We will use parameters t and p, so lets make sure first they have not been assigned to some other expressions (otherwise we w ill get incomprehensibe error messages)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "t:=evaln(t): p:=eval n(p):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "plot3d([4*cos(t)*s in(p),4*sin(t)*sin(p),4*cos(p)],t=-Pi..Pi/2,p=0..Pi/2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 101 "Note aga in you can drag the plot around with the mouse to see the surface from different view points." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 69 "Contour p lots are often useful for studying functions of 2 variables:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "c ontourplot(x^2-18*x*y+4*y^2,x=-10..10,y=-15..15,thickness=2,color=blue );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 47 "You can even specify the contours (very handy):" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 104 "conto urplot(x^2-18*x*y+4*y^2,x=-10..10,y=-15..15,thickness=2,color=blue,con tours=[-230,-160,0,160,230]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 87 "Many other plot commands are made ava ilable by loading the plots package - with(plots)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots) :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "tubeplot([t,t^2,t*sin( t)],t=-1..22,radius=6*(2+cos(t/4)));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "tubeplot([4*cos(t),4*sin(t),4*t],t=0..12,radius=3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "tubeplot([t,t^2,t^3],t=0. .1,radius=1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "spacecurve ([t,t^2,t^3],t=0..1,thickness=3,color=blue,axes=boxed);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 77 "Try rotat ing this plot with the mouse to see if you can make sense out of it." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT 274 43 "Stirling Numbers of the second kind, S(r,n)" } {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "with(combinat):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 275 0 "" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 151 "S(r,n), denoted by stirling2(r,n) in Maple, is the number of partitions of a set of cardinality r into n (nonemp ty) subsets. Clearly we must have " }{XPPEDIT 18 0 "n <= r;" "6#1%\"n G%\"rG" }{TEXT -1 231 ". You can think of it as the number of ways to place r distinguishable objects into n indistinguishable buckets \+ with no bucket empty. By convention there is one partition of the empt y set (the empty partition) with no subsets." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 126 "S(0,0) = stirlin g2(0,0); S(4,0) = stirling2(4,0); S(4,2) = stirling2(4,2); S(7,3) = st irling2(7,3); S(21,4) = stirling2(21,6);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 91 "The last two entries abov e show that a direct by-hand count may be difficult or infeasible." }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT 276 12 "Bell Numbers" }{TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "with(combinat):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 277 0 "" }{TEXT -1 269 "The Maple function call bell(n) returns the n- th Bell number. The n-th Bell number is the number of ways that a set \+ with n elements can be partitioned into a union of disjoint (nonempt y) subsets. For example, the set \{1,2,3,4\} and be partioned in the f ollowing ways: " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 17 "\{\{1\},\{2\},\{3\},\{4\}\}" }}{PARA 0 "" 0 "" {TEXT -1 15 "\{\{1,2\},\{3\},\{4\}\}" }}{PARA 0 "" 0 "" {TEXT -1 15 "\{\{2,3\}, \{1\},\{4\}\}" }}{PARA 0 "" 0 "" {TEXT -1 14 "\{\{3,4\},\{1\}\{2\}\}" }}{PARA 0 "" 0 "" {TEXT -1 15 "\{\{1,4\}.\{2\},\{3\}\}" }}{PARA 0 "" 0 "" {TEXT -1 15 "\{\{1,3\},\{2\},\{4\}\}" }}{PARA 0 "" 0 "" {TEXT -1 13 "\{\{1,2\},\{3,4\}\}" }}{PARA 0 "" 0 "" {TEXT -1 13 "\{\{2,3\},\{4, 1\}\}" }}{PARA 0 "" 0 "" {TEXT -1 13 "\{\{3,4\},\{1,2\}\}" }}{PARA 0 " " 0 "" {TEXT -1 13 "\{\{1,4\},\{2,3\}\}" }}{PARA 0 "" 0 "" {TEXT -1 13 "\{\{1,2,3\},\{4\}\}" }}{PARA 0 "" 0 "" {TEXT -1 13 "\{\{2,3,4\},\{ 1\}\}" }}{PARA 0 "" 0 "" {TEXT -1 13 "\{\{3,4,1\},\{2\}\}" }}{PARA 0 " " 0 "" {TEXT -1 13 "\{\{4,2,1\},\{3\}\}" }}{PARA 0 "" 0 "" {TEXT -1 11 "\{\{1,2,3,4\}\}" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 42 "so in 15 ways. Let's see what Maple says" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "bell( 4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 45 "The Bell numbers grow fairly quickly with n," }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "'bell(8)' = bell(8); 'bell(10)' = bell(10); 'bell(20)' = bell(20);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 120 "Clearly \+ a direct enumeration like the one we did above rapidly becomes impract ical. From the definition it is clear that" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "'bell(r)' = Sum(' S(r,n)',n=0..r);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 56 "Let's check this relation for the case enumerated \+ above:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "sum(stirling2(4,n),n=0..4);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 411 "There are a number of \+ interpretations of Bell numbers. For example, consider the problem of \+ putting r distinguishable objects into r indistinguishable buckets (in no particular order, since otherwise we could distinguish them), \+ with some buckets possibly left empty. Each arrangement (if we ignore the empty buckets) may be considered a partition of the set of object s. Thus the number of ways is bell(n)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 " " 0 "" {TEXT 278 56 "Number of factorizations of a square-free natural number" }{TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 363 "A natural number is square-free if it ha s no square factors. Such a number is a product of distinct primes. In this case we can find all factorization by partitioning the set of pr ime factors and multiplying out the ones corresponding to subsets in t he partition. Thus the number of factorizations is bell(r) where r \+ is the number of (distinct) prime factors." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 105 "For example, 210 is the produc t of the primes 2, 3, 5 and 7 and so has bell(4) = 15 factorizati ons. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 30 "Constructio n of all partitions" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 232 "Sometimes we want an explicit list of all partit ions of a set so we can perform some operation for each partition by s tepping through the list. Here is a procedure which returns the list o f all partitions of the set \{1,2,3,....,n\}. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "parts:=proc (n)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 " local P,A,B,C; option rem ember;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "if n=1 then " }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 11 " P:=[\{1\}];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "elif n=2 then" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 28 " P:=[ \{ \{1\},\{2\}\}, \{\{1,2\}\} ];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "el if n>2 then" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 " P:=[];" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 24 " for A in parts(n-1) do" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 34 " P:= [ op(P), A union \{\{n\}\} ];" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 17 " for B in A do" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 48 " C:= ( A minus \{B\} ) union \{ B union \{n\} \} ;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 " P:= [op(P), C ];" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 " od; " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 5 " od;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "elif n=0 t hen" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 " P:= [];" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 4 "else" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 " P:=FAIL ;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "return P;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "end:" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 26 " Let's check that it works:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "parts(3);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 91 "Be careful, parts(n) grows rapi dly with n. If you want to experiment save your work first." }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 14 "r-permutations" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 156 "The procedure permute(m,r) returns a list of all r-permutations of \{1,2,..,m\}. The procedure numbperm (m,r) returns the number of r-permutations. Thus" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "permute(5,3 ); numbperm(5,3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 155 "Like most Maple functions permute() is polymorp hic. If we pass a list L, say permute(L,r), we get all the r-permut aions of the elements of the list L" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "permute([a,b,c,d],3); num bperm([a,b,c,d],3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 82 "Note permute() and numbperm() even work correc tly on lists with repeated elements" }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "permute([a,b,c,c],3); numb perm([a,b,c,c],3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 37 "Multinomial and Binomial Coeffici ents" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 78 "The Maple functions multinomial() and binomial =() return w hat you expect:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 14 "binomial(9,4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "multinomial(8,3,3,2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "expand((x+y+z)^6);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 15 "The calculation" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "multin omial(6,2,1,3); multinomial(6,2,2,2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 143 "illustrates two terms of the multinomial expansion (x1+x2+...+xn)^m = sum(multinomial(m,k1... kn)* x1^k1* x2^k2* ....*xn^kn, k1+k2+...+kn = m)." }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 14 "r- combinations" }}{EXCHG {PARA 258 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 428 "We can select r objects, without regard to order, f rom a set of n objects (distinguishable since elements of a set) in C(n,r) = P(n,r)/r! = n!/(r!(n-r)!) ways, because P(n,r) is the nu mber of ways to choose the r objects in order, and if we disregard t he order, we clearly have to divide by r!. C(n,r) is called binomia l(n,r) in Maple. It is the number of combinations of n distinct obj ects taken r at a time." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "binomial(12,4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 77 "Note Maple can ev en simplify some expressions involving binomial coefficients" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "s um(binomial(n,k)^2,k=0..n); convert(%,factorial);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 71 "Here Maple resists simplifying the factorials, but the answer is clear." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 8 "Problems" }}{EXCHG {PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 279 9 "Problem 1" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 252 "A partiti on of a set X is a (special) subset of P(X). Hence if |X| = n the number of partitions of X is bounded by 2^(2^n), and is probably mu ch smaller. Conjecture log(bell(floor(x))) <= C 2^x, x>=1, and use \+ Maple to estimate the constant C." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 61 "(Yes. 10^9 is a valid answer, but I want \+ a smaller estimate.)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 280 9 "Problem 2" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 49 "Find the number o f factorizations of 23205. Note" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "ifactor(23205);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 132 "Can you coerce Maple i nto listing all of the factorizations, for example, by stepping over t he list of partitions of a suitable set?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 283 9 "Problem 3" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 168 "A small college has 3 dormitories, imaginatively called dorm A, d orm B and dorm C. Each dormitory has a large number of vacancies when \+ 60 new students arrive on campus." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT 281 9 "Part (A)." }{TEXT -1 192 " How many ways \+ can we distribute the 60 students among the 3 distinguishable dorms if we assume the students are indistinguishable, that is, we just care h ow many students end up in each dorm?" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 282 9 "Part (B)." }{TEXT -1 252 " How many ways can we distribute the 60 students among the 3 dist inguishable dorms if we assume the students are indistinguishable, tha t is, we just care how many students end up in each dorm, and if we re quire that each dorm gets at least one student?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}} {MARK "13" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }