MullerNewtonSolver implements IRootsSolver { @VisibleForTesting static Complex computeA2(Complex q2, Complex f2, Complex f0, Complex f1) { double tmp; double re0, re1, re2; double im0, im1, im2; re0 = q2.getRe(); im0 = q2.getIm(); re1 = f2.getRe(); im1 = f2.getIm(); re2 = q2.getRe() * f0.getRe() - q2.getIm() * f0.getIm(); im2 = q2.getRe() * f0.getIm() + q2.getIm() * f0.getRe(); re1 += re2; im1 += im2; re2 = 1 + q2.getRe(); im2 = q2.getIm(); tmp = re2 * f1.getRe() - im2 * f1.getIm(); im2 = re2 * f1.getIm() + im2 * f1.getRe(); re2 = tmp; re1 -= re2; im1 -= im2; tmp = re0 * re1 - im0 * im1; im0 = re0 * im1 + im0 * re1; re0 = tmp; return Complex.cart(re0, im0); } MullerNewtonSolver(); @Override void clear(); @Override MullerNewtonSolver exemplar(); @Override boolean factorize(final Polynomial p); @Override Polynomial remainder(); @Override Complex[] roots(); boolean isLeastSquaresDivision(); void setLeastSquaresDivision(boolean lq);  }
@Test public void testComputeA2() { for (int i = 0; i < 10; i++) { Complex q2 = random(), f0 = random(), f1 = random(), f2 = random(); Complex result = q2.times(f2.plus(q2.times(f0)).minus(q2.plus(1).times(f1))); assertEquals(result, computeA2(q2, f2, f0, f1), 0); } }