Mon Mar 1 16:13:20 MST 1999 aquarius% maple |\^/| Maple V Release 5.1 (WMI Campus Wide License) ._|\| |/|_. Copyright (c) 1981-1998 by Waterloo Maple Inc. All rights \ MAPLE / reserved. Maple and Maple V are registered trademarks of <____ ____> Waterloo Maple Inc. | Type ? for help. # ----------[ M a p l e ]---------- #interface(echo = 3); # ---------- Initialization ---------- > readlib(showtime): > on; # ---------- Algebra ---------- # One would think that the simplification 2 2^n => 2^(n + 1) would happen # automatically or at least easily ... O1 := 2*2^n; n 2 2 time = 0.01, bytes = 37810 O2 := simplify(%); (1 + n) 2 time = 0.03, bytes = 91166 # And how about 4 2^n => 2^(n + 2)? [Richard Fateman] O3 := fctr:= proc(e) if type(e, rational) then ifactor(e) else factor(e) fi end: time = 0.01, bytes = 9774 O4 := 4*2^n; n 4 2 time = 0.00, bytes = 4854 O5 := map(fctr, %); 2 n (2) 2 time = 0.02, bytes = 24934 O6 := subs(a = 2, simplify(expand(subs(2 = a, %)))); (2 + n) 2 time = 0.02, bytes = 32354 O7 := fctr:= 'fctr': time = 0.01, bytes = 4802 # (-1)^[n (n + 1)] => 1 for integer n O8 := assume(n, integer): time = 0.08, bytes = 232618 O9 := (-1)^(n*(n + 1)); (n~ (1 + n~)) (-1) time = 0.00, bytes = 4850 O10 := simplify(%); 1 time = 0.10, bytes = 107346 O11 := n:= 'n': time = 0.00, bytes = 4766 # Also easy => 2 (3 x - 5) O12 := q:= 6*x - 10: time = 0.01, bytes = 8722 O13 := factor(q); 6 x - 10 time = 0.01, bytes = 4402 O14 := [content(q), primpart(q)]; [2, 3 x - 5] time = 0.02, bytes = 12878 O15 := q:= 'q': time = 0.01, bytes = 4062 # Univariate gcd: gcd(p1, p2) => 1, gcd(p1 q, p2 q) => q [Richard Liska] O16 := p1:= 64*x^34 - 21*x^47 - 126*x^8 - 46*x^5 - 16*x^60 - 81: time = 0.01, bytes = 9586 O17 := p2:= 72*x^60 - 25*x^25 - 19*x^23 - 22*x^39 - 83*x^52 + 54*x^10 + 81: time = 0.01, bytes = 5326 O18 := q:= 34*x^19 - 25*x^16 + 70*x^7 + 20*x^3 - 91*x - 86: time = 0.00, bytes = 5494 O19 := gcd(p1, p2); 1 time = 0.03, bytes = 33782 O20 := gcd(expand(p1*q), expand(p2*q)) - q; 0 time = 0.04, bytes = 64958 # resultant(p1 q, p2 q) => 0 O21 := resultant(expand(p1*q), expand(p2*q), x); bytes used=1004764, alloc=851812, time=0.69 0 time = 1.18, bytes = 537010 # How about factorization? => p1 * p2 O22 := factor(expand(p1 * p2)); bytes used=2005836, alloc=1113908, time=4.73 bytes used=3006112, alloc=1179432, time=12.64 bytes used=4009672, alloc=1507052, time=15.00 60 25 23 39 52 10 -(72 x - 25 x - 19 x - 22 x - 83 x + 54 x + 81) 60 47 34 8 5 (16 x + 21 x - 64 x + 126 x + 46 x + 81) time = 14.32, bytes = 2816370 O23 := p1:= 'p1': time = 0.00, bytes = 3566 O24 := p2:= 'p2': time = 0.00, bytes = 3430 O25 := q:= 'q': time = 0.01, bytes = 3474 # Multivariate gcd: gcd(p1, p2) => 1, gcd(p1 q, p2 q) => q O26 := p1:= 24*x*y^19*z^8 - 47*x^17*y^5*z^8 + 6*x^15*y^9*z^2 - 3*x^22 + 5: time = 0.01, bytes = 7626 O27 := p2:= 34*x^5*y^8*z^13 + 20*x^7*y^7*z^7 + 12*x^9*y^16*z^4 + 80*y^14*z: time = 0.01, bytes = 4338 O28 := q:= 11*x^12*y^7*z^13 - 23*x^2*y^8*z^10 + 47*x^17*y^5*z^8: time = 0.00, bytes = 4294 O29 := gcd(p1, p2); 1 time = 0.02, bytes = 20482 O30 := gcd(expand(p1*q), expand(p2*q)) - q; bytes used=5012748, alloc=1703624, time=16.77 bytes used=6013284, alloc=1769148, time=17.66 15 10 2 5 3 2 2 5 8 12 7 13 2 8 10 (47 x + 11 x y z - 23 y z ) x y z - 11 x y z + 23 x y z 17 5 8 - 47 x y z time = 1.92, bytes = 2190854 O31 := simplify(%); 0 time = 0.01, bytes = 4346 # How about factorization? => p1 * p2 O32 := factor(expand(p1 * p2)); bytes used=7014096, alloc=1769148, time=18.71 bytes used=8021436, alloc=1769148, time=19.79 bytes used=9032736, alloc=1900196, time=20.59 bytes used=10037196, alloc=1900196, time=21.39 bytes used=11042260, alloc=1900196, time=22.27 bytes used=12042780, alloc=1965720, time=23.12 bytes used=13043040, alloc=1965720, time=23.99 7 22 17 5 8 15 9 2 19 8 -2 y z (3 x + 47 x y z - 6 x y z - 24 x y z - 5) 7 12 5 6 7 9 3 9 (40 y + 17 y z x + 10 z x + 6 y z x ) time = 5.99, bytes = 6598070 O33 := p1:= 'p1': time = 0.00, bytes = 3402 O34 := p2:= 'p2': time = 0.00, bytes = 3374 O35 := q:= 'q': time = 0.01, bytes = 3310 # => x^n for n > 0 [Chris Hurlburt] O36 := assume(n > 0): time = 0.01, bytes = 8762 O37 := gcd(2*x^(n + 4) - x^(n + 2), 4*x^(n + 1) + 3*x^n); 1 time = 0.01, bytes = 8394 O38 := n:= 'n': time = 0.00, bytes = 3334 # Resultants. If the resultant of two polynomials is zero, this implies they # have a common factor. See Keith O. Geddes, Stephen R. Czapor and George # Labahn, _Algorithms for Computer Algebra_, Kluwer Academic Publishers, 1992, # p. 286 => 0 O39 := resultant(3*x^4 + 3*x^3 + x^2 - x - 2, x^3 - 3*x^2 + x + 5, x); 0 time = 0.03, bytes = 26258 # Numbers are nice, but symbols allow for variability---try some high school # algebra: rational simplification => (x - 2)/(x + 2) O40 := (x^2 - 4)/(x^2 + 4*x + 4); 2 x - 4 ------------ 2 x + 4 x + 4 time = 0.01, bytes = 10378 O41 := normal(%); x - 2 ----- x + 2 time = 0.02, bytes = 18306 # This example requires more sophistication => e^(x/2) - 1 O42 := [(exp(1)^x - 1)/(exp(1)^(x/2) + 1), (exp(x) - 1)/(exp(x/2) + 1)]; x exp(1) - 1 exp(x) - 1 [-----------------, --------------] (1/2 x) exp(1/2 x) + 1 exp(1) + 1 time = 0.02, bytes = 9378 O43 := simplify(%); [exp(1/2 x) - 1, exp(1/2 x) - 1] time = 0.08, bytes = 90310 # Expand and factor polynomials O44 := (x + 1)^20; 20 (x + 1) time = 0.01, bytes = 6466 O45 := expand(%); 20 19 18 17 16 15 14 x + 20 x + 190 x + 1140 x + 4845 x + 15504 x + 38760 x 13 12 11 10 9 8 + 77520 x + 125970 x + 167960 x + 184756 x + 167960 x + 125970 x 7 6 5 4 3 2 + 77520 x + 38760 x + 15504 x + 4845 x + 1140 x + 190 x + 20 x + 1 time = 0.02, bytes = 12654 O46 := diff(%, x); 19 18 17 16 15 14 13 20 x + 380 x + 3420 x + 19380 x + 77520 x + 232560 x + 542640 x 12 11 10 9 8 + 1007760 x + 1511640 x + 1847560 x + 1847560 x + 1511640 x 7 6 5 4 3 2 + 1007760 x + 542640 x + 232560 x + 77520 x + 19380 x + 3420 x + 380 x + 20 time = 0.00, bytes = 4246 O47 := factor(%); 19 20 (x + 1) time = 0.02, bytes = 16498 # Completely factor this polynomial, then try to multiply it back together! O48 := solve(x^3 + x^2 - 7 = 0); bytes used=14052736, alloc=1965720, time=25.00 1/2 1/6 %2 + 2/3 %1 - 1/3, - 1/12 %2 - 1/3 %1 - 1/3 + 1/2 I 3 (1/6 %2 - 2/3 %1), 1/2 - 1/12 %2 - 1/3 %1 - 1/3 - 1/2 I 3 (1/6 %2 - 2/3 %1) 1 %1 := --------------------- 1/2 1/3 (748 + 12 3885 ) 1/2 1/3 %2 := (748 + 12 3885 ) time = 0.69, bytes = 640174 O49 := convert(map(e -> x - e, [%]), `*`); (x - 1/6 %2 - 2/3 %1 + 1/3) 1/2 (x + 1/12 %2 + 1/3 %1 + 1/3 - 1/2 I 3 (1/6 %2 - 2/3 %1)) 1/2 (x + 1/12 %2 + 1/3 %1 + 1/3 + 1/2 I 3 (1/6 %2 - 2/3 %1)) 1 %1 := --------------------- 1/2 1/3 (748 + 12 3885 ) 1/2 1/3 %2 := (748 + 12 3885 ) time = 0.01, bytes = 4786 O50 := simplify(expand(%)); 3 2 x + x - 7 time = 0.08, bytes = 97974 O51 := x^100 - 1; 100 x - 1 time = 0.01, bytes = 3610 O52 := factor(%); 4 3 2 20 15 10 5 (x - 1) (x + x + x + x + 1) (x + x + x + x + 1) (x + 1) 2 3 4 5 10 15 20 2 (1 - x + x - x + x ) (1 - x + x - x + x ) (1 + x ) 8 6 4 2 40 30 20 10 (x - x + x - x + 1) (x - x + x - x + 1) time = 0.04, bytes = 33666 # Factorization over the complex rationals # => (2 x + 3 i) (2 x - 3 i) (x + 1 + 4 i) (x + 1 - 4 i) O53 := factor(4*x^4 + 8*x^3 + 77*x^2 + 18*x + 153, I); (2 x + 3 I) (2 x - 3 I) (x + 1 - 4 I) (x + 1 + 4 I) time = 0.61, bytes = 616574 O54 := readlib(split): time = 0.01, bytes = 4354 O55 := split(4*x^4 + 8*x^3 + 77*x^2 + 18*x + 153, x); bytes used=15053244, alloc=2162292, time=26.21 4 (x + 2 + %1) (x - 3/8 - 3/8 %1) (x - %1) (x + 3/8 + 3/8 %1) 2 %1 := RootOf(_Z + 2 _Z + 17) time = 0.68, bytes = 376570 # Algebraic extensions O56 := alias(sqrt2 = RootOf(sqrt2^2 - 2)): time = 0.02, bytes = 13898 # => sqrt2 + 1 O57 := 1/(sqrt2 - 1); 1 --------- sqrt2 - 1 time = 0.01, bytes = 6602 O58 := simplify(%); sqrt2 + 1 time = 0.05, bytes = 44214 # => (x^2 - 2 x - 3)/(x - sqrt2) = (x + 1) (x - 3)/(x - sqrt2) # [Richard Liska] O59 := (x^3 + (sqrt2 - 2)*x^2 - (2*sqrt2 + 3)*x - 3*sqrt2)/(x^2 - 2); 3 2 x + (sqrt2 - 2) x - (2 sqrt2 + 3) x - 3 sqrt2 ----------------------------------------------- 2 x - 2 time = 0.02, bytes = 10418 O60 := factor(%); (x - 3) (x + 1) --------------- x - sqrt2 time = 0.26, bytes = 217486 O61 := alias(sqrt2 = sqrt2): time = 0.01, bytes = 3406 # Multiple algebraic extensions O62 := alias(sqrt3 = RootOf(sqrt3^2 - 3)): time = 0.01, bytes = 13986 O63 := alias(cbrt2 = RootOf(cbrt2^3 - 2)): time = 0.01, bytes = 10946 # => 2 cbrt2 + 8 sqrt3 + 18 cbrt2^2 + 12 cbrt2 sqrt3 + 9 O64 := (cbrt2 + sqrt3)^4; 4 (cbrt2 + sqrt3) time = 0.02, bytes = 6570 O65 := simplify(%); 2 2 cbrt2 + 8 sqrt3 + 12 cbrt2 sqrt3 + 18 cbrt2 + 9 time = 0.07, bytes = 68858 O66 := alias(sqrt3 = sqrt3, cbrt2 = cbrt2): time = 0.00, bytes = 3486 # Factor polynomials over finite fields and field extensions O67 := p:= x^4 - 3*x^2 + 1; 4 2 x - 3 x + 1 time = 0.01, bytes = 6658 O68 := factor(p); 2 2 (x + x - 1) (x - x - 1) time = 0.04, bytes = 52806 # => (x - 2)^2 (x + 2)^2 mod 5 O69 := Factor(p) mod 5; 2 2 (x + 3) (x + 2) time = 0.03, bytes = 28238 O70 := expand(%); 4 3 2 x + 10 x + 37 x + 60 x + 36 time = 0.00, bytes = 3638 # => (x^2 + x + 1) (x^9 - x^8 + x^6 - x^5 + x^3 - x^2 + 1) mod 65537 # [Paul Zimmermann] O71 := Factor(x^11 + x + 1) mod 65537; 9 8 6 5 3 2 2 (x + 65536 x + x + 65536 x + x + 65536 x + 1) (x + x + 1) time = 0.11, bytes = 106702 # => (x - phi) (x + phi) (x - phi + 1) (x + phi - 1) # where phi^2 - phi - 1 = 0 or phi = (1 +- sqrt(5))/2 O72 := alias(phi = RootOf(x^2 - x - 1 = 0)): time = 0.03, bytes = 19410 O73 := factor(p, phi); bytes used=16053428, alloc=2424388, time=27.65 (x - phi) (x - 1 + phi) (x + 1 - phi) (x + phi) time = 0.75, bytes = 435858 O74 := split(p, x); (x - phi) (x - 1 + phi) (x + 1 - phi) (x + phi) time = 0.11, bytes = 90866 O75 := alias(phi = phi): time = 0.01, bytes = 3410 O76 := p:= 'p': time = 0.00, bytes = 3306 O77 := expand((x - 2*y^2 + 3*z^3)^20): time = 0.05, bytes = 63782 O78 := factor(%); 2 3 20 (x - 2 y + 3 z ) time = 0.18, bytes = 209486 O79 := expand((sin(x) - 2*cos(y)^2 + 3*tan(z)^3)^20): time = 0.06, bytes = 86406 O80 := factor(%); bytes used=17054856, alloc=2555436, time=28.94 2 3 20 (2 cos(y) - sin(x) - 3 tan(z) ) time = 0.68, bytes = 434998 # expand[(1 - c^2)^5 (1 - s^2)^5 (c^2 + s^2)^10] => c^10 s^10 when # c^2 + s^2 = 1 [modification of a problem due to Richard Liska] O81 := q:= expand((1 - c^2)^5 * (1 - s^2)^5 * (c^2 + s^2)^10): time = 0.02, bytes = 31266 O82 := simplify(q, {c^2 + s^2 = 1}); bytes used=18055044, alloc=2817532, time=30.09 20 18 16 14 12 10 -c + 5 c - 10 c + 10 c - 5 c + c time = 0.98, bytes = 748094 O83 := factor(%); 10 5 5 -c (c - 1) (c + 1) time = 0.02, bytes = 17850 O84 := Groebner[gbasis]([q, c^2 + s^2 - 1], plex(c, s)); 20 18 16 14 12 10 2 2 [s - 5 s + 10 s - 10 s + 5 s - s , c + s - 1] bytes used=19060056, alloc=2883056, time=31.35 time = 0.90, bytes = 943658 O85 := factor(%); 10 5 5 2 2 [s (s - 1) (s + 1) , c + s - 1] time = 0.03, bytes = 21334 O86 := q:= 'q': time = 0.00, bytes = 3306 # => (x + y) (x - y) mod 3 O87 := Factor(4*x^2 - 21*x*y + 20*y^2) mod 3; (2 y + x) (y + x) time = 0.37, bytes = 389682 # => 1/4 (x + y) (2 x + y [-1 + i sqrt(3)]) (2 x + y [-1 - i sqrt(3)]) O88 := alias(isqrt3 = RootOf(isqrt3^2 + 3)): time = 0.02, bytes = 14446 O89 := factor(x^3 + y^3, isqrt3); bytes used=20060600, alloc=2883056, time=32.80 1/4 (2 x - y - y isqrt3) (2 x - y + y isqrt3) (y + x) time = 1.20, bytes = 709274 O90 := alias(isqrt3 = isqrt3): time = 0.00, bytes = 3426 O91 := split(x^3 + y^3, x); 2 2 2 2 (x - RootOf(_Z - y _Z + y )) (y + x) (x - y + RootOf(_Z - y _Z + y )) time = 0.13, bytes = 95146 # Partial fraction decomposition => 3/(x + 2) - 2/(x + 1) + 2/(x + 1)^2 O92 := (x^2 + 2*x + 3)/(x^3 + 4*x^2 + 5*x + 2); 2 x + 2 x + 3 ------------------- 3 2 x + 4 x + 5 x + 2 time = 0.01, bytes = 7118 O93 := convert(%, parfrac, x); 3 2 2 ----- + -------- - ----- x + 2 2 x + 1 (x + 1) time = 0.07, bytes = 67754 # Noncommutative algebra: note that (A B C)^(-1) = C^(-1) B^(-1) A^(-1) # => A B C A C B - C^(-1) B^(-1) C B O94 := (A &* B &* C - (A &* B &* C)^(-1)) &* A &* C &* B; /// 1 \ \ \ |||((A &* B) &* C) - -------------| &* A| &* C| &* B \\\ (A &* B) &* C/ / / time = 0.02, bytes = 9982 O95 := expand(%); 1 &*(A, B, C, A, C, B) - &*(-----------, A, C, B) &*(A, B, C) time = 0.04, bytes = 21402 # Jacobi's identity: [A, B, C] + [B, C, A] + [C, A, B] = 0 where [A, B, C] = # [A, [B, C]] and [A, B] = A B - B A is the commutator of A and B O96 := comm2:= (A, B) -> A &* B - B &* A: time = 0.02, bytes = 10334 O97 := comm3:= (A, B, C) -> comm2(A, comm2(B, C)): time = 0.01, bytes = 3622 O98 := comm2(A, B); (A &* B) - (B &* A) time = 0.00, bytes = 3358 O99 := comm3(A, B, C) + comm3(B, C, A) + comm3(C, A, B); (A &* ((B &* C) - (C &* B))) - (((B &* C) - (C &* B)) &* A) + (B &* ((C &* A) - (A &* C))) - (((C &* A) - (A &* C)) &* B) + (C &* ((A &* B) - (B &* A))) - (((A &* B) - (B &* A)) &* C) time = 0.00, bytes = 4538 O100 := expand(%); 0 time = 0.04, bytes = 25446 O101 := comm2:= 'comm2': time = 0.01, bytes = 3350 O102 := comm3:= 'comm3': time = 0.00, bytes = 3494 # ---------- Quit ---------- O103 := quit bytes used=20532152, alloc=2883056, time=33.39 real 35.56 user 33.45 sys 1.50