/** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients Polynomial coefficients. * @param initial Start value. * @return the full set of complex roots of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded when solving for one of the roots * @throws NullArgumentException if the {@code coefficients} is * {@code null}. * @throws NoDataException if the {@code coefficients} array is empty. * @since 3.1 */ public Complex[] solveAllComplex(double[] coefficients, double initial) throws NullArgumentException, NoDataException, TooManyEvaluationsException { return solveAllComplex(coefficients, initial, Integer.MAX_VALUE); }
NumberIsTooLargeException, NoBracketingException { final double min = getMin(); final double max = getMax(); final double initial = getStartValue(); final double functionValueAccuracy = getFunctionValueAccuracy(); verifySequence(min, initial, max); final double yInitial = computeObjectiveValue(initial); if (FastMath.abs(yInitial) <= functionValueAccuracy) { return initial; final double yMin = computeObjectiveValue(min); if (FastMath.abs(yMin) <= functionValueAccuracy) { return min; return laguerre(min, initial, yMin, yInitial); final double yMax = computeObjectiveValue(max); if (FastMath.abs(yMax) <= functionValueAccuracy) { return max; return laguerre(initial, max, yInitial, yMax);
/** * Check whether the given complex root is actually a real zero * in the given interval, within the solver tolerance level. * * @param min Lower bound for the interval. * @param max Upper bound for the interval. * @param z Complex root. * @return {@code true} if z is a real zero. */ public boolean isRoot(double min, double max, Complex z) { if (isSequence(min, z.getReal(), max)) { double tolerance = FastMath.max(getRelativeAccuracy() * z.abs(), getAbsoluteAccuracy()); return (FastMath.abs(z.getImaginary()) <= tolerance) || (z.abs() <= getFunctionValueAccuracy()); } return false; }
final LaguerreSolver solver = new LaguerreSolver(); final Complex[] result = solver.solveAllComplex(coeff, 0);
final double absoluteAccuracy = getAbsoluteAccuracy(); final double relativeAccuracy = getRelativeAccuracy(); final double functionValueAccuracy = getFunctionValueAccuracy(); z = z.subtract(nC.divide(denominator)); incrementEvaluationCount();
public double laguerre(double lo, double hi, double fLo, double fHi) { final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());
try { if (laguerreSolver == null) { laguerreSolver = new LaguerreSolver(); complexRoots = laguerreSolver.solveAllComplex(real, LAGUERRE_START); } catch (Exception e) { Log.debug("Problem solving with LaguerreSolver"
final double absoluteAccuracy = getAbsoluteAccuracy(); final double relativeAccuracy = getRelativeAccuracy(); final double functionValueAccuracy = getFunctionValueAccuracy(); z = z.subtract(nC.divide(denominator)); incrementEvaluationCount();
public double laguerre(double lo, double hi, double fLo, double fHi) { final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());
NumberIsTooLargeException, NoBracketingException { final double min = getMin(); final double max = getMax(); final double initial = getStartValue(); final double functionValueAccuracy = getFunctionValueAccuracy(); verifySequence(min, initial, max); final double yInitial = computeObjectiveValue(initial); if (Math.abs(yInitial) <= functionValueAccuracy) { return initial; final double yMin = computeObjectiveValue(min); if (Math.abs(yMin) <= functionValueAccuracy) { return min; return laguerre(min, initial, yMin, yInitial); final double yMax = computeObjectiveValue(max); if (Math.abs(yMax) <= functionValueAccuracy) { return max; return laguerre(initial, max, yInitial, yMax);
public void design() { reset(); for (int i = 0; i < degree + 1; ++i) { m_a[i] = reversebessel(i, degree); } LaguerreSolver laguerreSolver = new LaguerreSolver(); m_root = laguerreSolver.solveAllComplex(m_a,0.0); Complex inf = Complex.INF; int pairs = degree / 2; for (int i = 0; i < pairs; ++i) { Complex c = m_root[i]; addPoleZeroConjugatePairs(c, inf); } if ((degree & 1) == 1) add(new Complex(m_root[pairs].getReal()), inf); }
/** * Check whether the given complex root is actually a real zero * in the given interval, within the solver tolerance level. * * @param min Lower bound for the interval. * @param max Upper bound for the interval. * @param z Complex root. * @return {@code true} if z is a real zero. */ public boolean isRoot(double min, double max, Complex z) { if (isSequence(min, z.getReal(), max)) { double tolerance = Math.max(getRelativeAccuracy() * z.abs(), getAbsoluteAccuracy()); return (Math.abs(z.getImaginary()) <= tolerance) || (z.abs() <= getFunctionValueAccuracy()); } return false; }
final double absoluteAccuracy = getAbsoluteAccuracy(); final double relativeAccuracy = getRelativeAccuracy(); final double functionValueAccuracy = getFunctionValueAccuracy(); z = z.subtract(nC.divide(denominator)); incrementEvaluationCount();
/** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients Polynomial coefficients. * @param initial Start value. * @return the full set of complex roots of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded when solving for one of the roots * @throws NullArgumentException if the {@code coefficients} is * {@code null}. * @throws NoDataException if the {@code coefficients} array is empty. * @since 3.1 */ public Complex[] solveAllComplex(double[] coefficients, double initial) throws NullArgumentException, NoDataException, TooManyEvaluationsException { return solveAllComplex(coefficients, initial, Integer.MAX_VALUE); }
public double laguerre(double lo, double hi, double fLo, double fHi) { final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());
NumberIsTooLargeException, NoBracketingException { final double min = getMin(); final double max = getMax(); final double initial = getStartValue(); final double functionValueAccuracy = getFunctionValueAccuracy(); verifySequence(min, initial, max); final double yInitial = computeObjectiveValue(initial); if (FastMath.abs(yInitial) <= functionValueAccuracy) { return initial; final double yMin = computeObjectiveValue(min); if (FastMath.abs(yMin) <= functionValueAccuracy) { return min; return laguerre(min, initial, yMin, yInitial); final double yMax = computeObjectiveValue(max); if (FastMath.abs(yMax) <= functionValueAccuracy) { return max; return laguerre(initial, max, yInitial, yMax);
try { if (laguerreSolver == null) { laguerreSolver = new LaguerreSolver(); complexRoots = laguerreSolver.solveAllComplex(eqn, LAGUERRE_START, LAGUERRE_MAX_EVAL); } catch (ArithmeticException e) {
/** * Check whether the given complex root is actually a real zero * in the given interval, within the solver tolerance level. * * @param min Lower bound for the interval. * @param max Upper bound for the interval. * @param z Complex root. * @return {@code true} if z is a real zero. */ public boolean isRoot(double min, double max, Complex z) { if (isSequence(min, z.getReal(), max)) { double tolerance = FastMath.max(getRelativeAccuracy() * z.abs(), getAbsoluteAccuracy()); return (FastMath.abs(z.getImaginary()) <= tolerance) || (z.abs() <= getFunctionValueAccuracy()); } return false; }
/** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients Polynomial coefficients. * @param initial Start value. * @return the full set of complex roots of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded when solving for one of the roots * @throws NullArgumentException if the {@code coefficients} is * {@code null}. * @throws NoDataException if the {@code coefficients} array is empty. * @since 3.1 */ public Complex[] solveAllComplex(double[] coefficients, double initial) throws NullArgumentException, NoDataException, TooManyEvaluationsException { return solveAllComplex(coefficients, initial, Integer.MAX_VALUE); }
", derivative is " + derivative.toString()); final LaguerreSolver solver = new LaguerreSolver(); final Complex[] roots = solver.solveAllComplex(derivative.getCoefficients(), initialGuess, getMaxEvaluations()); if (roots == null) return null;