1 /* The file rtest_allnummod.mac has tests for max & min. Here is a file for new max & min tests.*/
2 (reset(maxmin_effort),0);
5 /* #3769 max or min called on CRE expressions */
6 max(a,b) - max(rat(a), b);
9 /* #3764 limit of min works with assume but not with asksign */
10 /* I can't figure out how to test for the asksign version of this bug. Here
11 is an assume version, but this wasn't the bug.*/
15 limit(min(x^a,x^(2*a))-x^a,a,inf);
21 /* #3765 min(und,...) gives error with trylevel > 1 */
22 block([maxmin_effort : 1], min(und,%pi));
25 block([maxmin_effort : 2], min(und,%pi));
28 block([maxmin_effort : 3], min(und,%pi));
31 block([maxmin_effort : 10], min(und,%pi));
34 block([maxmin_effort : 1], max(und,%pi));
37 block([maxmin_effort : 2], max(und,%pi));
40 block([maxmin_effort : 3], max(und,%pi));
43 block([maxmin_effort : 10], max(und,%pi));
46 /* #3736 Quoting either min or max inhibits simplification */
53 /* #3508 max(zeroa,zerob) gives zerob */
60 /* #3146 max() runs out of memory when comparing exponential functions */
61 max(2.103-7.053*%e^(-4.0681*10^5*t), 2.0325-6.9825*%e^(-4.9238*10^5*t));
62 max(2.0325-6.9825*%e^(-492380.0*t),2.103-7.053*%e^(-406810.0*t))$
64 /* #1498 min and max of imaginary and real numbers */
104 max(7*%i*inf+4*inf,4*%i*inf+3);
105 max(7*%i*inf+4*inf,4*%i*inf+3)$
107 min(7*%i*inf+4*inf,4*%i*inf+3);
108 min(7*%i*inf+4*inf,4*%i*inf+3)$
110 min(7*%i*minf+4*inf,4*%i*minf+3);
111 min(7*%i*minf+4*inf,4*%i*minf+3)$
113 min(7*%i*minf+4*inf,4*%i*-inf+3);
114 min(7*%i*minf+4*inf,4*%i*-inf+3)$
122 /* #1460 compare(max(1,%i)-%i,0) / FIX */
123 compare(max(1,%i)-%i,0);
126 is(equal(max(1,%i),0));
129 /* #1436 sign(max(7,x) - max(6,x)) --> error */
130 sign(max(7,x) - max(6,x));
133 /* #1172 max(inf, ...) doesn't simplify to inf */
137 /* #1171 max leads to UND error */
141 max(1/(q-1),1/(q-1));
144 compare(minf,1/(q-1));
147 compare(1/(q-1),minf);
150 /* #1073 max and min of an array*/
152 /* For now, let's comment these tests out...some of these bugs stem from
153 things like sign(make_array('any,2)) --> error, for example.
154 (f : make_array('any,2),0);
167 /* #990 ratsubst and sets, floor, ceiling, min, max */
168 ratsubst(a,b,min(a,b));
171 ratsubst(a,b,max(a,b));
174 /* #542 max and min with CRE expressions */
178 /* #398 MAX(a+b,c) is NOT equal to MAX(c,a+b) */
197 /* #338 min/max handles inf/minf/ind but not und */
208 /* does the assign function for maxmin_effort work? */
209 (xxx : maxmin_effort,0);
212 errcatch(maxmin_effort : 2/3);
215 is(maxmin_effort = xxx);
218 errcatch(maxmin_effort : 2<x);
221 is(maxmin_effort = xxx);
227 max(1, cos(x)^2+sin(x)^2);
230 min(1, cos(x)^2+sin(x)^2);
233 max(107, cos(x)^2+sin(x)^2);
236 min(107, cos(x)^2+sin(x)^2);
248 max(3/2, 1.51b0,F(x));
251 max(-inf, minf, log(2), 3/4);
254 max(3,1,4,1,5,9,2,6,5,3);
257 min(3,1,4,1,5,9,2,6,5,3);
272 max(max(a,b),max(c,d));
275 min(min(a,b),min(c,d));
278 min(max(a,b),min(c,d));
281 min(min(a,b),min(c,d));
288 /* Examples from Stavros Macrakis. These are slow for maxmin_effort > 3, so we'll try maxmin_effort = 2*/
289 (maxmin_effort : 2,0)$
292 lreduce('min,makelist(a[i],i,1,20));
293 min(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20])$
295 rreduce('min,makelist(a[i],i,1,20));
296 min(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20])$
298 xreduce('min,makelist(a[i],i,1,20));
299 min(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20])$
301 tree_reduce('min,makelist(a[i],i,1,20));
302 min(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20])$
304 lreduce('max,makelist(a[i],i,1,20));
305 max(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20])$
307 rreduce('max,makelist(a[i],i,1,20));
308 max(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20])$
310 xreduce('max,makelist(a[i],i,1,20));
311 max(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20])$
313 tree_reduce('max,makelist(a[i],i,1,20));
314 max(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20])$
316 (maxmin_effort : 10,0)$
328 max(a,min(b,max(c,min(d,a-1))));
331 max(a,min(a,max(c,min(d,a-1))));
334 (load(unwind_protect),0);
337 block([cntx : newcontext()],
344 block([cntx : newcontext()],
351 block([cntx : newcontext()],
358 block([cntx : newcontext()],
360 (assume(a<b, b<c,c<d),
361 max(a,min(b,max(c,d)))),
365 block([cntx : newcontext()],
367 (assume(b<a, a<c,c< d),
368 max(a,min(b,max(c,d)))),
372 block([cntx : newcontext()],
374 (assume(b<c,c<a,a< d),
375 max(a,min(b,max(c,d)))),
379 block([cntx : newcontext()],
381 (assume(b<c,c<d,d<a),
382 max(a,min(b,max(c,d)))),
386 (reset(maxmin_effort),0);