There are exact (closed-form) solutions to polynomial equations of degree up to and including 4. I.e. there's a quadratic formula, a cubic formula and even a quartic formula.
Do any of the standard python packages (or even some non-standard ones) implement these? I can see that Numpy offers the ability to find polynomial roots (numpy.polynomial.polynomial.polyroots
) but this routine appears to find the roots numerically via an eigenvalue method.
I'm not concerned about accuracy here (i.e. my issue with the Numpy routine is not that it will return floating point results when, perhaps, the answer is actually rational or integer in its real or imaginary parts).
I am concerned with speed. Is it reasonable to expect that a well-implemented cubic or quartic formula would return faster than the eigenvalue methods implemented by Numpy? I would have thought "yes". But I'm not 100% sure.