Search code examples
javamatrixcomplex-numberspolynomial-mathroot-finding

Complex-coefficient polynomial root finding in Java


I'm trying to find a way to compute roots of a polynomial with complex coefficients in Java (i.e. an equivalent of what is ridiculously easily done with roots() in MATLAB).

I'm ready to recode a root finding algorithm that builds the companion matrix and then uses generalized eigenvalue decomposition to find the roots, but for this I would need a library that handles complex-valued matrix operations.

I browsed for a while and nothing convincing seems to be available out there, which I think is rather weird. Then, I'd like to ask you:

  1. Do you know a (stable) Java library that performs root finding on polynomials defined by COMPLEX coefficients?

  2. Do you know a (stable) Java library that performs evd, svd, inverse, etc. on COMPLEX-valued matrices?

Note: I already looked at JAMA (doesn't handle complex), Michael Thomas Flanagan's Java Scientific Library (not available anymore), colt (doesn't seem to handle complex), Efficient Java Matrix Library (no complex either), DDogleg Numerics (does not handle polynomial with complex coefficients), JScience (not clear if evd is available) and common-math from Apache (not clear if they allow for complex matrices, and if yes, if evd is available).


Solution

  • The Durand-Kerner method also works for complex coefficients and does not rely on matrix computations.

    It's quite simple to implement, you could google up an implementation (Stackoverflow forbids me to link the one I found) or make one of your own. You could use the jscience library for the complex data types, not for the algorithm itself.

    EDIT: Didn't see that you need evd too, never mind my mention of jscience as an option to do the complex matrix math.