### Question:
QuadraticRealRootFinder implements Polynomial1DRootFinder<Double> { @Override public Double[] getRoots(RealPolynomialFunction1D function) { ArgChecker.notNull(function, "function"); double[] coefficients = function.getCoefficients(); ArgChecker.isTrue(coefficients.length == 3, "Function is not a quadratic"); double c = coefficients[0]; double b = coefficients[1]; double a = coefficients[2]; double discriminant = b * b - 4 * a * c; if (discriminant < 0) { throw new MathException("No real roots for quadratic"); } double q = -0.5 * (b + Math.signum(b) * discriminant); return new Double[] {q / a, c / q}; }  @Override Double[] getRoots(RealPolynomialFunction1D function);  }### Answer:
@Test public void test() { assertThatIllegalArgumentException() .isThrownBy(() -> FINDER.getRoots(null)); assertThatIllegalArgumentException() .isThrownBy(() -> FINDER.getRoots(new RealPolynomialFunction1D(1., 2., 3., 4.))); assertThatExceptionOfType(MathException.class) .isThrownBy(() -> FINDER.getRoots(new RealPolynomialFunction1D(12., 1., 12.))); final Double[] roots = FINDER.getRoots(F); assertThat(roots[0]).isCloseTo(-4.0, offset(EPS)); assertThat(roots[1]).isCloseTo(-3.0, offset(EPS)); }