# # 3.1 Polynomials and rational functions # 3.1.1 Factoring a polynomial # # # # MAPLE SESSION 1 # > p := x^2+5*x+6; > factor(p); > b := 1 - q^7 - q^8 - q^9 + q^15 > + q^16 > + q^17 - q^24; > factor(b); # # 3.1.2 Expanding an expression # # # # MAPLE SESSION 2 # > p := (x+2)*(x+3); > expand(%); > (1-q^8)*(1-q^7)*(1-q^6); > expand(%); > y := sqrt(x+2)*sqrt(x+3); > expand(y); > combine(y); > combine(y,radical); > combine(y,radical,symbolic); # # 3.1.3 Collecting like terms # # # # MAPLE SESSION 3 # > y; # # # MAPLE SESSION 4 # > restart: > y; # # # MAPLE SESSION 5 # > (x+y+1)*(x-y+1)*(x-y-1); > p := expand(%); > collect(p,x); # # 3.1.4 Simplifying an expression # # # # MAPLE SESSION 6 # > 3*4^(1/2)+5; > simplify(%); > x^2; > %^(1/2); > simplify(%); # # # MAPLE SESSION 7 # > y:=((x-2)^2)^(1/2); > assume(x>2); > simplify(y); # # # MAPLE SESSION 8 # > about(x); # # # MAPLE SESSION 9 # > x :='x'; # # # MAPLE SESSION 10 # > y; > simplify(y) assuming x>2; # # 3.1.5 Simplifying radicals # # # # MAPLE SESSION 11 # > y := x^3 + 3*x^2 + 3*x + 1; > simplify(y^(1/3)); > radsimp(y^(1/3)); > assume(x>-1); > simplify(y^(1/3)); > assume(x<-1); > simplify(y^(1/3)); > x := 'x': # # # MAPLE SESSION 12 # > 1/(1+sqrt(2)); > rationalize(%); > (1-2^(2/3))/(1+2^(1/3)); > rationalize(%); > y:= z/(1 + sqrt(x)); > rationalize(y); # # 3.1.6 Working in the real domain # # # # MAPLE SESSION 13 # > restart: > y := (1+x)^3: > simplify(y^(1/3)) assuming x<-1; # # # MAPLE SESSION 14 # > with(RealDomain): # # # MAPLE SESSION 15 # > y := (1+x)^3: > simplify(y^(1/3)) assuming x<-1; > simplify(y^(1/3)); # # # MAPLE SESSION 16 # > with(RealDomain): > x^2; > %^(1/2); > simplify(%); > y:=x^3+3*x^2+3*x+1; > simplify(y^(1/3)); # # # MAPLE SESSION 17 # > restart: > sqrt(-1); > with(RealDomain): > sqrt(-1); # # 3.1.7 Simplifying rational functions # # # # MAPLE SESSION 18 # > y:='y': z:='z': > a:= (x-y-z)*(x+y+z); > b :=(x^2-2*x*y-2*x*z+y^2+2*y*z+z^2)*(x^2-x*y+x*z-y*z); > c:=a/b; > normal(c); > simplify(c); > factor(c); # # # MAPLE SESSION 19 # > numer(c); > denom(c); > factor(%); # # # MAPLE SESSION 20 # > a:= 2*x^3+x^2+12; > b := x^2 - 4; > q := quo(a,b,x); > r := rem(a,b,x); > expand( a - (b*q + r) ); # # 3.1.8 Degree and coefficients of a polynomial # # # # MAPLE SESSION 21 # > p:= y*(x+y+1)*(x-y+1)*(x-y-1): > q := expand(%); > coeff(q,x,2); > coeff(p,x,2); > expand(%); > degree(q,x); # # # MAPLE SESSION 22 # > q := q - 2*x/y; > ldegree(q,x); > ldegree(q,y); > c1:=1; > c2:=0; > degree(c1,x); > degree(c2,x); # # 3.1.9 Substituting into an expression # # # # MAPLE SESSION 23 # > p := (x+y+z)*(x-y+z)*(x-y-z); > subs(x=1,p); # # 3.1.10 Restoring variable status # # # # MAPLE SESSION 24 # > p; > x:=1: y:=2: > p; # # # MAPLE SESSION 25 # > x := 'x': y := 'y': > p; # # 3.2 Equations # 3.2.1 Left- and right-hand sides # # # # MAPLE SESSION 26 # > eqn := x^2 - x = 1; > R := solve(eqn,x); > simplify(R[1]*R[2]); > expand(%); # # # MAPLE SESSION 27 # > eqn; > lhs(eqn); > subs(x=R[1],lhs(eqn)); > expand(%); # # 3.2.2 Finding exact solutions # # # # MAPLE SESSION 28 # > restart: > eqn1 := x^3+a*x=14; > eqn2 := a^2-x=7; > solve({eqn1,eqn2},{x,a}); # # 3.2.3 Finding approximate solutions # # # # MAPLE SESSION 29 # > polyeqn := Z^5+3*Z^4-12*Z^3-35*Z^2+42*Z+119=0: > a1 := fsolve(polyeqn,Z); > x1:= a1^2 -7; > subs({x=x1,a=a1},{eqn1,eqn2}); # # 3.2.4 Assigning solutions # # # # MAPLE SESSION 30 # > solve({x^3+a*x=14,a^2-x=7},{a,x}): > %[1]; > assign(%); > a; x; # # # MAPLE SESSION 31 # > unassign('a','x'); > a,x; # # 3.3 Fun with integers # 3.3.1 Complete integer factorization # # # # MAPLE SESSION 32 # > 2^(2^5)+1; > ifactor(%); > ifactor(5003266235067621177579); # # 3.3.2 Quotient and remainder # # # # MAPLE SESSION 33 # > a := 23; b := 5; > q := iquo(a,b); r := irem(a,b); > b*q+r; # # # MAPLE SESSION 34 # > x := 22/7; > floor(x); > frac(x); > floor(-x); > frac(-x); # # 3.3.3 Gcd and lcm # # # # MAPLE SESSION 35 # > gcd(28743,552805); > ifactor(28743); ifactor(552805); > lcm(21,35,99); # # 3.3.4 Primes # # # # MAPLE SESSION 36 # > ithprime(100); > isprime(2^101-1); > 7*3^10 + 10; > isprime(%); # # # MAPLE SESSION 37 # > matrix(20,10,[seq(ithprime(k),k=1..200)]); # # # MAPLE SESSION 38 # > nextprime(1000); > prevprime(1000); # # 3.3.5 Integer solutions # # # # MAPLE SESSION 39 # > x:='x': a:='a': > eqn1:= x^3+a*x=14: eqn2 := a^2-x=7: > isolve({eqn1,eqn2},{x,a}); # # 3.3.6 Reduction mod $p$ # # # # MAPLE SESSION 40 # > modp(117,13); > modp(129,13); > ifactor(129-12); > 117 mod 13; > 129 mod 13; > 1/17 mod 257; > modp(121*17,257); # # 3.4 Unit conversion # # # # MAPLE SESSION 41 # > convert( 1.0, 'units', 'ft', 'm' ); # # # MAPLE SESSION 42 # > convert( 100.0, 'temperature', 'degF', 'degC' ); # # # MAPLE SESSION 43 # > with(Units): > GetDimensions(); # # # MAPLE SESSION 44 # > convert([m,yd,km,mile],conversion\_table,output=grid, > filter=evalf[6]); # # # MAPLE SESSION 45 # > 12.1*Unit(ft)+4*Unit(m); # # # MAPLE SESSION 46 # > with(Units[Standard]): > 12.1*Unit(ft)+4*Unit(m); # # # MAPLE SESSION 47 # > max(12.1*Unit(ft),4*Unit(m)); # # # MAPLE SESSION 48 # > with(Units[Natural]): > max(12.1*ft,4*m); # # 3.5 Trigonometry # 3.5.1 Degrees and radians # # # # MAPLE SESSION 49 # > convert(72*degrees,radians); > convert(2/5*Pi,degrees); # # # MAPLE SESSION 50 # > 72*Pi/180; # # # MAPLE SESSION 51 # > convert(72,units,degrees,radians); > convert(2*Pi/5,units,radians,degrees); # # 3.5.2 Trigonometric functions # # # # MAPLE SESSION 52 # > sin(0); > cos(0); > tan(0); > sin(Pi/2); > cos(Pi/2); > tan(Pi/2); > cot(Pi/2); # # # MAPLE SESSION 53 # > arcsin(1/2); > arcsec(-2); > arctan(1); > arcsin(sin(Pi/12)); > arcsin(sin(Pi/12+Pi)); # # 3.5.2 Simplifying trigonometric functions # # # # MAPLE SESSION 54 # > expand(sin(a+b)); > expand(cos(a+b)); > expand(tan(a+b)); # # # MAPLE SESSION 55 # > y:=(1+sin(x)+cos(x))/(1+sin(x)-cos(x)); > simplify(y); # # # MAPLE SESSION 56 # > expand(sin(5*x)); > factor(%);