LearningGuide

# x0 1 215 216 chapter 7 solving calculus problems x0

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: expecting 1 argument, got %1”, nargs elif type(x, ’complex(ﬂoat )’) then evalf(’erﬁ ’(x)) elif type(x, ’∞’) then if type(x, ’cx _inﬁnity ’) then undeﬁned + undeﬁned ∗ I elif type(x, ’undeﬁned ’) then NumericTools : −ThrowUndeﬁned (x) elif type(x, ’extended _numeric ’) then x elif type( (x), ’∞’) then ∞ + ∞ ∗ I else CopySign(I, (x)) end if elif type(x, ’undeﬁned ’) then NumericTools : −ThrowUndeﬁned (x, ’preserve ’ = ’axes ’) elif type(x, ‘ ∗ ‘) and member(I, {op(x)}) then erf(−I ∗ x) ∗ I elif type(x, ’complex(numeric )’) and csgn(x) &lt; 0 then − erﬁ(−x) eliftype(x, ‘ ∗ ‘) and type(op(1, x), ’complex(numeric )’) and csgn(op(1, x)) &lt; 0then − erﬁ(−x) elif type(x, ‘ + ‘) and traperror(sign(x)) = −1 then − erﬁ(−x) else ’erﬁ ’(x) end if end proc The default value of verboseproc is 1. &gt; interface( verboseproc=1 ); The ?interface help page explains the possible settings of verboseproc and the other interface variables. One-Level Evaluation Local variables of a procedure use one-level evaluation. That is, if you assign a local variable, then the result of evaluation is the value most 206 • Chapter 6: Evaluation and Simpliﬁcation recently assigned directly to that variable. &gt; test:=proc() &gt; local x, y, z; &gt; x := y; &gt; y := z; &gt; z := 5; &gt; x; &gt; end proc: &gt; test(); y Compare this evaluation with the similar interactive example in this section on page 202. Full evaluation within a procedure is rarely necessary and can lead to ineﬃciency. If you require full evaluation within a procedure, use eval. Commands with Special Evaluation Rules The assigned and evaln Commands The functions assigned and evaln evaluate their arguments only to the level at which they become names. &gt; x := y; x := y &gt; y := z; y := z &gt; evaln(x); x The assigned command checks if a name has a value assigned to it. &gt; assigned( x ); true 6.4 Evaluation Rules • 207 The seq Command The seq command for creating expression sequences does not evaluate its arguments. Therefore, seq can use a variable with an assigned value as a counting variable. &gt; i := 2; i := 2 &gt; seq( i^2, i=1..5 ); 1, 4, 9, 16, 25 &gt; i; 2 Contrast this with the behavior of sum. &gt; sum( i^2, i=1..5 ); Error, (in sum) summation variable previously assigned, second argument evaluates to 2 = 1 .. 5 You can solve this problem by using right single quotes, as shown in the next section. Quotation and Unevaluation The Maple language supports the use of quotes to delay evaluation one level. Surrounding a name in right single quotes (’) prevents Maple from evaluating the name. Hence, right single quotes are referred to as unevaluation quotes. &gt; i := 4; i := 4 &gt; i; 4 &gt; ’i’; 208 • Chapter 6: Evaluation and Simpliﬁcation i Use this method to avoid the following problem. &gt; i; 4 &gt; sum( i^2, i=1..5 ); Error, (in sum) summation variable previously assigned, second argument evaluates to 4 = 1 .. 5 &gt; sum( ’i^2’, ’i’=1..5 ); 55 &gt; i; 4 Full evaluation of a quoted expression removes one level of quotes. &gt; x := 0; x := 0 &gt; ’’’x’+1’’; ’’x’ + 1’ &gt; %;...
View Full Document

Ask a homework question - tutors are online