TITLE: Finding roots of a polynomial without explicit coefficients
QUESTION [6 upvotes]: I am looking for a numerical algorithm to find all $n$ roots of a degree $n$ polynomial $P(x)$ without explicit knowledge of its coefficients. I can, however, evaluate $P(x)$ for any $x$. 
I am aware that I could just sample $n+1$ points of $P$ to find its coefficients, then look for the roots as usual (e.g. by diagonalizing the companion matrix). But without some background information about the polynomial's coefficients or roots, it is not clear to me what is the best way to choose the sampling points (if the roots happen to be spaced much farther apart than my sampling points, the polynomial will be very close to a linear function in the sampled region and so I'd expect the extracted coefficients to be sensitive to numerical errors). That's why I would rather not go via the coefficients. But if anybody has a good idea how to choose the sampling points adaptively based on evaluations of $P(x)$ to get the coefficients of $P$ in a robust way, I am all ears.
In case anyone is curious, the reason I am looking into this is to solve the following problem: Given $N\times N$ (positive symmetric) matrices $A$ and $B$, I need to find all $x$ such that $Ax+B$ is singular. This of course leads to diagonalization of $A^{-1}B$ if $A$ is invertible. The interesting case is if it is not. My approach would then be to find the zeros of $\det(Ax+B)$ which is a polynomial of degree a most $N$ in $x$. I do not know its coefficients explicitly but I can sample the determinant for different $x$ rather easily.

REPLY [3 votes]: I must caution you against converting your real problem into the question of finding all zeros of a polynomial. 
LAPACK and SCALAPACK already contains routines for your specific problem, the generalized eigenvalue problem for symmetric positive definite matrices,
$$Av = \lambda B v,$$
where $\lambda$ is a scalar and $v$ is an nonzero vector.
Unless you have unstated special requirements these routines should serve you well and they can also provide error estimates.
The nonsymmetric generalized eigenvalue problem is covered by LAPACK, and parallel implementations exist outside of ScaLAPACK.