DoubleFunction1D extends Function1D<Double, Double> { public DoubleFunction1D derivative() { return derivative(FiniteDifferenceType.CENTRAL, EPS); }  DoubleFunction1D derivative(); DoubleFunction1D derivative(final FiniteDifferenceType differenceType, final double eps); DoubleFunction1D add(final DoubleFunction1D f); DoubleFunction1D add(final double a); DoubleFunction1D divide(final DoubleFunction1D f); DoubleFunction1D divide(final double a); DoubleFunction1D multiply(final DoubleFunction1D f); DoubleFunction1D multiply(final double a); DoubleFunction1D subtract(final DoubleFunction1D f); DoubleFunction1D subtract(final double a); static DoubleFunction1D from(final Function1D<Double, Double> f);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDerivativeNullType() { F1.derivative(null, EPS); }
@Test public void testDerivative() { assertEquals(F1.derivative().evaluate(X), DF1.evaluate(X), 1e-3); assertEquals(F2.derivative().evaluate(X), DF2.evaluate(X), 1e-3); assertEquals(F1.derivative(FiniteDifferenceType.CENTRAL, 1e-5).evaluate(X), DF1.evaluate(X), 1e-3); assertEquals(F2.derivative(FiniteDifferenceType.CENTRAL, 1e-5).evaluate(X), DF2.evaluate(X), 1e-3); assertEquals(F1.derivative(FiniteDifferenceType.FORWARD, 1e-5).evaluate(X), DF1.evaluate(X), 1e-3); assertEquals(F2.derivative(FiniteDifferenceType.FORWARD, 1e-5).evaluate(X), DF2.evaluate(X), 1e-3); assertEquals(F1.derivative(FiniteDifferenceType.BACKWARD, 1e-5).evaluate(X), DF1.evaluate(X), 1e-3); assertEquals(F2.derivative(FiniteDifferenceType.BACKWARD, 1e-5).evaluate(X), DF2.evaluate(X), 1e-3); assertEquals(F3.derivative().evaluate(X), DF1.evaluate(X), 1e-15); assertEquals(F4.derivative().evaluate(X), DF2.evaluate(X), 1e-15); }