@Test(expectedExceptions = IllegalArgumentException.class) public void testNullFunction2() { ROOT_FINDER.getRoot((DoubleFunction1D) null, X1, X2); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullFunction6() { ROOT_FINDER.getRoot((DoubleFunction1D) null, X); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullInitialGuess1() { ROOT_FINDER.getRoot(F1, (Double) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullInitialGuess3() { ROOT_FINDER.getRoot(F1, DF1, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullHigher1() { ROOT_FINDER.getRoot(F2, X1, (Double) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullFunction3() { ROOT_FINDER.getRoot(null, DF2, X1, X2); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDerivative1() { ROOT_FINDER.getRoot(F2, null, X1, X2); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEnclosedExtremum() { ROOT_FINDER.getRoot(F2, DF2, X1, X3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullFunction5() { ROOT_FINDER.getRoot((Function<Double, Double>) null, X); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullLower1() { ROOT_FINDER.getRoot(F2, (Double) null, X2); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullHigher2() { ROOT_FINDER.getRoot(F1, X1, (Double) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullFunction4() { ROOT_FINDER.getRoot(null, DF1, X1, X2); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullHigher4() { ROOT_FINDER.getRoot(F1, DF1, X1, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDerivative4() { ROOT_FINDER.getRoot(F2, (Function<Double, Double>) null, X); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullInitialGuess2() { ROOT_FINDER.getRoot(F2, (Double) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullHigher3() { ROOT_FINDER.getRoot(F2, DF2, X1, null); }
/** * {@inheritDoc} * @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. */ @Override public Double getRoot(Function<Double, Double> function, Double x1, Double x2) { ArgChecker.notNull(function, "function"); return getRoot(DoubleFunction1D.from(function), x1, x2); }
/** * Uses the function and its derivative. This method uses an initial guess for the root, rather than bounds. * @param function The function, not null * @param derivative The derivative, not null * @param x The initial guess for the root, not null * @return The root * @throws MathException If the root is not found in 1000 attempts. */ public Double getRoot(Function<Double, Double> function, Function<Double, Double> derivative, Double x) { return getRoot(DoubleFunction1D.from(function), DoubleFunction1D.from(derivative), x); }
/** * Uses the {@link DoubleFunction1D#derivative()} method. This method uses an initial * guess for the root, rather than bounds. * * @param function The function, not null * @param x The initial guess for the root, not null * @return The root * @throws MathException If the root is not found in 1000 attempts. */ public Double getRoot(DoubleFunction1D function, Double x) { ArgChecker.notNull(function, "function"); return getRoot(function, function.derivative(), x); }
public Double getRoot(Function<Double, Double> function, Double x) { ArgChecker.notNull(function, "function"); ArgChecker.notNull(x, "x"); DoubleFunction1D f = DoubleFunction1D.from(function); return getRoot(f, f.derivative(), x); }