1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/* Original version of this file copyright 1999 by Michael Wester,
* and retrieved from http://www.math.unm.edu/~wester/demos/Numbers/problems.macsyma
* circa 2006-10-23.
*
* Released under the terms of the GNU General Public License, version 2,
* per message dated 2007-06-03 from Michael Wester to Robert Dodier
* (contained in the file wester-gpl-permission-message.txt).
*
* See: "A Critique of the Mathematical Abilities of CA Systems"
* by Michael Wester, pp 25--60 in
* "Computer Algebra Systems: A Practical Guide", edited by Michael J. Wester
* and published by John Wiley and Sons, Chichester, United Kingdom, 1999.
*/
/* ----------[ M a c s y m a ]---------- */
/* ---------- Initialization ---------- */
showtime: all$
prederror: false$
/* ---------- Numbers ---------- */
/* Let's begin by playing with numbers: infinite precision integers
=> 30414 0932017133 7804361260 8166064768 8443776415 6896051200 0000000000
*/
50!;
/* => 2^47 3^22 5^12 7^8 11^4 13^3 17^2 19^2 23^2 29 31 37 41 43 47 */
factor(%);
/* Double factorial => 10!! = 10*8*6*4*2 = 3840, 9!! = 9*7*5*3*1 = 945 */
[10!!, 9!!];
/* ABC base 16 => 2748 base 10 */
ibase: 16$
abc;
ibase: 9+1$
/* 123 base 10 => 234 base 7 */
obase: 7$
123;
obase: 10$
/* 677 base 8 => 1BF base 16 */
obase: 16$
ibase: 8$
677;
ibase: 12$
obase: 10$
/* [log base 8](32768) => 5 */
logb(8, 32768);
/* 5^(-1) mod 7 => 3; 5^(-1) mod 6 => 5 */
modulus: 7$
rat(5^(-1));
modulus: 6$
rat(5^(-1));
modulus: false$
/* Greatest common divisor => 74 */
gcdn([1776, 1554, 5698]);
/* Infinite precision rational numbers => 4861/2520 */
1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8 + 1/9 + 1/10;
/* Complete decimal expansion of a rational number => 0.142857 ... */
dfloat(1/7);
/* Multiply two complete decimal expansions and produce an exact result => 2 */
(7/11) * (22/7);
/* This number should immediately simplify to 3^(1/3) */
10/7 * (1 + 29/1000)^(1/3);
/* Simplify an expression with nested square roots => 1 + sqrt(3) */
sqrt(2*sqrt(3) + 4);
denest_sqrts(%);
/* Try a more complicated example (from the Putnam exam) => 3 + sqrt(2) */
sqrt(14 + 3*sqrt(3 + 2*sqrt(5 - 12*sqrt(3 - 2*sqrt(2)))));
denest_sqrts(%);
/* See D.J. Jeffrey and A.D. Rich, ``The nesting habits of radicals'', draft of
1998 => sqrt(2) + sqrt(3) + sqrt(5) */
sqrt(10 + 2*sqrt(6) + 2*sqrt(10) + 2*sqrt(15));
denest_sqrts(%);
/* Rationalize the denominator => 5 + 2 sqrt(6) */
(sqrt(3) + sqrt(2))/(sqrt(3) - sqrt(2));
ratsimp(%), algebraic: true;
rootscontract(%);
/* A factorization of 3 in the integers extended by sqrt(-5) */
sqrt(-2 + sqrt(-5)) * sqrt(-2 - sqrt(-5));
ratsimp(rootscontract(%));
/* => 3 + sqrt(7) [Jeffrey and Rich] */
(90 + 34*sqrt(7))^(1/3);
denest_sqrts(%);
/* This is a nontrivial way of writing 12 ! */
((135 + 78*sqrt(3))^(2/3) + 3)*sqrt(3)/(135 + 78*sqrt(3))^(1/3);
ratsimp(%), algebraic: true;
dfloat(%);
/* See David Jeffrey, ``Current Problems in Computer Algebra Systems'', talk
=> 1 + sqrt(2) */
(49 + 21*sqrt(2))^(1/5);
denest_sqrts(%);
/* A nasty example generated by Axiom => [log(sqrt(2) + 1) + sqrt(2)]/3 */
((6 - 4*sqrt(2))*log(3 - 2*sqrt(2)) + (3 - 2*sqrt(2))*log(17 - 12*sqrt(2))
+ 32 - 24*sqrt(2)) / (48*sqrt(2) - 72);
ratsimp(logcontract(ev(ratsimp(%), algebraic: true)));
dfloat(%);
dfloat((log(sqrt(2) + 1) + sqrt(2))/3);
/* Cardinal numbers => infinity */
2*inf - 3;
limit(%);
/* 2^aleph_0 => aleph_1 */
2^inf;
limit(%);
|