Example #1
0
def see_frobs(frob_data):
    ans = []
    seeram = False
    plist = [p for p in primes(2, 60)]
    for i in range(len(plist)):
        p = plist[i]
        dec = frob_data[i][1]
        if dec[0] == 0:
            ans.append([p, 'R'])
            seeram = True
        else:
            s = '$'
            firstone = True
            for j in dec:
                if not firstone:
                    s += r'{,}\,'
                if j[0] < 15:
                    s += r'{\href{%s}{%d} }' % (url_for(
                        'local_fields.by_label', label="%d.%d.0.1" %
                        (p, j[0])), j[0])
                else:
                    s += str(j[0])
                if j[1] > 1:
                    s += '^{' + str(j[1]) + '}'
                firstone = False
            s += '$'
            ans.append([p, s])
    return ans, seeram
Example #2
0
def frobs(nf):
    frob_at_p = residue_field_degrees_function(nf)
    D = nf.disc()
    ans = []
    seeram = False
    for p in primes(2, 60):
        if not ZZ(p).divides(D):
            # [3] ,   [2,1]
            dec = frob_at_p(p)
            vals = list(set(dec))
            vals = sorted(vals, reverse=True)
            dec = [[x, dec.count(x)] for x in vals]
            #dec2 = ["$" + str(x[0]) + ('^{' + str(x[1]) + '}$' if x[1] > 1 else '$') for x in dec]
            s = '$'
            firstone = 1
            for j in dec:
                if firstone == 0:
                    s += '{,}\,'
                s += str(j[0])
                if j[1] > 1:
                    s += '^{' + str(j[1]) + '}'
                firstone = 0
            s += '$'
            ans.append([p, s])
        else:
            ans.append([p, 'R'])
            seeram = True
    return ans, seeram
Example #3
0
def frobs(nf):
    frob_at_p = residue_field_degrees_function(nf)
    D = nf.disc()
    ans = []
    seeram = False
    for p in primes(2, 60):
        if not ZZ(p).divides(D):
            # [3] ,   [2,1]
            dec = frob_at_p(p)
            vals = list(set(dec))
            vals = sorted(vals, reverse=True)
            dec = [[x, dec.count(x)] for x in vals]
            #dec2 = ["$" + str(x[0]) + ('^{' + str(x[1]) + '}$' if x[1] > 1 else '$') for x in dec]
            s = '$'
            firstone = 1
            for j in dec:
                if firstone == 0:
                    s += '{,}\,'
                if j[0] < 15:
                    s += r'{\href{%s}{%d} }' % (url_for(
                        'local_fields.by_label', label="%d.%d.0.1" %
                        (p, j[0])), j[0])
                else:
                    s += str(j[0])
                if j[1] > 1:
                    s += '^{' + str(j[1]) + '}'
                firstone = 0
            s += '$'
            ans.append([p, s])
        else:
            ans.append([p, 'R'])
            seeram = True
    return ans, seeram
Example #4
0
def frobs(K):
    frob_at_p = residue_field_degrees_function(K)
    D = K.disc()
    ans = []
    seeram = False
    for p in primes(2, 60):
        if not ZZ(p).divides(D):
            # [3] ,   [2,1]
            dec = frob_at_p(p)
            vals = list(set(dec))
            vals = sorted(vals, reverse=True)
            dec = [[x, dec.count(x)] for x in vals]
            dec2 = ["$" + str(x[0]) + ('^{' + str(x[1]) + '}$' if x[1] > 1 else '$') for x in dec]
            s = '$'
            firstone = 1
            for j in dec:
                if firstone == 0:
                    s += '{,}\,'
                s += str(j[0])
                if j[1] > 1:
                    s += '^{' + str(j[1]) + '}'
                firstone = 0
            s += '$'
            ans.append([p, s])
        else:
            ans.append([p, 'R'])
            seeram = True
    return ans, seeram
Example #5
0
def frobs(K):
    frob_at_p = residue_field_degrees_function(K)
    D = K.disc()
    ans = []
    seeram = False
    for p in primes(2, 60):
        if not ZZ(p).divides(D):
            # [3] ,   [2,1]
            dec = frob_at_p(p)
            vals = list(set(dec))
            vals = sorted(vals, reverse=True)
            dec = [[x, dec.count(x)] for x in vals]
            dec2 = ["$" + str(x[0]) + ("^{" + str(x[1]) + "}$" if x[1] > 1 else "$") for x in dec]
            s = "$"
            firstone = 1
            for j in dec:
                if firstone == 0:
                    s += "{,}\,"
                s += str(j[0])
                if j[1] > 1:
                    s += "^{" + str(j[1]) + "}"
                firstone = 0
            s += "$"
            ans.append([p, s])
        else:
            ans.append([p, "R"])
            seeram = True
    return ans, seeram
Example #6
0
def test1(B=10**4):
    from sage.all import polygen, primes, QQ, EllipticCurve
    import psage.libs.smalljac.wrapper
    x = polygen(QQ, 'x')
    J = psage.libs.smalljac.wrapper.SmallJac(x**3 + 17 * x + 3)
    E = EllipticCurve([17, 3])
    N = E.conductor()
    for p in primes(B):
        if N % p:
            assert E.ap(p) == J.ap(p)
Example #7
0
def test2(B=500):
    from sage.all import polygen, primes, QQ, GF, HyperellipticCurve
    import psage.libs.smalljac.wrapper
    x = polygen(QQ, 'x')
    J = psage.libs.smalljac.wrapper.SmallJac(x**5 + 17 * x + 3)
    N = 97 * 3749861
    for p in primes(45, B):  # 45 comes from "(2g+1)(2N-1) = 45"
        if N % p:
            x = polygen(GF(p), 'x')
            C = HyperellipticCurve(x**5 + 17 * x + 3)
            assert C.frobenius_polynomial() == J.frob(p).charpoly()
Example #8
0
def test1(B=10 ** 4):
    from sage.all import polygen, primes, QQ, EllipticCurve
    import psage.libs.smalljac.wrapper

    x = polygen(QQ, "x")
    J = psage.libs.smalljac.wrapper.SmallJac(x ** 3 + 17 * x + 3)
    E = EllipticCurve([17, 3])
    N = E.conductor()
    for p in primes(B):
        if N % p:
            assert E.ap(p) == J.ap(p)
Example #9
0
def test2(B=500):
    from sage.all import polygen, primes, QQ, GF, HyperellipticCurve
    import psage.libs.smalljac.wrapper

    x = polygen(QQ, "x")
    J = psage.libs.smalljac.wrapper.SmallJac(x ** 5 + 17 * x + 3)
    N = 97 * 3749861
    for p in primes(45, B):  # 45 comes from "(2g+1)(2N-1) = 45"
        if N % p:
            x = polygen(GF(p), "x")
            C = HyperellipticCurve(x ** 5 + 17 * x + 3)
            assert C.frobenius_polynomial() == J.frob(p).charpoly()
Example #10
0
def read_line(line, debug=0):
    r""" Parses one line from input file.  Returns and a dict containing
    fields with keys as above.

    Sample line: 11 a 1 0,-1,1,-10,-20 7 1,0 0,1,0 0,0 0,1

    Fields: label (3 fields)
            a-invariants
            p0
            For each bad  prime:  'a'                if additive
                                  lambda,mu          if multiplicative (or 'o?' if unknown)
            For each good prime:  lambda,mu          if ordinary (or 'o?' if unknown)
                                  lambda+,lambda-,mu if supersingular (or 's?' if unknown)
    """
    data = {}
    if debug: print("Parsing input line {}".format(line[:-1]))
    fields = line.split()
    label = fields[0]+fields[1]+fields[2]
    data['label'] = label
    N = ZZ(fields[0])
    badp = N.support()
    nbadp = len(badp)
    p0 = int(fields[4])
    data['iwp0'] = p0
    if debug: print("p0={}".format(p0))

    iwdata = {}

    # read data for bad primes

    for p,pdat in zip(badp,fields[5:5+nbadp]):
        p = str(p)
        if debug>1: print("p={}, pdat={}".format(p,pdat))
        if pdat in ['o?','a']:
            iwdata[p]=pdat
        else:
            iwdata[p]=[int(x) for x in pdat.split(",")]

    # read data for all primes

    for p,pdat in zip(primes(1000),fields[5+nbadp:]):
        p = str(p)
        if debug>1: print("p={}, pdat={}".format(p,pdat))
        if pdat in ['s?','o?','a']:
            iwdata[p]=pdat
        else:
            iwdata[p]=[int(x) for x in pdat.split(",")]

    data['iwdata'] = iwdata
    if debug: print("label {}, data {}".format(label,data))
    return label, data
def read_line(line, debug=0):
    r""" Parses one line from input file.  Returns and a dict containing
    fields with keys as above.

    Sample line: 11 a 1 0,-1,1,-10,-20 7 1,0 0,1,0 0,0 0,1

    Fields: label (3 fields)
            a-invariants
            p0
            For each bad  prime:  'a'                if additive
                                  lambda,mu          if multiplicative (or 'o?' if unknown)
            For each good prime:  lambda,mu          if ordinary (or 'o?' if unknown)
                                  lambda+,lambda-,mu if supersingular (or 's?' if unknown)
    """
    data = {}
    if debug: print("Parsing input line {}".format(line[:-1]))
    fields = line.split()
    label = fields[0] + fields[1] + fields[2]
    data['label'] = label
    N = ZZ(fields[0])
    badp = N.support()
    nbadp = len(badp)
    p0 = int(fields[4])
    data['iwp0'] = p0
    if debug: print("p0={}".format(p0))

    iwdata = {}

    # read data for bad primes

    for p, pdat in zip(badp, fields[5:5 + nbadp]):
        p = str(p)
        if debug > 1: print("p={}, pdat={}".format(p, pdat))
        if pdat in ['o?', 'a']:
            iwdata[p] = pdat
        else:
            iwdata[p] = [int(x) for x in pdat.split(",")]

    # read data for all primes

    for p, pdat in zip(primes(1000), fields[5 + nbadp:]):
        p = str(p)
        if debug > 1: print("p={}, pdat={}".format(p, pdat))
        if pdat in ['s?', 'o?', 'a']:
            iwdata[p] = pdat
        else:
            iwdata[p] = [int(x) for x in pdat.split(",")]

    data['iwdata'] = iwdata
    if debug: print("label {}, data {}".format(label, data))
    return label, data
Example #12
0
def period_mapping(M):
    N=M.level()
    S=M.cuspidal_subspace()
    q=exists(primes(N+1,N**3+3), lambda x: x%N==1)[1] 
    #q is the smallest prime equal to 1 mod N
    Tq=M.hecke_matrix(q)
    dq=M.diamond_bracket_operator(q).matrix()
    to_cusp_space=(Tq-dq*q-1) #maybe use smaller primes in the future*(Tq-dq-q) 
    #to_cusp_space is a map whose image (over QQ) is the cuspidal subspace and is invertible when 
    #restricted to the cuspidal subspace so this means that we can compute the intergral period 
    #mapping (projection onto the cusps) by composing to_cusp_space by its inverse on the cuspidal
    #subspace
    codomain_restricted = to_cusp_space.restrict_codomain(S)
    restricted = codomain_restricted.restrict_domain(S)
    return codomain_restricted*restricted**(-1)
Example #13
0
def period_mapping(M):
    N=M.level()
    S=M.cuspidal_subspace()
    q=exists(primes(N+1,N**3+3), lambda x: x%N==1)[1] 
    #q is the smallest prime equal to 1 mod N
    Tq=M.hecke_matrix(q)
    dq=M.diamond_bracket_operator(q).matrix()
    to_cusp_space=(Tq-dq*q-1) #maybe use smaller primes in the future*(Tq-dq-q) 
    #to_cusp_space is a map whose image (over QQ) is the cuspidal subspace and is invertible when 
    #restricted to the cuspidal subspace so this means that we can compute the intergral period 
    #mapping (projection onto the cusps) by composing to_cusp_space by its inverse on the cuspidal
    #subspace
    codomain_restricted = to_cusp_space.restrict_codomain(S)
    restricted = codomain_restricted.restrict_domain(S)
    return codomain_restricted*restricted**(-1)
Example #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
Example #15
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
def get_form_data_from_file(nf, data_dir=NF_DIR, max_dim=50, verbose=False):
    """Fill in data for an incomplete WebNewform object by reading from a
    data file.  If a suitable file does not exist, the original
    WebNewform object is returned unchanged, with a message output.

    The data files only contain the extra data for dimensions less
    than some bound.  If the newform's dimension is greater then we do
    nothing.

    """
    if not nf.field_poly is None:
        return nf
    fname = label = nf.label
    datafile = "/".join([data_dir, fname])
    try:
        data = read_dtp(datafile, verbose=False)
    except FileNotFoundError:
        fname = fname[:fname.rindex(".")]
        datafile = "/".join([data_dir, fname])
        try:
            data = read_dtp(datafile, verbose=False)
        except FileNotFoundError:
            print("No file {} or {} found: no data available".format(datafile,label))
            return nf

    if verbose:
        print("Successfully read data for {} from file {}".format(label, fname))
        
    # Now we have data.  It is a dict with a single key (N,k,o) where
    # o is the character orbit number and value so we just extract the
    # single value for this key, which is another dict:

    data = list(data.values())[0]

    # This dict has keys ['dims', 'traces', 'ALs', 'polys',
    # 'eigdata'], and each value is a list, one per newform, so we
    # need to extract just one item from the relevant lists, according
    # to the newform we want.  This is determined by the 4th (last)
    # part of the label we have, which we need to convert to an
    # integer (from 0).

    # NB eigdata is a list of dicts (see later comment for details)
    # but *only* for components of dimension>1
    
    nf_index = class_to_int(label.split(".")[3])
    dims = data['dims']
    nf_eigdata_index = nf_index - dims.count(1)
    if verbose: # debug
        print("Newform label = {}".format(label))
        print("nf_index = {}".format(nf_index))
        print("len(polys) = {}".format(len(data['polys'])))
        print("len(dims) = {}".format(len(dims)))
        print("#dims>1 = {}".format(len(dims)-dims.count(1)))
        print("len(eigdata) = {}".format(len(data['eigdata'])))
        print("nf_eigdata_index = {}".format(nf_eigdata_index))
    dim = data['dims'][nf_index]
    assert dim == nf.dim
    nf.field_poly = data['polys'][nf_index]

    eigdata = data['eigdata'][nf_eigdata_index]

    # eigdata is a dict with keys  ['poly', 'basis', 'n', 'm', 'ans', 'char']
    chi_gens, chi_vals = eigdata['char']
    nf.hecke_ring_character_values = list(zip(chi_gens, chi_vals))
    # we will not need to access the char_order since this space has
    # already been selected to have an appropriate character.

    if verbose:
        print("hecke_ring_character_values = {}".format(nf.hecke_ring_character_values))
    
    Qx = PolynomialRing(QQ,'x')
    nf.hecke_field = K = NumberField(Qx(nf.field_poly), 'a_')
    nf.betas = [K(b) for b in eigdata['basis']]
    nf.an = eigdata['ans']
    nf.ap = [nf.an[p-1] for p in primes(len(nf.an))]

    if verbose: # debug
        print("We have {} a_n and {} a_p for newforms {}".format(len(nf.an), len(nf.ap), label))
    return nf
def make_euler_factors_db(E):
    r"""
    Returns a list of the Euler factors for all primes up to 100,
    given a database elliptic curve E (which has this many ap stored)
    """
    return [make_one_euler_factor_db(E, p) for p in primes(100)]
def make_euler_factors(E, maxp=100):
    r"""
    Returns a list of the Euler factors for all primes up to max_p,
    given a Sage elliptic curve E.
    """
    return [make_one_euler_factor(E, p) for p in primes(maxp)]
Example #19
0
def prime_powers(B=100, emax=5):
    for p in primes(B+1):
        for P in F.primes_above(p):
            for e in range(1,emax+1):
                yield p, P, e
Example #20
0
def prime_powers(B=100, emax=5):
    for p in primes(B + 1):
        for P in F.primes_above(p):
            for e in range(1, emax + 1):
                yield p, P, e