Index / Angle of the Real Root in a Cubic Equation. I am trying to find the roots of a general cubic equation, but with a twist: In case there is only one real root (the discriminant of the polynomial is less than zero), I want to separate the real root from the pair of complex conjugate roots and treat them differently (replace them by other complex roots specific to the actual problem I am solving).
Mark Rosales
Answered question
2022-11-04
Index / Angle of the Real Root in a Cubic Equation
- I am trying to find the roots of a general cubic equation, but with a twist:
In case there is only one real root (the discriminant of the polynomial is less than zero), I want to separate the real root from the pair of complex conjugate roots and treat them differently (replace them by other complex roots specific to the actual problem I am solving).
- I also want to stick to complex numbers (as opposed to explicit trigonometry) because I have to factor out all divisions at the end to represent the roots as homogeneous coordinates.
I currently use the approach described on Wikipedia. But because I use floating point arithmetic (not real numbers) it suffers from a bit of numeric instability, which makes it hard to tell which of the three results was supposed to be the real root (in case the curve is really flat and they are all close to the real line).
My current approach selects the root with the smallest absolute imaginary component. However I think there should be a better way to tell them apart before calculating the result, maybe related to the angles of the root of unity, so that I can get the index (k) of the real root () sooner.