Ejemplo n.º 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));
  }
Ejemplo n.º 2
0
  public double[] findAllRootsIn(UnivariatePolynomial p, double lowerBound, double upperBound) {
    p = p.shrink();
    if (makeSquarefree) {
      // make p squarefree
      UnivariatePolynomial gcd = UnivariatePolynomial.gcd(p, p.derive());
      if (gcd.degree() > 0)
        // Polynomial not squarefree!
        p = p.div(gcd);
    }

    return null;
  }