PolynomialFunctionNewtonForm implements UnivariateDifferentiableFunction { public double value(double z) { return evaluate(a, c, z); } PolynomialFunctionNewtonForm(double a[], double c[]); double value(double z); DerivativeStructure value(final DerivativeStructure t); int degree(); double[] getNewtonCoefficients(); double[] getCenters(); double[] getCoefficients(); static double evaluate(double a[], double c[], double z);  }
@Test public void testDerivative() { PolynomialFunctionNewtonForm p = new PolynomialFunctionNewtonForm(new double[] { 0, 1, 3, 1 }, new double[] { 0, 1, 2 }); double eps = 2.0e-14; for (double t = 0.0; t < 10.0; t += 0.1) { DerivativeStructure x = new DerivativeStructure(1, 4, 0, t); DerivativeStructure y = p.value(x); Assert.assertEquals(t * t * t, y.getValue(), eps * t * t * t); Assert.assertEquals(3.0 * t * t, y.getPartialDerivative(1), eps * 3.0 * t * t); Assert.assertEquals(6.0 * t, y.getPartialDerivative(2), eps * 6.0 * t); Assert.assertEquals(6.0, y.getPartialDerivative(3), eps * 6.0); Assert.assertEquals(0.0, y.getPartialDerivative(4), eps); } }