184 chapter 6 evaluation and simplication select type

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: the is command to directly test the properties of unknowns. > is( c>0 ); true > is(x, complex); true > is(x, real); true In this next example, Maple still assumes that the variable a is negative. > eq := xi^2 = a; 178 • Chapter 6: Evaluation and Simplification eq := ξ 2 = a ~ > solve( eq, {xi} ); {ξ = √ −a ~ I }, {ξ = −I √ −a ~} To remove assumptions that you make on a name, simply unassign the name. However, the expression eq still refers to a~. > eq; ξ2 = a~ You must remove the assumption on a inside eq before you remove the assumption on a. First, remove the assumptions on a inside eq. > eq := subs( a=’a’, eq ); eq := ξ 2 = a Then, unassign a. > a := ’a’; a := a If you require an assumption to hold for only one evaluation, then you can use the assuming command, described in the following subsection. When using the assuming command, you do not need to remove the assumptions on unknowns and equations. The assuming Command To perform a single evaluation under assumptions on the name(s) in an expression, use the assuming command. Its use is equivalent to imposing assumptions by using the assume facility, evaluating the expression, then removing the assumptions from the expression and names. This facilitates experimenting with the evaluation of an expression under different assumptions. > about(a); 6.2 Assumptions • 179 a: nothing known about this object > sqrt(a^2) assuming a<0; −a > about(a); a: nothing known about this object > sqrt(a^2) assuming a>0; a You can evaluate an expression under an assumption on all names in an expression > sqrt((a*b)^2) assuming positive; a b~ or assumptions on specific names. > ln(exp(x)) + ln(exp(y)) assuming x::real, y::complex; x ~ + ln(ey ) Using the Double Colon In the previous example, the double colon (::) indicates a property assignment. In general, it is used for type checking. For more information, refer to the ?type help page. 180 • Chapter 6: Evaluation and Simplification 6.3 Structural Manipulations Structural manipulations include selecting and changing parts of an object. They use knowledge of the structure or internal representation of an object rather than working with the expression as a purely mathematical expression. In the special cases of lists and sets, selecting an element is straightforward. The concept of what constitutes the parts of a general expression is more difficult. However, many of the commands that manipulate lists and sets also apply to general expressions. > L := { Z, Q, R, C, H, O }; L := {O, R, Z, Q, C, H } > L[3]; Z Mapping a Function onto a List or Set To apply a function or command to each of the elements rather than to the object as a whole, use the map command. > f( [a, b, c] ); f([a, b, c]) > map( f, [a, b, c] ); [f(a), f(b), f(c)] > map( expand, { (x+1)*(x+2), x*(x+2) } ); {x2 + 3 x + 2, x2 + 2 x} > map( x->x^2, [a, b, c] ); [a2 , b2 , c2 ] If you give map more than two ar...
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