While I appreciate the other answers given about theoretical foundations of decidability, I can't help but think that the original post - which has the "numerical-methods" category on it - may have been looking for a different kind of answer: something simple that is good enough to get things done... approximately... most of the time... for real-world instances... using something like floating point arithmetic... on polynomials which have less coefficients than the number of atoms that exist in the universe.
So given these relaxed standards of success, here's a simple randomized algorithm that will do.
At a high level, the algorithm is this:
- "De-black box" the polynomial.
- Use e.g. Sturm's theorem or one of the methods here to determine how many real roots there are within some sufficiently large interval.
As you seem to already know about Sturm's theorem, I'll focus on the first part, which is de-black boxing the polynomial.
The first part is nontrivial, but really the basic idea is about as simple as it gets:
- Choose a random real number $r$. Evaluate your polynomial at $f(r)$. Add the pair $(r, f(r))$ to your set of measurements.
- Use Lagrange interpolation to build a model of whatever you think the polynomial currently is based on your set of measurements so far. Call the resulting polynomial $\hat f(r)$.
- Estimate if $f(r) = \hat f(r)$ by trying $N$ randomly generated values $r_1, r_2, ..., r_N$, and seeing if $f(r_n) = \hat f(r_n)$ for all $n$. (Actually, even just setting $N = 1$ can be good enough, as we will see below.)
- If any of them aren't equal, you go back to step 1 and iterate with a new measurement.
- If they are all equal, we declare them to have passed the test and be "probably equal," and thus the algorithm has completed.
The last part is the famous Schwartz-Zippel algorithm, which solves the black-box Polynomial Identity Testing problem in randomized polynomial time.
There are a few things that need to be addressed:
First, from a "pure math" standpoint, there are a few things I've handwaved above in making this rigorous. What model of computation are we using? What does "random" mean? Are we assuming some physical way to generate infinite-precision "random" real numbers and compute stuff with them?
The short answer is that the Schwartz-Zippel algorithm above makes this all rigorous. We do not need magical infinite-precision random real numbers at all. All we need is a sufficiently large, finite set of values to seed our polynomial with, which can be rational numbers or integers or anything else. For instance, we can draw randomly from the set of all reals in $[0, 1)$ with at most 64 bits after the decimal point. Technically, all of these values are rational numbers. The Schwartz-Zippel lemma tells us that even just choosing one number from this set is sufficient to tell $f(x)$ and $\hat f(x)$ apart, as if the two are truly different, the chance you have magically drawn a real number $r$ for which $f(r) = \hat f(r)$ is no greater than $d/2^{64}$, where $d$ is the degree of the polynomial. So as long as we have $d \ll 2^{64}$, we're good to go. And doing this multiple times again decreases our chance of a false positive exponentially.
This also addresses JDH's point above, which in the setting of this answer, takes place in step 5 (the Schwartz-Zippel step). There is always a chance that one can get "false positives" here, and we can only successfully make them "exponentially unlikely" if we have some idea in advance of what we expect the maximum degree of our polynomial to be. However, it is noteworthy that, given any arbitrarily small desired false positive, the maximum degree increases exponentially with the number of bits of precision we use. So even as soon as we get to a modest amount of precision, we'll be alright, as our black boxes aren't made up of "exponentially large polynomials" we are evaluating which have more coefficients than atoms in the universe.
Lastly, while many of the "pure math" objections will tend to focus on step 5, in the "real world" one will tend to run into issues primarily in step 2. The real problem with this algorithm isn't that the notion of "randomness" isn't well-defined, but that Lagrange interpolation can be numerically unstable. Floating point roundoff error can easily ruin the location of the zeros even for polynomials with degree as low as 8.
It's a bit hard to address this because the extent to which this is a problem depends on what format the black-box polynomials will be in.
- Are the coefficients being stored using floating point arithmetic, where things are being quantized and rounded off after each polynomial evaluation?
- Or can we make it so we're using a computational algebra system where coefficients are stored using exact arbitrary-length rational values, so this isn't a problem?
- Or something else?
There are several possible ways of dealing with this issue - doing stable Lagrange interpolation in the presence of floating-point error is kind of a whole other question in and of itself, but as long as you have sufficient flexibility with the precision and representation of the arithmetic, you'll be alright.