# Please do not post homework # Matthew Esaia, January 26, Assignment 1 # 1.2 Basic syntax print(`Section 1.2`); 105/25-1/5; % + 1/5; # 2.1 Exact arithmetic and basic functions print(`Section 2.1`); 2/3 + 3/5; #12^20; # 2.2 Floating-point arithmetic print(`Section 2.2`); tan(Pi/5); evalf(%); E := exp(1): evalf(E, 20); Digits := 30; evalf(E); Digits := 10; evalf(sin(Pi/6)); convert(%, rational); # 3.1 Polynomials and rational functions print(`Section 3.1.1`); p := x^2 + 5*x + 6; factor(p); print(`Section 3.1.2`); p := (x + 2) * (x + 3); expand(%); print(`Section 3.1.3`); (x + y + 1) * (x - y + 1) * (x - y - 1); p := expand(%); collect(p, x); print(`Section 3.1.4`); 3 * 4^(1/2) + 5; simplify(%); x^2; y := %^(1/2); assume(x > 0); simplify(y); x := 'x'; # Removes the assumption that x > 0 print(`Section 3.1.5`); y := x^3 + 3 * x^2 + 3 * x + 1; simplify(y^(1/3)); radsimp(y^(1/3)); readlib(rationalize): # Some packages use readlib instead of with 1/(1+sqrt(2)); rationalize(%); print(`Section 3.1.6`); 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)); print(`Section 3.1.7`); x := 'x': y := 'y': p := (x + y + 1) * (x - y + 1) * (x - y - 1): q := expand(%): coeff(q, x, 2); coeff(p, x, 2); degree(q, x); print(`Section 3.1.8`); p := (x + y + z) * (x - y + z) * (x - y - z); subs(x = 1, y = 2, p); # 3.2 Equations print(`Section 3.2.1`); eqn := x^2 - x = 1; R := solve(eqn, x); simplify(R[1]*R[2]); print(`Section 3.2.2`); a := 'a': eqn1 := x^3 + a*x = 14: eqn2 := a^2 - x = 7: solve({eqn1, eqn2}, {x, a}); #%[1]; #assign(%); #a; x; # 3.3 Fun with integers print(`Section 3.3.1`); ifactor(2^(2^5)+ 1); # Prime factorization print(`Section 3.3.4`); ithprime(100); isprime(2^101 - 1); # isolve -> gives you an integer solution