/** * Uses the function and its derivative. * @param function The function, not null * @param derivative The derivative, not null * @param x1 The first bound of the root, not null * @param x2 The second bound of the root, not null * @return The root * @throws MathException If the root is not found in 1000 attempts; if the Newton * step takes the estimate for the root outside the original bounds. */ public Double getRoot(Function<Double, Double> function, Function<Double, Double> derivative, Double x1, Double x2) { checkInputs(function, x1, x2); ArgChecker.notNull(derivative, "derivative"); return getRoot(DoubleFunction1D.from(function), DoubleFunction1D.from(derivative), x1, x2); }
checkInputs(function, x1, x2); ArgChecker.notNull(derivative, "derivative function"); double y1 = function.applyAsDouble(x1);