PolynomialFunction implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction, Serializable { public double value(double x) { return evaluate(coefficients, x); } PolynomialFunction(double c[]); double value(double x); int degree(); double[] getCoefficients(); DerivativeStructure value(final DerivativeStructure t); PolynomialFunction add(final PolynomialFunction p); PolynomialFunction subtract(final PolynomialFunction p); PolynomialFunction negate(); PolynomialFunction multiply(final PolynomialFunction p); PolynomialFunction polynomialDerivative(); UnivariateFunction derivative(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testQuadratic() { double[] c = { -2, -3, 2 }; PolynomialFunction f = new PolynomialFunction(c); Assert.assertEquals(f.value(0), c[0], tolerance); Assert.assertEquals(0, f.value(-0.5), tolerance); Assert.assertEquals(0, f.value(2), tolerance); Assert.assertEquals(-2, f.value(1.5), tolerance); Assert.assertEquals(7, f.value(-1.5), tolerance); Assert.assertEquals(265.5312, f.value(12.34), tolerance); }