XLPack 6.1
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ 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) (DKA method)

Purpose
This routine computes all roots of a polynomial p(z) with complex coefficients by DKA (Durand-Kerner-Aberth) method.
p(z) = a0*z^n + a1*z^(n-1) + ... + an
Parameters
[in]NDegree 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
A(0) = Cmplx(1): A(1) = Cmplx(-19, -14): A(2) = Cmplx(67, 191)
A(3) = Cmplx(116, -612)
Call Dka(N, A(), Z(), Info, Iter)
For I = 0 To N - 1
Debug.Print Creal(Z(I)), Cimag(Z(I))
Next
Debug.Print "Iter =", Iter, "Info =", Info
End Sub
Example Results
8 4
4 9
7 0.999999999999997
Iter = 5 Info = 0