rounded.log 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. Sat Jun 29 13:37:56 PDT 1991
  2. REDUCE 3.4, 15-Jul-91 ...
  3. 1: 1:
  4. 2: 2:
  5. 3: 3: % Tests in the exact mode.
  6. x := 1/2;
  7. 1
  8. X := ---
  9. 2
  10. y := x + 0.7;
  11. 6
  12. Y := ---
  13. 5
  14. % Tests in approximate mode.
  15. on rounded;
  16. y;
  17. 1.2
  18. % as expected not converted to approximate form.
  19. z := y+1.2;
  20. Z := 2.4
  21. z/3;
  22. 0.8
  23. % Let's raise this to a high power.
  24. ws^24;
  25. 0.00472236648287
  26. % Now a high exponent value.
  27. % 10.2^821;
  28. % Elementary function evaluation.
  29. cos(pi);
  30. - 1
  31. symbolic ws;
  32. (!*SQ ((!:RD!: . -1.0) . 1) T)
  33. z := sin(pi);
  34. Z := 0
  35. symbolic ws;
  36. 0
  37. % Handling very small quantities.
  38. % With normal defaults, underflows are converted to 0.
  39. exp(-100000.1**2);
  40. 0
  41. % However, if you really want that small number, roundbf can be used.
  42. on roundbf;
  43. exp(-100000.1**2);
  44. 1.18440746497E-4342953505
  45. off roundbf;
  46. % Now let us evaluate pi.
  47. pi;
  48. 3.14159265359
  49. % Let us try a higher precision.
  50. precision 50;
  51. 12
  52. pi;
  53. 3.141 59265 35897 93238 46264 33832 79502 88419 71693 99375 1
  54. % Now find the cosine of pi/6.
  55. cos(ws/6);
  56. 0.866 02540 37844 38646 76372 31707 52936 18347 14026 26905 19
  57. % This should be the sqrt(3)/2.
  58. ws**2;
  59. 0.75
  60. %Here are some well known examples which show the power of this system.
  61. precision 10;
  62. 50
  63. % This should give the usual default again.
  64. let xx=e**(pi*sqrt(163));
  65. let yy=1-2*cos((6*log(2)+log(10005))/sqrt(163));
  66. % First notice that xx looks like an integer.
  67. xx;
  68. 2.625374126E+17
  69. % and that yy looks like zero.
  70. yy;
  71. 0
  72. % but of course it's an illusion.
  73. precision 50;
  74. 10
  75. xx;
  76. 26253 74126 40768 743.9 99999 99999 92500 72597 19818 56888 8
  77. yy;
  78. - 1.281 52565 59456 09277 51597 49532 17051 34 E -16
  79. %now let's look at an unusual way of finding an old friend;
  80. precision 50;
  81. 50
  82. procedure agm;
  83. <<a := 1$ b := 1/sqrt 2$ u:= 1/4$ x := 1$ pn := 4$ repeat
  84. <<p := pn;
  85. y := a; a := (a+b)/2; b := sqrt(y*b); % Arith-geom mean.
  86. u := u-x*(a-y)**2; x := 2*x; pn := a**2/u;
  87. write "pn=",pn>> until pn>=p; p>>;
  88. AGM
  89. let ag=agm();
  90. ag;
  91. pn=3.187 67264 27121 08627 20192 99705 25369 23265 10535 71859 4
  92. pn=3.141 68029 32976 53293 91807 04245 60009 38279 57194 38815 4
  93. pn=3.141 59265 38954 46496 00291 47588 18043 48610 88792 37261 3
  94. pn=3.141 59265 35897 93238 46636 06027 06631 32175 77024 11342 4
  95. pn=3.141 59265 35897 93238 46264 33832 79502 88419 71699 49164 7
  96. pn=3.141 59265 35897 93238 46264 33832 79502 88419 71693 99375 1
  97. pn=3.141 59265 35897 93238 46264 33832 79502 88419 71693 99375 1
  98. 3.141 59265 35897 93238 46264 33832 79502 88419 71693 99375 1
  99. % The limit is obviously.
  100. pi;
  101. 3.141 59265 35897 93238 46264 33832 79502 88419 71693 99375 1
  102. end;
  103. 4: 4:
  104. Quitting
  105. Sat Jun 29 13:38:02 PDT 1991