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 = '\( %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('\( %s \)' % factors) else: factors, gal_groups = galois_pretty_factors(poly, galois=display_galois, p = p) factors = make_bigint('\( %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 += "$\\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
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
def eigs_as_seqseq_to_qexp(self, prec_max): # Takes a sequence of sequence of integers (or pairs of integers in the hecke_ring_cyclotomic_generator != 0 case) and returns a string for the corresponding q expansion # For example, eigs_as_seqseq_to_qexp([[0,0],[1,3]]) returns "\((1+3\beta_{1})q\)\(+O(q^2)\)" prec = min(self.qexp_prec, prec_max) if prec == 0: return 'O(1)' eigseq = self.qexp[:prec] use_knowl = too_big(eigseq, 10**24) s = '' for j in range(len(eigseq)): term = self._elt(eigseq[j]) if term != 0: latexterm = latex(term) if use_knowl: latexterm = make_bigint(latexterm) if term.number_of_terms() > 1: latexterm = r"(" + latexterm + r")" if j > 0: if term == 1: latexterm = '' elif term == -1: latexterm = '-' if j == 1: latexterm += ' q' else: latexterm += ' q^{%d}' % j if s != '' and latexterm[0] != '-': latexterm = '+' + latexterm s += '\(' + latexterm + '\) ' # Work around bug in Sage's latex s = s.replace('betaq', 'beta q') return s + '\(+O(q^{%d})\)' % prec
def divisor_data(P): R = PolynomialRing(QQ,['x','z']); x = R('x');z = R('z') xP,yP = P[0],P[1] xden,yden = lcm([r[1] for r in xP]), lcm([r[1] for r in yP]) xD = sum([ZZ(xden)*ZZ(xP[i][0])/ZZ(xP[i][1])*x**i*z**(len(xP)-i-1) for i in range(len(xP))]) if str(xD.factor())[:4] == "(-1)": xD = -xD yD = sum([ZZ(yden)*ZZ(yP[i][0])/ZZ(yP[i][1])*x**i*z**(len(yP)-i-1) for i in range(len(yP))]) return [make_bigint(elt, 10) for elt in [str(xD.factor()).replace("**","^").replace("*",""), str(yden)+"y" if yden > 1 else "y", str(yD).replace("**","^").replace("*","")]], xD, yD, yden
def process_euler(f, p): fG = list_to_factored_poly_otherorder(f, galois=galois, p=p) if galois: factors, gal_groups = fG else: factors, gal_groups = fG, "" factors = make_bigint(r'\( %s \)' % factors) if gal_groups: if gal_groups[0] == [0, 0]: gal_groups = "" else: gal_groups = r"$\times$".join( transitive_group_display_knowl_C1_as_trivial( f"{n}T{t}") for n, t in gal_groups) return [gal_groups, factors, self.ordinary(f, p)]
def trace_expansion(self, prec_max=10): prec = min(self.texp_prec, prec_max) s = web_latex_split_on_pm(web_latex(coeff_to_power_series(self.texp[:prec], prec=prec), enclose=False)) if too_big(self.texp[:prec], 10**24): s = make_bigint(s) return s
def display_hecke_polys(form_labels, num_disp=5): """ Display a table of the characteristic polynomials of the Hecke operators for small primes Right now, the number of primes presented by default is 5, but that could be changed easily The rest could be seen by using "show more" / "show less" - The code for the table wrapping, scrolling etc. is common with many others and should be eventually replaced by a call to a single class/function with some parameters. INPUT: - ``form_labels`` - a list of strings, the labels of the newforms in the space - ``num_disp`` - an integer, the number of characteristic polynomials to display by default. """ #from time import clock def th_wrap(kwl, title): return ' <th>%s</th>' % display_knowl(kwl, title=title) def td_wrap(val): return ' <td>$%s$</th>' % val num_forms = len(form_labels) orbit_codes = [] for label in form_labels: data = db.mf_newforms.lookup(label, ['hecke_orbit_code']) orbit_codes.append(data['hecke_orbit_code']) hecke_polys_orbits = {} #factor_time = 0 for orbit_code in orbit_codes: for poly_item in db.mf_hecke_lpolys.search( {'hecke_orbit_code': orbit_code}): coeffs = poly_item['lpoly_factorization'] #t2 = clock() F_p = list_factored_to_factored_poly_otherorder(coeffs) #t3 = clock() #factor_time += (t3-t2) F_p = make_bigint(r'\( %s \)' % F_p) if (F_p != r"\( 1 \)") and (len(F_p) > 6): if (F_p[0] != '(') and (num_forms > 1): F_p = '(' + F_p + ')' hecke_polys_orbits[poly_item['p']] = hecke_polys_orbits.get( poly_item['p'], "") + F_p else: hecke_polys_orbits[poly_item['p']] = hecke_polys_orbits.get( poly_item['p'], "") #print "factoring took " + str(factor_time) if not hecke_polys_orbits: return "There are no characteristic polynomials of Hecke operators in the database" polys = [ '<div style="max-width: 100%; overflow-x: auto;">', '<table class="ntdata">', '<thead>', ' <tr>', th_wrap('p', '$p$'), th_wrap('lpoly', '$F_p(T)$'), ' </tr>', '</thead>', '<tbody>' ] loop_count = 0 for p, lpoly in hecke_polys_orbits.items(): if lpoly.strip() == "": lpoly = "1" if loop_count < num_disp: polys.append(' <tr>') else: polys.append(' <tr class="more nodisplay">') polys.extend([td_wrap(p), '<td>' + lpoly + '</th>']) polys.append(' </tr>') loop_count += 1 if loop_count > num_disp: polys.append(''' <tr class="less toggle"> <td colspan="{{colspan}}"> <a onclick="show_moreless("more"); return true" href="#moreep">show more</a> </td> </tr> <tr class="more toggle nodisplay"> <td colspan="{{colspan}}"> <a onclick="show_moreless("less"); return true" href="#eptable">show less</a> </td> </tr> ''') polys.extend(['</tbody>', '</table>', '</div>']) return '\n'.join(polys)