Example 2: Zeros of a Polynomial with Complex Coefficients
The zeros of a polynomial with Complex coefficients are computed.
import com.imsl.math.*;
public class ZeroPolynomialEx2 {
public static void main(String args[]) throws
ZeroPolynomial.DidNotConvergeException {
// Find zeros of z^3-(3+6i)*z^2+(-8+12i)*z+10
Complex coef[] = {
new Complex(10),
new Complex(-8, 12),
new Complex(-3, -6),
new Complex(1)
};
ZeroPolynomial zp = new ZeroPolynomial();
Complex root[] = zp.computeRoots(coef);
for (int k = 0; k < root.length; k++) {
System.out.println("root = " + root[k]);
System.out.println(" radius = "+ zp.getRadius(k));
System.out.println(" status = "+ zp.getStatus(k));
}
}
}
Output
root = 1.0+1.0i
radius = 6.105673569140261E-14
status = false
root = 1.0000000000000002+2.0000000000000004i
radius = 1.9846776908049295E-13
status = false
root = 0.9999999999999992+2.999999999999999i
radius = 1.5275632034267045E-13
status = false
Link to Java source.