RobWorkProject  23.9.11-
Classes | Namespaces
PolynomialSolver.hpp File Reference

Find solutions for roots of real and complex polynomial equations. More...

#include <rw/math/Polynomial.hpp>
#include <complex>
#include <vector>

Classes

class  PolynomialSolver
 Find solutions for roots of real and complex polynomial equations. More...
 

Namespaces

 rw
 Deprecated namespace since 16/4-2020 for this class.
 
 rw::math
 Matrices, vectors, configurations, and more.
 

Detailed Description

Find solutions for roots of real and complex polynomial equations.

The solutions are found analytically if the polynomial is of maximum order 3. For polynomials of order 4 and higher, Laguerre's Method is used to find roots until the polynomial can be deflated to order 3. The remaining roots will then be found analytically.

Some Polynomials are particularly easy to solve. A polynomial of the form \( a x^n + b = 0\) will be solved by taking the n'th roots of \(-\frac{b}{a}\) directly, giving n distinct roots in the complex plane.

To illustrate the procedure, consider the equation: \( 10^{-15} x^8 - 10^{-15} x^7 + x^7 + 2 x^6 - x^4 - 2x^3 + 10^{-15} x= 0\)

The solver will use the following procedure (here with the precision \( \epsilon = 10^{-14}\)):

  1. Remove terms that are small compared to \(\epsilon\): \( x^7 + 2 x^6 - x^4 - 2x^3 = 0\)
  2. Find zero roots and reduce the order: There is a triple root in x = 0 and the remaining polynomial becomes: \( x^4 + 2 x^3 - x - 2 = 0\).
  3. Use Laguerre to find a root of \( x^4 + 2 x^3 - x - 2 = 0\)

Depending on the initial guess for Laguerre, different roots might be found first. The algorithm will proceed differently depending on the found root:

  1. If root x=-2 is found, remaining polynomial after deflation is \( x^3 -1 = 0\). The roots are found directly as the cubic root of 1, which is three distinct roots in the complex plane (one is on the real axis).
  2. If root x=1 is found, remaining polynomial after deflation is \( x^3 + 3 x^2 +3 x + 2 = 0\). The roots are found analytically, giving one real root x=-2 and two complex conjugate roots \( x = -0.5 \pm \frac{\sqrt{3}}{2} i\).
  3. If other roots than x=1 or x=-2 is found (a complex root), remaining polynomial is a third order polynomial with complex coefficients. This polynomial is solved analytically to give remaining two real roots, and one remaining complex root.

Notice that cases 2+3 requires analytical solution of the third order polynomial equation. For higher order polynomials Laguerre would need to be used to find the next root. In this case it is particularly lucky to hit case 1, as this gives the solutions right away no matter what order the remaining polynomial is.