Basic Examples (3)
Count the number of solutions to a bivariate system:
Compare to the number of solutions produced by Solve:
Compare instead to the number of solutions produced by NSolve:
Scope (5)
Count the solutions to a trivariate system with two polynomials of degree 3 and one of degree 4:
Count the solutions to a larger system:
Count the solutions to an "offset" system, wherein the polynomials are set equal to nonzero constants:
Coefficients need not be rational:
This is somewhat faster than explicitly solving the system:
It is faster still to do the computation at modest finite precision:
Coefficients can be parameters, that is, unknown values:
We check that this is in fact the count for a specific set of parameter values:
An overdetermined system often will have no solutions:
A system of n polynomials in n variables might fail to have a finite solution set:
If we allow z to be a parameter then the solution count is finite:
Options (4)
This is a test system from an ISSAC 2001 conference paper:
It is quite slow to handle at exact precision:
It can be done quite efficiently at a working precision of 200 digits:
This is moreover several times faster than numerically solving the system at the same precision:
A more extreme example comes from a 2009 ISSAC conference paper:
NSolve on this example is 2-3 orders of magnitude slower:
Again, using a probabilistic approach, we count solutions in a certain prime field; with high probability this will agree with the total over the complexes:
Provide a weight matrix for the term ordering:
Use a prime modulus to count solutions for a large system:
This can be done much faster using a monomial order that is particularly well-suited for this system:
Properties and Relations (3)
The Caprasse system has 32 distinct solutions:
A count by multiplicity shows a larger value:
If we slightly perturb the system then Solve will find 56 distinct solutions in agreement with CountPolynomialSolutions:
Possible Issues (4)
Inconsistent results can arise if the system (taken from this Mathematica.StackExchange post) has coefficients with low precision:
We can get a different count by raising the precision:
As is indicated in the StackExchange thread, there are further subtleties-- six of the eight solutions are quite large:
This is because the exact system from which this was taken lives on the "discriminant variety" for systems with the same polynomial structure but having generic coefficients. Had we an exact form for the coefficients, these six would not be present (they go to infinity as the coefficients approach the discriminant variety).
One can isolate to the two expected solutions with some amount of trial and error in setting the Tolerance option of GroebnerBasis: