Beispiel #1
0
  /**
   * Find the smallest real root of p within lowerBound and upperBound (bounds may or may not be
   * included). If no real root exists in this interval, Double.NaN ist returned.
   *
   * @param p
   * @param lowerBound
   * @param upperBound
   * @return
   */
  public double findFirstRootIn(UnivariatePolynomial p, double lowerBound, double upperBound) {
    if (makeSquarefree) {
      // make p squarefree
      UnivariatePolynomial gcd = UnivariatePolynomial.gcd(p, p.derive());
      if (gcd.degree() > 0)
        // Polynomial not squarefree!
        p = p.div(gcd);
    }

    return EVAL(p, lowerBound, upperBound, p.evaluateAt(lowerBound), p.evaluateAt(upperBound));
  }
Beispiel #2
0
 private static double bisect(UnivariatePolynomial p, double lowerBound, double upperBound) {
   return bisect(p, lowerBound, upperBound, p.evaluateAt(lowerBound), p.evaluateAt(upperBound));
 }