P1 := x^2+y^2-4:

P2 := y^2-2*x+2:

Original question is find CAD of (some y)[P1 <0 and P2 <0]

how to use maple 12 and maple 2015 to find Q1,Q2,Q3 which are projection of P1 and P2

my book show sample points are [-4,-1-sqrt(7),-3,-2,0,1,3/2,-1+sqrt(7),9/5,2,3]

but FindSamples result is not the same with my book, is it my book wrong or FindSamples function wrong?

I find result of my script is the same as book's quantifier position at 7,8,9 though sample points has little different

how to generalize my following script to multiple variables x, y, z, and more ?

and

I compare with maple 2015 result are different from my book solution, is maple 2015 more advanced version CAD?

with(ListTools):

P1 := x^2+y^2-4:

P2 := y^2-2*x+2:

Q1 := x^2 + 2*x - 6;

Q2 := x^2 - 4;

Q3 := x - 1;

sourcesamples := sort(evalf([solve(Q1), solve(Q2), solve(Q3)]),`<`);

FindSamples:=proc(sourcesamples)

local N, P;

N:=nops(sourcesamples);

P:=proc(a,b)

local a1, b1, m1, n, m;

if a=b then error "Should be a<>b" fi;

a1,b1:=op(convert(sort([a,b],(x,y)->evalf(x)<evalf(y)),rational));

count := 0:

for n from 1 do

m1:=a1*n;

m:=`if`(type(m1,integer),m1+1,ceil(m1));

count := count + 1:

if is(m/n>a1) and is(m/n<b1) then return m/n fi;

od;

print("count=",count);

end proc:

[ceil(sourcesamples[1])-1, seq(op([sourcesamples[i],P(sourcesamples[i],sourcesamples[i+1])]), i=1..N-1),sourcesamples[N],floor(sourcesamples[N])+1];

end proc:

RemoveComplex := proc(yy)

local result, k:

result := []:

for k in yy do

if Im(k) = 0 then

result := [op(result), k]:

end if:

od:

if result = [] then

result := []:

end if:

return result:

end proc:

Joinsolution := proc(param1, param2group)

local result, k:

result := []:

for k in param2group do

result := [op(result), [param1, k]]:

od:

return result:

end proc:

CADsamples := FindSamples(sourcesamples):

CADresult1 := []:

for mm in CADsamples do

#print(mm):

if MakeUnique(RemoveComplex([solve(subs(x=mm, P1)), solve(subs(x=mm, P2))])) = [] then

CADresult1 := [op(CADresult1), op(Joinsolution(mm,[0]))];

else

CADresult1 := [op(CADresult1), op(Joinsolution(mm,FindSamples(sort(evalf(MakeUnique(RemoveComplex([solve(subs(x=mm, P1)), solve(subs(x=mm, P2))]))),`<`))))];

end if:

od:

CADresult1;

for mm in CADresult1 do

if subs(x=mm[1],subs(y=mm[2], P1)) < 0 and subs(x=mm[1],subs(y=mm[2], P2)) < 0 then

print("solution ", mm, SearchAll(mm[1],CADsamples), evalf(mm)):

end if:

od:

Compare with

with(RegularChains):

with(ChainTools):

with(MatrixTools):

with(ConstructibleSetTools):

with(ParametricSystemTools):

with(SemiAlgebraicSetTools):

with(FastArithmeticTools):

R := PolynomialRing([x,y]):

sys := [x^2+y^2-4,y^2-2*x+2]:

N := []:

P := []:

H := [x]:

dec := RealTriangularize(sys,N,P,H,R):

proj := Projection(sys, N, P, H, 1, R);

Display(dec, R);

P := SamplePoints(sys, R);

Display(P, R);

cad := CylindricalAlgebraicDecompose(sys, R);