355w2003_lab03 - MLC Lab Visit - Lab 03 - Maple Mth 355...

Info iconThis 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 = AB 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
Background image of page 1

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

View Full DocumentRight 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);
Background 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!
Background image of page 3

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

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

This note was uploaded on 02/11/2012 for the course MTH 141, 142, taught by Professor Mcallister during the Spring '08 term at SUNY Empire State.

Page1 / 17

355w2003_lab03 - MLC Lab Visit - Lab 03 - Maple Mth 355...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online