Thu Feb 25 19:35:04 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; # ---------- Numbers ---------- # Let's begin by playing with numbers: infinite precision integers # => 30414 0932017133 7804361260 8166064768 8443776415 6896051200 0000000000 O1 := 50!; 30414093201713378043612608166064768844377641568960512000000000000 time = 0.02, bytes = 38154 # => 2^47 3^22 5^12 7^8 11^4 13^3 17^2 19^2 23^2 29 31 37 41 43 47 O2 := ifactor(%); 47 22 12 8 4 3 2 2 2 (2) (3) (5) (7) (11) (13) (17) (19) (23) (29) (31) (37) (41) (43) (47) time = 0.03, bytes = 45346 # Double factorial => 10!! = 10*8*6*4*2 = 3840, 9!! = 9*7*5*3*1 = 945 #[10!!, 9!!]; O3 := 3!!; 720 time = 0.02, bytes = 12898 # ABC base 16 => 2748 base 10 O4 := reverse:= proc(l) local i, n, ll; O4 := n:= nops(l); O4 := ll:= array(1..n); O4 := for i from 1 to n do O4 := ll[i]:= l[n + 1 - i] O4 := od; O4 := convert(ll, list) O4 := end: time = 0.05, bytes = 41354 O5 := convert(reverse([c, b, a]), base, 16, 10); `Error, `.(9117, `convert/base/topowerof10`, 1, a::nonnegint, 256*c+16*b+a) time = 0.02, bytes = 17734 O6 := reverse(convert(reverse([10, 11, 12]), base, 16, 10)); [2, 7, 4, 8] time = 0.00, bytes = 18598 # 123 base 10 => 234 base 7 O7 := reverse(convert(123, base, 7)); [2, 3, 4] time = 0.01, bytes = 13534 # 677 base 8 => 1BF base 16 O8 := reverse(convert(reverse([6, 7, 7]), base, 8, 16)); [1, 11, 15] time = 0.01, bytes = 14694 # [log base 8](32768) => 5 O9 := log[8](32768); ln(32768) --------- ln(8) time = 0.02, bytes = 14694 O10 := simplify(%); 5 time = 0.03, bytes = 42058 # 5^(-1) mod 7 => 3; 5^(-1) mod 6 => 5 O11 := 5^(-1) mod 7; 3 time = 0.01, bytes = 8538 O12 := 5^(-1) mod 6; 5 time = 0.01, bytes = 4650 # Greatest common divisor => 74 O13 := igcd(1776, 1554, 5698); 74 time = 0.00, bytes = 7618 # Infinite precision rational numbers => 4861/2520 O14 := 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8 + 1/9 + 1/10; 4861 ---- 2520 time = 0.01, bytes = 9870 # Complete decimal expansion of a rational number => 0.142857 ... O15 := evalf(1/7); .1428571429 time = 0.01, bytes = 8438 # Multiply two complete decimal expansions and produce an exact result => 2 O16 := (7/11) * (22/7); 2 time = 0.01, bytes = 8918 # This number should immediately simplify to 3^(1/3) O17 := 10/7 * (1 + 29/1000)^(1/3); 1/3 2/3 1/700 1029 1000 time = 0.01, bytes = 8910 O18 := simplify(%); 1/3 3 time = 0.05, bytes = 115238 # Simplify an expression with nested square roots => 1 + sqrt(3) O19 := sqrt(2*sqrt(3) + 4); 1/2 3 + 1 time = 0.01, bytes = 12358 # Try a more complicated example (from the Putnam exam) => 3 + sqrt(2) O20 := sqrt(14 + 3*sqrt(3 + 2*sqrt(5 - 12*sqrt(3 - 2*sqrt(2))))); 1/2 3 + 2 time = 0.03, bytes = 21910 # See D.J. Jeffrey and A.D. Rich, ``The nesting habits of radicals'', draft of # 1998 => sqrt(2) + sqrt(3) + sqrt(5) O21 := sqrt(10 + 2*sqrt(6) + 2*sqrt(10) + 2*sqrt(15)); 1/2 1/2 1/2 1/2 (10 + 2 6 + 2 10 + 2 15 ) time = 0.02, bytes = 36974 O22 := radsimp(%); 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 2 (5 + 3 2 + 5 2 + 3 5 ) time = 0.09, bytes = 121362 # Rationalize the denominator => 5 + 2 sqrt(6) O23 := (sqrt(3) + sqrt(2))/(sqrt(3) - sqrt(2)); 1/2 1/2 3 + 2 ----------- 1/2 1/2 3 - 2 time = 0.00, bytes = 10550 O24 := combine(expand(rationalize(%))); 1/2 5 + 2 6 time = 0.06, bytes = 59490 # A factorization of 3 in the integers extended by sqrt(-5) O25 := sqrt(-2 + sqrt(-5)) * sqrt(-2 - sqrt(-5)); bytes used=1202856, alloc=917336, time=0.83 1/2 1/2 1/2 1/2 (-2 + I 5 ) (-2 - I 5 ) time = 0.25, bytes = 317422 O26 := factor(%); bytes used=2203140, alloc=1441528, time=1.83 bytes used=3203876, alloc=1834672, time=3.01 3 time = 2.24, bytes = 2026346 # => 3 + sqrt(7) [Jeffrey and Rich] O27 := (90 + 34*sqrt(7))^(1/3); 1/2 1/3 (90 + 34 7 ) time = 0.01, bytes = 7490 O28 := radnormal(%); 1/2 3 + 7 time = 0.35, bytes = 331406 # This is a nontrivial way of writing 12 ! O29 := ((135 + 78*sqrt(3))^(2/3) + 3)*sqrt(3)/(135 + 78*sqrt(3))^(1/3); 1/2 2/3 1/2 ((135 + 78 3 ) + 3) 3 ----------------------------- 1/2 1/3 (135 + 78 3 ) time = 0.02, bytes = 9122 O30 := factor(%); 12 time = 0.41, bytes = 384470 # See David Jeffrey, ``Current Problems in Computer Algebra Systems'', talk # => 1 + sqrt(2) O31 := (49 + 21*sqrt(2))^(1/5); 1/2 1/5 (49 + 21 2 ) time = 0.00, bytes = 12478 O32 := radsimp(%); 1/5 1/2 1/5 7 (7 + 3 2 ) time = 0.03, bytes = 41246 # A nasty example generated by Axiom => [log(sqrt(2) + 1) + sqrt(2)]/3 O33 := ((6 - 4*sqrt(2))*log(3 - 2*sqrt(2)) + (3 - 2*sqrt(2))*log(17 - 12*sqrt(2)) O33 := + 32 - 24*sqrt(2)) / (48*sqrt(2) - 72); 1/2 1/2 1/2 1/2 1/2 ((6 - 4 2 ) ln(3 - 2 2 ) + (3 - 2 2 ) ln(17 - 12 2 ) + 32 - 24 2 ) / 1/2 / (48 2 - 72) / time = 0.01, bytes = 15914 O34 := simplify(combine(radnormal(%))); bytes used=4204508, alloc=2096768, time=4.29 bytes used=5207440, alloc=2096768, time=5.49 bytes used=6207888, alloc=2227816, time=6.94 bytes used=7208144, alloc=2293340, time=8.45 bytes used=8208300, alloc=2358864, time=9.77 bytes used=9208568, alloc=2358864, time=11.06 1/2 1/2 1/6 1/2 1/2 1/6 1/3 2 + ln((17 - 12 2 ) + 2 (17 - 12 2 ) ) time = 7.94, bytes = 5754470 O35 := rationalize(1/(sqrt(2) - 1)); 1/2 1 + 2 time = 0.01, bytes = 8814 # Cardinal numbers => infinity O36 := 2*infinity - 3; infinity time = 0.01, bytes = 7098 # 2^aleph_0 => aleph_1 O37 := 2^infinity; infinity 2 time = 0.01, bytes = 6522 O38 := simplify(%); infinity time = 0.03, bytes = 29382 # ---------- Quit ---------- O39 := quit bytes used=9980048, alloc=2358864, time=12.04 real 13.36 user 12.10 sys 1.16