def download_hmf_magma(**args): label = str(args['label']) f = get_hmf(label) if f is None: return "No such form" F = WebNumberField(f['field_label']) F_hmf = get_hmf_field(f['field_label']) hecke_pol = f['hecke_polynomial'] hecke_eigs = map(str, f['hecke_eigenvalues']) AL_eigs = f['AL_eigenvalues'] outstr = 'P<x> := PolynomialRing(Rationals());\n' outstr += 'g := P!' + str(F.coeffs()) + ';\n' outstr += 'F<w> := NumberField(g);\n' outstr += 'ZF := Integers(F);\n\n' # outstr += 'ideals_str := [' + ','.join([st for st in F_hmf["ideals"]]) + '];\n' # outstr += 'ideals := [ideal<ZF | {F!x : x in I}> : I in ideals_str];\n\n' outstr += 'NN := ideal<ZF | {' + f["level_ideal"][1:-1] + '}>;\n\n' outstr += 'primesArray := [\n' + ','.join([st for st in F_hmf["primes"]]).replace('],[', '],\n[') + '];\n' outstr += 'primes := [ideal<ZF | {F!x : x in I}> : I in primesArray];\n\n' if hecke_pol != 'x': outstr += 'heckePol := ' + hecke_pol + ';\n' outstr += 'K<e> := NumberField(heckePol);\n' else: outstr += 'heckePol := x;\nK := Rationals(); e := 1;\n' outstr += '\nheckeEigenvaluesArray := [' + ', '.join([st for st in hecke_eigs]) + '];' outstr += '\nheckeEigenvalues := AssociativeArray();\n' outstr += 'for i := 1 to #heckeEigenvaluesArray do\n heckeEigenvalues[primes[i]] := heckeEigenvaluesArray[i];\nend for;\n\n' outstr += 'ALEigenvalues := AssociativeArray();\n' for s in AL_eigs: outstr += 'ALEigenvalues[ideal<ZF | {' + s[0][1:-1] + '}>] := ' + str(s[1]) + ';\n' outstr += '\n// EXAMPLE:\n// pp := Factorization(2*ZF)[1][1];\n// heckeEigenvalues[pp];\n\n' outstr += '/* EXTRA CODE: recompute eigenform (warning, may take a few minutes or longer!):\n' outstr += 'M := HilbertCuspForms(F, NN);\n' outstr += 'S := NewSubspace(M);\n' outstr += '// SetVerbose("ModFrmHil", 1);\n' outstr += 'newspaces := NewformDecomposition(S);\n' outstr += 'newforms := [Eigenform(U) : U in newspaces];\n' outstr += 'ppind := 0;\n' outstr += 'while #newforms gt 1 do\n' outstr += ' pp := primes[ppind];\n' outstr += ' newforms := [f : f in newforms | HeckeEigenvalue(f,pp) eq heckeEigenvalues[pp]];\n' outstr += 'end while;\n' outstr += 'f := newforms[1];\n' outstr += '// [HeckeEigenvalue(f,pp) : pp in primes] eq heckeEigenvaluesArray;\n' outstr += '*/\n' return outstr
def download_hmf_sage(**args): label = str(args['label']) f = get_hmf(label) if f is None: return "No such form" hecke_pol = f['hecke_polynomial'] hecke_eigs = map(str, f['hecke_eigenvalues']) AL_eigs = f['AL_eigenvalues'] F = WebNumberField(f['field_label']) F_hmf = get_hmf_field(f['field_label']) outstr = '/*\n This code can be loaded, or copied and paste using cpaste, into Sage.\n' outstr += ' It will load the data associated to the HMF, including\n' outstr += ' the field, level, and Hecke and Atkin-Lehner eigenvalue data.\n' outstr += '*/\n\n' outstr += 'P.<x> = PolynomialRing(QQ)\n' outstr += 'g = P(' + str(F.coeffs()) + ')\n' outstr += 'F.<w> = NumberField(g)\n' outstr += 'ZF = F.ring_of_integers()\n\n' outstr += 'NN = ZF.ideal(' + f["level_ideal"] + ')\n\n' outstr += 'primes_array = [\n' + ','.join( [st for st in F_hmf["primes"]]).replace('],[', '],\\\n[') + ']\n' outstr += 'primes = [ZF.ideal(I) for I in primes_array]\n\n' if hecke_pol != 'x': outstr += 'heckePol = ' + hecke_pol + '\n' outstr += 'K.<e> = NumberField(heckePol)\n' else: outstr += 'heckePol = x\nK = QQ\ne = 1\n' outstr += '\nhecke_eigenvalues_array = [' + ', '.join( [st for st in hecke_eigs]) + ']' outstr += '\nhecke_eigenvalues = {}\n' outstr += 'for i in range(len(hecke_eigenvalues_array)):\n hecke_eigenvalues[primes[i]] = hecke_eigenvalues_array[i]\n\n' outstr += 'AL_eigenvalues = {}\n' for s in AL_eigs: outstr += 'AL_eigenvalues[ZF.ideal(%s)] = %s\n' % (s[0], s[1]) outstr += '\n# EXAMPLE:\n# pp = ZF.ideal(2).factor()[0][0]\n# hecke_eigenvalues[pp]\n' return outstr
def download_hmf_sage(**args): label = str(args['label']) f = get_hmf(label) if f is None: return "No such form" hecke_pol = f['hecke_polynomial'] hecke_eigs = map(str, f['hecke_eigenvalues']) AL_eigs = f['AL_eigenvalues'] F = WebNumberField(f['field_label']) F_hmf = get_hmf_field(f['field_label']) outstr = '/*\n This code can be loaded, or copied and paste using cpaste, into Sage.\n' outstr += ' It will load the data associated to the HMF, including\n' outstr += ' the field, level, and Hecke and Atkin-Lehner eigenvalue data.\n' outstr += '*/\n\n' outstr += 'P.<x> = PolynomialRing(QQ)\n' outstr += 'g = P(' + str(F.coeffs()) + ')\n' outstr += 'F.<w> = NumberField(g)\n' outstr += 'ZF = F.ring_of_integers()\n\n' outstr += 'NN = ZF.ideal(' + f["level_ideal"] + ')\n\n' outstr += 'primes_array = [\n' + ','.join([st for st in F_hmf["primes"]]).replace('],[', '],\\\n[') + ']\n' outstr += 'primes = [ZF.ideal(I) for I in primes_array]\n\n' if hecke_pol != 'x': outstr += 'heckePol = ' + hecke_pol + '\n' outstr += 'K.<e> = NumberField(heckePol)\n' else: outstr += 'heckePol = x\nK = QQ\ne = 1\n' outstr += '\nhecke_eigenvalues_array = [' + ', '.join([st for st in hecke_eigs]) + ']' outstr += '\nhecke_eigenvalues = {}\n' outstr += 'for i in range(len(hecke_eigenvalues_array)):\n hecke_eigenvalues[primes[i]] = hecke_eigenvalues_array[i]\n\n' outstr += 'AL_eigenvalues = {}\n' for s in AL_eigs: outstr += 'AL_eigenvalues[ZF.ideal(%s)] = %s\n' % (s[0],s[1]) outstr += '\n# EXAMPLE:\n# pp = ZF.ideal(2).factor()[0][0]\n# hecke_eigenvalues[pp]\n' return outstr
def download_hmf_magma(**args): label = str(args['label']) f = get_hmf(label) if f is None: return "No such form" F = WebNumberField(f['field_label']) F_hmf = get_hmf_field(f['field_label']) hecke_pol = f['hecke_polynomial'] hecke_eigs = map(str, f['hecke_eigenvalues']) AL_eigs = f['AL_eigenvalues'] outstr = '/*\n This code can be loaded, or copied and pasted, into Magma.\n' outstr += ' It will load the data associated to the HMF, including\n' outstr += ' the field, level, and Hecke and Atkin-Lehner eigenvalue data.\n' outstr += ' At the *bottom* of the file, there is code to recreate the\n' outstr += ' Hilbert modular form in Magma, by creating the HMF space\n' outstr += ' and cutting out the corresponding Hecke irreducible subspace.\n' outstr += ' From there, you can ask for more eigenvalues or modify as desired.\n' outstr += ' It is commented out, as this computation may be lengthy.\n' outstr += '*/\n\n' outstr += 'P<x> := PolynomialRing(Rationals());\n' outstr += 'g := P!' + str(F.coeffs()) + ';\n' outstr += 'F<w> := NumberField(g);\n' outstr += 'ZF := Integers(F);\n\n' # outstr += 'ideals_str := [' + ','.join([st for st in F_hmf["ideals"]]) + '];\n' # outstr += 'ideals := [ideal<ZF | {F!x : x in I}> : I in ideals_str];\n\n' outstr += 'NN := ideal<ZF | {' + f["level_ideal"][1:-1] + '}>;\n\n' outstr += 'primesArray := [\n' + ','.join( [st for st in F_hmf["primes"]]).replace('],[', '],\n[') + '];\n' outstr += 'primes := [ideal<ZF | {F!x : x in I}> : I in primesArray];\n\n' if hecke_pol != 'x': outstr += 'heckePol := ' + hecke_pol + ';\n' outstr += 'K<e> := NumberField(heckePol);\n' else: outstr += 'heckePol := x;\nK := Rationals(); e := 1;\n' outstr += '\nheckeEigenvaluesArray := [' + ', '.join( [st for st in hecke_eigs]) + '];' outstr += '\nheckeEigenvalues := AssociativeArray();\n' outstr += 'for i := 1 to #heckeEigenvaluesArray do\n heckeEigenvalues[primes[i]] := heckeEigenvaluesArray[i];\nend for;\n\n' outstr += 'ALEigenvalues := AssociativeArray();\n' for s in AL_eigs: outstr += 'ALEigenvalues[ideal<ZF | {' + s[0][1:-1] + '}>] := ' + str( s[1]) + ';\n' outstr += '\n// EXAMPLE:\n// pp := Factorization(2*ZF)[1][1];\n// heckeEigenvalues[pp];\n\n' outstr += '/* EXTRA CODE: recompute eigenform (warning, may take a few minutes or longer!):\n' outstr += 'M := HilbertCuspForms(F, NN);\n' outstr += 'S := NewSubspace(M);\n' outstr += '// SetVerbose("ModFrmHil", 1);\n' outstr += 'newspaces := NewformDecomposition(S);\n' outstr += 'newforms := [Eigenform(U) : U in newspaces];\n' outstr += 'ppind := 0;\n' outstr += 'while #newforms gt 1 do\n' outstr += ' pp := primes[ppind];\n' outstr += ' newforms := [f : f in newforms | HeckeEigenvalue(f,pp) eq heckeEigenvalues[pp]];\n' outstr += 'end while;\n' outstr += 'f := newforms[1];\n' outstr += '// [HeckeEigenvalue(f,pp) : pp in primes] eq heckeEigenvaluesArray;\n' outstr += '*/\n' return outstr
def render_field_webpage(args): data = None info = {} bread = bread_prefix() # This function should not be called unless label is set. label = clean_input(args['label']) nf = WebNumberField(label) data = {} if nf.is_null(): if re.match(r'^\d+\.\d+\.\d+\.\d+$', label): flash_error("Number field %s was not found in the database.", label) else: flash_error("%s is not a valid label for a number field.", label) return redirect(url_for(".number_field_render_webpage")) info['wnf'] = nf data['degree'] = nf.degree() data['class_number'] = nf.class_number_latex() ram_primes = nf.ramified_primes() t = nf.galois_t() n = nf.degree() data['is_galois'] = nf.is_galois() data['autstring'] = r'\Gal' if data['is_galois'] else r'\Aut' data['is_abelian'] = nf.is_abelian() if nf.is_abelian(): conductor = nf.conductor() data['conductor'] = conductor dirichlet_chars = nf.dirichlet_group() if dirichlet_chars: data['dirichlet_group'] = [ r'<a href = "%s">$\chi_{%s}(%s,·)$</a>' % (url_for('characters.render_Dirichletwebpage', modulus=data['conductor'], number=j), data['conductor'], j) for j in dirichlet_chars ] if len(data['dirichlet_group']) == 1: data[ 'dirichlet_group'] = r'<span style="white-space:nowrap">$\lbrace$' + data[ 'dirichlet_group'][0] + r'$\rbrace$</span>' else: data['dirichlet_group'] = r'$\lbrace$' + ', '.join( data['dirichlet_group'] [:-1]) + '<span style="white-space:nowrap">' + data[ 'dirichlet_group'][-1] + r'$\rbrace$</span>' if data['conductor'].is_prime() or data['conductor'] == 1: data['conductor'] = r"\(%s\)" % str(data['conductor']) else: factored_conductor = factor_base_factor(data['conductor'], ram_primes) factored_conductor = factor_base_factorization_latex( factored_conductor) data['conductor'] = r"\(%s=%s\)" % (str( data['conductor']), factored_conductor) data['galois_group'] = group_pretty_and_nTj(n, t, True) data['auts'] = db.gps_transitive.lookup(r'{}T{}'.format(n, t))['auts'] data['cclasses'] = cclasses_display_knowl(n, t) data['character_table'] = character_table_display_knowl(n, t) data['class_group'] = nf.class_group() data['class_group_invs'] = nf.class_group_invariants() data['signature'] = nf.signature() data['coefficients'] = nf.coeffs() nf.make_code_snippets() D = nf.disc() data['disc_factor'] = nf.disc_factored_latex() if D.abs().is_prime() or D == 1: data['discriminant'] = bigint_knowl(D, cutoff=60, sides=3) else: data['discriminant'] = bigint_knowl( D, cutoff=60, sides=3) + r"\(\medspace = %s\)" % data['disc_factor'] if nf.frobs(): data['frob_data'], data['seeram'] = see_frobs(nf.frobs()) else: # fallback in case we haven't computed them in a case data['frob_data'], data['seeram'] = frobs(nf) # This could put commas in the rd, we don't want to trigger spaces data['rd'] = ('$%s$' % fixed_prec(nf.rd(), 2)).replace(',', '{,}') # Bad prime information npr = len(ram_primes) ramified_algebras_data = nf.ramified_algebras_data() if isinstance(ramified_algebras_data, str): loc_alg = '' else: # [label, latex, e, f, c, gal] loc_alg = '' for j in range(npr): if ramified_algebras_data[j] is None: loc_alg += '<tr><td>%s<td colspan="7">Data not computed' % str( ram_primes[j]).rstrip('L') else: from lmfdb.local_fields.main import show_slope_content mydat = ramified_algebras_data[j] p = ram_primes[j] loc_alg += '<tr><td rowspan="%d">$%s$</td>' % (len(mydat), str(p)) mm = mydat[0] myurl = url_for('local_fields.by_label', label=mm[0]) lab = mm[0] if mm[3] * mm[2] == 1: lab = r'$\Q_{%s}$' % str(p) loc_alg += '<td><a href="%s">%s</a><td>$%s$<td>$%d$<td>$%d$<td>$%d$<td>%s<td>$%s$' % ( myurl, lab, mm[1], mm[2], mm[3], mm[4], mm[5], show_slope_content(mm[8], mm[6], mm[7])) for mm in mydat[1:]: lab = mm[0] myurl = url_for('local_fields.by_label', label=lab) if mm[3] * mm[2] == 1: lab = r'$\Q_{%s}$' % str(p) loc_alg += '<tr><td><a href="%s">%s</a><td>$%s$<td>$%d$<td>$%d$<td>$%d$<td>%s<td>$%s$' % ( myurl, lab, mm[1], mm[2], mm[3], mm[4], mm[5], show_slope_content(mm[8], mm[6], mm[7])) loc_alg += '</tbody></table>' ram_primes = str(ram_primes)[1:-1] # Get rid of python L for big numbers ram_primes = ram_primes.replace('L', '') if not ram_primes: ram_primes = r'\textrm{None}' data['phrase'] = group_phrase(n, t) zk = nf.zk() Ra = PolynomialRing(QQ, 'a') zk = [latex(Ra(x)) for x in zk] zk = ['$%s$' % x for x in zk] zk = ', '.join(zk) grh_label = '<small>(<a title="assuming GRH" knowl="nf.assuming_grh">assuming GRH</a>)</small>' if nf.used_grh( ) else '' # Short version for properties grh_lab = nf.short_grh_string() if 'computed' in str(data['class_number']): grh_lab = '' grh_label = '' pretty_label = field_pretty(label) if label != pretty_label: pretty_label = "%s: %s" % (label, pretty_label) info.update(data) rootofunity = '%s (order $%d$)' % (nf.root_of_1_gen(), nf.root_of_1_order()) info.update({ 'label': pretty_label, 'label_raw': label, 'polynomial': web_latex(nf.poly()), 'ram_primes': ram_primes, 'integral_basis': zk, 'regulator': web_latex(nf.regulator()), 'unit_rank': nf.unit_rank(), 'root_of_unity': rootofunity, 'fund_units': nf.units_safe(), 'cnf': nf.cnf(), 'grh_label': grh_label, 'loc_alg': loc_alg }) bread.append(('%s' % nf_label_pretty(info['label_raw']), ' ')) info['downloads_visible'] = True info['downloads'] = [('worksheet', '/')] info['friends'] = [] if nf.can_class_number(): # hide ones that take a lond time to compute on the fly # note that the first degree 4 number field missed the zero of the zeta function if abs(D**n) < 50000000: info['friends'].append(('L-function', "/L/NumberField/%s" % label)) info['friends'].append(('Galois group', "/GaloisGroup/%dT%d" % (n, t))) if 'dirichlet_group' in info: info['friends'].append(('Dirichlet character group', url_for("characters.dirichlet_group_table", modulus=int(conductor), char_number_list=','.join( str(a) for a in dirichlet_chars), poly=info['polynomial']))) resinfo = [] galois_closure = nf.galois_closure() if galois_closure[0] > 0: if galois_closure[1]: resinfo.append(('gc', galois_closure[1])) if galois_closure[2]: info['friends'].append(('Galois closure', url_for(".by_label", label=galois_closure[2][0]))) else: resinfo.append(('gc', [dnc])) sextic_twins = nf.sextic_twin() if sextic_twins[0] > 0: if sextic_twins[1]: resinfo.append(('sex', r' $\times$ '.join(sextic_twins[1]))) else: resinfo.append(('sex', dnc)) siblings = nf.siblings() # [degsib list, label list] # first is list of [deg, num expected, list of knowls] if siblings[0]: for sibdeg in siblings[0]: if not sibdeg[2]: sibdeg[2] = dnc else: nsibs = len(sibdeg[2]) sibdeg[2] = ', '.join(sibdeg[2]) if nsibs < sibdeg[1]: sibdeg[2] += ', some ' + dnc resinfo.append(('sib', siblings[0])) for lab in siblings[1]: if lab: labparts = lab.split('.') info['friends'].append(("Degree %s sibling" % labparts[0], url_for(".by_label", label=lab))) arith_equiv = nf.arith_equiv() if arith_equiv[0] > 0: if arith_equiv[1]: resinfo.append( ('ae', ', '.join(arith_equiv[1]), len(arith_equiv[1]))) for aelab in arith_equiv[2]: info['friends'].append(('Arithmetically equivalent sibling', url_for(".by_label", label=aelab))) else: resinfo.append(('ae', dnc, len(arith_equiv[1]))) info['resinfo'] = resinfo learnmore = learnmore_list() title = "Number field %s" % info['label'] if npr == 1: primes = 'prime' else: primes = 'primes' if len(ram_primes) > 30: ram_primes = 'see page' else: ram_primes = '$%s$' % ram_primes properties = [('Label', nf_label_pretty(label)), ('Degree', prop_int_pretty(data['degree'])), ('Signature', '$%s$' % data['signature']), ('Discriminant', prop_int_pretty(D)), ('Root discriminant', '%s' % data['rd']), ('Ramified ' + primes + '', ram_primes), ('Class number', '%s %s' % (data['class_number'], grh_lab)), ('Class group', '%s %s' % (data['class_group_invs'], grh_lab)), ('Galois group', group_pretty_and_nTj(data['degree'], t))] downloads = [('Stored data to gp', url_for('.nf_download', nf=label, download_type='data'))] for lang in [["Magma", "magma"], ["SageMath", "sage"], ["Pari/GP", "gp"]]: downloads.append(('Download {} code'.format(lang[0]), url_for(".nf_download", nf=label, download_type=lang[1]))) from lmfdb.artin_representations.math_classes import NumberFieldGaloisGroup from lmfdb.artin_representations.math_classes import artin_label_pretty try: info["tim_number_field"] = NumberFieldGaloisGroup(nf._data['coeffs']) arts = [ z.label() for z in info["tim_number_field"].artin_representations() ] #print arts for ar in arts: info['friends'].append(( 'Artin representation ' + artin_label_pretty(ar), url_for( "artin_representations.render_artin_representation_webpage", label=ar))) v = nf.factor_perm_repn(info["tim_number_field"]) def dopow(m): if m == 0: return '' if m == 1: return '*' return '*<sup>%d</sup>' % m info["mydecomp"] = [dopow(x) for x in v] except AttributeError: pass return render_template("nf-show-field.html", properties=properties, credit=NF_credit, title=title, bread=bread, code=nf.code, friends=info.pop('friends'), downloads=downloads, learnmore=learnmore, info=info, KNOWL_ID="nf.%s" % label)
def download_hmf_magma(**args): label = str(args['label']) f = get_hmf(label) if f is None: return "No such form" F = WebNumberField(f['field_label']) F_hmf = get_hmf_field(f['field_label']) hecke_pol = f['hecke_polynomial'] hecke_eigs = [str(eig) for eig in f['hecke_eigenvalues']] AL_eigs = f['AL_eigenvalues'] outstr = '/*\n This code can be loaded, or copied and pasted, into Magma.\n' outstr += ' It will load the data associated to the HMF, including\n' outstr += ' the field, level, and Hecke and Atkin-Lehner eigenvalue data.\n' outstr += ' At the *bottom* of the file, there is code to recreate the\n' outstr += ' Hilbert modular form in Magma, by creating the HMF space\n' outstr += ' and cutting out the corresponding Hecke irreducible subspace.\n' outstr += ' From there, you can ask for more eigenvalues or modify as desired.\n' outstr += ' It is commented out, as this computation may be lengthy.\n' outstr += '*/\n\n' outstr += 'P<x> := PolynomialRing(Rationals());\n' outstr += 'g := P!' + str(F.coeffs()) + ';\n' outstr += 'F<w> := NumberField(g);\n' outstr += 'ZF := Integers(F);\n\n' # outstr += 'ideals_str := [' + ','.join([st for st in F_hmf["ideals"]]) + '];\n' # outstr += 'ideals := [ideal<ZF | {F!x : x in I}> : I in ideals_str];\n\n' outstr += 'NN := ideal<ZF | {' + f["level_ideal"][1:-1] + '}>;\n\n' outstr += 'primesArray := [\n' + ','.join( [st for st in F_hmf["primes"]]).replace('],[', '],\n[') + '];\n' outstr += 'primes := [ideal<ZF | {F!x : x in I}> : I in primesArray];\n\n' if hecke_pol != 'x': outstr += 'heckePol := ' + hecke_pol + ';\n' outstr += 'K<e> := NumberField(heckePol);\n' else: outstr += 'heckePol := x;\nK := Rationals(); e := 1;\n' outstr += '\nheckeEigenvaluesArray := [' + ', '.join( [st for st in hecke_eigs]) + '];' outstr += '\nheckeEigenvalues := AssociativeArray();\n' outstr += 'for i := 1 to #heckeEigenvaluesArray do\n heckeEigenvalues[primes[i]] := heckeEigenvaluesArray[i];\nend for;\n\n' outstr += 'ALEigenvalues := AssociativeArray();\n' for s in AL_eigs: outstr += 'ALEigenvalues[ideal<ZF | {' + s[0][1:-1] + '}>] := ' + str( s[1]) + ';\n' outstr += '\n// EXAMPLE:\n// pp := Factorization(2*ZF)[1][1];\n// heckeEigenvalues[pp];\n\n' outstr += '\n'.join([ 'print "To reconstruct the Hilbert newform f, type', ' f, iso := Explode(make_newform());";', '', 'function make_newform();', ' M := HilbertCuspForms(F, NN);', ' S := NewSubspace(M);', ' // SetVerbose("ModFrmHil", 1);', ' NFD := NewformDecomposition(S);', ' newforms := [* Eigenform(U) : U in NFD *];', '', ' if #newforms eq 0 then;', ' print "No Hilbert newforms at this level";', ' return 0;', ' end if;', '', ' print "Testing ", #newforms, " possible newforms";', ' newforms := [* f: f in newforms | IsIsomorphic(BaseField(f), K) *];', ' print #newforms, " newforms have the correct Hecke field";', '', ' if #newforms eq 0 then;', ' print "No Hilbert newform found with the correct Hecke field";', ' return 0;', ' end if;', '', ' autos := Automorphisms(K);', ' xnewforms := [* *];', ' for f in newforms do;', ' if K eq RationalField() then;', ' Append(~xnewforms, [* f, autos[1] *]);', ' else;', ' flag, iso := IsIsomorphic(K,BaseField(f));', ' for a in autos do;', ' Append(~xnewforms, [* f, a*iso *]);', ' end for;', ' end if;', ' end for;', ' newforms := xnewforms;', '', ' for P in primes do;', ' xnewforms := [* *];', ' for f_iso in newforms do;', ' f, iso := Explode(f_iso);', ' if HeckeEigenvalue(f,P) eq iso(heckeEigenvalues[P]) then;', ' Append(~xnewforms, f_iso);', ' end if;', ' end for;', ' newforms := xnewforms;', ' if #newforms eq 0 then;', ' print "No Hilbert newform found which matches the Hecke eigenvalues";', ' return 0;', ' else if #newforms eq 1 then;', ' print "success: unique match";', ' return newforms[1];', ' end if;', ' end if;', ' end for;', ' print #newforms, "Hilbert newforms found which match the Hecke eigenvalues";', ' return newforms[1];', '', 'end function;' ]) return outstr
def download_bmf_sage(**args): """Generates the sage code for the user to obtain the BMF eigenvalues. As in the HMF case, and unlike the website, we export *all* eigenvalues in the database, not just 50, and not just those away from the level.""" label = "-".join([args['field_label'], args['level_label'], args['label_suffix']]) try: f = WebBMF.by_label(label) except ValueError: return "Bianchi newform not found" hecke_pol = f.hecke_poly_obj hecke_eigs = f.hecke_eigs F = WebNumberField(f.field_label) K = f.field.K() primes_in_K = [p for p,_ in zip(primes_iter(K),hecke_eigs)] prime_gens = [p.gens_reduced() for p in primes_in_K] outstr = '"""\n This code can be loaded, or copied and paste using cpaste, into Sage.\n' outstr += ' It will load the data associated to the BMF, including\n' outstr += ' the field, level, and Hecke and Atkin-Lehner eigenvalue data (if known).\n' outstr += '"""\n\n' outstr += 'P = PolynomialRing(QQ, "x")\nx = P.gen()\n' outstr += 'g = P(' + str(F.coeffs()) + ')\n' outstr += 'F = NumberField(g, "{}")\n'.format(K.gen()) outstr += '{} = F.gen()\n'.format(K.gen()) outstr += 'ZF = F.ring_of_integers()\n\n' outstr += 'NN = ZF.ideal({})\n\n'.format(f.level.gens()) outstr += 'primes_array = [\n' + ','.join([str(st).replace(' ', '') for st in prime_gens]).replace('],[', '],\\\n[') + ']\n' outstr += 'primes = [ZF.ideal(I) for I in primes_array]\n\n' Qx = PolynomialRing(QQ,'x') if hecke_pol != 'x': outstr += 'heckePol = P({})\n'.format(str((Qx(hecke_pol)).list())) outstr += 'K = NumberField(heckePol, "z")\nz = K.gen()\n' else: outstr += 'heckePol = x\nK = QQ\ne = 1\n' hecke_eigs_processed = [str(st).replace(' ', '') if st != 'not known' else '"not known"' for st in hecke_eigs] outstr += '\nhecke_eigenvalues_array = [' + ', '.join(hecke_eigs_processed) + ']' outstr += '\nhecke_eigenvalues = {}\n' outstr += 'for i in range(len(hecke_eigenvalues_array)):\n hecke_eigenvalues[primes[i]] = hecke_eigenvalues_array[i]\n\n' if f.have_AL: AL_eigs = f.AL_table_data outstr += 'AL_eigenvalues = {}\n' for s in AL_eigs: outstr += 'AL_eigenvalues[ZF.ideal(%s)] = %s\n' % (s[0],s[1]) else: outstr += 'AL_eigenvalues ="not known"\n' outstr += '\n# EXAMPLE:\n# pp = ZF.ideal(2).factor()[0][0]\n# hecke_eigenvalues[pp]\n' return outstr
def download_bmf_magma(**args): label = "-".join([args['field_label'], args['level_label'], args['label_suffix']]) try: f = WebBMF.by_label(label) except ValueError: return "Bianchi newform not found" hecke_pol = f.hecke_poly_obj hecke_eigs = f.hecke_eigs F = WebNumberField(f.field_label) K = f.field.K() primes_in_K = [p for p,_ in zip(primes_iter(K),hecke_eigs)] prime_gens = [list(p.gens()) for p in primes_in_K] outstr = '/*\n This code can be loaded, or copied and pasted, into Magma.\n' outstr += ' It will load the data associated to the BMF, including\n' outstr += ' the field, level, and Hecke and Atkin-Lehner eigenvalue data.\n' outstr += ' At the *bottom* of the file, there is code to recreate the\n' outstr += ' Bianchi modular form in Magma, by creating the BMF space\n' outstr += ' and cutting out the corresponding Hecke irreducible subspace.\n' outstr += ' From there, you can ask for more eigenvalues or modify as desired.\n' outstr += ' It is commented out, as this computation may be lengthy.\n' outstr += '*/\n\n' outstr += 'P<x> := PolynomialRing(Rationals());\n' outstr += 'g := P!' + str(F.coeffs()) + ';\n' outstr += 'F<{}> := NumberField(g);\n'.format(K.gen()) outstr += 'ZF := Integers(F);\n\n' outstr += 'NN := ideal<ZF | {}>;\n\n'.format(set(f.level.gens())) outstr += 'primesArray := [\n' + ','.join([str(st).replace(' ', '') for st in prime_gens]).replace('],[', '],\n[') + '];\n' outstr += 'primes := [ideal<ZF | {F!x : x in I}> : I in primesArray];\n\n' if hecke_pol != 'x': outstr += 'heckePol := ' + hecke_pol + ';\n' outstr += 'K<z> := NumberField(heckePol);\n' else: outstr += 'heckePol := x;\nK := Rationals(); e := 1;\n' hecke_eigs_processed = [str(st).replace(' ', '') if st != 'not known' else '"not known"' for st in hecke_eigs] outstr += '\nheckeEigenvaluesList := [*\n'+ ',\n'.join(hecke_eigs_processed) + '\n*];\n' outstr += '\nheckeEigenvalues := AssociativeArray();\n' outstr += 'for i in [1..#heckeEigenvaluesList] do\n heckeEigenvalues[primes[i]] := heckeEigenvaluesList[i];\nend for;\n' if f.have_AL: AL_eigs = f.AL_table_data outstr += '\nALEigenvalues := AssociativeArray();\n' for s in AL_eigs: outstr += 'ALEigenvalues[ideal<ZF | {}>] := {};\n'.format(set(s[0]), s[1]) else: outstr += '\nALEigenvalues := "not known";\n' outstr += '\n// EXAMPLE:\n// pp := Factorization(2*ZF)[1][1];\n// heckeEigenvalues[pp];\n\n' outstr += '\n'.join([ 'print "To reconstruct the Bianchi newform f, type', ' f, iso := Explode(make_newform());";', '', 'function make_newform();', ' M := BianchiCuspForms(F, NN);', ' S := NewSubspace(M);', ' // SetVerbose("Bianchi", 1);', ' NFD := NewformDecomposition(S);', ' newforms := [* Eigenform(U) : U in NFD *];', '', ' if #newforms eq 0 then;', ' print "No Bianchi newforms at this level";', ' return 0;', ' end if;', '', ' print "Testing ", #newforms, " possible newforms";', ' newforms := [* f: f in newforms | IsIsomorphic(BaseField(f), K) *];', ' print #newforms, " newforms have the correct Hecke field";', '', ' if #newforms eq 0 then;', ' print "No Bianchi newform found with the correct Hecke field";', ' return 0;', ' end if;', '', ' autos := Automorphisms(K);', ' xnewforms := [* *];', ' for f in newforms do;', ' if K eq RationalField() then;', ' Append(~xnewforms, [* f, autos[1] *]);', ' else;', ' flag, iso := IsIsomorphic(K,BaseField(f));', ' for a in autos do;', ' Append(~xnewforms, [* f, a*iso *]);', ' end for;', ' end if;', ' end for;', ' newforms := xnewforms;', '', ' for P in primes do;', ' if Valuation(NN,P) eq 0 then;', ' xnewforms := [* *];', ' for f_iso in newforms do;', ' f, iso := Explode(f_iso);', ' if HeckeEigenvalue(f,P) eq iso(heckeEigenvalues[P]) then;', ' Append(~xnewforms, f_iso);', ' end if;', ' end for;', ' newforms := xnewforms;', ' if #newforms eq 0 then;', ' print "No Bianchi newform found which matches the Hecke eigenvalues";', ' return 0;', ' else if #newforms eq 1 then;', ' print "success: unique match";', ' return newforms[1];', ' end if;', ' end if;', ' end if;', ' end for;', ' print #newforms, "Bianchi newforms found which match the Hecke eigenvalues";', ' return newforms[1];', '', 'end function;']) return outstr
def download_hmf_magma(**args): label = str(args['label']) f = get_hmf(label) if f is None: return "No such form" F = WebNumberField(f['field_label']) F_hmf = get_hmf_field(f['field_label']) hecke_pol = f['hecke_polynomial'] hecke_eigs = map(str, f['hecke_eigenvalues']) AL_eigs = f['AL_eigenvalues'] outstr = '/*\n This code can be loaded, or copied and pasted, into Magma.\n' outstr += ' It will load the data associated to the HMF, including\n' outstr += ' the field, level, and Hecke and Atkin-Lehner eigenvalue data.\n' outstr += ' At the *bottom* of the file, there is code to recreate the\n' outstr += ' Hilbert modular form in Magma, by creating the HMF space\n' outstr += ' and cutting out the corresponding Hecke irreducible subspace.\n' outstr += ' From there, you can ask for more eigenvalues or modify as desired.\n' outstr += ' It is commented out, as this computation may be lengthy.\n' outstr += '*/\n\n' outstr += 'P<x> := PolynomialRing(Rationals());\n' outstr += 'g := P!' + str(F.coeffs()) + ';\n' outstr += 'F<w> := NumberField(g);\n' outstr += 'ZF := Integers(F);\n\n' # outstr += 'ideals_str := [' + ','.join([st for st in F_hmf["ideals"]]) + '];\n' # outstr += 'ideals := [ideal<ZF | {F!x : x in I}> : I in ideals_str];\n\n' outstr += 'NN := ideal<ZF | {' + f["level_ideal"][1:-1] + '}>;\n\n' outstr += 'primesArray := [\n' + ','.join([st for st in F_hmf["primes"]]).replace('],[', '],\n[') + '];\n' outstr += 'primes := [ideal<ZF | {F!x : x in I}> : I in primesArray];\n\n' if hecke_pol != 'x': outstr += 'heckePol := ' + hecke_pol + ';\n' outstr += 'K<e> := NumberField(heckePol);\n' else: outstr += 'heckePol := x;\nK := Rationals(); e := 1;\n' outstr += '\nheckeEigenvaluesArray := [' + ', '.join([st for st in hecke_eigs]) + '];' outstr += '\nheckeEigenvalues := AssociativeArray();\n' outstr += 'for i := 1 to #heckeEigenvaluesArray do\n heckeEigenvalues[primes[i]] := heckeEigenvaluesArray[i];\nend for;\n\n' outstr += 'ALEigenvalues := AssociativeArray();\n' for s in AL_eigs: outstr += 'ALEigenvalues[ideal<ZF | {' + s[0][1:-1] + '}>] := ' + str(s[1]) + ';\n' outstr += '\n// EXAMPLE:\n// pp := Factorization(2*ZF)[1][1];\n// heckeEigenvalues[pp];\n\n' outstr += '/* EXTRA CODE: recompute eigenform (warning, may take a few minutes or longer!):\n' outstr += 'M := HilbertCuspForms(F, NN);\n' outstr += 'S := NewSubspace(M);\n' outstr += '// SetVerbose("ModFrmHil", 1);\n' outstr += 'newspaces := NewformDecomposition(S);\n' outstr += 'newforms := [Eigenform(U) : U in newspaces];\n' outstr += 'ppind := 0;\n' outstr += 'while #newforms gt 1 do\n' outstr += ' pp := primes[ppind];\n' outstr += ' newforms := [f : f in newforms | HeckeEigenvalue(f,pp) eq heckeEigenvalues[pp]];\n' outstr += 'end while;\n' outstr += 'f := newforms[1];\n' outstr += '// [HeckeEigenvalue(f,pp) : pp in primes] eq heckeEigenvaluesArray;\n' outstr += '*/\n' return outstr
def render_field_webpage(args): data = None info = {} bread = [('Global Number Fields', url_for(".number_field_render_webpage"))] # This function should not be called unless label is set. label = clean_input(args['label']) nf = WebNumberField(label) data = {} if nf.is_null(): if re.match(r'^\d+\.\d+\.\d+\.\d+$', label): flash_error("Number field %s was not found in the database.", label) else: flash_error("%s is not a valid label for a global number field.", label) return redirect(url_for(".number_field_render_webpage")) info['wnf'] = nf data['degree'] = nf.degree() data['class_number'] = nf.class_number_latex() ram_primes = nf.ramified_primes() t = nf.galois_t() n = nf.degree() data['is_galois'] = nf.is_galois() data['is_abelian'] = nf.is_abelian() if nf.is_abelian(): conductor = nf.conductor() data['conductor'] = conductor dirichlet_chars = nf.dirichlet_group() if len(dirichlet_chars)>0: data['dirichlet_group'] = ['<a href = "%s">$\chi_{%s}(%s,·)$</a>' % (url_for('characters.render_Dirichletwebpage',modulus=data['conductor'], number=j), data['conductor'], j) for j in dirichlet_chars] data['dirichlet_group'] = r'$\lbrace$' + ', '.join(data['dirichlet_group']) + r'$\rbrace$' if data['conductor'].is_prime() or data['conductor'] == 1: data['conductor'] = "\(%s\)" % str(data['conductor']) else: factored_conductor = factor_base_factor(data['conductor'], ram_primes) factored_conductor = factor_base_factorization_latex(factored_conductor) data['conductor'] = "\(%s=%s\)" % (str(data['conductor']), factored_conductor) data['galois_group'] = group_pretty_and_nTj(n,t,True) data['cclasses'] = cclasses_display_knowl(n, t) data['character_table'] = character_table_display_knowl(n, t) data['class_group'] = nf.class_group() data['class_group_invs'] = nf.class_group_invariants() data['signature'] = nf.signature() data['coefficients'] = nf.coeffs() nf.make_code_snippets() D = nf.disc() data['disc_factor'] = nf.disc_factored_latex() if D.abs().is_prime() or D == 1: data['discriminant'] = "\(%s\)" % str(D) else: data['discriminant'] = "\(%s=%s\)" % (str(D), data['disc_factor']) data['frob_data'], data['seeram'] = frobs(nf) # This could put commas in the rd, we don't want to trigger spaces data['rd'] = ('$%s$' % fixed_prec(nf.rd(),2)).replace(',','{,}') # Bad prime information npr = len(ram_primes) ramified_algebras_data = nf.ramified_algebras_data() if isinstance(ramified_algebras_data,str): loc_alg = '' else: # [label, latex, e, f, c, gal] loc_alg = '' for j in range(npr): if ramified_algebras_data[j] is None: loc_alg += '<tr><td>%s<td colspan="7">Data not computed'%str(ram_primes[j]).rstrip('L') else: mydat = ramified_algebras_data[j] p = ram_primes[j] loc_alg += '<tr><td rowspan="%d">$%s$</td>'%(len(mydat),str(p)) mm = mydat[0] myurl = url_for('local_fields.by_label', label=mm[0]) lab = mm[0] if mm[3]*mm[2]==1: lab = r'$\Q_{%s}$'%str(p) loc_alg += '<td><a href="%s">%s</a><td>$%s$<td>$%d$<td>$%d$<td>$%d$<td>%s<td>$%s$'%(myurl,lab,mm[1],mm[2],mm[3],mm[4],mm[5],show_slope_content(mm[8],mm[6],mm[7])) for mm in mydat[1:]: lab = mm[0] if mm[3]*mm[2]==1: lab = r'$\Q_{%s}$'%str(p) loc_alg += '<tr><td><a href="%s">%s</a><td>$%s$<td>$%d$<td>$%d$<td>$%d$<td>%s<td>$%s$'%(myurl,lab,mm[1],mm[2],mm[3],mm[4],mm[5],show_slope_content(mm[8],mm[6],mm[7])) loc_alg += '</tbody></table>' ram_primes = str(ram_primes)[1:-1] # Get rid of python L for big numbers ram_primes = ram_primes.replace('L', '') if ram_primes == '': ram_primes = r'\textrm{None}' data['phrase'] = group_phrase(n, t) zk = nf.zk() Ra = PolynomialRing(QQ, 'a') zk = [latex(Ra(x)) for x in zk] zk = ['$%s$' % x for x in zk] zk = ', '.join(zk) grh_label = '<small>(<a title="assuming GRH" knowl="nf.assuming_grh">assuming GRH</a>)</small>' if nf.used_grh() else '' # Short version for properties grh_lab = nf.short_grh_string() if 'Not' in str(data['class_number']): grh_lab='' grh_label='' pretty_label = field_pretty(label) if label != pretty_label: pretty_label = "%s: %s" % (label, pretty_label) info.update(data) if nf.degree() > 1: gpK = nf.gpK() rootof1coeff = gpK.nfrootsof1() rootofunityorder = int(rootof1coeff[1]) rootof1coeff = rootof1coeff[2] rootofunity = web_latex(Ra(str(pari("lift(%s)" % gpK.nfbasistoalg(rootof1coeff))).replace('x','a'))) rootofunity += ' (order $%d$)' % rootofunityorder else: rootofunity = web_latex(Ra('-1'))+ ' (order $2$)' info.update({ 'label': pretty_label, 'label_raw': label, 'polynomial': web_latex_split_on_pm(nf.poly()), 'ram_primes': ram_primes, 'integral_basis': zk, 'regulator': web_latex(nf.regulator()), 'unit_rank': nf.unit_rank(), 'root_of_unity': rootofunity, 'fund_units': nf.units(), 'grh_label': grh_label, 'loc_alg': loc_alg }) bread.append(('%s' % info['label_raw'], ' ')) info['downloads_visible'] = True info['downloads'] = [('worksheet', '/')] info['friends'] = [] if nf.can_class_number(): # hide ones that take a lond time to compute on the fly # note that the first degree 4 number field missed the zero of the zeta function if abs(D**n) < 50000000: info['friends'].append(('L-function', "/L/NumberField/%s" % label)) info['friends'].append(('Galois group', "/GaloisGroup/%dT%d" % (n, t))) if 'dirichlet_group' in info: info['friends'].append(('Dirichlet character group', url_for("characters.dirichlet_group_table", modulus=int(conductor), char_number_list=','.join( [str(a) for a in dirichlet_chars]), poly=info['polynomial']))) resinfo=[] galois_closure = nf.galois_closure() if galois_closure[0]>0: if len(galois_closure[1])>0: resinfo.append(('gc', galois_closure[1])) if len(galois_closure[2]) > 0: info['friends'].append(('Galois closure',url_for(".by_label", label=galois_closure[2][0]))) else: resinfo.append(('gc', [dnc])) sextic_twins = nf.sextic_twin() if sextic_twins[0]>0: if len(sextic_twins[1])>0: resinfo.append(('sex', r' $\times$ '.join(sextic_twins[1]))) else: resinfo.append(('sex', dnc)) siblings = nf.siblings() # [degsib list, label list] # first is list of [deg, num expected, list of knowls] if len(siblings[0])>0: for sibdeg in siblings[0]: if len(sibdeg[2]) ==0: sibdeg[2] = dnc else: sibdeg[2] = ', '.join(sibdeg[2]) if len(sibdeg[2])<sibdeg[1]: sibdeg[2] += ', some '+dnc resinfo.append(('sib', siblings[0])) for lab in siblings[1]: if lab != '': labparts = lab.split('.') info['friends'].append(("Degree %s sibling"%labparts[0] ,url_for(".by_label", label=lab))) arith_equiv = nf.arith_equiv() if arith_equiv[0]>0: if len(arith_equiv[1])>0: resinfo.append(('ae', ', '.join(arith_equiv[1]), len(arith_equiv[1]))) for aelab in arith_equiv[2]: info['friends'].append(('Arithmetically equivalent sibling',url_for(".by_label", label=aelab))) else: resinfo.append(('ae', dnc, len(arith_equiv[1]))) info['resinfo'] = resinfo learnmore = learnmore_list() title = "Global Number Field %s" % info['label'] if npr == 1: primes = 'prime' else: primes = 'primes' if len(label)>25: label = label[:16]+'...'+label[-6:] properties2 = [('Label', label), ('Degree', '$%s$' % data['degree']), ('Signature', '$%s$' % data['signature']), ('Discriminant', '$%s$' % data['disc_factor']), ('Root discriminant', '%s' % data['rd']), ('Ramified ' + primes + '', '$%s$' % ram_primes), ('Class number', '%s %s' % (data['class_number'], grh_lab)), ('Class group', '%s %s' % (data['class_group_invs'], grh_lab)), ('Galois Group', group_pretty_and_nTj(data['degree'], t)) ] downloads = [] for lang in [["Magma","magma"], ["SageMath","sage"], ["Pari/GP", "gp"]]: downloads.append(('Download {} code'.format(lang[0]), url_for(".nf_code_download", nf=label, download_type=lang[1]))) from lmfdb.artin_representations.math_classes import NumberFieldGaloisGroup try: info["tim_number_field"] = NumberFieldGaloisGroup(nf._data['coeffs']) v = nf.factor_perm_repn(info["tim_number_field"]) def dopow(m): if m==0: return '' if m==1: return '*' return '*<sup>%d</sup>'% m info["mydecomp"] = [dopow(x) for x in v] except AttributeError: pass return render_template("number_field.html", properties2=properties2, credit=NF_credit, title=title, bread=bread, code=nf.code, friends=info.pop('friends'), downloads=downloads, learnmore=learnmore, info=info, KNOWL_ID="nf.%s"%label)