61 args(ceiling(rat(x)));
64 args(ceiling(rat(a+b)));
70 ceiling(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)$
88 (declare(n,integer),0);
118 (declare(m,integer),0);
136 ceiling(6*n - 28 * m);
145 (forget(m < 0, n >0), 0);
169 ceiling(x + 10!) + floor(-x - 10!);
172 ceiling(a/b + 1909) + floor(-a/b - 1909);
190 (kill(x,numerval),0);
193 (kill(xx), assume(0 < xx, xx < 1),0);
208 (kill(xx), assume(0 <= xx, xx < 1),0);
217 (kill(xx), assume(0 < xx, xx <= 1),0);
226 (assume(-1 < yy, yy < 0),0);
235 (kill(yy), assume(-1 <= yy, yy < 0),0);
244 (kill(yy), assume(-1 < yy, yy <= 0),0);
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));
281 ceiling(5 * signum(x));
282 ceiling(5 * signum(x))$
284 ceiling(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);
296 ceiling(ne * no / 2);
314 (remove(ne,even, no,odd),0);
317 (remove(n,integer),remove(m,integer),0);
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));
359 (p : charfun(not(equal(x,1))),0);
369 charfun(not(equal(z,1)))$
371 (p : charfun(-1 < x and x < 1),0);
389 block ([prederror : true], charfun (x < 1));
394 is(compare(1,2) = "<");
397 is(compare(2,1) = ">");
400 is(compare(2,2) = "=");
403 is(compare(x,abs(x)) = "<=");
406 is(compare(abs(x),x) = ">=");
409 is(compare(1/x,0) = "#");
424 is(compare(%i,%i) = "=");
427 is(compare(a < b, a < b) = "=");
430 is(compare(rat(x),x) = "=");
433 compare([1,2],[5,6]);
439 /* With revision 1.15 of maxmin.lisp this result has changed to notcomparable */
440 is(compare(infinity,infinity) = "=");
443 is(compare(inf,inf) = "=");
446 compare(infinity,inf);
449 is(compare(inf,-minf) = "=");
452 is(compare(inf,inf+7) = "=");
455 is(compare(inf,minf) = ">");
458 is(compare(inf,-inf) = ">");
461 is(compare(minf,-minf) = "<");
464 is(compare(log(x), log(x) + 1) = "<");
467 is(compare(log(x), log(x)) = "=");
470 is(compare(acosh(x^2+1), acosh(x^2+1) + 1) = "<");
506 featurep(5.6b0, even);
509 featurep(5.7b0, odd);
524 featurep(false, even);
530 featurep(false, odd);
533 featurep([false], odd);
539 featurep(rat(a<b),even);
542 featurep(5 = 7, odd);
545 featurep([2,4,6],even);
548 (declare(ni, integer, me, even, no, odd, ne, even, mo,odd),0);
557 featurep(2*ni, even);
560 featurep(2*ni+1,odd);
569 featurep(abs(me),even);
572 featurep(abs(mo),odd);
575 featurep(ni * me, even);
578 featurep(ni * no, odd);
581 featurep(me + ne, even);
584 featurep(me - ne, even)$
587 featurep(7*me - 9*ne, even)$
590 featurep(no * mo, odd);
593 featurep(no + mo, odd);
596 featurep(me^7, even);
602 featurep(me^(-9), even);
608 featurep(no^(-7), odd);
611 featurep(no^ni, even);
614 featurep(ne^%i, even);
617 featurep(rat(x+x*y,x), even);
620 featurep(rat(ne),even);
623 featurep(rat(ne^2 + 5 * ne),even);
626 featurep(rat(no), odd);
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);
707 floor(floor(x) + floor(y));
710 floor(floor(x) - floor(y));
713 floor(floor(x) * floor(y));
716 floor(6 * floor(x) + 28 * floor(y));
717 6 * floor(x) + 28 * floor(y)$
722 (declare(n,integer),0);
731 (declare(np,integer),0);
758 (declare(m,integer),0);
824 floor(1007^3 + 9/17);
839 floor(max(n,6) + 1/3);
848 floor(5 * n - 7 * m);
851 floor(5 * n - 7 * m + 1/8);
857 floor(2 * n + 5 + 3/%pi);
860 is(floor(sqrt(117)) <= sqrt(117));
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);
872 sum(floor(k * 17 / 507),k,1,506);
875 ceiling(x) + floor(-x);
878 sum(floor((41 + k)/27),k,0,26);
881 sum(floor((-41 + k)/27),k,0,26);
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));
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));
911 floor(10! * sqrt(5) *(sqrt(5) - 1/sqrt(5)) + 1/(10^9 *%pi));
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);
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);
957 featurep(%pi,integer);
963 featurep(-x,integer);
966 featurep(signum(x),integer);
969 featurep(charfun(a < b),integer);
972 featurep(floor(2001 + x/z),integer);
975 featurep(ceiling(a*b+c),integer);
978 (declare(ne,even,no,odd, ni, integer),0);
981 featurep(ni,integer);
984 featurep(ni + 8, integer);
987 featurep(ni + ne, integer);
990 featurep(abs(ni + 371)!,integer);
993 featurep(23 * ne,integer);
996 featurep(-23 * ne + 15,integer);
999 featurep(ni^89,integer);
1002 featurep(ni^-89,integer);
1005 featurep(ni / ne,integer);
1008 featurep(abs(ni),integer);
1011 featurep(ni^(no^2), integer);
1014 featurep(abs(ni), integer);
1017 featurep(abs(ne/2),integer);
1020 (remove(ne,even,no,odd,ni,integer),0);
1063 lmax(makelist(1/i,i,1,1000));
1066 lmin(makelist(1/i,i,1,1000));
1074 (put(trylevel,1, maxmin),0);
1077 /*---boundary cases---*/
1084 /*----singleton cases---*/
1098 (assume(-1 < x, x < 1),0);
1113 (forget(-1 < x, x < 1),0);
1161 /*--- extended reals ---*/
1211 min(a,min(b,min(c,d)));
1214 max(a,max(b,max(c,d)));
1217 max(max(a,b),max(c,d));
1220 min(min(a,b),min(c,d));
1223 /*--non-comparable cases--*/
1225 max(und,false,true,%i,ind,3,4,5);
1226 max(und,false,true,%i,ind,5)$
1228 min(und,false,true,%i,ind,3,4,5);
1229 min(und,false,true,%i,ind,3);
1234 min(a # b, a,a,b,a);
1245 max(a,b) - max(b,b,a);
1248 min(a,b) - min(a,a,a,b);
1260 max(u,n,k,u+1,n+2,k+3);
1263 min(u,n,k,u+1,n+2,k+3);
1269 /*--CRE expressions----*/
1271 ratdisrep(max(x,rat(x)));
1274 ratdisrep(min(x,rat(x)))$
1277 ratdisrep(max(rat(x*y)));
1280 ratdisrep(max(rat(x^2+y,x), rat(x^2+y,y)));
1283 /*--absolute values---*/
1291 max(abs(x),5*abs(x), 7*abs(x));
1294 min(abs(x),5*abs(x), 7*abs(x));
1297 max(acos(x), acos(x) + 1);
1300 min(log(x), log(x) + %pi);
1306 (mode(a,b,c) := min(max(a,b),max(b,c),max(a,c)),0);
1318 /*--- sign can't handle this
1321 ----------------------------*/
1323 mode(abs(x),0,-abs(x));
1329 mode(exp(x+1), exp(x+2), exp(x));
1332 /*-- try a higher trylevel----*/
1334 (put(trylevel,2,maxmin),0);
1352 max(-cos(x^2), cos(x), cos(x^2));
1353 max(cos(x), abs(cos(x^2)))$
1355 min(-cos(x^2), cos(x), cos(x^2));
1356 min(cos(x), -abs(cos(x^2)))$
1358 /*--try a higher trylevel-----*/
1360 (put(trylevel,3,maxmin),0);
1408 [mod(5.0, 3.0), mod(5.0, -3.0), mod(-5.0, 3.0), mod(-5.0, -3.0)];
1409 [2.0, -1.0, 1.0, -2.0];
1411 [mod(5.0b0, 3.0b0), mod(5.0b0, -3.0b0), mod(-5.0b0, 3.0b0), mod(-5.0b0, -3.0b0)];
1412 [2.0b0, -1.0b0, 1.0b0, -2.0b0];
1414 /* I'd rather do this up to 10^6 at least but it takes too long. Oh well. */
1415 every (lambda ([k], mod(float(k*k), float(k)) = 0.0), makelist (k, k, 1, 10000));
1418 every (lambda ([k], mod(bfloat(k*k), bfloat(k)) = 0.0b0), makelist (k, k, 1, 10000));
1436 floor(sqrt(5)) + mod(sqrt(5),1);
1439 floor(-sqrt(5)) + mod(-sqrt(5),1);
1469 rationalize(0.25b0);
1472 rationalize(2.5b-1);
1475 rationalize(0.35b0 - 3.5b-1);
1484 rationalize(100.125b0);
1487 rationalize(-100.125b0);
1502 rationalize(infinity);
1517 rationalize(log(0.25 * x - 0.5));
1520 rationalize([u,n,k]);
1526 rationalize(a^^0.125);
1529 rationalize(rat(a+b + 0.125));
1530 (8 * a + 8 * b + 1)/8$
1532 rationalize(rat(1+x+x^2.0));
1535 rationalize(matrix([a,0.25],[-a,2.0^z]));
1536 matrix([a,1/4],[-a,2^z]);
1538 rationalize([[0.75],[m,j,w],[-2.0],[a.m.h]]);
1539 [[3/4],[m,j,w],[-2],[a.m.h]]$
1541 rationalize(f(-0.1875) + %pi * 3.0);
1544 rationalize(f(-0.1875b0) + %pi * 3.0);
1547 rationalize(a = 2.5);
1550 rationalize(abs(x - 0.1875));
1556 rationalize(0.09375 < 0.3984375);
1559 rationalize(0.09375b0 < 0.3984375b0);
1562 (reset (fpprec), 0);
1565 /* SF bug 1703298 max leads to UND error */
1570 max(1/(q-1),1/(q-1));
1573 sort(args(max(1/(q-1),1/(q-2))));
1574 ''(sort([1/(q-1),1/(q-2)]))$
1576 is(compare(1/(q-1),minf) = ">");
1579 is(compare(minf, 1/(q-1)) = "<");
1582 /* SF bug 1703376 max(inf, ...) doesn't simplify to inf */
1590 /* SF bug 1764114 signum misses simp rule */
1592 (tellsimpafter (signum(x), zzz), signum(-x));
1595 floor(log(8) / log(2));
1598 ceiling(log(8) / log(2));
1601 floor(log(125) / log(5) + 42 / 5);
1604 ceiling(log(125) / log(5) + 42 / 5);
1607 /* SF bug [ 1220227 ] MIN is not correct (problem with "is" function) */
1609 (f(h,k,l):=(h^k)*((1/h)*k*(1+l)+(d-k)*2*l),
1610 g(h,k,l):=2*d*l+(h^k)*((1/h)*k*(1-l)-(d-k)*2*l),
1613 aa: f((1-v)^(1/2),2,l),
1620 min (aa, bb, cc, dd);
1621 min (3.0*sqrt(1 - v), 1.0*sqrt(v) + 2.0, (0.5/v - 1.0)*v + 2.0);
1626 block ([prederror : false], is (cc > aa));
1629 block ([prederror : false], is (cc > bb));
1632 block ([prederror : false], is (cc > dd));
1635 /* SF bug [ 1995595 ] sign(max(7,x) - max(6,x)) --> error */
1637 sign (max (7, foo543) - max (6, foo543));
1640 /* SF bug [ 2144225 ] rationalize bug / fix (?) */
1641 map('rationalize, [cos(s)]);
1644 map(lambda([s], rationalize(s)), [cos(s)]);
1647 integrate(floor(x),x);
1648 (-floor(x)+2*x-1)*floor(x)/2$
1650 integrate(floor(x),x,0,3);
1653 integrate(ceiling(x),x);
1654 (-ceiling(x)+2*x+1)*ceiling(x)/2$
1656 integrate(ceiling(x),x,0,4);
1659 (remvalue(d, l, aa, bb, cc, dd),0);
1662 /* Bug report ID: 2123651 - min and max of imaginary and real numbers
1663 * These are the examples from the bug report.
1702 max(7*%i*inf+4*inf,4*%i*inf+3);
1703 'max(4*%i*inf+3,7*%i*inf+4*inf);
1705 min(7*%i*inf+4*inf,4*%i*inf+3);
1706 'min(7*%i*inf+4*inf,4*%i*inf+3);
1708 min(7*%i*minf+4*inf,4*%i*minf+3);
1709 'min(7*%i*minf+4*inf,4*%i*minf+3);
1711 min(7*%i*minf+4*inf,4*%i*-inf+3);
1712 'min(4*%i*-inf+3,7*%i*minf+4*inf);
1720 /* 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" */
1722 sublist (makelist (i, i, 1, 1000), lambda ([i], float(i*i)/float(i) - float(i) # 0.0));
1725 sublist (makelist (i, i, 1, 1000), lambda ([i], float(i)/float(i) # 1.0));
1728 sublist (makelist (i, i, 1, 1000), lambda ([i], bfloat(i*i)/bfloat(i) - bfloat(i) # 0b0));
1731 sublist (makelist (i, i, 1, 1000), lambda ([i], bfloat(i)/bfloat(i) # 1b0));
1734 sublist (makelist (i, i, 1, 1000), lambda ([i], mod (float(i*i), float(i)) # 0.0));
1737 sublist (makelist (i, i, 1, 1000), lambda ([i], mod (float(i), float(i)) # 0.0));
1740 sublist (makelist (i, i, 1, 1000), lambda ([i], mod (bfloat(i*i), bfloat(i)) # 0b0));
1743 sublist (makelist (i, i, 1, 1000), lambda ([i], mod (bfloat(i), bfloat(i)) # 0b0));