/**
   * tests the value of a constant polynomial.
   *
   * <p>value of this is 2.5 everywhere.
   */
  public void testConstants() throws MathException {
    double[] c = {2.5};
    PolynomialFunction f = new PolynomialFunction(c);

    // verify that we are equal to c[0] at several (nonsymmetric) places
    assertEquals(f.value(0.0), c[0], tolerance);
    assertEquals(f.value(-1.0), c[0], tolerance);
    assertEquals(f.value(-123.5), c[0], tolerance);
    assertEquals(f.value(3.0), c[0], tolerance);
    assertEquals(f.value(456.89), c[0], tolerance);

    assertEquals(f.degree(), 0);
    assertEquals(f.derivative().value(0), 0, tolerance);

    assertEquals(f.polynomialDerivative().derivative().value(0), 0, tolerance);
  }
  /**
   * tests the value of a linear polynomial.
   *
   * <p>This will test the function f(x) = 3*x - 1.5
   *
   * <p>This will have the values <tt>f(0.0) = -1.5, f(-1.0) = -4.5, f(-2.5) = -9.0, f(0.5) = 0.0,
   * f(1.5) = 3.0</tt> and <tt>f(3.0) = 7.5</tt>
   */
  public void testLinear() throws MathException {
    double[] c = {-1.5, 3.0};
    PolynomialFunction f = new PolynomialFunction(c);

    // verify that we are equal to c[0] when x=0
    assertEquals(f.value(0.0), c[0], tolerance);

    // now check a few other places
    assertEquals(-4.5, f.value(-1.0), tolerance);
    assertEquals(-9.0, f.value(-2.5), tolerance);
    assertEquals(0.0, f.value(0.5), tolerance);
    assertEquals(3.0, f.value(1.5), tolerance);
    assertEquals(7.5, f.value(3.0), tolerance);

    assertEquals(f.degree(), 1);

    assertEquals(f.polynomialDerivative().derivative().value(0), 0, tolerance);
  }