1 /* Let's place the known bugs at the end. */
3 (kill(all), reset(), load("fourier_elim"), 0);
6 fourier_elim([max(x,0) > 0],[x]);
9 fourier_elim([max(x,0) >= 0],[x]);
12 fourier_elim([min(x,0) >= 0],[x]);
15 fourier_elim([abs(x) <= 1],[x]);
16 [x=1] or [x=-1] or [-1<x,x<1]$
18 fourier_elim([0 < 1],[]);
21 fourier_elim([0 < 1],[x]);
24 fourier_elim([0 >= 1],[]);
27 fourier_elim([0 > 1],[x]);
30 fourier_elim([abs(x) < 1],[x]);
36 fourier_elim([x # inf],[x]);
39 fourier_elim([-x # inf],[x]);
42 fourier_elim([x # minf],[x,y]);
45 fourier_elim([-x # minf],[x,y]);
48 fourier_elim([x # %i],[x,y,z]);
51 fourier_elim([-x # %i],[x]);
54 fourier_elim([x # 0],[x]);
57 fourier_elim([-x # 0],[x]);
60 fourier_elim([x # 10],[x]);
63 fourier_elim([-x # 10],[x]);
64 [-10 < x] or [x < -10]$
66 fourier_elim([x^2 # 100],[x]);
67 [-10 < x,x < 10] or [10 < x] or [x < -10]$
69 fourier_elim([-x^2 # 100],[x]);
72 fourier_elim([x = 5, x <= 5],[x]);
75 fourier_elim([x = 5, x >= 5],[x]);
78 fourier_elim([x = 5, x < 5],[x]);
81 fourier_elim([x = 5],[x]);
84 fourier_elim([x = 5, x = 6],[x]);
87 fourier_elim([x = 5, x < 6],[x]);
90 fourier_elim([x = 5, x > 6],[x]);
93 fourier_elim([x = 5, x >= 5],[x]);
96 fourier_elim([x = 5, x >= 0],[x]);
99 fourier_elim([x = y, y = 7],[x,y]);
102 fourier_elim([x = 2*y + 1, y = 7],[x,y]);
105 fourier_elim([x + y = 2, x - y = 0],[x,y]);
108 fourier_elim([x + y = 2, x - y = 0],[]);
111 (eqs : [0 < x, x < 1, 0 < y, y < 1, 0 < z, x+y+z < 4],0);
114 fourier_elim(eqs,[z,y,x]);
115 [0<z,z<-y-x+4,0<y,y<1,0<x,x<1]$
117 fourier_elim(eqs,[x,y,z]);
118 [0<x,x<min(1,-z-y+4),0<y,y<min(1,4-z),0<z,z<4]$
120 fourier_elim(fourier_elim(eqs,[y,x,z]),[z,y,x]);
121 [0<z,z<-y-x+4,0<y,y<1,0<x,x<1]$
126 fourier_elim([x^2 > 0],[x]);
129 fourier_elim([x^3 > 0],[x]);
132 fourier_elim([x^4 > 0],[x]);
135 fourier_elim([x^2 >= 0],[x]);
138 fourier_elim([x^2 <= 0],[x]);
141 fourier_elim([x^2 + 1 < 0], [x]);
144 fourier_elim([x^2 + 1 > 0], [x]);
147 fourier_elim([x^2 + 1 >= 0], [x]);
150 fourier_elim([x^2 + 1 # 0], [x]);
153 fourier_elim([2^x < 2^y], [x, y]);
156 fourier_elim([1.5^x > 1.5^y], [x, y]);
159 fourier_elim([a * b > 0],[a,b]);
160 [0<a,0<b] or [a<0,b<0]$
162 fourier_elim([x >= x],[x]);
165 fourier_elim([1 >= 1/10],[]);
168 fourier_elim([x^2 # 100],[x]);
169 [-10 < x,x < 10] or [10 < x] or [x < -10]$
171 fourier_elim([x # inf, x # minf],[]);
174 fourier_elim([x # inf],[]);
177 fourier_elim([x # %i],[]);
180 fourier_elim([1-x > 0, x - %e > 0],[x]);
183 fourier_elim([-1/a > 0],[a]);
186 fourier_elim([x # infinity],[x]);
189 fourier_elim([x^2-1 < 0],[x]);
192 fourier_elim([(x^2+1) < 0],[x]);
195 fourier_elim([x^2 < 0],[x]);
198 fourier_elim([x^2+1 = 0],[x]);
201 fourier_elim([x /(1 + x^2) < 1],[x]);
204 fourier_elim([x*(1-x) > 0, (x-12) * (1/2-x) > 0],[x]);
207 fourier_elim([(x-12) * (1/2-x) > 0],[x]);
210 fourier_elim([y >= 0, y <= 0],[y]);
213 fourier_elim([(x-5) / (x-7) <= 10],[x]);
214 [x = 65/9] or [65/9 < x] or [x < 7]$
216 fourier_elim([x*(1-x) < 0, (x-6)*(10-x) < 0],[x]);
217 [10 < x] or [1 < x,x < 6] or [x < 0]$
219 fourier_elim([x*y*z < 0],[x,y,z]);
220 [x<0,0<y,0<z] or [0<x,y<0,0<z] or [0<x,0<y,z<0] or [x<0,y<0,z<0]$
222 fourier_elim([1 = 1],[]);
225 fourier_elim([1 = 1, x + y < 1, x - y > 1],[x,y]);
228 fourier_elim([1 = -1, x + y < 1, x - y > 1],[x,y]);
231 fourier_elim([1 = 0],[]);
234 fourier_elim([inf = 0],[]);
237 fourier_elim([inf = minf],[]);
240 fourier_elim([sqrt(2) = sqrt(5)],[]);
243 fourier_elim([sqrt(2) # sqrt(5)],[]);
246 fourier_elim([max(x,y) < 1, min(x,y) > -1],[x,y]);
250 fourier_elim([min(x,0) > 0],[x]);
253 fourier_elim([x[1] + x[2] < 1, x[1] - x[2] > -1], [x[1], x[2]]);
254 [x[2]-1<x[1],x[1]<1-x[2],x[2]<1]$
256 fourier_elim([rat(x+y) < 1, x - y > -1],[x, rat(y)]);
259 fourier_elim([rat(x*(1-x)) < 0, rat((x-6)*(10-x)) < 0],[x]);
260 [10 < x] or [1 < x,x < 6] or [x < 0]$
262 fourier_elim([x * (x+1) * (x+2) < 0],[y,x]);
263 [-1 < x,x < 0] or [x < -2]$
265 fourier_elim([x * (x+1) * (x+2) < 0, x > -2],[y,x]);
268 fourier_elim([x * (x+1) * (x+2) < 0, x > -2, x > 0],[y,x]);
271 fourier_elim([x < 1 and x > 5],[x]);
274 fourier_elim([x < 1 or x > 5],[x]);
277 fourier_elim([y+x=2,x-y=0, y < 8],[x,y]);
280 fourier_elim([y+x=2,x-y=0, y < 1],[x,y]);
283 fourier_elim([y+x=2,x-y=0, y < 8],[x,y]);
286 fourier_elim([abs(x) + abs(x/2) + abs(x/3) = 1],[x]);
287 [x=-6/11] or [x=6/11]$
289 fourier_elim([abs(x) + abs(x/2) + abs(x/3) # 1],[x]);
290 [x = 0] or [0 < x,x < 6/11] or [-6/11 < x,x < 0] or [x < -6/11] or [6/11 < x]$
292 fourier_elim([max(x,6) < max(x,7)],[x]);
293 [x<6] or [x=6] or [6<x,x<7]$
295 fourier_elim([max(x,6) < max(x,7) - 1],[x]);
298 fourier_elim([max(x,-x) = abs(x)],[x]);
301 fourier_elim([max(x,-x) # abs(x)],[x]);
304 fourier_elim([max(x,-x) < abs(x)],[x]);
307 fourier_elim([min(x,1) < max(x,1)],[x]);
310 fourier_elim([max(x,-x/2) < 1],[x]);
313 fourier_elim([abs(x - abs(x-1)) + abs(x) < 1],[x]);
314 [0<x,x<1/2] or [x=1/2] or [1/2<x,x<2/3]$ /* [0 < x, x < 2/3] is better */
316 fourier_elim([x * (x-1) < a * (a - 1)],[x,a]);
317 [1-a<x,x<a,1/2<a] or [a<x,x<1-a,a<1/2]$
319 fourier_elim([x < 3.14], [x]);
322 fourier_elim([x > 3.14],[x]);
325 fourier_elim([2.78b0 * x > 3.14b0],[x]);
326 [1.129496402877698b0 < x]$
328 fourier_elim([min(x,0) >= 0],[x]);
331 /* This answer isn't wrong, but it could be simplified. */
333 fourier_elim([abs(x - abs(x - abs(x - 23))) > abs(x-1)],[x]);
334 [x<1] or [x=1] or [1<x,x<6] or [11<x,x<23/2] or [x=23/2] or [23/2<x,x<12]$
336 fourier_elim([sqrt(5) * x < 1],[x]);
339 fourier_elim([sqrt(2) < x + y, x < sqrt(5), y < 1],[x,y]);
340 [sqrt(2)-y<x,x<sqrt(5),sqrt(2)-sqrt(5)<y,y<1]$
342 fourier_elim([max(x,y) < min(x,y)],[x,y]);
345 fourier_elim([min(x,y) < max(x,y)],[x,y]);
348 fourier_elim([min(x,y) <= max(x,y)],[x,y]);
349 [x=y] or [x<y] or [y<x]$
351 fourier_elim([0>=x,0=z],[x,z]);
352 [x=0,z=0] or [z=0,x<0]$
354 fourier_elim(x < 1 and x >= 1,[x]);
357 fourier_elim(x <= 1 and x >= 1,[x]);
360 fourier_elim([log(x) > log(a)],[x, a]);
365 fourier_elim([abs(x)>1], [x]);
370 fourier_elim([f(abs(x)) < 0],[x]);
373 fourier_elim([f(abs(x)) > 0],[x]);
376 fourier_elim([log(x) < log(a)],[x,a]);
377 [0 < x, x < a, 0 < a]$
384 affine_p(2*%pi*%i,[x,y,z]);
393 affine_p(x[1],[x[1]]);
405 affine_p(a*x+y,[x,y]);
408 affine_p(a*x+y*sin(q),[x,y]);
411 affine_p((x-y)/(a-b),[x,y]);
414 affine_p((x^2-y^2)/(x-y),[x,y]);
417 affine_p(sin(x),[x]);
432 affine_p(taylor(x,x,0,1),[x]);
435 affine_p((x^2+y^2)/(x-y),[x,y]);
438 affine_p(x[1]^2,[x[1]]);
441 affine_p(x[1]*y[1],[x[1],y[1]]);
444 /* actual regressions */
446 fourier_elim(x = y*z,[x,y,z]); /* #2628 fourier elimination on equality */
450 fourier_elim([x < 1/a],[x]);
453 fourier_elim([x - cos(z) < 0],[x]);
456 fourier_elim([x - z^42 < 0],[x]);
459 /* I think this bug is related to linsolve([x=3.14],[x]) --> [x = 157/50]. Even when
460 keepfloat is true, linsolve converts floats to rationals. */
461 fourier_elim([x<=3.14],[x]);
462 [x = 3.14] or [x < 3.14]$
464 /* end of known bugs */
466 /* #3799 fourier_elim returns non-(in)equations */
468 fourier_elim([x0 + 2*x1 + 2 <= 0, -3*x0 + 4*x1 - 4 <= 0], [x0,x1]);
469 [x0=-8/5,x1=-1/5] or [x0=(4*x1-4)/3,x1<-1/5] or [x0=-2*x1-2,x1<-1/5] or [(4*x1)/3-4/3<x0,x0<-2*x1-2,x1<-1/5]$
471 xxx : fourier_elim([x0 + 2*x1 + 2 <= 0, -3*x0 + 4*x1 - 4 <= 0], [x0]);
472 [x0=-2*x1-2,5*x1+1=0] or [x0=(4*x1-4)/3,-6*(5*x1+1)>0] or [x0=-2*x1-2,-2*(5*x1+1)>0] or [(4*x1)/3-4/3<x0,x0<-2*x1-2,-
475 fourier_elim(subst(x1=-1/5, xxx),[x0]);
478 fourier_elim(subst(x1=-1/5, [x0 + 2*x1 + 2 <= 0, -3*x0 + 4*x1 - 4 <= 0]), [x0]);
481 fourier_elim([a=0],[a]);
484 fourier_elim([a=0],[]);
487 fourier_elim([a=k,a>k],[a]);
490 fourier_elim([a=k,a>k],[k]);
493 fourier_elim([a=k,a>k],[]);
496 fourier_elim([0<=b+x,b<=x],[b,x]);
497 [b=0,x=0] or [b=x,0<x] or [b=-x,0<x] or [-x<b,b<x,0<x]$
499 fourier_elim([0<=b+x,b<=x],[x,b]);
500 [x=0,b=0] or [x=b,0<b] or [x=-b,b<0] or [max(-b,b)<x]$
502 xxx : fourier_elim([0<=b+x,b<=x],[b]);
503 [b=x,x=0] or [b=x,2*x>0] or [b=-x,2*x>0] or [-x<b,b<x,2*x>0]$
505 fourier_elim(xxx,[b,x]);
506 [-x<b,b<x,0<x] or [b=-x,0<x] or [b=x,0<x] or [b=0,x=0]$
508 xxx : fourier_elim([0<=b+x,b<=x],[b]);
509 [b=x,x=0] or [b=x,2*x>0] or [b=-x,2*x>0] or [-x<b,b<x,2*x>0]$
511 fourier_elim(subst(x=107,xxx),[b]);
512 [-107<b,b<107] or [b=-107] or [b=107]$
514 /* #2783 fourier_elim and "domain : complex" */
516 block([domain : complex], fourier_elim((x-1)/(x-5) <= 1/3,[x]));
517 [x=-1] or [-1<x,x<5]$