LearningGuide

# 1 2 root32 1 2 213 164 chapter 6 evaluation

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: y using the collect command. > collect( x^2 + 2*x + 1 - a*x + b - c*x^2, x ); (1 − c) x2 + (2 − a) x + b + 1 The second argument to the collect command speciﬁes on which variable it should base the collection. > poly := x^2 + 2*y*x - 3*y + y^2*x^2; poly := x2 + 2 y x − 3 y + y 2 x2 > collect( poly, x ); 6.1 Mathematical Manipulations • 159 (1 + y 2 ) x2 + 2 y x − 3 y > collect( poly, y ); y 2 x2 + (2 x − 3) y + x2 You can collect on variables or unevaluated function calls. > trig_expr := sin(x)*cos(x) + sin(x) + y*sin(x); trig _expr := sin(x) cos(x) + sin(x) + y sin(x) > collect( trig_expr, sin(x) ); (cos(x) + 1 + y ) sin(x) > DE := diff(f(x),x,x)*sin(x) - diff(f(x),x)*sin(f(x)) > + sin(x)*diff(f(x),x) + sin(f(x))*diff(f(x),x,x); 2 d d d DE := ( dx2 f(x)) sin(x) − ( dx f(x)) sin(f(x)) + sin(x) ( dx f(x)) d + sin(f(x)) ( dx2 f(x)) 2 > collect( DE, diff ); (−sin(f(x)) + sin(x)) ( d d2 f(x)) + (sin(x) + sin(f(x))) ( 2 f(x)) dx dx You cannot collect on sums or products. > big_expr := z*x*y + 2*x*y + z; big _expr := z x y + 2 y x + z > collect( big_expr, x*y ); Error, (in collect) cannot collect y*x 160 • Chapter 6: Evaluation and Simpliﬁcation Instead, make a substitution before you collect. In the preceding case, substituting a dummy name for x*y, then collecting on the dummy name produces the desired result. > subs( x=xyprod/y, big_expr ); z xyprod + 2 xyprod + z > collect( %, xyprod ); (z + 2) xyprod + z > subs( xyprod=x*y, % ); (z + 2) y x + z Section 6.3 Structural Manipulations explains the use of the subs command. If you are collecting coeﬃcients of more than one variable simultaneously, two options are available, the recursive and distributed forms. The recursive form initially collects in the ﬁrst speciﬁed variable, then in the next, and so on. The default is the recursive form. > poly := x*y + z*x*y + y*x^2 - z*y*x^2 + x + z*x; poly := y x + z x y + y x2 − z y x2 + x + z x > collect( poly, [x,y] ); (1 − z ) y x2 + ((1 + z ) y + 1 + z ) x The distributed form collects the coeﬃcients of all variables at the same time. > collect( poly, [x,y], distributed ); (1 + z ) x + (1 + z ) y x + (1 − z ) y x2 The collect command does not sort the terms. Use the sort command to sort. See this section, page 171. 6.1 Mathematical Manipulations • 161 Factoring Polynomials and Rational Functions To write a polynomial as a product of terms of smallest possible degree, use the factor command. > factor( x^2-1 ); (x − 1) (x + 1) > factor( x^3+y^3 ); (x + y ) (x2 − y x + y 2 ) You can also factor rational functions. The factor command factors both the numerator and the denominator, then removes common terms. > rat_expr := (x^16 - y^16) / (x^8 - y^8); rat _expr := x16 − y 16 x8 − y 8 > factor( rat_expr ); x8 + y 8 > rat_expr := (x^16 - y^16) / (x^7 - y^7); rat _expr := x16 − y 16 x7 − y 7 > factor(rat_expr); (x + y ) (x2 + y 2 ) (x4 + y 4 ) (x8 + y 8 ) x6 + y x5 + y 2 x4 + y 3 x3 + y 4 x2 + y 5 x + y 6 Specifying the Algebraic Number Field The factor command factors a polynomial over the ring implied by the coeﬃcients. The following polynomial has intege...
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