|
|
◆ Dka()
| Sub Dka |
( |
N As |
Long, |
|
|
A() As |
Complex, |
|
|
Z() As |
Complex, |
|
|
Info As |
Long, |
|
|
Optional Iter As |
Long, |
|
|
Optional MaxIter As |
Long = 0 |
|
) |
| |
Roots of a polynomial (complex coefficients) (3rd order DKA method)
- Purpose
- This routine computes all roots of a polynomial p(z) with complex coefficients by 3rd order DKA (Durand-Kerner-Aberth) method.
p(z) = a0*z^n + a1*z^(n-1) + ... + an
- Parameters
-
| [in] | N | Degree of polynomial. (N >= 1) |
| [in] | A() | Array A(LA - 1) (LA >= N + 1)
Complex coefficient vector of p(z) (a0 to an). |
| [out] | Z() | Array Z(LZ - 1) (LZ >= N)
The obtained zeros. |
| [out] | Info | = 0: Successful exit.
= -1: The argument N had an illegal value. (N <= 0)
= -2: The argument A() is invalid.
= -3: The argument Z() is invalid.
= 1: Maximum number of iterations exceeded. |
| [out] | Iter | (Optional)
Number of iterations required to converge. |
| [in] | MaxIter | (Optional)
Maximum number of iterations. (default = 10 * N)
If MaxIter <= 0, the default value will be used. |
- Reference
- (Japanese book) Masatake Mori "FORTRAN77 Numerical Calculation Programming (augmented edition)" Iwanami Shoten (1987)
- Example Program
- Solve the following algebraic equation.
x^3 + (-19-14i)*x^2 + (67+191i)*x + 116-612i = 0
The exact solutions are 8 + 4i, 4 + 9i and 7 + i. Sub Ex_Dka()
Const N As Long = 3
Dim A(N) As Complex, Z(N - 1) As Complex
Dim Iter As Long, Info As Long, I As Long
Call Dka(N, A(), Z(), Info, Iter)
For I = 0 To N - 1
Next
Debug.Print "Iter =", Iter, "Info =", Info
End Sub
Function Cmplx(R As Double, Optional I As Double=0) As Complex Building complex number
Function Cimag(A As Complex) As Double Imaginary part of complex number
Function Creal(A As Complex) As Double Real part of complex number
Sub Dka(N As Long, A() As Complex, Z() As Complex, Info As Long, Optional Iter As Long, Optional MaxIter As Long=0) Roots of a polynomial (complex coefficients) (3rd order DKA method)
- Example Results
8 4
4 9
7 0.999999999999997
Iter = 5 Info = 0
|