I have a bunch of implicit algebraic surfaces, and for various combinations of those surfaces, I want to check if the number of intersection points is infinite.
For example, 3 perpendicular cylinders have 8 intersection points.
In[1]:= Solve[x^2 + y^2 == 1 && y^2 + z^2 == 1 && z^2 + x^2 == 1, {x, y, z}, Reals]
Out[1]= {{x -> -(1/Sqrt[2]), y -> -(1/Sqrt[2]), z -> -(1/Sqrt[2])},
{x -> -(1/Sqrt[2]), y -> -(1/Sqrt[2]), z -> 1/Sqrt[2] },
…
Whereas 2 cylinders have infinite intersection points.
In[2]:= Solve[x^2 + y^2 == 1 && x^2 + z^2 == 1, {x, y, z}, Reals]
Out[2]= {{y -> ConditionalExpression[-Sqrt[1 - x^2], -1 <= x <= 1],
z -> ConditionalExpression[-Sqrt[1 - x^2], -1 <= x <= 1]},
…
Length
and CountDistinct
don't help; they get the number of formulas in the list, not the number of solutions described by those formulas.
In[3]:= Solve[x^2 + y^2 == 1 && x^2 + z^2 == 1, {x, y, z}, Reals] // Length
Out[3]= 4
Nor does replacing Solve
with Reduce
.
I came up with a very hacky method: if FindInstance
can find a "large" number of solutions, then guess that there are infinite solutions.
In[4]:= n = 1000;
In[5]:= Length[FindInstance[x^2+y^2-1==0 && y^2+z^2-1==0 && x^2+z^2-1==0, {x,y,z}, Reals, n]] == n
Out[5]= False
In[6]:= Length[FindInstance[x^2+y^2-1==0 && x^2+z^2-1==0, {x,y,z}, Reals, n]] == n
Out[6]= True
But that's unreliable and inefficient. Is there a better way?
NSolve
. It will issue a message for solution sets with positive dimension. (2) If you have a bound on the number of solutions in the finite case, e.g. the Bezout bound, thenFindInstance
providing more solutions than that bound suffices to show the solution set is infinite. $\endgroup$