Update AUTHORS file using admin/list_authors.pl.
[maxima/cygwin.git] / tests / rtest_allnummod.mac
blobb28fa4384fbbdc2feb8a5f16fa927bdaefab4e34
1 (ratprint : false, kill (all));
2 done;
4 ceiling(42);
5 42$
7 ceiling(-128);
8 -128$
10 ceiling(-5/2);
11 -2$
13 ceiling(0);
16 ceiling(5/2);
19 ceiling(-5.6);
20 -5$
22 ceiling(7.8);
25 ceiling(-5.6b0);
26 -5$
28 ceiling(7.8b0);
31 ceiling(%pi);
34 ceiling(%e);
37 ceiling(%phi);
40 ceiling(minf);
41 und$
43 ceiling(inf);
44 und$
46 ceiling(infinity);
47 ceiling(infinity)$
49 ceiling(zeroa);
52 ceiling(zerob);
55 ceiling(und);
56 und$
58 ceiling(ind);
59 und$
61 args(ceiling(rat(x)));
62 [x]$
64 args(ceiling(rat(a+b)));
65 [a+b]$
67 ceiling(ceiling(x));
68 '(ceiling(x))$
70 ceiling(5 + ceiling(x));
71 5 + ceiling(x)$
73 ceiling(ceiling(x) + ceiling(y));
74 ceiling(x) + ceiling(y)$
76 ceiling(ceiling(x) - ceiling(y));
77 ceiling(x) - ceiling(y)$
79 ceiling(ceiling(x) * ceiling(y));
80 ceiling(x) * ceiling(y)$
82 ceiling(6 * ceiling(x) - 28 * ceiling(y));
83 6 * ceiling(x) - 28 * ceiling(y)$
85 ceiling(floor(x));
86 '(floor(x))$
88 (declare(n,integer),0);
91 ceiling(n);
94 ceiling(abs(n));
95 abs(n)$
97 ceiling(abs(n)!);
98 abs(n)!$
100 ceiling(n + 1932);
101 n + 1932$
103 ceiling(n - 128);
104 n - 128$
106 ceiling(n^5);
107 n^5$
109 (assume(n > 0),0);
112 ceiling(5^n);
113 5^n$
115 ceiling(-n);
118 (declare(m,integer),0);
121 (assume(m < 0),0);
124 ceiling(7^m);
125 '(ceiling(7^m))$
127 ceiling(n*m);
128 n*m$
130 ceiling(n + m);
131 n + m$
133 ceiling(n -m);
134 n - m$
136 ceiling(6*n - 28 * m);
137 6*n - 28 * m$
139 ceiling(abs(n+m)!);
140 abs(n+m)!$
142 ceiling(abs(n) - n);
143 abs(n) - n$
145 (forget(m < 0, n >0), 0);
148 ceiling(max(n,m));
149 max(n,m)$
151 ceiling(min(n,m));
152 min(n,m)$
154 ceiling(x+17);
155 ceiling(x) + 17$
157 ceiling(a*b - 32);
158 ceiling(a*b) - 32$
160 ceiling(-x);
161 -floor(x)$
163 ceiling(-exp(x));
164 -floor(exp(x))$
166 ceiling(rat(x));
167 ceiling(x)$
169 ceiling(x + 10!) + floor(-x - 10!);
172 ceiling(a/b + 1909) + floor(-a/b - 1909);
175 (numerval(x,5.6),0);
178 floor(x);
181 ceiling(x);
184 floor(x+8);
187 ceiling(x+8);
190 (kill(x,numerval),0);
193 (kill(xx), assume(0 < xx, xx < 1),0);
196 floor(xx);
199 ceiling(xx);
202 floor(-xx);
205 ceiling(-xx);
208 (kill(xx), assume(0 <= xx, xx < 1),0);
211 floor(xx);
214 ceiling(-xx);
217 (kill(xx), assume(0 < xx, xx <= 1),0);
220 ceiling(xx);
223 floor(-xx);
226 (assume(-1 < yy, yy < 0),0);
229 floor(yy);
232 ceiling(yy);
235 (kill(yy), assume(-1 <= yy, yy < 0),0);
238 floor(yy);
241 ceiling(-yy);
244 (kill(yy), assume(-1 < yy, yy <= 0),0);
247 ceiling(yy);
250 floor(-yy);
253 ceiling(%i^%i);
256 ceiling(asin(-107) -42);
257 ceiling(asin(-107)) - 42$
259 /* SF bug  #1653672 */
261 trigsimp(floor(asin(cos(sqrt(2))^2 + sin(sqrt(2))^2 - 1/7)));
264 trigsimp(ceiling(asin(cos(sqrt(2))^2 + sin(sqrt(2))^2 - 1/7)));
267 /* SF bug #1644378 */
269 (x : ?bigfloatone,0);
272 (ceiling(log(2)), is(x = ?bigfloatone));
273 true$
275 (remvalue(x),0);
278 ceiling(signum(x));
279 ceiling(signum(x))$
281 ceiling(5 * signum(x));
282 ceiling(5 * signum(x))$
284 ceiling(charfun(x < 5) + 7);
285 charfun(x < 5) + 7$
287 ceiling(max(34, abs(n)!, n * m, n + m, n^8));
288 max(34, abs(n)!, n * m, n + m, n^8)$
290 (declare(ne,even, no, odd),0);
293 ceiling(ne);
296 ceiling(ne * no / 2);
297 ne * no / 2$
299 ceiling(ne^2 + 1);
300 ne^2 + 1$
302 ceiling(abs(ne)!);
303 abs(ne)!$
305 ceiling(no);
308 ceiling(ne/2);
309 ne/2$
311 ceiling((no + 1)/2);
312 (no + 1)/2$
314 (remove(ne,even, no,odd),0);
317 (remove(n,integer),remove(m,integer),0);
320 charfun(true);
323 charfun(false);
326 charfun(1 < 3);
329 charfun(1 <= 3);
332 charfun(1 > 3);
335 charfun(1 >= 3);
338 charfun(1 = 3);
341 charfun(1 # 3);
344 charfun(integerp(3));
347 charfun(integerp(sqrt(5)));
350 (p : charfun(x < 1), subst(x=5,p));
353 (p : charfun(x < 1), subst(x=-10,p));
356 charfun(rat(x));
357 charfun(x)$
359 (p : charfun(not(equal(x,1))),0);
362 subst(x=1,p);
365 subst(x=5,p);
368 subst(x=z,p);
369 charfun(not(equal(z,1)))$
371 (p : charfun(-1 < x and x < 1),0);
374 subst(x=1/%pi,p);
377 subst(x = -1,p);
380 subst(x = 1, p);
383 subst(x = 0,p);
386 (remvalue(p),0);
389 block ([prederror : true], charfun (x < 1));
390 charfun(x < 1)$
394 is(compare(1,2) = "<");
395 true$
397 is(compare(2,1) = ">");
398 true$
400 is(compare(2,2) = "=");
401 true$
403 is(compare(x,abs(x)) = "<=");
404 true$
406 is(compare(abs(x),x) = ">=");
407 true$
409 is(compare(1/x,0) = "#");
410 true$
412 compare(a,b);
413 unknown$
415 compare(a,1);
416 unknown$
418 compare(%i,1);
419 notcomparable$
421 compare(1+ %i,0);
422 notcomparable$
424 is(compare(%i,%i) = "=");
425 true$
427 is(compare(a < b, a < b) = "=");
428 true$
430 is(compare(rat(x),x) = "=");
431 true$
433 compare([1,2],[5,6]);
434 notcomparable$
436 compare(%i,%i + 1);
437 notcomparable$
439 /* With revision 1.15 of maxmin.lisp this result has changed to notcomparable */
440 is(compare(infinity,infinity) = "=");
441 false$
443 is(compare(inf,inf) = "=");
444 true$
446 compare(infinity,inf);
447 notcomparable$
449 is(compare(inf,-minf) = "=");
450 true$
452 is(compare(inf,inf+7) = "=");
453 true$
455 is(compare(inf,minf) = ">");
456 true$
458 is(compare(inf,-inf) = ">");
459 true$
461 is(compare(minf,-minf) = "<");
462 true$
464 is(compare(log(x), log(x) + 1) = "<");
465 true$
467 is(compare(log(x), log(x)) = "=");
468 true$
470 is(compare(acosh(x^2+1), acosh(x^2+1) + 1) = "<");
471 true$
476 featurep(5,even);
477 false$
479 featurep(5,odd);
480 true$
482 featurep(-5,even);
483 false$
485 featurep(-5,odd);
486 true$
488 featurep(0,even);
489 true$
491 featurep(0,odd);
492 false$
494 featurep(2/3, even);
495 false$
497 featurep(-5/7,odd);
498 false$
500 featurep(5.6, even);
501 false$
503 featurep(0.0, even);
504 false$
506 featurep(5.6b0, even);
507 false$
509 featurep(5.7b0, odd);
510 false$
512 featurep(x,even);
513 false$
515 featurep(x,odd);
516 false$
518 featurep(%i,even);
519 false$
521 featurep(2*x, even);
522 false$
524 featurep(false, even);
525 false$
527 featurep(true,even);
528 false$
530 featurep(false, odd);
531 false$
533 featurep([false], odd);
534 false$
536 featurep(a<b, even);
537 false$
539 featurep(rat(a<b),even);
540 false$
542 featurep(5 = 7, odd);
543 false$
545 featurep([2,4,6],even);
546 false$
548 (declare(ni, integer, me, even, no, odd, ne, even, mo,odd),0);
551 featurep(me,even);
552 true$
554 featurep(no,odd);
555 true$
557 featurep(2*ni, even);
558 true$
560 featurep(2*ni+1,odd);
561 true$
563 featurep(-me,even);
564 true$
566 featurep(-me,odd);
567 false$
569 featurep(abs(me),even);
570 true$
572 featurep(abs(mo),odd);
573 true$
575 featurep(ni * me, even);
576 true$
578 featurep(ni * no, odd);
579 false$
581 featurep(me + ne, even);
582 true$
584 featurep(me - ne, even)$
585 true$
587 featurep(7*me - 9*ne, even)$
588 true$
590 featurep(no * mo, odd);
591 true$
593 featurep(no + mo, odd);
594 false$
596 featurep(me^7, even);
597 true$
599 featurep(me^7, odd);
600 false$
602 featurep(me^(-9), even);
603 false$
605 featurep(no^7, odd);
606 true$
608 featurep(no^(-7), odd);
609 false$
611 featurep(no^ni, even);
612 false$
614 featurep(ne^%i, even);
615 false$
617 featurep(rat(x+x*y,x), even);
618 false$
620 featurep(rat(ne),even);
621 true$
623 featurep(rat(ne^2 + 5 * ne),even);
624 true$
626 featurep(rat(no), odd);
627 true$
629 /* ... open it close it, break it fix it, ... declare it, remove it */
631 (remove(ni, integer, me, even, no, odd, ne, even, mo,odd),0);
638 floor(42);
641 floor(-128);
642 -128$
644 floor(-5/2);
647 floor(0);
650 floor(0.0);
653 floor(0.0b0);
656 floor(5/2);
659 floor(-5.6);
662 floor(7.8);
665 floor(-5.6b0);
668 floor(7.8b0);
671 floor(%pi);
674 floor(%e);
677 floor(%phi);
680 floor(minf);
681 und$
683 floor(inf);
684 und$
686 floor(infinity);
687 und$
689 floor(zeroa);
692 floor(zerob);
695 floor(und);
696 und$
698 floor(ind);
699 und$
701 floor(floor(x));
702 '(floor(x))$
704 floor(5 + floor(x));
705 5 + floor(x)$
707 floor(floor(x) + floor(y));
708 floor(x) + floor(y)$
710 floor(floor(x) - floor(y));
711 floor(x) - floor(y)$
713 floor(floor(x) * floor(y));
714 floor(x) * floor(y)$
716 floor(6 * floor(x) + 28 * floor(y));
717 6 * floor(x) + 28 * floor(y)$
719 floor(ceiling(x));
720 ceiling(x)$
722 (declare(n,integer),0);
725 floor(n);
728 floor(abs(n));
729 abs(n)$
731 (declare(np,integer),0);
734 (assume(np >= 0),0);
737 floor(np!);
738 np!$
740 floor(n + 1932);
741 n + 1932$
743 floor(n - 128);
744 n - 128$
746 floor(n^5);
747 n^5$
749 (assume(n > 0),0);
752 floor(5^n);
753 5^n$
755 floor(-n);
758 (declare(m,integer),0);
761 (assume(m < 0),0);
764 floor(7^m);
765 '(floor(7^m))$
767 floor(n*m);
768 n*m$
770 floor(n + m);
771 n + m$
773 floor(n -m);
774 n - m$
776 floor(6*n - 28 * m);
777 6*n - 28 * m$
779 floor(abs(n+m)!);
780 abs(n+m)!$
782 floor(abs(n) - n);
783 abs(n) - n$
785 floor(max(n,m));
786 max(n,m)$
788 floor(min(n,m));
789 min(n,m)$
791 floor(x+17);
792 floor(x) + 17$
794 floor(a*b - 32);
795 floor(a*b) - 32$
797 floor(-x);
798 -ceiling(x)$
800 floor(-exp(x));
801 -ceiling(exp(x))$
803 floor(rat(x));
804 floor(x)$
806 floor(107^5 + 1/8);
807 107^5$
809 floor(10! + 1/%pi);
810 10!$
812 floor(104! + 1/%e);
813 104!$
815 floor(-107^5 + 1/8);
816 -107^5$
818 floor(-10! + 1/%pi);
819 -10!$
821 floor(-104! + 1/%e);
822 -104!$
824 floor(1007^3 + 9/17);
825 1007^3$
827 floor(n + 1/%pi);
830 floor(n - 1/%pi);
831 n - 1$
833 floor(2 * n + 2/3);
834 2 * n$
836 floor(abs(n) + 1/5);
837 abs(n)$
839 floor(max(n,6) + 1/3);
840 max(n,6);
842 floor(n * m + 1/%e);
843 n * m$
845 floor(n + m - 2/3);
846 n + m -1$
848 floor(5 * n - 7 * m);
849 5 * n - 7 * m$
851 floor(5 * n - 7 * m + 1/8);
852 5 * n - 7 * m$
854 floor(7 + %i/5);
855 7 + floor(%i / 5)$
857 floor(2 * n + 5 + 3/%pi);
858 2 * n + 5$
860 is(floor(sqrt(117)) <=  sqrt(117));
861 true$
863 floor(107! / 2) + ceiling(107! / 2) - 107!;
866 floor(-107! / 2) + ceiling(-107! / 2) + 107!;
869 sum(floor(k * 17 / 5),k,1,4);
870 16 * 4 / 2$
872 sum(floor(k * 17 / 507),k,1,506);
873 16 * 506 / 2$
875 ceiling(x) + floor(-x);
878 sum(floor((41 + k)/27),k,0,26);
881 sum(floor((-41 + k)/27),k,0,26);
882 -41$
884 sum(floor(%pi + k/56),k,0,55) - floor(56 * %pi);
887 sum(floor(-sqrt(1932) + k/56),k,0,55) - floor(-56 * sqrt(1932));
891 floor(sqrt(978) + sqrt(979)) - floor(sqrt(4* 978 + 2));
894 floor(%i^%i);
897 floor(acos(67) + 42);
898 floor(acos(67)) + 42$
900 /* See "Concrete Mathematics", 3.27, page 87. */
902 sum(floor(sqrt(k)),k,1,25^2-1);
903 25^2 * 25 - 25^3 / 3 - 25^2/2 - 25/6$
905 expand(floor(sqrt(5) * (sqrt(5) - 1/sqrt(5))));
908 floor(10! * sqrt(5) *(sqrt(5) - 1/sqrt(5)) + 1/(10^6 *%pi));
909 4 * 10!$
911 floor(10! * sqrt(5) *(sqrt(5) - 1/sqrt(5)) + 1/(10^9 *%pi));
912 4 * 10!$
914 floor(sqrt(5) *(sqrt(5) - 1/sqrt(5)) + 1/(10^15 *%pi));
917 floor(sqrt(5) *(sqrt(5) - 1/sqrt(5)) + 1/(10^159 *%pi) + 1/2);
920 (declare(ne,even, no, odd),0);
923 floor(ne);
926 floor(28 * ne - 5);
927 28 * ne - 5$
929 floor(ne / 2 - 14);
930 ne / 2 - 14$
932 floor(no);
935 floor(ne/2);
936 ne/2$
938 floor((no + 1)/2);
939 (no + 1)/2$
941 (remove(ne,even, no,odd),forget(np >= 0), 0);
944 (forget(m < 0, n >0), remove(n,integer),remove(m,integer), remove(np,integer), 0);
948 featurep(-1,integer);
949 true$
951 featurep(0,integer);
952 true$
954 featurep(1,integer);
955 true$
957 featurep(%pi,integer);
958 false$
960 featurep(x,integer);
961 false$
963 featurep(-x,integer);
964 false$
966 featurep(signum(x),integer);
967 false$
969 featurep(charfun(a < b),integer);
970 true$
972 featurep(floor(2001 + x/z),integer);
973 true$
975 featurep(ceiling(a*b+c),integer);
976 true$
978 (declare(ne,even,no,odd, ni, integer),0);
981 featurep(ni,integer);
982 true$
984 featurep(ni + 8, integer);
985 true$
987 featurep(ni + ne, integer);
988 true$
990 featurep(abs(ni + 371)!,integer);
991 true$
993 featurep(23 * ne,integer);
994 true$
996 featurep(-23 * ne + 15,integer);
997 true$
999 featurep(ni^89,integer);
1000 true$
1002 featurep(ni^-89,integer);
1003 false$
1005 featurep(ni / ne,integer);
1006 false$
1008 featurep(abs(ni),integer);
1009 true$
1011 featurep(ni^(no^2), integer);
1012 true$
1014 featurep(abs(ni), integer);
1015 true$
1017 featurep(abs(ne/2),integer);
1018 true$
1020 (remove(ne,even,no,odd,ni,integer),0);
1027 lmax([]);
1028 minf$
1030 lmax(set());
1031 minf$
1033 lmin([]);
1034 inf$
1036 lmin(set());
1037 inf$
1039 lmax([2,3,5]);
1042 lmax(set(2,3,4));
1045 lmin([2,3,4]);
1048 lmin(set(2,3,4));
1051 lmax([x]);
1054 lmin([x]);
1057 lmax([x,x,x]);
1060 lmin([x,x,x]);
1063 lmax(makelist(1/i,i,1,1000));
1066 lmin(makelist(1/i,i,1,1000));
1067 1/1000$
1069 (maxmin_effort : 3,0);
1072 /*---boundary cases---*/
1073 max();
1074 minf$
1076 min();
1077 inf$
1079 /*----singleton cases---*/
1081 max(a);
1084 min(a);
1087 max(inf);
1088 inf$
1090 max(minf);
1091 minf$
1093 (assume(-1 < x, x < 1),0);
1096 max(acos(x));
1097 acos(x)$
1099 min(acos(x));
1100 acos(x)$
1102 max(log(x+2));
1103 log(x+2)$
1105 min(log(x+2));
1106 log(x+2)$
1108 (forget(-1 < x, x < 1),0);
1111 max(a-b);
1112 a-b$
1114 min(a-b);
1115 a-b$
1117 max(1/x);
1118 1/x$
1120 min(1/x);
1121 1/x$
1123 max(-x);
1126 min(-x);
1127 min(-x)$
1130 /*---numbers----*/
1132 min(1,2,3);
1135 max(1,2,3);
1138 min(1,1/5,-8);
1141 max(1,1/5,-8);
1144 max(0.34,9.1);
1145 9.1$
1147 min(0.34,9.1);
1148 0.34$
1150 max(0.34b0,9.1);
1151 9.1$
1153 min(0.34b0,9.1);
1154 0.34b0$
1156 /*--- extended reals ---*/
1158 max(3,inf);
1159 inf$
1161 max(3, minf);
1164 min(2/3,inf);
1165 2/3$
1167 min(2/3,minf);
1168 minf$
1170 max(inf,minf);
1171 inf$
1173 min(inf,minf);
1174 minf$
1176 max(inf,minf,2,3);
1177 inf$
1179 min(inf,2,3);
1182 max(x,inf,minf);
1183 inf$
1185 min(x,minf,inf);
1186 minf$
1188 max(minf,a,b,inf);
1189 inf$
1191 min(a,b,minf,inf);
1192 minf$
1194 max(7.78b0, inf);
1195 inf$
1198 /*--flatten----*/
1200 max(a,max(b,c));
1201 max(a,b,c)$
1203 min(a,min(b,c));
1204 min(a,b,c)$
1206 min(a,min(b,min(c,d)));
1207 min(a,b,c,d)$
1209 max(a,max(b,max(c,d)));
1210 max(a,b,c,d)$
1212 max(max(a,b),max(c,d));
1213 max(a,b,c,d)$
1215 min(min(a,b),min(c,d));
1216 min(a,b,c,d)$
1218 /*--non-comparable cases--*/
1220 (xx : max(und,false,true,%i,ind,3,4,5), cons(op(xx), args(xx)));
1221 [max, 5, %i, ind, und, true, false]$
1223 (xx : min(und,false,true,%i,ind,3,4,5), cons(op(xx), args(xx)));
1224 [min, 3, %i, ind, und, true, false]$
1226 (xx : max(a < b, a,a,b), cons(op(xx), args(xx)));
1227 [max, a, a < b, b]$
1229 (xx : min(a # b, a,a,b,a), cons(op(xx), args(xx)));
1230 [min, a, a # b, b]$
1232 /*---symbolic----*/
1234 (remvalue(xx),max(a,b,a));
1235 max(a,b)$
1237 min(a,b,b);
1238 min(a,b)$
1240 max(a,b) - max(b,b,a);
1243 min(a,b) - min(a,a,a,b);
1246 min(0,a^2);
1249 max(0,-a^2);
1252 max(x,abs(x));
1253 abs(x);
1255 max(u,n,k,u+1,n+2,k+3);
1256 max(u+1,n+2,k+3);
1258 min(u,n,k,u+1,n+2,k+3);
1259 min(u,n,k);
1261 max(x^2, x^2+1,-6);
1262 x^2 + 1$
1264 /*--CRE expressions----*/
1266 ratdisrep(max(x,rat(x)));
1269 ratdisrep(min(x,rat(x)))$
1272 ratdisrep(max(rat(x*y)));
1273 x*y$
1275 ratdisrep(max(rat(x^2+y,x), rat(x^2+y,y)));
1276 x^2+y$
1278 /*--absolute values---*/
1280 max(x,abs(x));
1281 abs(x)$
1283 min(x,abs(x));
1284 min(x,abs(x))$
1286 max(abs(x),5*abs(x), 7*abs(x));
1287 7*abs(x)$
1289 min(abs(x),5*abs(x), 7*abs(x));
1290 abs(x)$
1292 max(acos(x), acos(x) + 1);
1293 acos(x)+1$
1295 min(log(x), log(x) + %pi);
1296 log(x)$
1299 /*---other-----*/
1301 (median(a,b,c) := min(max(a,b),max(b,c),max(a,c)),0);
1304 median(1,2,3);
1307 median(-56,1,%pi);
1310 median(x,x,x);
1313 median(x,x,y);
1316 median(abs(x),0,-abs(x));
1319 median(a,a+1,a+28);
1320 a+1$
1322 median(exp(x+1), exp(x+2), exp(x));
1323 exp(x+1)$
1325 /*-- try a higher value of maxmin_effort ----*/
1327 (maxmin_effort : 3,0);
1330 max(x,-x);
1331 abs(x)$
1333 min(x,-x);
1334 -abs(x)$
1336 max(x,7,-x);
1337 max(7,abs(x));
1339 max(x,-7,-x);
1340 abs(x)$
1342 min(x,7,-x);
1343 -abs(x)$
1345 max(-cos(x^2), cos(x), cos(x^2));
1346 max(cos(x), abs(cos(x^2)))$
1348 min(-cos(x^2), cos(x), cos(x^2));
1349 min(cos(x), -abs(cos(x^2)))$
1351 /*--try a higher maxmin_effort-----*/
1353 (maxmin_effort : 10,0);
1356 max(x,2*x,3*x);
1357 max(x,3*x);
1359 min(x,2*x,3*x);
1360 min(x,3*x);
1362 max(x,0,2*x,3*x);
1363 max(0,3*x);
1365 min(x,0,2*x,3*x);
1366 min(0,3*x);
1368 max(x^2,x^4,x^6);
1369 max(x^2,x^6);
1371 min(x^2,x^4,x^6);
1372 min(x^2,x^6);
1374 (kill(median),0);
1380 (kill(all),0);
1383 mod(12,0);
1386 mod(x,0);
1389 mod(5,3);
1392 mod(5,-3);
1395 mod(-5,3);
1398 mod(-5,-3);
1401 [mod(5.0, 3.0), mod(5.0, -3.0), mod(-5.0, 3.0), mod(-5.0, -3.0)];
1402 [2.0, -1.0, 1.0, -2.0];
1404 [mod(5.0b0, 3.0b0), mod(5.0b0, -3.0b0), mod(-5.0b0, 3.0b0), mod(-5.0b0, -3.0b0)];
1405 [2.0b0, -1.0b0, 1.0b0, -2.0b0];
1407 /* I'd rather do this up to 10^6 at least but it takes too long. Oh well. */
1408 every (lambda ([k], mod(float(k*k), float(k)) = 0.0), makelist (k, k, 1, 10000));
1409 true;
1411 every (lambda ([k], mod(bfloat(k*k), bfloat(k)) = 0.0b0), makelist (k, k, 1, 10000));
1412 true;
1414 mod(0,0);
1417 mod(0,x);
1420 mod(x,1);
1421 x - floor(x);
1423 mod(x,0);
1426 mod(a*x,a*y);
1427 a * mod(x,y)$
1429 floor(sqrt(5)) + mod(sqrt(5),1);
1430 sqrt(5)$
1432 floor(-sqrt(5)) + mod(-sqrt(5),1);
1433 -sqrt(5)$
1435 mod(%pi,1);
1436 %pi-3$
1438 /* Some tests for rat(float) */
1440 ratprint:false;
1441 false$
1443 makelist(ratdisrep(rat(0.333333)),ratepsilon,[1e-1,1e-2,1e-3,1e-4,1e-5, 1e-7, 1e-15, 1e-100, 1e-300]);
1444 [1/3,1/3,1/3,1/3,1/3,333332/999997,333333/1000000,333333/1000000,333333/1000000]$
1446 makelist(ratdisrep(rat(float(%e))),ratepsilon,[1e-1,1e-2,1e-3,1e-4,1e-5, 1e-7, 1e-15, 1e-100, 1e-300]);
1447 [8/3,19/7,87/32,193/71,1264/465,2721/1001,28245729/10391023,325368125/119696244,325368125/119696244]$
1449 ratepsilon: 2e-4;
1450 2e-4$
1452 ratdisrep(map('rat,[0.1415914,0.0,-0.9999,0.99999,-1.0001,1.00001,0.501099]));
1453 [16/113,0,-1,1,-1,1,227/453]$
1455 /* Denormalized numbers -- SF bug 3777 */
1457 setify(makelist(float(rat(1.2345e-320))-1.2345e-320,ratepsilon,[1e-1,1e-2,1e-3,1e-4,1e-5, 1e-7, 2e-15, 1e-100, 1e-300]));
1458 {0.0}$
1460 /* Wait for 3778 to be fixed */
1461 /* setify(makelist(float(rat(-1.5432e-320))-1.5432e-320,ratepsilon,[1e-1,1e-2,1e-3,1e-4,1e-5, 1e-7, 2e-15, 1e-100, 1e-300])); */
1462 /* {0.0} */
1464 (ratepsilon:2e-15,0);
1468 /* rationalize */
1470 (fpprec : 18,0);
1473 rationalize(-46);
1474 -46$
1476 rationalize(-2/3);
1477 -2/3$
1479 rationalize(0);
1482 rationalize(0.25);
1483 1/4$
1485 rationalize(0.25b0);
1486 1/4$
1488 rationalize(2.5b-1);
1489 1/4$
1491 rationalize(0.35b0 - 3.5b-1);
1494 rationalize(-0.75);
1495 -3/4$
1497 rationalize(1.125);
1498 9/8$
1500 rationalize(100.125b0);
1501 801/8$
1503 rationalize(-100.125b0);
1504 -801/8$
1506 rationalize(%i);
1509 rationalize(%pi);
1510 %pi$
1512 rationalize(minf);
1513 minf$
1515 rationalize(inf);
1516 inf$
1518 rationalize(infinity);
1519 infinity$
1521 rationalize(x);
1524 rationalize(-x);
1527 rationalize(a+b/c);
1528 a+b/c$
1530 rationalize(a^b);
1531 a^b$
1533 rationalize(log(0.25 * x - 0.5));
1534 log(x/4 - 1/2)$
1536 rationalize([u,n,k]);
1537 [u,n,k]$
1539 rationalize(v.t);
1540 v.t$
1542 rationalize(a^^0.125);
1543 a^^(1/8)$
1545 block([ratprint : false], rationalize(rat(a+b + 0.125)));
1546 (8 * a + 8 * b + 1)/8$
1548 block([ratprint : false], rationalize(rat(1+x+x^2.0)));
1549 1+x+x^2$
1551 rationalize(matrix([a,0.25],[-a,2.0^z]));
1552 matrix([a,1/4],[-a,2^z]);
1554 rationalize([[0.75],[m,j,w],[-2.0],[a.m.h]]);
1555 [[3/4],[m,j,w],[-2],[a.m.h]]$
1557 rationalize(f(-0.1875) + %pi * 3.0);
1558 f(-3/16) + 3 * %pi$
1560 rationalize(f(-0.1875b0) + %pi * 3.0);
1561 f(-3/16) + 3 * %pi$
1563 rationalize(a = 2.5);
1564 a = 5/2$
1566 rationalize(abs(x - 0.1875));
1567 abs(x - 3/16)$
1569 rationalize(x!);
1572 rationalize(0.09375 < 0.3984375);
1573 3/32 < 51/128$
1575 rationalize(0.09375b0 < 0.3984375b0);
1576 3/32 < 51/128$
1578 (reset (fpprec), 0);
1581 /* SF bug 1703298  max leads to UND error */
1583 max(1/(q-1));
1584 1/(q-1)$
1586 max(1/(q-1),1/(q-1));
1587 1/(q-1)$
1589 sort(args(max(1/(q-1),1/(q-2))));
1590 ''(sort([1/(q-1),1/(q-2)]))$
1592 is(compare(1/(q-1),minf) = ">");
1593 true$
1595 is(compare(minf, 1/(q-1)) = "<");
1596 true$
1598 /* SF bug 1703376  max(inf, ...) doesn't simplify to inf */
1600 max(1/(1-x),inf);
1601 inf$
1603 min(1/(1-x),minf);
1604 minf$
1606 /* SF bug 1764114  signum misses simp rule */
1608 (tellsimpafter (signum(x), zzz), signum(-x));
1609 -zzz;
1611 floor(log(8) / log(2));
1614 ceiling(log(8) / log(2));
1617 floor(log(125) / log(5) + 42 / 5);
1620 ceiling(log(125) / log(5) + 42 / 5);
1623 /* SF bug [ 1220227 ] MIN is not correct (problem with "is" function) */
1625 (f(h,k,l):=(h^k)*((1/h)*k*(1+l)+(d-k)*2*l),
1626  g(h,k,l):=2*d*l+(h^k)*((1/h)*k*(1-l)-(d-k)*2*l),
1627  d:2,
1628  l:0.5,
1629  aa: f((1-v)^(1/2),2,l),
1630  bb: f((1-v),1,l),
1631  cc: g(v^(1/2),2,l),
1632  dd: g(v,1,l),
1633  0);
1636 block([ratprint : false],min (aa, bb, cc, dd));
1637 min(3.0*sqrt(1-v),1.0*sqrt(v)+2.0,(1.5/(1-v)+1.0)*(1-v))$
1639 block([ratprint : false], ratsimp (bb - dd));
1642 block ([prederror : false], is (cc > aa));
1643 unknown;
1645 block ([prederror : false], is (cc > bb));
1646 unknown;
1648 block ([prederror : false], is (cc > dd));
1649 unknown;
1651 /* SF bug [ 1995595 ] sign(max(7,x) - max(6,x)) --> error */
1653 sign (max (7, foo543) - max (6, foo543));
1654 pnz;
1656 /* SF bug [ 2144225 ] rationalize bug / fix (?) */
1657 map('rationalize, [cos(s)]);
1658 [cos(s)]$
1660 map(lambda([s], rationalize(s)), [cos(s)]);
1661 [cos(s)]$
1663 integrate(floor(x),x);
1664 (-floor(x)+2*x-1)*floor(x)/2$
1666 integrate(floor(x),x,0,3);
1669 integrate(ceiling(x),x);
1670 (-ceiling(x)+2*x+1)*ceiling(x)/2$
1672 integrate(ceiling(x),x,0,4);
1675 (remvalue(d, l, aa, bb, cc, dd),0);
1678 /* Bug report ID: 2123651 - min and max of imaginary and real numbers
1679  * These are the examples from the bug report.
1680  */
1682 (xx : min(%i*inf,inf), cons(op(xx), args(xx)));
1683 [min, inf,%i*inf]$
1685 (xx : min(%i*minf,minf), cons(op(xx), args(xx)));
1686 [min, minf,%i*minf];
1688 (xx : min(%i*inf,inf), cons(op(xx), args(xx)));
1689 [min, inf, %i*inf]$
1691 (xx : min(%i*minf,minf), cons(op(xx), args(xx)));
1692 [min,minf,%i*minf];
1694 (xx : min(%i*-inf,-inf), cons(op(xx), args(xx)));
1695 [min, - %i*inf, minf]$
1697 (xx : min(%i*-inf,minf), cons(op(xx), args(xx)));
1698 [min, - %i*inf, minf]$
1700 (xx : min(%i*minf,-inf), cons(op(xx), args(xx)));
1701 [min, minf,%i*minf];
1703 (xx : max(%i*minf,inf), cons(op(xx), args(xx)));
1704 [max, inf,%i*minf];
1706 (xx : max(%i*minf,minf), cons(op(xx), args(xx)));
1707 [max, minf,%i*minf];
1709 (xx : max(%i*inf,inf), cons(op(xx), args(xx)));
1710 [max, inf,%i*inf];
1712 (xx : max(%i*-inf,-inf), cons(op(xx), args(xx)));
1713 [max,-inf,%i*-inf];
1715 (xx : max(%i*minf,minf), cons(op(xx), args(xx)));
1716 [max,minf,%i*minf];
1718 (xx : max(7*%i*inf+4*inf,4*%i*inf+3), cons(op(xx), args(xx)));
1719 [max, 4*%i*inf+3,7*%i*inf+4*inf];
1721 (xx : min(7*%i*inf+4*inf,4*%i*inf+3), cons(op(xx), args(xx)));
1722 [min,4*%i*inf+3,7*%i*inf+4*inf]$
1724 (xx : min(7*%i*minf+4*inf,4*%i*minf+3), cons(op(xx), args(xx)));
1725 [min,4*%i*minf+3,7*%i*minf+4*inf]$
1727 (xx : min(7*%i*minf+4*inf,4*%i*-inf+3), cons(op(xx), args(xx)));
1728 [min,4*%i*-inf+3,7*%i*minf+4*inf];
1730 (remvalue(xx), min(-inf,minf));
1731 minf;
1733 max(-inf,minf);
1734 -inf;
1736 /* mailing list 2016-03-11: "bfloat divide bad; WAS: nonzero remainder of mod(x*x, x) where x is a small integer float or bigfloat" */
1738 sublist (makelist (i, i, 1, 1000), lambda ([i], float(i*i)/float(i) - float(i) # 0.0));
1741 sublist (makelist (i, i, 1, 1000), lambda ([i], float(i)/float(i) # 1.0));
1744 sublist (makelist (i, i, 1, 1000), lambda ([i], bfloat(i*i)/bfloat(i) - bfloat(i) # 0b0));
1747 sublist (makelist (i, i, 1, 1000), lambda ([i], bfloat(i)/bfloat(i) # 1b0));
1750 sublist (makelist (i, i, 1, 1000), lambda ([i], mod (float(i*i), float(i)) # 0.0));
1753 sublist (makelist (i, i, 1, 1000), lambda ([i], mod (float(i), float(i)) # 0.0));
1756 sublist (makelist (i, i, 1, 1000), lambda ([i], mod (bfloat(i*i), bfloat(i)) # 0b0));
1759 sublist (makelist (i, i, 1, 1000), lambda ([i], mod (bfloat(i), bfloat(i)) # 0b0));
1762 /* See #3736 Quoting either min or max inhibits simplification */ 
1763 'max(1,1);
1766 'min(1,1);
1769 values;
1772 contexts;
1773 [initial, global]$
1775 (reset(ratprint),0);