evalf sol 06662394321 2475353222 1570796327

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

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

Unformatted text preview: ’x’ + 1 > %; x+1 > %; 6.4 Evaluation Rules • 209 1 Important: Quoting an expression delays evaluation, but does not prevent automatic simplifications and arithmetic. > ’1-1’; 0 > ’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. > x := 1; x := 1 > x; 1 > x := ’x’; x := x > x; x However, in general, you must use evaln. > i := 4; i := 4 > a[i] := 9; a4 := 9 210 • Chapter 6: Evaluation and Simplification Note that ’a[i]’ is a[i] not a[4]. > ’a[i]’; ai You must use evaln to unassign a[i]. > evaln( a[i] ); a4 > 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. > divide( x^2-1, x-1, ’q’ ); true > 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. > q := 2; q := 2 > divide( x^2-y^2, x-y, q ); Error, wrong number (or type) of parameters in function divide 6.4 Evaluation Rules • 211 > q := evaln(q); q := q > divide( x^2-y^2, x-y, q ); true > 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. > a||b; ab The concatenation operator, “||”, in a name causes evaluation of the right-hand side of the operator, but not the left. > a := x; a := x > b := 2; b := 2 > a||b; a2 > c := 3; 212 • Chapter 6: Evaluation and Simplification c := 3 > a||b||c; a23 If a name does not evaluate to a single symbol, Maple does not evaluate a concatenation. > a := x; a := x > b := y+1; b := y + 1 > new_name := a||b; new _name := a||(y + 1) > y := 3; y := 3 > new_name; a4 You can use concatenated names to assign and create expressions. > i := 1; i := 1 > b||i := 0; b1 := 0 You must use right single quotes. 6.5 Conclusion > 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. > 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 specifies 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 simplification 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