This is a program to find all real and imaginary roots of a polynomial.
It's based on Durand-Kerner method. This method has a drawback: if a root is
double, triple... (multiple root) the method is slightly efficient. Fortunately, there is an algorithm
to find multiple roots. The program first find multiple roots, if any the polynomial is deflated
and then are found the remainder of the roots.
The program is a part of a automatic control project even in development.
To run this program you will need the 'LNAutils' by PAP.
Example: To find the roots of the polynomial: x5-14x4+162x3-652x2+2145x+8450 and to measure
the elapsed time you would have to write:
require ("LACutils/RootP","LNAutils/MatPrint","LNAutils/TimeElap")local r,h,m,slocal a={1,-14,162,-652,2145,8450}h,m,s=gettime()r=RootP(a)TimeElapsed(h,m,s,1)print("roots=")MatPrint(r,"%.8")
The roots are stored in a table of two dimensions:
r 1' /> -> real part root 1, r 2' /> -> imaginary part root 1
r 1' /> -> real part root 2, r 2' /> -> imaginary part root 2 ... and so on.