{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

355w2003_lab03 - MLC Lab Visit Lab 03 Maple Mth 355(a.k.a...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
MLC Lab Visit - Lab 03 - Maple Mth 355 (a.k.a. Mth 399) Jan 22, 2003 Maple 7 Bent E. Petersen There are 4 problems below. Problem solutions are due Jan 29, 2003. Email your solutions to me as Maple worksheet attachments. Your worksheet must execute correctly for full credit. In this worksheet we investigate a few more features of Maple. Introduction If you are viewing the MWS version of this document you will note all the Maple output has been removed. You will have to execute each command (by pressing Enter when the cursor is on the command line) to see the output. You can of course also use the menu selections Edit/Execute/Worksheet to execute the entire worksheet, but you should execute the commands one at a time and take the opportunity to experiment along the way! Change some things to see how things work. The static PDF version of this document shows all of the Maple output. It is useful to look at when Maple is not available. > Equations > restart; In Maple any expression, including an equation, may be assigned to a label. Thus we can take a simple equation such as A=B and assign it to a label for ease in dealing with it. Thus > eqn1:=A=B; := eqn1 = A B Here eqn1 is the label (or name) of the equation A=B. Sometimes we wish to extract the left or right (hand) side of an equation. > lhs(eqn1); A > rhs(eqn1); B
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
There are devious, sometimes useful, ways to achieve the same thing. For example, > subs(eqn1,A); B Here we have taken the expression A and substituted A=B in it. The result is of course B. Note eqn1 is not altered in any way - it simply provides the specification for what to substitute for what. Note also the subs() approach has the advantage that, unlike rhs(), it correctly handles expressions containing several equations. Another approach is to use the assign() function. It assigns the right side of each equality in a list to the left side, that is the left side becomes a label for the right side. Thus > assign(eqn1); > B:=6; A; := B 6 6 In case we want to use A and B again let’s unassign them: > unassign(’A’,’B’); The single quotes here prevent Maple from evaluating A and B. Otherwise we would be trying to unassign 6, which would produce an error. > Functions and Differentiation > restart; A function in Maple is defined by the "arrow" notation: > f:=x->x^2+2*x-3; := f x + x 2 2 x 3 A suitable expression may be converted to a function by using unapply(). Thus > expr:=x^2+2*x-3; := expr + x 2 2 x 3 > g:=unapply(expr,x);
Image of page 2
:= g x + x 2 2 x 3 Yes there is a related apply() function too! > apply(g,x); + x 2 2 x 3 It’s usually easier just to use g(x) to apply g to x. Functions are evaluated in the usual familiar way, whereas expressions are evaluated by using the substitute command subs(). Thus > f(t); f(6); + t 2 2 t 3 45 > subs(x=6,expr); 45 One thing to be careful about is the x in the arrow notation above is local to the function we are defining, that is, it is just a dummy variable. Thus > h:=x->expr; := h x expr does not define the same function as f above, but instead defines the constant function whose value is expr, > h(t); h(6); + x 2 2 x 3 + x 2 2 x 3 It is best not to be too devious when defining functions. Errors like this can be hard to find!
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern