# Methods for confirming that a polynomial root with errors is complex?

For large degree polynomials (>=5) with real coefficients, the only general root-finding algorithms are approximate. Since polynomials might have complex roots, any algorithm for finding the real roots of a polynomial must apply an approximate root-finding algorithm, then filter the results to obtain only real solutions.

A naive algorithm for filtering the results for real solutions, by simply checking that the imaginary part is identical to 0:

## Filter Algorithm 1:

\begin{align*} \text{complex}(x) = \begin{cases} \text{True} & \text{imag}(x) = 0, \\ \text{False}& \text{else} \end{cases} \end{align*}

Is insufficient, since, due to the approximate nature of the initial root-finding, real solutions are not guaranteed to have imaginary parts that are identical to 0.

One possibility is to apply a "tolerance" to check that the imaginary part is not above a certain threshold. However, complex roots may have small imaginary parts, and this risks identifying actual complex roots as real ones.

Another possibility may be to check to see if the complex conjugate of a particular root is also a root, but, since we have already narrowed our search to approximate roots with small imaginary parts, then this will not help separate real roots from complex ones.

How can we determine with higher precision if a particular approximate root is "truly" a complex root, or is actually a real root with a floating-point error imaginary part?

• Plug in the real component of the root back into the polynomial. See how close to zero it is. – Don Thousand Sep 23 at 17:24
• @DonThousand, but, if $p$ is my polynomial and $p(a+\epsilon i) \approx 0$ where $\epsilon$ is very small, then since $p$ is continuous, $p(a) \approx 0$, since a small change in $x$ must produce a small change in $y$. – Scott Sep 23 at 17:35
• Does the polynomial have real coefficients (or coefficients which are all real multiplies of a fixed complex number that can be divided out)? If so, then you can attempt to filter by using an intermediate value theorem checker: look at the real part of your proposed root, move a little left and a little right and check whether the polynomial changed sign. If it did, then you know the root you have approximated is real. If it didn't, then there are some things that could make it a false negative, some of which can be ruled out with further calculation (e.g. by finding roots of the derivative). – Ian Sep 23 at 18:05
• (Cont.) If the polynomial has "fundamentally complex" coefficients (i.e. the coefficients are not real multiples of a fixed complex number) then this problem is more or less hopeless in general (all you can really do is confirm that the root is within some horizontal strip of the real axis). – Ian Sep 23 at 18:06
• @Ian, my polynomials all have real coefficients. I have edited the question to reflect your observation. – Scott Sep 23 at 18:09

You simply can't tell, by nature of it being an approximate algorithm. Even if the imaginary part is $$0$$ as a floating point number, that doesn't rule out that the imaginary part is nonzero, but smaller than the smallest possible floating point number.