Example #1
0
def CMorbits(D):
    s = sum([
        2**(len(prime_divisors(old_div(D, d))))
        for d in divisors(D) if is_fundamental_discriminant(-d) and Zmod(d)
        (old_div(D, d)).is_square()
    ]) + 1
    return s
Example #2
0
def class_nr_pos_def_qf(D):
    r"""
    Compute the class number of positive definite quadratic forms.
    For fundamental discriminants this is the class number of Q(sqrt(D)),
    otherwise it is computed using: Cohen 'A course in Computational Algebraic Number Theory', p. 233
    """
    if D>0:
        return 0
    D4 = D % 4
    if D4 == 3 or D4==2:
        return 0
    K = QuadraticField(D)
    if is_fundamental_discriminant(D):
        return K.class_number()
    else:
        D0 = K.discriminant()
        Df = ZZ(D).divide_knowing_divisible_by(D0)
        if not is_square(Df):
            raise ArithmeticError("Did not get a discrimimant * square! D={0} disc(D)={1}".format(D,D0))
        D2 = sqrt(Df)
        h0 = QuadraticField(D0).class_number()
        w0 = _get_w(D0)
        w = _get_w(D)
        #print "w,w0=",w,w0
        #print "h0=",h0
        h = 1
        for p in prime_divisors(D2):
            h = QQ(h)*(1-kronecker(D0,p)/QQ(p))
        #print "h=",h
        #print "fak=",
        h=QQ(h*h0*D2*w)/QQ(w0)
        return h
 def get_atkin_lehner_eigenvalues(self):
     r"""
     Get the Atkin-Lehner eigenvalues from database if they exist. 
     """
     
     if not ((self.character().is_trivial() or self.character().order() == 2) and not self._atkin_lehner_eigenvalues is None):
         return None
     C = connect_to_modularforms_db('Atkin-Lehner.files')
     fs = get_files_from_gridfs('Atkin-Lehner')
     s = {'N':int(self.level()),'k':int(self.weight()),
          'cchi':int(self.chi()),'newform':int(self.newform_number())}
     res = C.find_one(s)
     self._atkin_lehner_eigenvalues = {}
     if not res is None:
         alid = res['_id']
         al = loads(fs.get(alid).read())
         for d in prime_divisors(self.level()):
             self._atkin_lehner_eigenvalues[d] = 1 if al[d]=='+' else -1
     else: # We compute them
         A = self.as_factor()
         for p in prime_divisors(self.level()):
             self._atkin_lehner_eigenvalues[p]= int(A.atkin_lehner_operator(p).matrix()[0,0])
Example #4
0
def bad_formal_immersion_data(d):
    """
    This is the Oesterlé for type 1 primes with modular symbols main routine.
    The computation is actually a two step rocket. First Proposition 6.8 of
    Derickx-Kamienny-Stein-Stoll is used to replace Parents polynomial of
    degree 6 bound by something reasonable, and then Proposition 6.3 is used
    to go from something reasonable to the exact list.
    """
    assert d > 0

    p_bad = prime_range(11)
    p_done = {}
    q_to_bad_p = {}

    M = construct_M(d)[0]

    for p in prime_range(11, 2 * M * d):
        # first do a relatively cheap test
        if is_formal_immersion_fast(d, p):
            continue
        # this is less cheap but still quite fast
        if is_formal_immersion_medium(d, p) == 1:
            continue
        # this is the most expensive but give the correct answer
        is_formal = is_formal_immersion(d, p)
        if is_formal:
            if is_formal > 1:
                p_done[p] = is_formal
        else:
            p_bad.append(p)

    for p, q_prod in p_done.items():
        for q in prime_divisors(q_prod):
            q_to_bad_p[q] = q_to_bad_p.get(q, 1) * p

    return p_bad, q_to_bad_p
Example #5
0
def lfuncEPhtml(L,fmt):
    """ Euler product as a formula and a table of local factors.
    """
    texform_gen = "\[L(s) = "  # "\[L(A,s) = "
    texform_gen += "\prod_{p \\text{ prime}} F_p(p^{-s})^{-1} \]\n"

    pfactors = prime_divisors(L.level)
    if len(pfactors) == 1:  #i.e., the conductor is prime
        pgoodset = "$p \\neq " + str(pfactors[0]) + "$"
        pbadset = "$p = " + str(pfactors[0]) + "$"
    else:
        badset = "\\{" + str(pfactors[0])
        for j in range(1,len(pfactors)):
            badset += ",\\;"
            badset += str(pfactors[j])
        badset += "\\}"
        pgoodset = "$p \\notin " + badset + "$"
        pbadset = "$p \\in " + badset + "$"


    ans = ""
    ans += texform_gen + "where, for " + pgoodset + ",\n"
    if L.degree == 4 and L.motivic_weight == 1:
        ans += "\[F_p(T) = 1 - a_p T + b_p T^2 -  a_p p T^3 + p^2 T^4 \]"
        ans += "with $b_p = a_p^2 - a_{p^2}$. "
    elif L.degree == 2 and L.motivic_weight == 1:
        ans += "\[F_p(T) = 1 - a_p T + p T^2 .\]"
    else:
        ans += "\(F_p\) is a polynomial of degree " + str(L.degree) + ". "
    ans += "If " + pbadset + ", then $F_p$ is a polynomial of degree at most "
    ans += str(L.degree - 1) + ". "
    bad_primes = []
    for lf in L.bad_lfactors:
        bad_primes.append(lf[0])
    eulerlim = 25
    good_primes = []
    for j in range(0, eulerlim):
        this_prime = Primes().unrank(j)
        if this_prime not in bad_primes:
            good_primes.append(this_prime)
    eptable = "<table id='eptable' class='ntdata euler'>\n"
    eptable += "<thead>"
    eptable += "<tr class='space'><th class='weight'></th><th class='weight'>$p$</th><th class='weight'>$F_p$</th>"
    if L.degree > 2:
        eptable += "<th class='weight galois'>$\Gal(F_p)$</th>"
    eptable += "</tr>\n"
    eptable += "</thead>"
    goodorbad = "bad"
    for lf in L.bad_lfactors:
        try:
            thispolygal = list_to_factored_poly_otherorder(lf[1], galois=True)
            eptable += ("<tr><td>" + goodorbad + "</td><td>" + str(lf[0]) + "</td><td>" +
                        "$" + thispolygal[0] + "$" +
                        "</td>")
            if L.degree > 2:
                eptable += "<td class='galois'>"
                this_gal_group = thispolygal[1]
                if this_gal_group[0]==[0,0]:
                    pass   # do nothing, because the local faco is 1
                elif this_gal_group[0]==[1,1]:
                    eptable += group_display_knowl(this_gal_group[0][0],this_gal_group[0][1],'$C_1$')
                else:
                    eptable += group_display_knowl(this_gal_group[0][0],this_gal_group[0][1])
                for j in range(1,len(thispolygal[1])):
                    eptable += "$\\times$"
                    eptable += group_display_knowl(this_gal_group[j][0],this_gal_group[j][1])
                eptable += "</td>"
            eptable += "</tr>\n"

        except IndexError:
            eptable += "<tr><td></td><td>" + str(j) + "</td><td>" + "not available" + "</td></tr>\n"
        goodorbad = ""
    goodorbad = "good"
    firsttime = " class='first'"
    good_primes1 = good_primes[:9]
    good_primes2 = good_primes[9:]
    for j in good_primes1:
        this_prime_index = prime_pi(j) - 1
        thispolygal = list_to_factored_poly_otherorder(L.localfactors[this_prime_index],galois=True)
        eptable += ("<tr" + firsttime + "><td>" + goodorbad + "</td><td>" + str(j) + "</td><td>" +
                    "$" + thispolygal[0] + "$" +
                    "</td>")
        if L.degree > 2:
            eptable += "<td class='galois'>"
            this_gal_group = thispolygal[1]
            eptable += group_display_knowl(this_gal_group[0][0],this_gal_group[0][1])
            for j in range(1,len(thispolygal[1])):
                eptable += "$\\times$"
                eptable += group_display_knowl(this_gal_group[j][0],this_gal_group[j][1])
            eptable += "</td>"
        eptable += "</tr>\n"


#        eptable += "<td>" + group_display_knowl(4,1) + "</td>"
#        eptable += "</tr>\n"
        goodorbad = ""
        firsttime = ""
    firsttime = " id='moreep'"
    for j in good_primes2:
        this_prime_index = prime_pi(j) - 1
        thispolygal = list_to_factored_poly_otherorder(L.localfactors[this_prime_index],galois=True)
        eptable += ("<tr" + firsttime +  " class='more nodisplay'" + "><td>" + goodorbad + "</td><td>" + str(j) + "</td><td>" +
                    "$" + list_to_factored_poly_otherorder(L.localfactors[this_prime_index], galois=True)[0] + "$" +
                    "</td>")
        if L.degree > 2:
            this_gal_group = thispolygal[1]
            eptable += "<td class='galois'>"
            eptable += group_display_knowl(this_gal_group[0][0],this_gal_group[0][1])
            for j in range(1,len(thispolygal[1])):
                eptable += "$\\times$"
                eptable += group_display_knowl(this_gal_group[j][0],this_gal_group[j][1])
            eptable += "</td>"

        eptable += "</tr>\n"
        firsttime = ""

    eptable += "<tr class='less toggle'><td></td><td></td><td> <a onclick='"
    eptable += 'show_moreless("more"); return true' + "'"
    eptable += ' href="#moreep" '
    eptable += ">show more</a></td></tr>\n"
    eptable += "<tr class='more toggle nodisplay'><td></td><td></td><td> <a onclick='"
    eptable += 'show_moreless("less"); return true' + "'"
    eptable += ' href="#eptable" '
    eptable += ">show less</a></td></tr>\n"
    eptable += "</table>\n"
    ans += "\n" + eptable
    return(ans)
Example #6
0
def lfuncEPhtml(L,fmt, prec = None):
    """
        Euler product as a formula and a table of local factors.
    """


    # Formula
    texform_gen = "\[L(s) = "  # "\[L(A,s) = "
    texform_gen += "\prod_{p \\text{ prime}} F_p(p^{-s})^{-1} \]\n"
    pfactors = prime_divisors(L.level)

    if len(pfactors) == 0:
        pgoodset = None
        pbadset =  None
    elif len(pfactors) == 1:  #i.e., the conductor is prime
        pgoodset = "$p \\neq " + str(pfactors[0]) + "$"
        pbadset = "$p = " + str(pfactors[0]) + "$"
    else:
        badset = "\\{" + str(pfactors[0])
        for j in range(1,len(pfactors)):
            badset += ",\\;"
            badset += str(pfactors[j])
        badset += "\\}"
        pgoodset = "$p \\notin " + badset + "$"
        pbadset = "$p \\in " + badset + "$"


    ans = ""
    ans += texform_gen + "where"
    if pgoodset is not None:
        ans += ", for " + pgoodset
    ans += ",\n"
    if L.motivic_weight == 1 and L.characternumber == 1 and L.degree in [2,4]:
        if L.degree == 4:
            ans += "\[F_p(T) = 1 - a_p T + b_p T^2 -  a_p p T^3 + p^2 T^4 \]"
            ans += "with $b_p = a_p^2 - a_{p^2}$. "
        elif L.degree == 2:
            ans += "\[F_p(T) = 1 - a_p T + p T^2 .\]"
    else:
        ans += "\(F_p\) is a polynomial of degree " + str(L.degree) + ". "
    if pbadset is not None:
        ans += "If " + pbadset + ", then $F_p$ is a polynomial of degree at most "
        ans += str(L.degree - 1) + ". "

    # Figuring out good and bad primes
    bad_primes = []
    for lf in L.bad_lfactors:
        bad_primes.append(lf[0])
    eulerlim = 25
    good_primes = []
    for p in primes_first_n(eulerlim):
        if p not in bad_primes:
            good_primes.append(p)


    #decide if we display galois
    display_galois = True
    if L.degree <= 2  or L.degree >= 12:
        display_galois = False
    if L.coefficient_field == "CDF":
        display_galois = False

    def pretty_poly(poly, prec = None):
        out = "1"
        for i,elt in enumerate(poly):
            if elt is None or (i == prec and prec != len(poly) - 1):
                out += "O(%s)" % (seriesvar(i, "polynomial"),)
                break;
            elif i > 0:
                out += seriescoeff(elt, i, "series", "polynomial", 3)
        return out


    eptable = r"""<div style="max-width: 100%; overflow-x: auto;">"""
    eptable += "<table class='ntdata euler'>\n"
    eptable += "<thead>"
    eptable += "<tr class='space'><th class='weight'></th><th class='weight'>$p$</th>"
    if L.degree > 2  and L.degree < 12:
        display_galois = True
        eptable += "<th class='weight galois'>$\Gal(F_p)$</th>"
    else:
        display_galois = False
    eptable += r"""<th class='weight' style="text-align: left;">$F_p$</th>"""
    eptable += "</tr>\n"
    eptable += "</thead>"
    def row(trclass, goodorbad, p, poly):
        out = ""
        try:
            if L.coefficient_field == "CDF" or None in poly:
                factors = str(pretty_poly(poly, prec = prec))
            elif not display_galois:
                factors = list_to_factored_poly_otherorder(poly, galois=display_galois, prec = prec, p = p)
            else:
                factors, gal_groups = list_to_factored_poly_otherorder(poly, galois=display_galois, p = p)
            out += "<tr" + trclass + "><td>" + goodorbad + "</td><td>" + str(p) + "</td>";
            if display_galois:
                out += "<td class='galois'>"
                if gal_groups[0]==[0,0]:
                    pass   # do nothing, because the local faco is 1
                elif gal_groups[0]==[1,1]:
                    out += group_display_knowl(gal_groups[0][0], gal_groups[0][1],'$C_1$')
                else:
                    out += group_display_knowl(gal_groups[0][0], gal_groups[0][1])
                for n, k in gal_groups[1:]:
                    out += "$\\times$"
                    out += group_display_knowl(n, k)
                out += "</td>"
            out += "<td>" +"$" + factors + "$" + "</td>"
            out += "</tr>\n"

        except IndexError:
            out += "<tr><td></td><td>" + str(j) + "</td><td>" + "not available" + "</td></tr>\n"
        return out
    goodorbad = "bad"
    trclass = ""
    for lf in L.bad_lfactors:
        eptable += row(trclass, goodorbad, lf[0], lf[1])
        goodorbad = ""
        trclass = ""
    goodorbad = "good"
    trclass = " class='first'"
    good_primes1 = good_primes[:9]
    good_primes2 = good_primes[9:]
    for j in good_primes1:
        this_prime_index = prime_pi(j) - 1
        eptable += row(trclass, goodorbad, j, L.localfactors[this_prime_index])
        goodorbad = ""
        trclass = ""
    trclass = " id='moreep'  class='more nodisplay'"
    for j in good_primes2:
        this_prime_index = prime_pi(j) - 1
        eptable += row(trclass, goodorbad, j, L.localfactors[this_prime_index])
        trclass = " class='more nodisplay'"

    eptable += r"""<tr class="less toggle"><td colspan="2"> <a onclick="show_moreless(&quot;more&quot;); return true" href="#moreep">show more</a></td>"""

    last_entry = ""
    if display_galois:
        last_entry +="<td></td>"
    last_entry += "<td></td>"
    eptable += last_entry
    eptable += "</tr>"
    eptable += r"""<tr class="more toggle nodisplay"><td colspan="2"><a onclick="show_moreless(&quot;less&quot;); return true" href="#eptable">show less</a></td>"""
    eptable += last_entry
    eptable += "</tr>\n</table>\n</div>\n"
    ans += "\n" + eptable
    return(ans)
Example #7
0
def lfuncEPhtml(L, fmt):
    """
        Euler product as a formula and a table of local factors.
    """


    # Formula
    texform_gen = r"\[L(s) = "  # r"\[L(A,s) = "
    texform_gen += r"\prod_{p \text{ prime}} F_p(p^{-s})^{-1} \]" + "\n"
    pfactors = prime_divisors(L.level)

    if len(pfactors) == 0:
        pgoodset = None
        pbadset =  None
    elif len(pfactors) == 1:  #i.e., the conductor is prime
        pgoodset = r"$p \neq " + str(pfactors[0]) + "$"
        pbadset = "$p = " + str(pfactors[0]) + "$"
    else:
        badset = r"\{" + str(pfactors[0])
        for j in range(1,len(pfactors)):
            badset += r",\;"
            badset += str(pfactors[j])
        badset += r"\}"
        pgoodset = r"$p \notin " + badset + "$"
        pbadset = r"$p \in " + badset + "$"


    ans = ""
    ans += texform_gen + "where"
    if pgoodset is not None:
        ans += ", for " + pgoodset
    ans += ",\n"
    if L.motivic_weight == 1 and L.characternumber == 1 and L.degree in [2,4]:
        if L.degree == 4:
            ans += r"\[F_p(T) = 1 - a_p T + b_p T^2 -  a_p p T^3 + p^2 T^4 \]"
            ans += "with $b_p = a_p^2 - a_{p^2}$. "
        elif L.degree == 2:
            ans += r"\[F_p(T) = 1 - a_p T + p T^2 .\]"
    else:
        ans += r"\(F_p(T)\) is a polynomial of degree " + str(L.degree) + ". "
    if pbadset is not None:
        ans += "If " + pbadset + ", then $F_p(T)$ is a polynomial of degree at most "
        ans += str(L.degree - 1) + ". "

    # Figuring out good and bad primes
    bad_primes = [p for p, _ in L.bad_lfactors]
    good_primes = [p for p in prime_range(100) if p not in bad_primes]
    p_index = {p: i for i, p in enumerate(prime_range(100))}

    #decide if we display galois
    display_galois = True
    if L.degree <= 2  or L.degree >= 12:
        display_galois = False
    elif L.coefficient_field == "CDF":
        display_galois = False
    elif all(None in elt for elt in (L.localfactors + L.bad_lfactors)):
        display_galois = False

    def pretty_poly(poly, prec=None):
        out = "1"
        for i, elt in enumerate(poly):
            if elt is None or (i == prec and prec != len(poly) - 1):
                out += "+O(%s)" % (seriesvar(i, "polynomial"),)
                break
            elif i > 0:
                out += seriescoeff(elt, i, "series", "polynomial", 3)
        return out


    eptable = r"""<div style="max-width: 100%; overflow-x: auto;">"""
    eptable += "<table class='ntdata euler'>\n"
    eptable += "<thead>"
    eptable += "<tr class='space'><th class='weight'></th><th class='weight'>$p$</th>"
    if display_galois:
        eptable += r"<th class='weight galois'>$\Gal(F_p)$</th>"
    eptable += r"""<th class='weight' style="text-align: left;">$F_p(T)$</th>"""
    eptable += "</tr>\n"
    eptable += "</thead>"
    def row(trclass, goodorbad, p, poly):
        if isinstance(poly[0], list):
            galois_pretty_factors = list_factored_to_factored_poly_otherorder
        else:
            galois_pretty_factors = list_to_factored_poly_otherorder
        out = ""
        try:
            if L.coefficient_field == "CDF" or None in poly:
                factors = r'\( %s \)' % pretty_poly(poly)
                gal_groups = [[0,0]]
            elif not display_galois:
                factors = galois_pretty_factors(poly, galois=display_galois, p = p)
                factors =  make_bigint(r'\( %s \)' % factors)
            else:
                factors, gal_groups = galois_pretty_factors(poly, galois=display_galois, p = p)
                factors =  make_bigint(r'\( %s \)' % factors)
            out += "<tr" + trclass + "><td>" + goodorbad + "</td><td>" + str(p) + "</td>"
            if display_galois:
                out += "<td class='galois'>"
                if gal_groups[0]==[0,0]:
                    pass   # do nothing, because the local factor is 1
                else:
                    out += r"$\times$".join( [group_display_knowl_C1_as_trivial(n,k) for n, k in gal_groups] )
                out += "</td>"
            out += "<td> %s </td>" % factors
            out += "</tr>\n"

        except IndexError:
            out += "<tr><td></td><td>" + str(j) + "</td><td>" + "not available" + "</td></tr>\n"
        return out
    goodorbad = "bad"
    trclass = ""
    for p, lf in L.bad_lfactors:
        if p in L.localfactors_factored_dict:
            lf = L.localfactors_factored_dict[p]
        eptable += row(trclass, goodorbad, p, lf)
        goodorbad = ""
        trclass = ""
    goodorbad = "good"
    trclass = " class='first'"
    for j, good_primes in enumerate([good_primes[:9], good_primes[9:]]):
        for p in good_primes:
            if p in L.localfactors_factored_dict:
                lf = L.localfactors_factored_dict[p]
            else:
                lf = L.localfactors[p_index[p]]
            eptable += row(trclass, goodorbad, p, lf)
            goodorbad = ""
            if j == 0:
                trclass = ""
            elif j == 1:
                trclass = " class='more nodisplay'"
        else:
            if j == 0:
                trclass = " id='moreep'  class='more nodisplay'"

    eptable += r"""<tr class="less toggle"><td colspan="2"> <a onclick="show_moreless(&quot;more&quot;); return true" href="#moreep">show more</a></td>"""

    last_entry = ""
    if display_galois:
        last_entry +="<td></td>"
    last_entry += "<td></td>"
    eptable += last_entry
    eptable += "</tr>"
    eptable += r"""<tr class="more toggle nodisplay"><td colspan="2"><a onclick="show_moreless(&quot;less&quot;); return true" href="#eptable">show less</a></td>"""
    eptable += last_entry
    eptable += "</tr>\n</table>\n</div>\n"
    ans += "\n" + eptable
    return(ans)
Example #8
0
def lfuncEPhtml(L, fmt):
    """ Euler product as a formula and a table of local factors.
    """
    texform_gen = "\[L(s) = "  # "\[L(A,s) = "
    texform_gen += "\prod_{p \\text{ prime}} F_p(p^{-s})^{-1} \]\n"

    pfactors = prime_divisors(L.level)
    if len(pfactors) == 1:  #i.e., the conductor is prime
        pgoodset = "$p \\neq " + str(pfactors[0]) + "$"
        pbadset = "$p = " + str(pfactors[0]) + "$"
    else:
        badset = "\\{" + str(pfactors[0])
        for j in range(1, len(pfactors)):
            badset += ",\\;"
            badset += str(pfactors[j])
        badset += "\\}"
        pgoodset = "$p \\notin " + badset + "$"
        pbadset = "$p \\in " + badset + "$"

    ans = ""
    ans += texform_gen + "where, for " + pgoodset + ",\n"
    if L.degree == 4 and L.motivic_weight == 1:
        ans += "\[F_p(T) = 1 - a_p T + b_p T^2 -  a_p p T^3 + p^2 T^4 \]"
        ans += "with $b_p = a_p^2 - a_{p^2}$. "
    elif L.degree == 2 and L.motivic_weight == 1:
        ans += "\[F_p(T) = 1 - a_p T + p T^2 .\]"
    else:
        ans += "\(F_p\) is a polynomial of degree " + str(L.degree) + ". "
    ans += "If " + pbadset + ", then $F_p$ is a polynomial of degree at most "
    ans += str(L.degree - 1) + ". "
    bad_primes = []
    for lf in L.bad_lfactors:
        bad_primes.append(lf[0])
    eulerlim = 25
    good_primes = []
    for j in range(0, eulerlim):
        this_prime = Primes().unrank(j)
        if this_prime not in bad_primes:
            good_primes.append(this_prime)
    eptable = "<table id='eptable' class='ntdata euler'>\n"
    eptable += "<thead>"
    eptable += "<tr class='space'><th class='weight'></th><th class='weight'>$p$</th><th class='weight'>$F_p$</th>"
    if L.degree > 2:
        eptable += "<th class='weight galois'>$\Gal(F_p)$</th>"
    eptable += "</tr>\n"
    eptable += "</thead>"
    goodorbad = "bad"
    for lf in L.bad_lfactors:
        try:
            thispolygal = list_to_factored_poly_otherorder(lf[1], galois=True)
            eptable += ("<tr><td>" + goodorbad + "</td><td>" + str(lf[0]) +
                        "</td><td>" + "$" + thispolygal[0] + "$" + "</td>")
            if L.degree > 2:
                eptable += "<td class='galois'>"
                this_gal_group = thispolygal[1]
                if this_gal_group[0] == [0, 0]:
                    pass  # do nothing, because the local faco is 1
                elif this_gal_group[0] == [1, 1]:
                    eptable += group_display_knowl(this_gal_group[0][0],
                                                   this_gal_group[0][1],
                                                   '$C_1$')
                else:
                    eptable += group_display_knowl(this_gal_group[0][0],
                                                   this_gal_group[0][1])
                for j in range(1, len(thispolygal[1])):
                    eptable += "$\\times$"
                    eptable += group_display_knowl(this_gal_group[j][0],
                                                   this_gal_group[j][1])
                eptable += "</td>"
            eptable += "</tr>\n"

        except IndexError:
            eptable += "<tr><td></td><td>" + str(
                j) + "</td><td>" + "not available" + "</td></tr>\n"
        goodorbad = ""
    goodorbad = "good"
    firsttime = " class='first'"
    good_primes1 = good_primes[:9]
    good_primes2 = good_primes[9:]
    for j in good_primes1:
        this_prime_index = prime_pi(j) - 1
        thispolygal = list_to_factored_poly_otherorder(
            L.localfactors[this_prime_index], galois=True)
        eptable += ("<tr" + firsttime + "><td>" + goodorbad + "</td><td>" +
                    str(j) + "</td><td>" + "$" + thispolygal[0] + "$" +
                    "</td>")
        if L.degree > 2:
            eptable += "<td class='galois'>"
            this_gal_group = thispolygal[1]
            eptable += group_display_knowl(this_gal_group[0][0],
                                           this_gal_group[0][1])
            for j in range(1, len(thispolygal[1])):
                eptable += "$\\times$"
                eptable += group_display_knowl(this_gal_group[j][0],
                                               this_gal_group[j][1])
            eptable += "</td>"
        eptable += "</tr>\n"

        #        eptable += "<td>" + group_display_knowl(4,1) + "</td>"
        #        eptable += "</tr>\n"
        goodorbad = ""
        firsttime = ""
    firsttime = " id='moreep'"
    for j in good_primes2:
        this_prime_index = prime_pi(j) - 1
        thispolygal = list_to_factored_poly_otherorder(
            L.localfactors[this_prime_index], galois=True)
        eptable += ("<tr" + firsttime + " class='more nodisplay'" + "><td>" +
                    goodorbad + "</td><td>" + str(j) + "</td><td>" + "$" +
                    list_to_factored_poly_otherorder(
                        L.localfactors[this_prime_index], galois=True)[0] +
                    "$" + "</td>")
        if L.degree > 2:
            this_gal_group = thispolygal[1]
            eptable += "<td class='galois'>"
            eptable += group_display_knowl(this_gal_group[0][0],
                                           this_gal_group[0][1])
            for j in range(1, len(thispolygal[1])):
                eptable += "$\\times$"
                eptable += group_display_knowl(this_gal_group[j][0],
                                               this_gal_group[j][1])
            eptable += "</td>"

        eptable += "</tr>\n"
        firsttime = ""

    eptable += "<tr class='less toggle'><td></td><td></td><td> <a onclick='"
    eptable += 'show_moreless("more"); return true' + "'"
    eptable += ' href="#moreep" '
    eptable += ">show more</a></td></tr>\n"
    eptable += "<tr class='more toggle nodisplay'><td></td><td></td><td> <a onclick='"
    eptable += 'show_moreless("less"); return true' + "'"
    eptable += ' href="#eptable" '
    eptable += ">show less</a></td></tr>\n"
    eptable += "</table>\n"
    ans += "\n" + eptable
    return (ans)
Example #9
0
def read_all(filename):
    # label -> [p, Lp]
    euler_factors_cc = {}
    # label -> labels
    orbits = {}
    # label -> postgres row as list
    rows = {}
    instances = {}


    base_dir = os.path.dirname(os.path.abspath(filename))
    lfun_dir = os.path.join(base_dir, 'lfun')
    linecount = line_count(filename)
    check_all_files(filename, linecount)

    k = 0
    with open(filename, 'r') as F:
        for line in F:
            linesplit = line[:-1].split(':')
            hoc, label, conrey_label_tmp, embedding_index_tmp, embedding_m, ap_txt = linesplit
            level, weight, char_orbit, hecke_orbit, conrey_label, embedding_index = label.split(".")
            assert conrey_label_tmp == conrey_label
            assert embedding_index_tmp == embedding_index
            mf_orbit_label = ".".join([level, weight, char_orbit, hecke_orbit])
            if mf_orbit_label not in orbits:
                orbits[mf_orbit_label] = []
            orbits[mf_orbit_label].append(label)

            ap_list = [ toCCC(*elt.split(',')) for elt in ap_txt[2:-2].split('],[')]
            ap_list = zip(primes_first_n(len(ap_list)),ap_list)

            lpfilename = os.path.join(lfun_dir, label + ".lpdata")
            lffilename = os.path.join(lfun_dir, label + ".lpdata.lfunction")

            if not all(map(os.path.exists, [lpfilename, lffilename])):
                continue

            level, weight, conrey_label, embedding_index = map(int, [level, weight, conrey_label, embedding_index])

            G = DirichletGroup_conrey(level, CCC)
            char = DirichletCharacter_conrey(G, conrey_label)


            # the basis
            row = constant_lf(level, weight, 2)
            row['origin'] = "ModularForm/GL2/Q/holomorphic/%d/%d/%s/%s/%d/%d" % (level, weight, char_orbit, hecke_orbit, conrey_label, embedding_index)
            row['self_dual'] = self_dual(char, ap_list)
            row['central_character'] = "%s.%s" % (level, conrey_label)
            # sets accuracy, root_number, sign_arg, leading_term, order_of_vanishing, positive_zeros, plot_delta, plot_values
            for key, val in read_lfunction_file(lffilename).iteritems():
                row[key] = val

            if row['self_dual']:
                row['conjugate'] = '\N'
            else:
                lfconjfilename=  os.path.join(lfun_dir, label + ".lpdata.conj.lfunction")
                assert os.path.exists(lfconjfilename)
                row['conjugate'] = read_lfunction_file(lfconjfilename)['Lhash']


            def euler_factor(p, ap):
                if p.divides(level):
                    return [1, -ap]
                charval = CCC(2*char.logvalue(p)).exppii()
                if charval.contains_exact(ZZ(1)):
                    charval = 1
                elif charval.contains_exact(ZZ(-1)):
                    charval = -1
                return [1, -ap, (p**(weight-1))*charval]
            cut = 30 if level == 1 else max(30, prime_pi(max(prime_divisors(level))))
            euler_factors = [ euler_factor(*elt) for elt in ap_list[:cut] ]
            bad_euler_factors = [ [elt[0], euler_factor(*elt)] for elt in ap_list if elt[0].divides(level)]

            euler_factors_cc[label] = euler_factors
            row['euler_factors'] = map( lambda x : map(CBF_to_pair, x), euler_factors)
            row['bad_lfactors'] =  map( lambda x: [int(x[0]), map(CBF_to_pair, x[1])], bad_euler_factors)
            row['coefficient_field'] = 'CDF'
            for i, ai in enumerate(dirichlet(CCC, euler_factors[:11])[2:12]):
                if i + 2 <= 10:
                    row['a' + str(i+2)] = CBF_to_pair(ai)


            for key in schema_lf:
                assert key in row, "%s not in row = %s" % (key, row)
            assert len(row) == len(schema_lf), "%s != %s" % (len(row) , len(schema_lf))
            rows[label] = [row[key] for key in schema_lf]
            instances[label] = (row['origin'], row['Lhash'], 'CMF')
            k += 1
            if linecount > 10:
                if (k % (linecount//10)) == 0:
                    print "read_all %.2f%% done" % (k*100./linecount)
    print "read_all Done"

    rational_rows = populate_rational_rows(orbits, euler_factors_cc, rows, instances)
    
    positive_zeros = schema_lf_dict['positive_zeros']
    for elt, val in rows.iteritems():
        assert isinstance(val[positive_zeros], str), "%s, %s, %s" % (elt, type(val[positive_zeros]), val[positive_zeros])
    lfun_filename = filename + ".lfunctions"
    instances_filename = filename + ".instances"
    export_lfunctions(rows, rational_rows, instances, lfun_filename, instances_filename)
    return 0
Example #10
0
def lfuncEPhtml(L, fmt, prec=None):
    """
        Euler product as a formula and a table of local factors.
    """

    # Formula
    texform_gen = "\[L(s) = "  # "\[L(A,s) = "
    texform_gen += "\prod_{p \\text{ prime}} F_p(p^{-s})^{-1} \]\n"
    pfactors = prime_divisors(L.level)

    if len(pfactors) == 0:
        pgoodset = None
        pbadset = None
    elif len(pfactors) == 1:  #i.e., the conductor is prime
        pgoodset = "$p \\neq " + str(pfactors[0]) + "$"
        pbadset = "$p = " + str(pfactors[0]) + "$"
    else:
        badset = "\\{" + str(pfactors[0])
        for j in range(1, len(pfactors)):
            badset += ",\\;"
            badset += str(pfactors[j])
        badset += "\\}"
        pgoodset = "$p \\notin " + badset + "$"
        pbadset = "$p \\in " + badset + "$"

    ans = ""
    ans += texform_gen + "where"
    if pgoodset is not None:
        ans += ", for " + pgoodset
    ans += ",\n"
    if L.motivic_weight == 1 and L.characternumber == 1 and L.degree in [2, 4]:
        if L.degree == 4:
            ans += "\[F_p(T) = 1 - a_p T + b_p T^2 -  a_p p T^3 + p^2 T^4 \]"
            ans += "with $b_p = a_p^2 - a_{p^2}$. "
        elif L.degree == 2:
            ans += "\[F_p(T) = 1 - a_p T + p T^2 .\]"
    else:
        ans += "\(F_p\) is a polynomial of degree " + str(L.degree) + ". "
    if pbadset is not None:
        ans += "If " + pbadset + ", then $F_p$ is a polynomial of degree at most "
        ans += str(L.degree - 1) + ". "

    # Figuring out good and bad primes
    bad_primes = []
    for lf in L.bad_lfactors:
        bad_primes.append(lf[0])
    eulerlim = 25
    good_primes = []
    for p in primes_first_n(eulerlim):
        if p not in bad_primes:
            good_primes.append(p)

    #decide if we display galois
    display_galois = True
    if L.degree <= 2 or L.degree >= 12:
        display_galois = False
    if L.coefficient_field == "CDF":
        display_galois = False

    def pretty_poly(poly, prec=None):
        out = "1"
        for i, elt in enumerate(poly):
            if elt is None or (i == prec and prec != len(poly) - 1):
                out += "O(%s)" % (seriesvar(i, "polynomial"), )
                break
            elif i > 0:
                out += seriescoeff(elt, i, "series", "polynomial", 3)
        return out

    eptable = r"""<div style="max-width: 100%; overflow-x: auto;">"""
    eptable += "<table class='ntdata euler'>\n"
    eptable += "<thead>"
    eptable += "<tr class='space'><th class='weight'></th><th class='weight'>$p$</th>"
    if L.degree > 2 and L.degree < 12:
        display_galois = True
        eptable += "<th class='weight galois'>$\Gal(F_p)$</th>"
    else:
        display_galois = False
    eptable += r"""<th class='weight' style="text-align: left;">$F_p$</th>"""
    eptable += "</tr>\n"
    eptable += "</thead>"

    def row(trclass, goodorbad, p, poly):
        out = ""
        try:
            if L.coefficient_field == "CDF" or None in poly:
                factors = str(pretty_poly(poly, prec=prec))
            elif not display_galois:
                factors = list_to_factored_poly_otherorder(
                    poly, galois=display_galois, prec=prec, p=p)
            else:
                factors, gal_groups = list_to_factored_poly_otherorder(
                    poly, galois=display_galois, p=p)
            out += "<tr" + trclass + "><td>" + goodorbad + "</td><td>" + str(
                p) + "</td>"
            if display_galois:
                out += "<td class='galois'>"
                if gal_groups[0] == [0, 0]:
                    pass  # do nothing, because the local faco is 1
                elif gal_groups[0] == [1, 1]:
                    out += group_display_knowl(gal_groups[0][0],
                                               gal_groups[0][1], '$C_1$')
                else:
                    out += group_display_knowl(gal_groups[0][0],
                                               gal_groups[0][1])
                for n, k in gal_groups[1:]:
                    out += "$\\times$"
                    out += group_display_knowl(n, k)
                out += "</td>"
            out += "<td>" + "$" + factors + "$" + "</td>"
            out += "</tr>\n"

        except IndexError:
            out += "<tr><td></td><td>" + str(
                j) + "</td><td>" + "not available" + "</td></tr>\n"
        return out

    goodorbad = "bad"
    trclass = ""
    for lf in L.bad_lfactors:
        eptable += row(trclass, goodorbad, lf[0], lf[1])
        goodorbad = ""
        trclass = ""
    goodorbad = "good"
    trclass = " class='first'"
    good_primes1 = good_primes[:9]
    good_primes2 = good_primes[9:]
    for j in good_primes1:
        this_prime_index = prime_pi(j) - 1
        eptable += row(trclass, goodorbad, j, L.localfactors[this_prime_index])
        goodorbad = ""
        trclass = ""
    trclass = " id='moreep'  class='more nodisplay'"
    for j in good_primes2:
        this_prime_index = prime_pi(j) - 1
        eptable += row(trclass, goodorbad, j, L.localfactors[this_prime_index])
        trclass = " class='more nodisplay'"

    eptable += r"""<tr class="less toggle"><td colspan="2"> <a onclick="show_moreless(&quot;more&quot;); return true" href="#moreep">show more</a></td>"""

    last_entry = ""
    if display_galois:
        last_entry += "<td></td>"
    last_entry += "<td></td>"
    eptable += last_entry
    eptable += "</tr>"
    eptable += r"""<tr class="more toggle nodisplay"><td colspan="2"><a onclick="show_moreless(&quot;less&quot;); return true" href="#eptable">show less</a></td>"""
    eptable += last_entry
    eptable += "</tr>\n</table>\n</div>\n"
    ans += "\n" + eptable
    return (ans)
Example #11
0
def atkin_lehner_signs(A):
    N = A.level()
    return [A.atkin_lehner_operator(p).matrix()[0,0] for p in prime_divisors(N)]