/** * Real root bound. With f(M) * f(-M) != 0. * * @param f univariate polynomial. * @return M such that -M < root(f) < M. */ public C realRootBound(GenPolynomial<C> f) { if (f == null) { return null; } RingFactory<C> cfac = f.ring.coFac; C M = cfac.getONE(); if (f.isZERO() || f.isConstant()) { return M; } C a = f.leadingBaseCoefficient().abs(); for (C c : f.getMap().values()) { C d = c.abs().divide(a); if (M.compareTo(d) < 0) { M = d; } } // works also without this case, only for optimization // to use rational number interval end points // can fail if real root is in interval [r,r+1] // for too low precision or too big r, since r is approximation if ((Object) M instanceof RealAlgebraicNumber) { RealAlgebraicNumber Mr = (RealAlgebraicNumber) M; BigRational r = Mr.magnitude(); M = cfac.fromInteger(r.numerator()).divide(cfac.fromInteger(r.denominator())); } M = M.sum(f.ring.coFac.getONE()); // System.out.println("M = " + M); return M; }
/** * Quotient absolute value. * * @return the absolute value of this. * @see edu.jas.structure.RingElem#abs() */ public Quotient<C> abs() { return new Quotient<C>(ring, num.abs(), den, true); }