Пример #1
0
def test():
    from sage.all import QQ
    R2 = PolynomialRing(QQ,2)
    x, y = R2.gens()
    ef = y+x^2
    fun = x^3+x*y

    try:
        print(Eval0(ef,[ef,fun]))
        print("not OK")
    except ValueError:
        print("OK")

    print(Eval0(ef,[fun+x^2,fun]))

    F = x^2+y^2-1
    print(Eval(F, [x,1-y], [0,1]))
    print(Eval(F, [1+y,x], [0,1]))
    print(Eval(F, [1+y,x], [-1,0]))
    print(Eval(F, [x,1-y], [-1,0]))

    R3 = PolynomialRing(QQ,3)
    X, Y, Z = R3.gens()
    F = X^2+Y^2-Z^2
    print(EvalHomog(F, [X,Z-Y], [0,1,1]))
    print(EvalHomog(F, [Z+Y,X], [0,1,1]))
    print(EvalHomog(F, [Z+Y,X], [-1,0,1]))
    print(EvalHomog(F, [X,Z-Y], [-1,0,1]))
    print(EvalHomog(F, [X,Z-Y], [3,4,5]))
Пример #2
0
    def theta_sym(self, j=2):
        '''
        Returns an image as a vector valued (Sym_{j} j:even) Fourier expansion
        of the generalized Theta operator associated with
        the Rankin-cohen operator {F, G}_{Sym_{j}}.

        [Reference]
        Ibukiyama, Vector valued Siegel modular forms of symmetric
        tensor weight of small degrees, COMMENTARI MATHEMATICI
        UNIVERSITATIS SANCTI PAULI VOL 61, NO 1, 2012.

        Boecherer, Nagaoka,
        On p-adic properties of Siegel modular forms, arXiv, 2013.
        '''
        R = PolynomialRing(QQ, "r1, r2, r3")
        (r1, r2, r3) = R.gens()
        S = PolynomialRing(R, "u1, u2")
        (u1, u2) = S.gens()
        pl = (r1 * u1 ** 2 + r2 * u1 * u2 + r3 * u2 ** 2) ** (j // 2)
        pldct = pl.dict()
        formsdict = {}
        for (_, i), ply in pldct.iteritems():
            formsdict[i] = sum([v * self._differential_operator_monomial(a, b, c)
                                for (a, b, c), v in ply.dict().iteritems()])
        forms = [x for _, x in
                 sorted([(i, v) for i, v in formsdict.iteritems()],
                        key=lambda x: x[0])]
        return SymWtGenElt(forms, self.prec, self.base_ring)
Пример #3
0
def _pair_gens_r_s():
    rnames = "r11, r12, r22, s11, s12, s22"
    unames = "u1, u2"
    RS_ring = PolynomialRing(QQ, names=rnames)
    (r11, r12, r22, s11, s12, s22) = RS_ring.gens()
    (u1, u2) = PolynomialRing(RS_ring, names=unames).gens()
    r = r11 * u1 ** 2 + 2 * r12 * u1 * u2 + r22 * u2 ** 2
    s = s11 * u1 ** 2 + 2 * s12 * u1 * u2 + s22 * u2 ** 2
    return (RS_ring.gens(), (u1, u2), (r, s))
Пример #4
0
def function_field_element(f, R):
    r""" Return the numerator and denominator of a function field element.

    INPUT:

    - ``f`` -- an element of a function field `F`, which is a finite extension
      of a rational function field `F_0` over a field `K`
    - ``R`` -- an order of `K`

    OUTPUT: a pair `g, h` of polynomials over `R` in two variables `x, y` such
    that f = g/h (if we map `x` to the generator of `F_0` and `y` to the
    generator of `F/F_0`.

    """
    F = f.parent()
    if hasattr(F, "polynomial"):
        # F0 = F.base_field()
        # A0 = F0._ring
        f = f.element()
        n = f.degree()
        # now f is an univariant polynomial over F0
        h = lcm([f[i].denominator() for i in range(n + 1)])
        g = h * f
        a = lcm([
            common_denominator_of_polynomial(g[i].numerator(), ZZ)
            for i in range(n + 1) if not g[i].is_zero()
        ])
        b = common_denominator_of_polynomial(h, R)
        c = lcm(a, b)
        g = c * g
        h = c * h
        B = PolynomialRing(R, 2, ['x', 'y'])
        x = B.gens()[0]
        y = B.gens()[1]
        g = sum([g[i].numerator()(x) * y**i for i in range(g.degree() + 1)])
        h = h(x)
        return g, h
    else:
        # f seems to constant in y
        g = f.numerator()
        h = f.denominator()
        a = common_denominator_of_polynomial(g, R)
        b = common_denominator_of_polynomial(h, R)
        c = lcm(a, b)
        g = c * g
        h = c * h
        B = PolynomialRing(R, 2, ['x', 'y'])
        x = B.gens()[0]
        return g(x), h(x)
Пример #5
0
def function_field_equation(R, F):
    r""" Return the equation defining a function field.

    INPUT:

    - ``R`` -- an integral domain
    - ``F`` -- a function field, defined as a simple finite extension of a
      rational function field over the fraction field `K` of `R`

    OUTPUT: a polynomial `G` over `R` in two variables such that
    `F = K(x, y | G(x,y)=0)`.

    """
    G = F.polynomial()
    # G should be an univariat polynomial over a rational function field F0
    F0 = G.parent().base_ring()
    A0 = F0._ring()
    # A0 is a polynomial ring over K, the fraction field of R
    K = A0.base_ring()
    assert R.fraction_field() == K, "K must be the fraction field of R"
    coeffs = [G[i] for i in range(G.degree() + 1)]
    a = lcm([c.denominator() for c in coeffs if not c.is_zero()])
    coeffs = [(a * c).numerator() for c in coeffs]
    # now coeffs is a list of univariat polynomials over a field
    common_denominator = R.one()
    for c in coeffs:
        common_denominator = lcm([
            c[i].denominator()
            for i in range(c.degree() + 1) if not c[i].is_zero()
        ] + [common_denominator])
    B = PolynomialRing(R, 2, ['x', 'y'])
    x = B.gens()[0]
    y = B.gens()[1]
    coeffs = [(common_denominator * c)(x) for c in coeffs]
    return sum([coeffs[i] * y**i for i in range(len(coeffs))])
Пример #6
0
def twistPolynomial(poly, k):
    R = PolynomialRing(ZZ, 'x,v')
    x, v = R.gens()
    f = R(poly)
    g = v - x ^ k
    T = PolynomialRing(QQ, 'v')
    return T(f.resultant(g))
Пример #7
0
def main1():
    S = PolynomialRing(GF(Integer(13)), names=('x',))
    (x,) = S.gens()
    R = S.quotient(x**Integer(2) - Integer(3), names=('alpha',))
    (alpha,) = R.gens()
    print((Integer(2) + Integer(3) * alpha)
          * (Integer(1) + Integer(2) * alpha))
Пример #8
0
def _anihilate_pol(k, M):
    '''
    k: The weight of an element c, where c is a construction
    for generators of M_{det^* sym(10)} and an instance of
    ConstDivision.
    M: an instance of Sym10EvenDiv or Sym10OddDiv.
    Return a polynomial pl such that the subspace of M anihilated by pl(T(2))
    is equal to the subspace of holomorphic modular forms.
    '''
    R = PolynomialRing(QQ, names="x")
    x = R.gens()[0]
    if k % 2 == 0:
        # Klingen-Eisenstein series
        f = CuspForms(1, k + 10).basis()[0]
        return x - f[2] * (1 + QQ(2) ** (k - 2))
    elif k == 13:
        # Kim-Ramakrishnan-Shahidi lift
        f = CuspForms(1, 12).basis()[0]
        a = f[2]
        return x - f[2] ** 3 + QQ(2) ** 12 * f[2]
    else:
        chrply = M.hecke_charpoly(2)
        dim = hilbert_series_maybe(10)[k]
        l = [(a, b) for a, b in chrply.factor() if a.degree() == dim]
        if len(l) > 1 or l[0][1] != 1:
            raise RuntimeError
        else:
            return l[0][0]
Пример #9
0
 def Poincare_polynomial(self):
     from sage.all import QQ, PolynomialRing
     PR = PolynomialRing(QQ, 'Y')
     Y = PR.gens()[0]
     if self.poset != None:
         P = self.poset
         atoms = self.atoms()
         if P.rank() == 0:
             return PR(1)
         if P.rank() == 1:
             return PR(1 + len(atoms) * Y)
     else:
         # Lazy
         A = self.hyperplane_arrangement
         assert A != None, "Expected either a poset or hyperplane arrangement."
         if A.rank() == 0:
             return PR(1)
         if A.rank() == 1:
             return PR(1 + len(A) * Y)
     if self.hyperplane_arrangement == None:
         chi = self.poset.characteristic_polynomial()
         q = chi.variables()[0]
         d = chi.degree(q)
         return PR((-Y)**d * chi.subs({q: -Y**-1}))
     D = self._lazy_deletion(1)
     R = self._lazy_restriction(1)
     return PR(D.Poincare_polynomial() + Y * R.Poincare_polynomial())
Пример #10
0
 def eu(p):
     """
     local euler factor
     """
     f = rho.local_factor(p)
     co = [ZZ(round(x)) for x in f.coefficients(sparse=False)]
     R = PolynomialRing(QQ, "T")
     T = R.gens()[0]
     return sum(co[n] * T**n for n in range(len(co)))
Пример #11
0
 def eu(p):
     """
     local euler factor
     """
     f = rho.local_factor(p)
     co = [ZZ(round(x)) for x in f.coefficients(sparse=False)]
     R = PolynomialRing(QQ, "T")
     T = R.gens()[0]
     return sum( co[n] * T**n for n in range(len(co)))
Пример #12
0
def SL2_to_SLN(A, N):
    F = A.base_ring()
    R = PolynomialRing(F, ['x', 'y'])
    x, y = R.gens()
    X, Y = A * vector(R, (x, y))
    monomials = [x**(N - 1 - i) * y**i for i in range(N)]
    image_vectors = [m(X, Y) for m in monomials]
    return matrix(F, [[v.monomial_coefficient(m) for m in monomials]
                      for v in image_vectors])
Пример #13
0
def multiplication_end(E, m):
    p = E.base_ring().characteristic()
    Q = PolynomialRing(E.base_field(), ['x', 'y'])
    x, y = Q.gens()
    R = Q.fraction_field()
    if m % p == 0:
        return add_maps(E.multiplication_by_m(m - 1), (R(x), R(y)), E)
    else:
        return normalize_map(E.multiplication_by_m(m), E)
Пример #14
0
def compute_local_roots_SMF2_scalar_valued(K, ev, k, embedding):
    ''' computes the dirichlet series for a Lfunction_SMF2_scalar_valued
    '''

    L = ev.keys()
    m = ZZ(max(L)).isqrt() + 1
    ev2 = {}
    for p in primes(m):

        try:
            ev2[p] = (ev[p], ev[p * p])
        except:
            break

    logger.debug(str(ev2))
    ret = []
    for p in ev2:
        R = PolynomialRing(K, 'x')
        x = R.gens()[0]

        f = (1 - ev2[p][0] * x +
             (ev2[p][0]**2 - ev2[p][1] - p**(2 * k - 4)) * x**2 -
             ev2[p][0] * p**(2 * k - 3) * x**3 + p**(4 * k - 6) * x**4)

        Rnum = PolynomialRing(CF, 'y')
        x = Rnum.gens()[0]
        fnum = Rnum(0)
        if K != QQ:
            for i in range(int(f.degree()) + 1):
                fnum = fnum + f[i].complex_embeddings(NN)[embedding] * (
                    x / p**(k - 1.5))**i
        else:
            for i in range(int(f.degree()) + 1):
                fnum = fnum + f[i] * (x / CF(p**(k - 1.5)))**i

        r = fnum.roots(CF)
        r = [1 / a[0] for a in r]
        # a1 = r[1][0]/r[0][0]
        # a2 = r[2][0]/r[0][0]
        # a0 = 1/r[3][0]

        ret.append((p, r))

    return ret
Пример #15
0
def _hecke_pol_klingen(k, j):
    '''k: even.
    F: Kligen-Eisenstein series of determinant weight k whose Hecke field is
    the rational filed. Return the Hecke polynomial of F at 2.
    '''
    f = CuspForms(1, k + j).basis()[0]
    R = PolynomialRing(QQ, names="x")
    x = R.gens()[0]
    pl = QQ(1) - f[2] * x + QQ(2) ** (k + j - 1) * x ** 2
    return pl * pl.subs({x: x * QQ(2) ** (k - 2)})
Пример #16
0
def _hecke_pol_krs_lift():
    '''Return the Hecke polynomial of KRS lift of weight det^{13}Sym(10) at 2.
    '''
    R = PolynomialRing(QQ, names="x")
    x = R.gens()[0]
    f = CuspForms(1, 12).basis()[0]
    a = f[2]
    b = QQ(2) ** 11
    return ((1 - (a ** 3 - 3 * a * b) * x + b ** 3 * x ** 2) *
            (1 - a * b * x + b ** 3 * x ** 2))
Пример #17
0
def compute_local_roots_SMF2_scalar_valued(K, ev, k, embedding):
    ''' computes the dirichlet series for a Lfunction_SMF2_scalar_valued
    '''

    L = ev.keys()
    m = ZZ(max(L)).isqrt() + 1
    ev2 = {}
    for p in primes(m):

        try:
            ev2[p] = (ev[p], ev[p * p])
        except:
            break

    logger.debug(str(ev2))
    ret = []
    for p in ev2:
        R = PolynomialRing(K, 'x')
        x = R.gens()[0]

        f = (1 - ev2[p][0] * x + (ev2[p][0] ** 2 - ev2[p][1] - p ** (
            2 * k - 4)) * x ** 2 - ev2[p][0] * p ** (2 * k - 3) * x ** 3 + p ** (4 * k - 6) * x ** 4)

        Rnum = PolynomialRing(CF, 'y')
        x = Rnum.gens()[0]
        fnum = Rnum(0)
        if K != QQ:
            for i in range(int(f.degree()) + 1):
                fnum = fnum + f[i].complex_embeddings(NN)[embedding] * (x / p ** (k - 1.5)) ** i
        else:
            for i in range(int(f.degree()) + 1):
                fnum = fnum + f[i] * (x / CF(p ** (k - 1.5))) ** i

        r = fnum.roots(CF)
        r = [1 / a[0] for a in r]
        # a1 = r[1][0]/r[0][0]
        # a2 = r[2][0]/r[0][0]
        # a0 = 1/r[3][0]

        ret.append((p, r))

    return ret
Пример #18
0
def _bracket_vec_val(vecs):
    if isinstance(vecs[0], SWGElt):
        v1, v2, v3 = [a.forms for a in vecs]
    else:
        v1, v2, v3 = vecs
    j = len(v1) - 1

    def _names(s):
        return ", ".join([s + str(i) for i in range(j + 1)])

    R = PolynomialRing(QQ, names=", ".join([_names(s) for s in
                                            ["x", "y", "z"]]))
    gens_x = R.gens()[: j + 1]
    gens_y = R.gens()[j + 1: 2 * (j + 1)]
    gens_z = R.gens()[2 * (j + 1):]
    S = PolynomialRing(R, names="u, v")
    u, v = S.gens()

    def _pol(gens):
        return sum([a * u ** (j - i) * v ** i
                    for i, a in zip(range(j + 1), gens)])

    f_x, f_y, f_z = [_pol(gens) for gens in [gens_x, gens_y, gens_z]]
    A = matrix([[f_x, f_y],
                [f_y, f_z]])
    vec = matrix([u, v]).transpose()
    g = (vec.transpose() * A * vec)[0][0]
    pol_dc = {(i, j + 2 - i): g[(i, j + 2 - i)] for i in range(j + 3)}

    def pol_to_val(f):
        dct = {}

        def _dct(gens, v):
            return {a: b for a, b in zip(gens, v)}

        dct.update(_dct(gens_x, v1))
        dct.update(_dct(gens_y, v2))
        dct.update(_dct(gens_z, v3))
        return f.subs(dct)

    res_dc = {k: pol_to_val(v) for k, v in pol_dc.iteritems()}
    return [res_dc[(j + 2 - i, i)] for i in range(j + 3)]
Пример #19
0
def gluing_equation_ideal(manifold):
    n = manifold.num_tetrahedra()
    R = PolynomialRing(QQ, 'z', n)
    zs = R.gens()
    eqns = manifold.gluing_equations('rect')
    c_to_exp = {1: 0, -1: 1}
    hermite = matrix([a + b + [c_to_exp[c]]
                      for a, b, c in eqns]).hermite_form()
    eqns = [(row[:n], row[n:2 * n], row[-1] % 2) for row in hermite
            if not (row[:-1] == 0 and row[-1] % 2 == 0)]
    return R.ideal([polynomial_eval_eqn(eqn, zs) for eqn in eqns])
Пример #20
0
def G_poly(l, m):
    '''The polynomial G of y1, y2 and y3 given in Proposition 3.7, [Kat].
    '''
    R = PolynomialRing(QQ, names="y1, y2, y3")
    y1, y2, y3 = R.gens()
    return sum(binomial(2 * n + l - QQ(5) / QQ(2), n) * y3 ** n *
               sum((-y2) ** nu * (2 * y1) ** (m - 2 * n - 2 * nu) *
                   binomial(l + m - nu - QQ(5) / QQ(2), m - 2 * n - nu) *
                   binomial(m - 2 * n - nu, nu)
                   for nu in range((m - 2 * n) // 2 + 1))
               for n in range(m // 2 + 1))
Пример #21
0
 def _hecke_tp_charpoly(self, p, var='x', algorithm='linbox'):
     a = p ** (self.wt - 2) + 1
     N = self.klingeneisensteinAndCuspForms()
     S = CuspForms(1, self.wt)
     m = S.dimension()
     R = PolynomialRing(QQ, names=var)
     x = R.gens()[0]
     f = R(S.hecke_matrix(p).charpoly(var=var, algorithm=algorithm))
     f1 = f.subs({x: a ** (-1) * x}) * a ** m
     g = R(N.hecke_matrix(p).charpoly(var=var, algorithm=algorithm))
     return R(g / f1)
Пример #22
0
def homog(F, d):
    """ List of homogeneous polynomials in F[X,Y] of degree d, up to scaling.
    """
    Fx = PolynomialRing(F, 'x')
    Fxy = PolynomialRing(F, ['x', 'y'])
    x, y = Fxy.gens()

    def homog(f):
        return Fxy(y**d * f(x / y))

    return [homog(Fx(list(v))) for v in ProjectiveSpace(F, d)]
Пример #23
0
def intersection_points(F,G):
    """Given F, G homogeneous in 3 variables, returns a list of their
    intersection points in P^2.  Note that we can just find the
    rational_points() on the associated subscheme of P^2 but over Q
    that takes much longer.
    """
    R3 = F.parent()
    k = R3.base_ring()
    R2 = PolynomialRing(k,2,'uv')
    u,v = R2.gens()
    R1 = PolynomialRing(k,'w')
    w = R1.gens()[0]
    sols = []

    # We stratify the possible points as follows:
    # (1) [0,1,0], checked directly;
    # (2) [1,y,0], roots of a univariate polynomial;
    # (3) [x,y,1], found using resultants

    # Check the point [0,1,0] with X=Z=0:
    if F([0,1,0])==0 and G([0,1,0])==0:
        sols = [[0,1,0]]

    # Find other points [1,y,0] with Z=0:
    f = F([1,w,0])
    g = G([1,w,0])
    h = f.gcd(g)
    sols += [[1,r,0] for r in h.roots(multiplicities=False)]

    # Find all other points [x,y,1] with Z!=0:
    f = F([u,v,1])
    g = G([u,v,1])
    # the following resultant is w.r.t. the first variable u, so is a
    # polynomial in v; we convert it into a univariate polynomial in
    # w:
    res = (f.resultant(g))([1,w])
    for r in res.roots(multiplicities=False):
        h = f([w,r]).gcd(g([w,r]))
        for s in h.roots(multiplicities=False):
            sols.append([s,r,1])
    return sols
Пример #24
0
def interpolate_deg2(dct, bd, autom=True, parity=None):
    '''parity is 0 if the parity of the weight and the character coincide
    else 1.
    '''
    t_ring = PolynomialRing(QQ, names="t")
    t = t_ring.gens()[0]
    u_ring = PolynomialRing(QQ, names="u")
    u = u_ring.gens()[0]

    # lift the values of dct
    dct = {k: v.lift() for k, v in dct.items()}

    def interpolate_pol(x, d):
        prd = mul([x - a for a in d])
        prd_dff = prd.derivative(x)
        return sum([v * prd_dff.subs({x: k}) ** (-1) * prd // (x - k)
                    for k, v in d.items()])

    def t_pol_dct(n, m):
        if not autom:
            dct_t = {a: v[(n, m)] * a ** (2 * bd) for a, v in dct.items()}
            return t_ring(interpolate_pol(t, dct_t))
        # put u = t + t^(-1)
        elif parity == 0:
            dct_u = {a + a ** (-1): v[(n, m)] for a, v in dct.items()}
            u_pol = interpolate_pol(u, dct_u)
            return t_ring(t ** (2 * bd) * u_pol.subs({u: t + t ** (-1)}))
        else:
            dct_u = {a + a ** (-1): v[(n, m)] / (a - a ** (-1))
                     for a, v in dct.items()}
            u_pol = interpolate_pol(u, dct_u)
            return t_ring(t ** (2 * bd) * u_pol.subs({u: t + t ** (-1)}) *
                          (t - t ** (-1)))

    fc_dct = {}
    for n in range(bd + 1):
        for m in range(bd + 1):
            pl = t_pol_dct(n, m)
            for r in range(-int(floor(2 * sqrt(n * m))), int(floor(2 * sqrt(n * m))) + 1):
                fc_dct[(n, r, m)] = pl[r + 2 * bd]
    return fc_dct
Пример #25
0
 def _get_Rgens(self):
     d = self.dim
     if self.single_generator:
         if self.hecke_ring_power_basis and self.field_poly_root_of_unity != 0:
             R = PolynomialRing(QQ, self._nu_var)
         else:
             R = PolynomialRing(QQ, 'beta')
         beta = R.gen()
         return [beta**i for i in range(d)]
     else:
         R = PolynomialRing(QQ, ['beta%s' % i for i in range(1,d)])
         return [1] + [g for g in R.gens()]
Пример #26
0
 def curve_string_parser(self, rec):
     curve_str = rec["curve"]
     curve_str = curve_str.replace("^", "**")
     K = self.make_base_field(rec)
     nu = K.gens()[0]
     S0 = PolynomialRing(K, "x")
     x = S0.gens()[0]
     S = PolynomialRing(S0, "y")
     y = S.gens()[0]
     parts = curve_str.split("=")
     lhs_poly = sage_eval(parts[0], locals={"x": x, "y": y, "nu": nu})
     lhs_cs = lhs_poly.coefficients()
     if len(lhs_cs) == 1:
         h = 0
     elif len(lhs_cs) == 2:  # if there is a cross-term
         h = lhs_poly.coefficients()[0]
     else:
         raise NotImplementedError("for genus > 2")
     # rhs_poly = sage_eval(parts[1], locals = {'x':x, 'y':y, 'nu':nu})
     f = sage_eval(parts[1], locals={"x": x, "y": y, "nu": nu})
     return f, h
Пример #27
0
def dict_to_pol(dct, bd=global_prec, base_ring=QQ):
    R = PolynomialRing(base_ring, "u1, u2, q1, q2")
    (u1, u2, q1, q2) = R.gens()
    S = R.quotient(u1 * u2 - 1)
    (uu1, uu2, qq1, qq2) = S.gens()

    l = PrecisionDeg2(bd)
    if not hasattr(dct, "__getitem__"):
        return dct
    return sum([dct[(n, r, m)] * uu1 ** r * qq1 ** n * qq2 ** m
                if r > 0 else dct[(n, r, m)]
                * uu2 ** (-r) * qq1 ** n * qq2 ** m for n, r, m in l])
Пример #28
0
def belongs_to_radical(f, I):
    """
    Test if f in I.radical().
    """
    R = PolynomialRing(QQ,
                       I.ring().ngens() + 1,
                       I.ring().variable_names() + ('Zoo', ))
    Zoo = R.gens()[-1]
    J = R.ideal([R(g) for g in I.gens()] + [R(1) - Zoo * R(f)])
    return [
        R(1)
    ] == J.groebner_basis(algorithm='singular' if common.plumber else '')
Пример #29
0
 def test_cusp_sp_wt28_hecke_charpoly(self):
     R = PolynomialRing(QQ, names="x")
     x = R.gens()[0]
     pl = (x ** Integer(7) - Integer(599148384) * x ** Integer(6) +
           Integer(85597740037545984) * x ** Integer(5) +
           Integer(4052196666582552432082944) * x ** Integer(4) -
           Integer(992490558368877866775830593536000) * x ** Integer(3) -
           Integer(7786461340613962559507216233894458163200) * x ** Integer(2) +
           Integer(2554655965904300151500968857660777576875950080000) * x +
           Integer(2246305351725266922462270484154998253269432286576640000))
     S = CuspFormsDegree2(28)
     self.assertTrue(R(S.hecke_charpoly(2)) == pl)
Пример #30
0
    def root(self):
        if self.mode == 'K':
            ell = self.ell
            self.RS = RationalSet([PositiveOrthant(ell)], ambient_dim=ell)

            actual_ring = self.ring
            F = FractionField(actual_ring)
            r = matrix(F, self.R).rank()
            self.r = r
            if not self.d:
                return

            F = [
                LaurentIdeal(
                    gens=[LaurentPolynomial(f) for f in self.R.minors(j)],
                    RS=self.RS,
                    normalise=True) for j in range(r + 1)
            ]
        elif self.mode == 'O':
            self.RS = RationalSet([PositiveOrthant(self.d)],
                                  ambient_dim=self.d)
            actual_ring = PolynomialRing(QQ, 'x', self.d)
            xx = vector(actual_ring, actual_ring.gens())
            self.C = matrix(actual_ring,
                            [xx * matrix(actual_ring, A) for A in self.basis])
            r = matrix(FractionField(actual_ring), self.C).rank()
            self.r = r
            if not self.d:
                return
            F = [
                LaurentIdeal(
                    gens=[LaurentPolynomial(f) for f in self.C.minors(j)],
                    RS=self.RS,
                    normalise=True) for j in range(r + 1)
            ]
        else:
            raise ValueError('invalid mode')

        oo = r + 1

        # On pairs:
        # The first component is used as is, the second is multiplied by the extra
        # variable. Note that index 0 corresponds to {1} and index oo to {0}.
        self.pairs = ([(oo, 0)] + [(i, oo) for i in range(1, r)] +
                      [(i, i - 1) for i in range(1, r + 1)])
        # Total number of pairs: 2 * r
        self.integrand = ((1, ) + (2 * r - 1) * (0, ),
                          (self.d - r + 1, ) + (r - 1) * (-1, ) + r * (+1, ))
        self.datum = IgusaDatum(F + [
            LaurentIdeal(gens=[], RS=self.RS, ring=FractionField(actual_ring))
        ]).simplify()
        return self.datum
Пример #31
0
 def _test(self):
     from sage.all import GF, PolynomialRing, proof
     k = GF(4, 'u')
     u = k.gen()
     R = PolynomialRing(k, 'v')
     v = R.gen()
     l = R.quo(v**3 + v + 1)
     v = l.gen()
     R = PolynomialRing(l, 'x,y')
     x, y = R.gens()
     f = y**3 + x**3 + (u + 1) * x
     with proof.WithProof('polynomial', False):
         f.factor()
Пример #32
0
 def enum_proj_points(I):
     R = I.ring()
     k = R.base()
     n = R.ngens() - 1
     for i in range(n + 1):
         R_ = PolynomialRing(k, 'x', n - i)
         v = [k(0)] * i + [k(1)]
         pr = R.hom(v + list(R_.gens()), R_)
         for rest in enum_points(pr(I)):
             pt = v + rest
             if bound == None or global_height(
                     pt, prec=prec) <= bound + tolerance:
                 yield pt
Пример #33
0
def gluing_equation_ideal_alt(manifold):
    n = manifold.num_tetrahedra()
    vars = []
    for i in range(n):
        vars += ['z%d' % i, 'zp%d' % i, 'zpp%d' % i]
    R = PolynomialRing(QQ, vars)
    zs = R.gens()
    toric_eqns = matrix(manifold.gluing_equations('log')).hermite_form()
    eqns = [toric_to_poly(zs, eqn) for eqn in toric_eqns]
    for i in range(n):
        z, zp, zpp = zs[3 * i:3 * (i + 1)]
        eqns += [z * zp * zpp + 1, zp * (1 - z) - 1]
    return R.ideal(eqns)
Пример #34
0
def _to_polynomial(f, val1):
    prec = f.prec.value
    R = PolynomialRing(QQ if f.base_ring == ZZ else f.base_ring,
                       names="q1, q2")
    q1, q2 = R.gens()
    I = R.ideal([q1 ** (prec + 1), q2 ** (prec + 1)])
    S = R.quotient_ring(I)
    res = sum([sum([f.fc_dct.get((n, r, m), 0) * QQ(val1) ** r
                    for r in range(-int(floor(2 * sqrt(n * m))), int(floor(2 * sqrt(n * m))) + 1)])
               * q1 ** n * q2 ** m
               for n in range(prec + 1)
               for m in range(prec + 1)])
    return S(res)
Пример #35
0
 def eu(p):
     """
     local euler factor
     """
     if self.selfdual:
         K = QQ
     else:
         K = ComplexField()
     R = PolynomialRing(K, "T")
     T = R.gens()[0]
     if self.conductor % p != 0:
         return  1 - ComplexField()(chi(p)) * T
     else:
         return R(1)
Пример #36
0
 def eu(p):
     """
     local euler factor
     """
     if self.selfdual:
         K = QQ
     else:
         K = ComplexField()
     R = PolynomialRing(K, "T")
     T = R.gens()[0]
     if self.conductor % p != 0:
         return 1 - ComplexField()(chi(p)) * T
     else:
         return R(1)
Пример #37
0
 def eu(p):
     """
     Local euler factor
     """
     ans = F.q_expansion_embeddings(p + 1)
     K = ComplexField()
     R = PolynomialRing(K, "T")
     T = R.gens()[0]
     N = self.conductor
     if N % p != 0 : # good reduction
         return 1 - ans[p-1][self.number] * T + T**2
     elif N % (p**2) != 0: # semistable reduction
         return 1 - ans[p-1][self.number] * T
     else:
         return R(1)
Пример #38
0
def extract_frobenius(E, f):
    Q = PolynomialRing(E.base_field(), 'x')
    R = PolynomialRing(E.base_field(), ['x', 'y'])
    x, y = R.gens()
    u, v = Q(f[0].numerator()), Q(f[0].denominator())
    s, t = R(f[1].numerator()), R(f[1].denominator())
    s = Q((s / y).numerator())
    r = 0
    while u.derivative() == 0:
        r += 1
        u = extract_frobenius_poly(E, u)
        v = extract_frobenius_poly(E, v)
        s = extract_frobenius_poly(E, s)
        t = extract_frobenius_poly(E, t)
    return (u / v, s * y / t), r
Пример #39
0
def m_operator(k1, k2, k3, rnames=None, unames=None):
    '''The operator M_k by van Dorp.
    '''
    if rnames is None:
        rnames = "r11, r12, r22, s11, s12, s22, t11, t12, t22"
    if unames is None:
        unames = "u1, u2"
    R = PolynomialRing(QQ, names=rnames)
    S = PolynomialRing(R, names=unames)
    r11, r12, r22, s11, s12, s22, t11, t12, t22 = R.gens()
    rs = (r11, r12, r22)
    ss = (s11, s12, s22)
    ts = (t11, t12, t22)
    u1, u2 = S.gens()

    def bracket_op(rs):
        r1, r2, r3 = rs
        return r1 * u1**2 + 2 * r2*u1*u2 + r3 * u2**2

    def x_op_val(f):
        r, s, t = f.parent().gens()
        return f.subs({r: bracket_op(rs),
                       s: bracket_op(ss),
                       t: bracket_op(ts)})

    def m_op_val(f):
        r, s, t = f.parent().gens()
        x_val = x_op_val(f)
        xs = [k * x_val for k in [k3, k2, k1]]
        brxs = [bracket_op(a) * x_op_val(f.derivative(b))
                for a, b in zip([ts, ss, rs], [t, s, r])]
        brcks = [bracket_op(cross_prod(a, b))
                 for a, b in zip([rs, ts, ss], [ss, rs, ts])]
        return sum([a * (b + c) for a, b, c in zip(brcks, xs, brxs)])

    return m_op_val
Пример #40
0
 def euler_factor_of_spinor_l(self, p, var="x"):
     '''
     Assuming self is eigenform, this method returns p-Euler factor of
     spinor L as a polynomial.
     '''
     K = self.base_ring
     if hasattr(K, "fraction_field"):
         K = K.fraction_field()
     R = PolynomialRing(K, 1, names=var, order='neglex')
     x = R.gens()[0]
     a1 = self.hecke_eigenvalue(p)
     a2 = self.hecke_eigenvalue(p ** 2)
     mu = 2 * self.wt + self.sym_wt - 3
     return (1 - a1 * x + (a1 ** 2 - a2 - p ** (mu - 1)) * x ** 2 -
             a1 * p ** mu * x ** 3 + p ** (2 * mu) * x ** 4)
Пример #41
0
 def eu(p):
     """
     Local euler factor
     """
     # There was no function q_expansion_embeddings before the transition to postgres
     # so I'm not sure what this is supposed to do.
     ans = F.q_expansion_embeddings(p + 1)
     K = ComplexField()
     R = PolynomialRing(K, "T")
     T = R.gens()[0]
     N = self.conductor
     if N % p != 0 : # good reduction
         return 1 - ans[p-1][self.number] * T + T**2
     elif N % (p**2) != 0: # semistable reduction
         return 1 - ans[p-1][self.number] * T
     else:
         return R(1)
Пример #42
0
def tr(word):
    R = PolynomialRing(QQ, ['x', 'y', 'z'])
    x, y, z = R.gens()
    simple_cases = {'': 2, 'a': x, 'A': x, 'b': y, 'B': y, 'ab': z, 'ba': z}
    if simple_cases.has_key(word):
        return simple_cases[word]
    L = some_letter_repeats(word)
    if L != None:
        i = word.find(L)
        w = word[i:] + word[:i]
        j = w[1:].find(L) + 1
        w1, w2 = w[:j], w[j:]
    else:  # Reduce the number of inverse letters
        i = [i for i, L in enumerate(word) if L == L.upper()][0]
        w = word[i:] + word[:i]
        w1, w2 = w[:1], w[1:]
    return tr(w1) * tr(w2) - tr(reduce_word(inverse_word(w1) + w2))
Пример #43
0
    def _hecke_tp2_charpoly(self, p, var='x', algorithm='linbox'):
        u = p ** (self.wt - 2)
        N = self.klingeneisensteinAndCuspForms()
        S = CuspForms(1, self.wt)
        m = S.dimension()
        R = PolynomialRing(QQ, names=var)
        x = R.gens()[0]
        f = R(S.hecke_matrix(p).charpoly(var=var, algorithm=algorithm))
        g = R(N.hecke_matrix(p ** 2).charpoly(var=var, algorithm=algorithm))

        def morph(a, b, f, m):
            G = (-1) ** m * f.subs({x: -x}) * f
            alst = [[k // 2, v] for k, v in G.dict().iteritems()]
            F = sum([v * x ** k for k, v in alst])
            return a ** m * F.subs({x: (x - b) / a})
        f1 = morph(u ** 2 + u + 1, -p * u ** 3 - u ** 2 - p * u, f, m)
        return R(g / f1)
Пример #44
0
 def eu(p):
     """
     Local euler factor
     """
     # There was no function q_expansion_embeddings before the transition to postgres
     # so I'm not sure what this is supposed to do.
     ans = F.q_expansion_embeddings(p + 1)
     K = ComplexField()
     R = PolynomialRing(K, "T")
     T = R.gens()[0]
     N = self.conductor
     if N % p != 0:  # good reduction
         return 1 - ans[p - 1][self.number] * T + T**2
     elif N % (p**2) != 0:  # semistable reduction
         return 1 - ans[p - 1][self.number] * T
     else:
         return R(1)
Пример #45
0
def _odd_sym6_pol_dct():
    R = PolynomialRing(QQ, names="r,s,t")
    r, s, t = R.gens()
    dnm = {15: QQ(160),
           17: QQ(192),
           19: QQ(1920),
           21: QQ(2880),
           23: QQ(16)}
    nm = {15: (5, -14, 7),
          17: (4, -8, 3),
          19: (22, -24, 5),
          21: (22, -24, 5),
          23: (13, -14, 3)}
    res = {}
    for k in dnm.keys():
        a, b, c = nm[k]
        res[k] = (a*r**2 + b * r * t + c*t**2) * QQ(1)/QQ(dnm[k])
    return res
Пример #46
0
 def euler_factor_of_standard_l(self, p, var="x"):
     '''
     Assuming self is eigenform, this method returns p-Euler factor of
     standard L as a polynomial.
     '''
     K = self.base_ring
     if hasattr(K, "fraction_field"):
         K = K.fraction_field()
     mu = 2 * self.wt + self.sym_wt - 3
     b = p ** mu
     laml = self.hecke_eigenvalue(p)
     laml2 = self.hecke_eigenvalue(p ** 2)
     a1 = laml ** 2 / QQ(b)
     a2 = laml2 / QQ(b) + QQ(1) / QQ(p)
     R = PolynomialRing(K, 1, names=var, order='neglex')
     x = R.gens()[0]
     return 1 + (a2 - a1 + 1) * x + a2 * x ** 2 - a2 * x ** 3 \
         + (-a2 + a1 - 1) * x ** 4 - x ** 5
Пример #47
0
def pol_to_dict(pl, bd=global_prec, base_ring=QQ):
    R = PolynomialRing(base_ring, "u1,u2,q1,q2")
    (u1, u2, q1, q2) = R.gens()
    S = R.quotient(u1 * u2 - 1)
    (uu1, uu2, qq1, qq2) = S.gens()
    l = PrecisionDeg2(bd)
    pl_lft = pl.lift()
    dct = dict()
    for n, r, m in l:
        if r >= 0:
            cfs = pl_lft.coefficient({u1: r, u2: 0, q1: n, q2: m})
        else:
            cfs = pl_lft.coefficient({u1: 0, u2: -r, q1: n, q2: m})
        dct[(n, r, m)] = cfs
    for t in l:
        if not t in dct.keys():
            dct[t] = 0
    return dct
Пример #48
0
 def eu(p):
     """
     Local Euler factor passed as a function
     whose input is a prime and
     whose output is a polynomial
     such that evaluated at p^-s,
     we get the inverse of the local factor
     of the L-function
     """
     R = PolynomialRing(QQ, "T")
     T = R.gens()[0]
     N = self.conductor
     if N % p != 0 : # good reduction
         return 1 - E.ap(p) * T + p * T**2
     elif N % (p**2) != 0: # multiplicative reduction
         return 1 - E.ap(p) * T
     else:
         return R(1)
Пример #49
0
 def eu(p):
     """
     Local Euler factor passed as a function
     whose input is a prime and
     whose output is a polynomial
     such that evaluated at p^-s,
     we get the inverse of the local factor
     of the L-function
     """
     R = PolynomialRing(QQ, "T")
     T = R.gens()[0]
     N = self.conductor
     if N % p != 0:  # good reduction
         return 1 - E.ap(p) * T + p * T**2
     elif N % (p**2) != 0:  # multiplicative reduction
         return 1 - E.ap(p) * T
     else:
         return R(1)
Пример #50
0
    def test_vecor_valued_klingen(self):
        lst = [(18, 2), (20, 2), (12, 4), (14, 4)]
        R = PolynomialRing(QQ, names="x")
        x = R.gens()[0]

        def euler_factor_at_2(f):
            wt = f.weight()
            return 1 - f[2] * x + 2 ** (wt - 1) * x ** 2

        for k, j in lst:
            M = vvld_smfs(j, k, 4)
            S = CuspForms(1, j + k)
            f = S.basis()[0]
            f = f * f[1] ** (-1)
            pl = euler_factor_at_2(f)
            lam = (1 + 2 ** (k - 2)) * f[2]
            F = M.eigenform_with_eigenvalue_t2(lam)
            self.assertEqual(R(F.euler_factor_of_spinor_l(2)),
                             pl * pl.subs({x: 2 ** (k - 2) * x}))
Пример #51
0
    def eigenvector_with_eigenvalue(self, lin_op, lm):
        '''Let lin_op(f, t) be an endomorphsim of self and assume
        it has a unique eigenvector (up to constant) with eigenvalue lm.
        This medhod returns an eigenvector.
        '''
        basis = self.basis()
        dim = len(basis)
        if hasattr(lm, "parent"):
            K = lm.parent()
            if hasattr(K, "fraction_field"):
                K = K.fraction_field()
        else:
            K = QQ
        A = self.matrix_representaion(lin_op)
        S = PolynomialRing(K, names="x")
        x = S.gens()[0]
        f = S(A.charpoly())
        g = S(f // (x - lm))
        cffs_g = [g[y] for y in range(dim)]
        A_pws = []
        C = identity_matrix(dim)
        for i in range(dim):
            A_pws.append(C)
            C = A * C

        for i in range(dim):
            clm_i = [a.columns()[i] for a in A_pws]
            w = sum((a * v for a, v in zip(cffs_g, clm_i)))
            if w != 0:
                egvec = w
                break

        res = sum([a * b for a, b in zip(egvec, basis)])
        # TODO: Use a construction class to construct basis.
        if all(hasattr(b, "_construction") and
               b._construction is not None for b in basis):
            res._construction = sum([a * b._construction
                                     for a, b in zip(egvec, basis)])

        if hasattr(res, 'set_parent_space'):
            res.set_parent_space(self)
        return res
Пример #52
0
def graph_to_generic_matrix(G, t):
    if t not in ['symmetric', 'antisymmetric']:
        raise ValueError('unsupported type of matrix')
    if G.has_multiple_edges():
        raise ValueError('parallel edges not supported')

    A = G.adjacency_matrix()
    d = A.nrows()
    n = sum(A[i, j] for i in range(d) for j in range(i, d))
    R = PolynomialRing(QQ, n, 'x')
    B = matrix(R, d, d)

    it = iter(R.gens())

    for i in range(d):
        for j in range(i, d):
            B[i, j] = next(it) if A[i, j] else 0
            if i < j:
                B[j, i] = -B[i, j] if t == 'antisymmetric' else B[i, j]
    return B
Пример #53
0
def find_sqrt(a, p):
    assert (p - Integer(1)) % Integer(4) == Integer(0)
    assert legendre_symbol(a, p) == Integer(1)

    S = PolynomialRing(GF(p), names=('x',))
    (x,) = S.gens()
    R = S.quotient(x**Integer(2) - a, names=('alpha',))
    (alpha,) = R.gens()

    while True:
        z = GF(p).random_element()
        w = (Integer(1) + z * alpha)**((p - Integer(1)) // Integer(2))
        (u, v) = (w[Integer(0)], w[Integer(1)])
        if v != Integer(0):
            break

    if (-u / v)**Integer(2) == a:
        return -u / v
    if ((Integer(1) - u) / v)**Integer(2) == a:
        return (Integer(1) - u) / v
    if ((-Integer(1) - u) / v)**Integer(2) == a:
        return (-Integer(1) - u) / v
Пример #54
0
def add_maps(f, g, E):
    if f == 0:
        return g
    if g == 0:
        return f
    Q = PolynomialRing(E.base_ring(), ['x', 'y'])
    x, y = Q.gens()
    a = E.a4()
    b = E.a6()
    r = x**3 + a * x + b
    if f[0] != g[0]:
        m = (g[1] - f[1]) / (g[0] - f[0])
        sum_x = m**2 - f[0] - g[0]
        sum_y = m * (f[0] - sum_x) - f[1]
        return standard_form((sum_x, sum_y), E)
    if f[1] != g[1]:
        return 0
    if f == g and f[1] == 0:
        return 0
    if f == g and f[1] != 0:
        m = (3 * f[0]**2 + a) / (2 * f[1])
        sum_x = m**2 - 2 * f[0]
        sum_y = m * (f[0] - sum_x) - f[1]
        return standard_form((sum_x, sum_y), E)
Пример #55
0
def crystalline_obstruction(f,
                            p,
                            precision,
                            over_Qp=False,
                            pedantic=False,
                            **kwargs):
    """
    INPUT:

    - ``f`` -- a polynomial defining the curve or surface.  Note if given an hyperelliptic curve we will try to change the model over Qpbar,
    in order to work with an odd and monic model over Qp.

    - ``p`` -- a prime of good reduction

    - ``precision`` -- a lower bound for the desired precision to run the computations, this increases the time exponentially

    - ``over_Qp`` -- by default False, if True uses the factorization of the cyclotomic polynomials over Qp

    - ``pedantic` -- by default False, if True might inform user of some bound improvements which werent achieved by pure linear algebra arguments

    - ``kwargs`` -- keyword arguments to bypass some computations or to be passed to controlledreduction

    OUTPUT:

    - an upper bound on the number of Tate classes over Qbar

    - a dictionary more information, matching the papers notation, on how one we attained that bound



    EXAMPLES::

    README examples

    Jacobians of hyperelliptic curves with a Weierstrass point over Qp

    Example 5.1

        sage: from crystalline_obstruction import crystalline_obstruction
        sage: f = ZZ['x,y']('x^5 - 2*x^4 + 2*x^3 - 4*x^2 + 3*x - 1 -y^2')
        sage: crystalline_obstruction(f=f, p=31, precision=3) # bounding dim Pic
        (1,
         {'dim Li': [1],
          'dim Ti': [2],
          'factors': [(t - 1, 2)],
          'p': 31,
          'precision': 3,
          'rank T(X_Fpbar)': 2})


    Bounding the geometric dimension of Endomorphism algebra

        sage: f = ZZ['x,y']('x^5 - 2*x^4 + 2*x^3 - 4*x^2 + 3*x - 1 -y^2')
        sage: crystalline_obstruction(f=f, p=31, precision=3, tensor=True) # bounding dim End
        (1,
         {'dim Li': [1],
          'dim Ti': [4],
          'factors': [(t - 1, 4)],
          'p': 31,
          'precision': 3,
          'rank T(X_Fpbar)': 4})

    Example 5.2

        sage: f = ZZ['x,y']('x^5 - 2*x^4 + 7*x^3 - 5*x^2 + 8*x + 3 -y^2')
        sage: crystalline_obstruction(f=f, p=4999, precision=20) # bounding dim Pic
        (2,
         {'dim Li': [2],
          'dim Ti': [2],
          'factors': [(t - 1, 2)],
          'p': 4999,
          'precision': 20,
          'rank T(X_Fpbar)': 2})

    Hyperelliptic curve given in a non-Weierstrass format

        sage: f = ZZ['x,y']('(2*x^6+3*x^5+5*x^4+6*x^3+4*x^2+x) -y*(x^4+x^3+x) -y^2')
        sage: crystalline_obstruction(f=f, p=59, precision=3)
        (3,
         {'dim Li': [1, 2],
          'dim Ti': [3, 6],
          'factors': [(t - 1, 3), (t^2 + t + 1, 3)],
          'p': 59,
          'precision': 3,
          'rank T(X_Fpbar)': 9})

    Jacobians of quartic plane curves
    Example 5.3

        sage: f = ZZ['x,y,z']('x*y^3 + x^3*z - x*y^2*z + x^2*z^2 + y^2*z^2 - y*z^3')
        sage: crystalline_obstruction(f, p=31, precision=3) # bounding dim Pic
        (1,
         {'dim Li': [1],
          'dim Ti': [3],
          'factors': [(t - 1, 3)],
          'p': 31,
          'precision': 3,
          'rank T(X_Fpbar)': 3})

    Product of 3 elliptic curves over x^3 - 3*x - 1

        sage: f=ZZ['x,y,z']('x^3*z + x^2*y*z + x^2*z^2 - x*y^3 - x*y*z^2 - x*z^3 + y^2*z^2')
        sage: crystalline_obstruction(f=f, p=31, precision=3) # bounding dim Pic
        (3,
         {'dim Li': [1, 2],
          'dim Ti': [3, 6],
          'factors': [(t - 1, 3), (t^2 + t + 1, 3)],
          'p': 31,
          'precision': 3,
          'rank T(X_Fpbar)': 9})


    Another gennus 3 plane quartic

        sage: f = ZZ['x,y,z']('x^4+x^2*y^2+2*x^2*y*z-x^2*z^2-6*y^4+16*y^3*z-12*y^2*z^2-16*y*z^3-6*z^4')
        sage: crystalline_obstruction(f=f, p=5003, precision=3) # bounding dim Pic
        (6,
         {'dim Li': [2, 2, 2],
          'dim Ti': [2, 3, 4],
          'factors': [(t + 1, 2), (t - 1, 3), (t^2 + 1, 2)],
          'p': 5003,
          'precision': 3,
          'rank T(X_Fpbar)': 9})
        sage: crystalline_obstruction(f=f, p=5003, precision=3, tensor=True) # bounding dim End
        (9,
         {'dim Li': [2, 3, 4],
          'dim Ti': [4, 6, 8],
          'factors': [(t + 1, 4), (t - 1, 6), (t^2 + 1, 4)],
          'p': 5003,
          'precision': 3,
          'rank T(X_Fpbar)': 18})

    Quartic surfaces

    Example 5.5

        sage: f = ZZ['x,y,z,w']("x^4 + y^4 + z^4 + w^4 + 101^3*x*y*z*w")
        sage: crystalline_obstruction(f, p=101, precision=3)
        (20,
         {'dim Li': [1, 7, 12],
          'dim Ti': [1, 7, 12],
          'factors': [(t - 1, 1), (t - 1, 7), (t + 1, 12)],
          'p': 101,
          'precision': 3,
          'rank T(X_Fpbar)': 20})
        sage: crystalline_obstruction(f=f, p=101, precision=4)
        (19,
         {'dim Li': [1, 6, 12],
          'dim Ti': [1, 7, 12],
          'factors': [(t - 1, 1), (t - 1, 7), (t + 1, 12)],
          'p': 101,
          'precision': 4,
          'rank T(X_Fpbar)': 20})

    Example 5.6

        sage: f = ZZ['x,y,z,w']("y^4 - x^3*z + y*z^3 + z*w^3 + w^4")
        sage: crystalline_obstruction(f=f, p=89, precision=3)
        (4,
         {'dim Li': [1, 0, 3, 0],
          'dim Ti': [1, 1, 4, 4],
          'factors': [(t - 1, 1), (t + 1, 1), (t - 1, 4), (t^4 + 1, 1)],
          'p': 89,
          'precision': 3,
          'rank T(X_Fpbar)': 10})

    Example 5.7

        sage: f = ZZ['x,y,z,w']("x^4 + 2*y^4 + 2*y*z^3 + 3*z^4 - 2*x^3*w- 2*y*w^3")
        sage: crystalline_obstruction(f=f, p=67, precision=3)
        (3,
         {'dim Li': [1, 2],
          'dim Ti': [1, 3],
          'factors': [(t - 1, 1), (t + 1, 3)],
          'p': 67,
          'precision': 3,
          'rank T(X_Fpbar)': 4})

    TESTS::

    Check that precision = 3 is sufficient

        sage: from crystalline_obstruction import crystalline_obstruction
        sage: crystalline_obstruction(f=ZZ['x,y']('y^2-(48*x^8 + 12*x^6 - 22*x^4- 13*x^2 - 2)'),p=107,precision=3)
        (2,
         {'dim Li': [2],
          'dim Ti': [3],
          'factors': [(t - 1, 3)],
          'p': 107,
          'precision': 3,
          'rank T(X_Fpbar)': 3})

    Check that the result is consistent at various primes and different precision parameters and never giving a wrong upper bound:

        sage: crystalline_obstruction(f=ZZ['x,y']('y^2-(48*x^8 + 12*x^6 - 22*x^4- 13*x^2 - 2)'),p=107,precision=3,tensor=True)
        (2,
         {'dim Li': [2],
          'dim Ti': [6],
          'factors': [(t - 1, 6)],
          'p': 107,
          'precision': 3,
          'rank T(X_Fpbar)': 6})
        sage: for p in [103, 107]:
        ....:     for i in range(3,8):
        ....:         print(crystalline_obstruction(f=ZZ['x,y']('-x^8 - 7*x^7 - 7*x^6 + 14*x^5 +35*x^4 + 35*x^3 + 14*x^2 - x - 1 - y^2'),
        ....:                             p=p,precision=i,tensor=True))
        ....:
        (18, {'precision': 3, 'p': 103, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 6), (t + 1, 6), (t^2 - t + 1, 6), (t^2 + t + 1, 6)], 'dim Ti': [6, 6, 12, 12], 'dim Li': [3, 3, 6, 6]})
        (18, {'precision': 4, 'p': 103, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 6), (t + 1, 6), (t^2 - t + 1, 6), (t^2 + t + 1, 6)], 'dim Ti': [6, 6, 12, 12], 'dim Li': [3, 3, 6, 6]})
        (18, {'precision': 5, 'p': 103, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 6), (t + 1, 6), (t^2 - t + 1, 6), (t^2 + t + 1, 6)], 'dim Ti': [6, 6, 12, 12], 'dim Li': [3, 3, 6, 6]})
        (18, {'precision': 6, 'p': 103, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 6), (t + 1, 6), (t^2 - t + 1, 6), (t^2 + t + 1, 6)], 'dim Ti': [6, 6, 12, 12], 'dim Li': [3, 3, 6, 6]})
        (18, {'precision': 7, 'p': 103, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 6), (t + 1, 6), (t^2 - t + 1, 6), (t^2 + t + 1, 6)], 'dim Ti': [6, 6, 12, 12], 'dim Li': [3, 3, 6, 6]})
        (18, {'precision': 3, 'p': 107, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 18), (t + 1, 18)], 'dim Ti': [18, 18], 'dim Li': [9, 9]})
        (18, {'precision': 4, 'p': 107, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 18), (t + 1, 18)], 'dim Ti': [18, 18], 'dim Li': [9, 9]})
        (18, {'precision': 5, 'p': 107, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 18), (t + 1, 18)], 'dim Ti': [18, 18], 'dim Li': [9, 9]})
        (18, {'precision': 6, 'p': 107, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 18), (t + 1, 18)], 'dim Ti': [18, 18], 'dim Li': [9, 9]})
        (18, {'precision': 7, 'p': 107, 'rank T(X_Fpbar)': 36, 'factors': [(t - 1, 18), (t + 1, 18)], 'dim Ti': [18, 18], 'dim Li': [9, 9]})


    Check that some prime attains the (3,3) bound:

        sage: for p in [101, 103, 113]:
        ....:     print(p)
        ....:     print(crystalline_obstruction(ZZ['x,y'](' 4*x^8 - 20*x^6 + 33*x^4 - 17*x^2 - 2 - y^2'), p=p, precision=3))
        ....:     print(crystalline_obstruction(ZZ['x,y'](' 4*x^8 - 20*x^6 + 33*x^4 - 17*x^2 - 2 - y^2'), p=p, precision=3, tensor=True))
        ....:
        101
        (6, {'precision': 3, 'p': 101, 'rank T(X_Fpbar)': 9, 'factors': [(t + 1, 4), (t - 1, 5)], 'dim Ti': [4, 5], 'dim Li': [2, 4]})
        (9, {'precision': 3, 'p': 101, 'rank T(X_Fpbar)': 18, 'factors': [(t + 1, 8), (t - 1, 10)], 'dim Ti': [8, 10], 'dim Li': [4, 5]})
        103
        (4, {'precision': 3, 'p': 103, 'rank T(X_Fpbar)': 5, 'factors': [(t - 1, 5)], 'dim Ti': [5], 'dim Li': [4]})
        (5, {'precision': 3, 'p': 103, 'rank T(X_Fpbar)': 10, 'factors': [(t - 1, 10)], 'dim Ti': [10], 'dim Li': [5]})
        113
        (3, {'precision': 3, 'p': 113, 'rank T(X_Fpbar)': 3, 'factors': [(t - 1, 3)], 'dim Ti': [3], 'dim Li': [3]})
        (3, {'precision': 3, 'p': 113, 'rank T(X_Fpbar)': 6, 'factors': [(t - 1, 6)], 'dim Ti': [6], 'dim Li': [3]})
    """
    if 'cp' in kwargs and 'frob_matrix' in kwargs:
        cp = kwargs['cp']
        frob_matrix = kwargs['frob_matrix']
        shift = kwargs.get('shift', 0)
    else:
        precision, cp, frob_matrix, shift = compute_frob_matrix_and_cp_H2(
            f, p, precision, **kwargs)
    Rt = PolynomialRing(ZZ, 't')
    t = Rt.gens()[0]
    cp = Rt(cp)
    rank, k, cyc_factor = rank_fieldextension(cp, shift)
    if cyc_factor:
        tate_factor = tate_factor_Zp(cyc_factor.expand())
        max_degree = max(elt.degree() for elt, _ in tate_factor)
        if max_degree > precision - 1:
            warnings.warn(
                'Precision is very likely too low to correctly compute the Tate classes at this prime'
            )
    factor_i, dim_Ti, _, dim_Li = upper_bound_tate(cp,
                                                   frob_matrix,
                                                   precision,
                                                   over_Qp=over_Qp,
                                                   pedantic=pedantic)
    res = {}
    res['precision'] = precision
    res['p'] = p
    res['rank T(X_Fpbar)'] = rank
    res['factors'] = []
    if shift > 0:
        res['factors'].append((t - 1, 1))
    # normalize the cyclotomic factors
    for factor, exp in factor_i:
        res['factors'].append((factor(t / p), exp))
    if over_Qp:
        if shift > 0:
            dim_Li = [[shift]] + dim_Li
            dim_Ti = [[shift]] + dim_Ti
        upper_bound = rank - (sum(sum(dim_Ti, [])) - sum(sum(dim_Li, [])))
    else:
        if shift > 0:
            dim_Li = [shift] + dim_Li
            dim_Ti = [shift] + dim_Ti
        upper_bound = rank - (sum(dim_Ti) - sum(dim_Li))
    res['dim Ti'] = dim_Ti
    res['dim Li'] = dim_Li
    return upper_bound, res
from sage.all import PolynomialRing, ZZ

pr = PolynomialRing(ZZ, ('a', 'd', 'X1', 'X2', 'Y1', 'Y2'), 6)
a, d, X1, X2, Y1, Y2 = pr.gens()
k, d2 = 2 * d, 2 * d
T1 = X1 * Y1
T2 = X2 * Y2
Z1, Z2 = 1, 1
formula = {}
t0 = Y1 - X1
formula['t0'] = t0
t1 = Y2 - X2
formula['t1'] = t1
A = t0 * t1
formula['A'] = A
t2 = Y1 + X1
formula['t2'] = t2
t3 = Y2 + X2
formula['t3'] = t3
B = t2 * t3
formula['B'] = B
t4 = k * T2
formula['t4'] = t4
C = T1 * t4
formula['C'] = C
D = 2 * Z1
formula['D'] = D
E = B - A
formula['E'] = E
F = D - C
formula['F'] = F
Пример #57
0
 def enum_points(I):
     possibleValues = get_elements()
     R = I.ring()
     F = R.base()
     ch = F.characteristic()
     n = R.ngens()
     if n == 0:
         if I.is_zero():
             yield []
         return
     if I.is_one():
         return
     if all(map(lambda _: _.degree() == 1,
                I.gens())) and (ch > 0 or I.dimension() == 0):
         # solve using linear algebra
         f = R.hom(n * [0], F)
         A = matrix([f(g.coefficient(xi)) for xi in R.gens()]
                    for g in I.gens())
         b = vector(-g.constant_coefficient() for g in I.gens())
         v0 = A.solve_right(b)
         r = A.rank()
         if r == n:
             yield list(v0)
         else:
             K = A.right_kernel().matrix()
             for v in F**(n - r):
                 yield list(v * K + v0)
         return
     if ch > 0 and I.is_homogeneous():
         yield [F(0)] * n
         for pt in enum_proj_points(I):
             for sca in get_elements():
                 if sca != 0:
                     yield [x * sca for x in pt]
         return
     elim = I.elimination_ideal(I.ring().gens()[1:])
     g = elim.gens()[0]
     if g != 0:
         S = F['u']
         pr1 = R.hom([S.gen()] + [0] * (n - 1), S)
         possibleValues = (v[0] for v in pr1(g).roots() if bound == None or
                           global_height([v[0], F(1)]) <= bound + tolerance)
         if split:
             nonSplit = (f[0] for f in factor(pr1(g)) if f[0].degree() > 1)
             for f in nonSplit:
                 if ch == 0:
                     F_ = f.splitting_field('a')
                     # `polredbest` from PARI/GP, improves performance significantly
                     f = gen_to_sage(
                         pari(F_.gen().minpoly('x')).polredbest(),
                         {'x': S.gen()})
                 F_ = f.splitting_field('a')
                 R_ = PolynomialRing(F_, 'x', n)
                 I = R_.ideal(
                     [f.change_ring(base_change(F, F_)) for f in I.gens()])
                 for pt in enum_points(I):
                     yield pt
                 return
     R_ = PolynomialRing(F, 'x', n - 1)
     if n == 1:
         for v in possibleValues:
             yield [v]
     else:
         for v in possibleValues:
             pr2 = R.hom([v] + list(R_.gens()), R_)
             for rest in enum_points(pr2(I)):
                 yield [v] + rest
Пример #58
0
def _triple_gens():
    rnames = "r11, r12, r22, s11, s12, s22, t11, t12, t22"
    unames = "u1, u2"
    R = PolynomialRing(QQ, names=rnames)
    S = PolynomialRing(R, names=unames)
    return (R.gens(), S.gens())