# Check if infinite solutions to a system of polynomial equations?

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?

• (1) If you relax the reals requirement you can use 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, then FindInstance providing more solutions than that bound suffices to show the solution set is infinite. Oct 13, 2020 at 21:47
• Why does Reduce not help. If the results of reduce are functions of some variables, you know that there are an infinity of solutions. Oct 14, 2020 at 12:19
• @DanielLichtblau, (1) That seems to work, thanks! (2) I wasn't aware of Bézout. It looks like it won't help me because not all my polynomials are homogeneous (?) e.g. one of my surfaces is x^2 + y^2 + (z^2 + 1)*(z^4 - 1)/4 == 0.
– ppm
Oct 14, 2020 at 19:02
• @DanielHuber How can I check for functions in the output of Reduce? And is Reduce guaranteed to only output functions in the infinite case?
– ppm
Oct 14, 2020 at 19:03
• Use total degrees. Their product is an upper bound and hence applies in the non-homogeneous case. Oct 14, 2020 at 19:07