def ll_common_denominator(f):
    """For a polynomial f with fractional coefficients, write out the
    polynomial such that there is only a single denominator."""
    # f should be a polynomial
    if not is_Polynomial(f):
        return ll_raw(f)
    # first determine the lcm of the denominators of the coefficients
    cd = reduce(lcm, [c.denominator() for c in f])
    if is_Polynomial(cd) and cd.degree() > 0:
        return "\\frac{" + ll_raw(cd * f) + "}{" + ll_raw(factor(cd)) + "}"
    else:
        return ll_raw(f)
Beispiel #2
0
def gauss_valuation(poly, prime, prec=30):
    """Compute the Gauss norm of the given polynomial, with prime
    identifying the valuation."""
    if is_Polynomial(poly):
        return min([valuation(c, prime) for c in poly])
    if is_LaurentSeries(poly):
        return series_valuation(poly, prime, prec)
    else:
        # in case we just get a constant
        return valuation(poly, prime)
Beispiel #3
0
def poly_reduced_degree(poly, prime):
    if is_Polynomial(poly):
        i = poly.degree()
        v = 1
        while v > 0 and i >= 0:
            v = valuation(poly[i], prime)
            i -= 1
        return i+1
    elif valuation(poly, prime) > 0:
        return -infinity
    else:
        return 0
Beispiel #4
0
 def m(poly_or_vector, *args):
     if is_Polynomial(poly_or_vector):
         return f(poly_or_vector.coefficients(), *args)
     else:
         return f(poly_or_vector, *args)