LearningGuide

evalf sol 06662394321 2475353222 1570796327

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ’x’ + 1 &gt; %; x+1 &gt; %; 6.4 Evaluation Rules • 209 1 Important: Quoting an expression delays evaluation, but does not prevent automatic simpliﬁcations and arithmetic. &gt; ’1-1’; 0 &gt; ’p+q-i-p+3*q’; 4q − i If you enclose a simple variable in right single quotes, the result is the name of the variable. You can use this method to unassign a variable. &gt; x := 1; x := 1 &gt; x; 1 &gt; x := ’x’; x := x &gt; x; x However, in general, you must use evaln. &gt; i := 4; i := 4 &gt; a[i] := 9; a4 := 9 210 • Chapter 6: Evaluation and Simpliﬁcation Note that ’a[i]’ is a[i] not a[4]. &gt; ’a[i]’; ai You must use evaln to unassign a[i]. &gt; evaln( a[i] ); a4 &gt; a[i] := evaln( a[i] ); a4 := a4 Using Quoted Variables as Function Arguments Some Maple commands use names as a way to return information in addition to the standard return value. The divide command assigns the quotient to the global name, q. &gt; divide( x^2-1, x-1, ’q’ ); true &gt; q; x+1 Use a quoted name to ensure that you are not passing a variable with an assigned value into the procedure. You can avoid the need for quotes if you ensure that the name you use has no previously assigned value. &gt; q := 2; q := 2 &gt; divide( x^2-y^2, x-y, q ); Error, wrong number (or type) of parameters in function divide 6.4 Evaluation Rules • 211 &gt; q := evaln(q); q := q &gt; divide( x^2-y^2, x-y, q ); true &gt; q; x+y Note: The rem, quo, irem, and iquo commands behave in a similar manner. Concatenation of Names Concatenation is a way to form new variable names based on others. &gt; a||b; ab The concatenation operator, “||”, in a name causes evaluation of the right-hand side of the operator, but not the left. &gt; a := x; a := x &gt; b := 2; b := 2 &gt; a||b; a2 &gt; c := 3; 212 • Chapter 6: Evaluation and Simpliﬁcation c := 3 &gt; a||b||c; a23 If a name does not evaluate to a single symbol, Maple does not evaluate a concatenation. &gt; a := x; a := x &gt; b := y+1; b := y + 1 &gt; new_name := a||b; new _name := a||(y + 1) &gt; y := 3; y := 3 &gt; new_name; a4 You can use concatenated names to assign and create expressions. &gt; i := 1; i := 1 &gt; b||i := 0; b1 := 0 You must use right single quotes. 6.5 Conclusion &gt; sum( ’a||k’ * x^k, k=0..8 ); • 213 a0 + a1 x + a2 x2 + a3 x3 + a4 x4 + a5 x5 + a6 x6 + a7 x7 + a8 x8 If you do not use right single quotes, Maple evaluates a||k to ak. &gt; sum( a||k * x^k, k=0..8 ); ak + ak x + ak x2 + ak x3 + ak x4 + ak x5 + ak x6 + ak x7 + ak x8 You can also use concatenation to form title strings for plots. 6.5 Conclusion In this chapter, you have seen how to perform many kinds of expression manipulations, from adding two equations to selecting individual parts of a general expression. In general, no rule speciﬁes which form of an expression is the simplest. The commands in this chapter allow you to convert an expression to many forms, often the ones you would consider simplest. If not, you can use side relations to specify your own simpliﬁcation rules, or assumptions to specify properties of unknowns. You have also seen that Maple, in most cases, uses full evaluation of variables. Some exceptions exist, which include la...
View Full Document

This note was uploaded on 08/27/2012 for the course MATH 1100 taught by Professor Nil during the Spring '12 term at National University of Singapore.

Ask a homework question - tutors are online