
// Make newform 720.6.a.ba in Magma, downloaded from the LMFDB on 11 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_720_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_720_6_a_ba();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_720_6_a_ba();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function ConvertToHeckeField(input: pass_field := false, Kf := [])
    if not pass_field then
        poly := [-540, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-4, 8]];
    Rf_basisdens := [1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_720_a();"
function MakeCharacter_720_a()
    N := 720;
    order := 1;
    char_gens := [271, 181, 641, 577];
    v := [1, 1, 1, 1];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

function MakeCharacter_720_a_Hecke( : Kf := Kf)
    return MakeCharacter_720_a();
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..prec]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 6;
    raw_aps := [[0, 0], [0, 0], [-25, 0], [4, 1], [244, 2], [306, 3], [-430, -1], [48, 11], [1492, 13], [-1118, 20], [-4676, -31], [5306, 31], [-8578, 14], [-220, 92], [-8364, -29], [-15742, -82], [-30732, 54], [25798, -94], [22908, -224], [-48728, 56], [29426, -130], [58388, 135], [-68316, -12], [62462, -222], [-19630, 468], [102362, -148], [-69836, -539], [-40540, 234], [54718, -896], [33858, 651], [-49908, 985], [-242172, -124], [275426, -59], [-10784, -295], [-112054, -2156], [242644, 485], [124394, -295], [-409620, 1204], [338916, -187], [-288622, 1636], [213908, -2860], [36038, -888], [-121504, 1664], [252170, 814], [327202, -462], [266244, -4539], [795192, -2079], [167012, 1171], [83716, 2552], [-634322, -2278], [27474, -4687], [566280, -630], [-28302, -1072], [-456852, 800], [724402, -3877], [364764, 3351], [-649998, 36], [1296140, -511], [934018, 6009], [-597810, 6302], [-568332, -52], [-662430, 11002], [-149724, -8134], [153200, -2142], [652498, -7998], [-1293222, 6446], [753456, 6797], [-267750, -242], [1554948, 1230], [-152394, 1438], [1781066, -8915], [2214056, 5960], [-2874172, -8721], [-244590, -15523], [286040, 9951], [-3701500, -5869], [223146, 20688], [652898, 18279], [1121566, -4492], [-3988422, -9392], [-643804, 4460], [4027342, -5902], [-891760, 2064], [-4454854, 7694], [-460060, -1311], [-6339140, -5776], [2006734, 12076], [-2090214, -18284], [672354, 14072], [1321308, 18905], [-1097524, -14958], [-980320, -19472], [-4481060, 6611], [478100, 40514], [145080, -35855], [-6787700, -7369], [-95150, -5008], [-1256218, 41996], [-9072340, 12946], [1247470, -55520], [-9887492, -392], [2076290, 8552], [-4575604, -13310], [-10507066, -11368], [-8154992, 6409], [-4210974, -29768], [-1911500, -52306], [-2773966, 68375], [3865368, -54008], [9064538, 39288], [4054324, -53209], [-389286, -20137], [-4946414, -38079], [-1515776, -7191], [4633644, -38041], [1096422, 31110], [-6968996, 36320], [503508, -975], [-8402110, 44944], [-5545988, -42558], [-5006866, 75782], [8027802, -77278], [-1190326, 103024], [-540364, 92926], [949016, 18129], [16630274, 23876], [-9352002, -5618], [8554200, 68190], [13909404, 50119], [8427354, 72317], [13972632, 2237], [6021268, -112927], [21737612, 34345], [-2557678, 113485], [17347638, 1196], [4376082, -27012], [-12163342, 90830], [9816868, -67774], [5833314, 46324], [-4974786, 53022], [-7101472, -96695], [19653210, -81640], [-15788908, -21559], [-541364, 25300], [-14514258, 103016], [20844952, 50868], [28853178, 37963], [8259594, 22823], [-16623416, 38747], [6718652, 29565], [1234906, -207903], [26044470, 11318], [-9629428, -120840], [26730084, 32601], [-18714820, -63882], [15756664, -143234], [19637700, -92239], [-16667202, -40488], [3821962, -18464], [39514482, 9628], [-35129108, -14462], [8637394, -62323], [16647788, 66359], [32530156, -49004], [39119058, 7855], [-29685404, 18377], [41146836, -89381], [13779138, -123315], [17280498, 91568], [-26024022, 138900], [-25672860, 34490], [17825550, 59648], [25719128, -12772], [-41041086, -118310], [25989572, -119941], [-11023474, -142514], [-54695768, -87781], [-9341462, -189592], [26810924, -22505], [49973502, 97904], [11982924, -36583], [13115964, 127846], [-15566, -32295], [3259626, 54627], [-38463580, -119969], [-8950262, -73052], [22863906, 107387], [25479796, -9726], [46937802, -8144], [9534640, 29612], [-57052118, 99462], [-473436, 277722], [34372504, -45431], [-69613022, 107444], [7470788, -147304], [14796362, -259341], [-37638222, -13328], [31614594, 200491], [-46880830, 190663], [32034676, 145057], [38675954, -96300], [-505340, -469725], [27325546, -55377], [35080498, -268052], [60431900, 225032], [-40213126, -260090], [-3395028, 267061], [-42643700, -202058], [-50784210, -19014], [-4090600, 119523], [-74748054, 103610], [-32428502, 346588], [-43954140, 358109], [38941756, -183264], [30482960, -225826], [13435514, -46348], [37038036, -448501], [-27836882, -458112], [39046780, 299947], [-31158318, 117288], [-26043922, 565242], [-78655932, 13321], [59698774, -59350], [-406500, -178391], [-2152852, 17370], [-50121610, 403124], [-14637414, 482259], [-45043416, -97602], [-48525004, 46173], [-26093124, 191976], [-52628734, -201033], [18379000, 539361], [47184508, 488457], [115514094, 106138], [-29414260, 9466], [-19345956, 177657], [31246290, -255056], [-99963286, -274484], [54497420, -613944], [19068552, -22312], [-78932996, -383626], [3141792, -847163], [-68499052, -433451], [-98117290, -219054], [-11668838, -160803], [-4264752, -564342], [-38732572, 396411], [-64795044, -264618], [-7172696, -228721], [-16743396, -548135], [56587418, -507019], [-81927858, -309732], [41235964, -268889], [176804682, -36472], [-155401958, 35130], [-40271796, 394542], [-43956618, -620252], [1283148, -292114], [51902098, -110242], [25025586, -237286], [-14261500, 540915], [11680076, 723086], [-14188658, -121110], [87149938, -121337], [27933658, 830041], [42018632, 522705], [104534194, -552692], [24072518, -751672], [-64282308, 434402], [42208330, -1011944], [126289870, 299092], [16605124, -372550], [107407234, -142194], [62647076, 828735], [-20728198, -46466], [-55560940, 436249], [53130420, -262182], [-123809306, -716710], [113587178, 254512], [-120349404, -377808], [-23137164, 740415], [11066508, -739117], [-52403132, -723263], [-69788730, -144212], [-40937188, -878514], [-91606240, -217580], [11073954, 899244], [200401498, 145360], [156416908, 7327], [-189504658, 423916], [12328066, -569064], [-157691788, 33616], [119308482, -611199], [32077132, -460340], [-6610158, -986549], [134924290, -719684], [-204018556, -364593], [31844226, 464670], [110415996, -701916], [61490556, -757472], [122034178, -1225110], [54241234, -162932], [-18533780, 819649], [257391276, 115458], [-87018296, -472573], [132834882, -250696], [-74639700, 81496], [-25207130, 1505606], [146357488, 291994], [70726562, 18669], [69944684, -528067], [-46884566, 15740], [-99762850, 754416], [713588, -588462], [74008956, -273713], [235152122, 259604], [232314580, 901108], [104183512, -1269262], [-52530214, 503242], [47614894, 995984], [102066032, -338317], [56561010, -1365822], [-195069950, -1161988], [-179481244, 134947], [165250490, 711143], [109964402, -377936], [219514536, -728047], [155516244, 208468], [37769500, 1481597], [-476918, -837632], [-123056682, -215366], [-199872062, -741788], [-64218564, 301649], [-48922132, 72974], [2393288, 481671], [-68957620, 2058380], [-10703762, 35408], [143878458, -999759], [-95881510, 1267436], [-216247860, -834003], [-241257678, -78539], [-64059350, 955799], [-119016790, 802784], [-156749908, 316931], [18504122, -1783090], [-9306628, -1234218], [134280974, -155454], [300666484, 807952], [32405608, 1175002], [-245521886, 500486], [-215314576, -408601], [199160538, -129116], [463873906, 128468], [123313252, -418377], [112782174, 733610], [236814226, -233067], [72095952, 808788], [-251263780, 243632], [-234215270, -535707], [-198941508, 1461467], [-143852718, -760783], [-2695386, 1350444], [-139163220, 944757], [-45214004, -57384], [-51741732, -542656], [106696570, -1315196], [-305354006, 1394654], [-223845732, 514627], [56073706, 270388], [-140302588, -1168244], [-91061384, -730101], [-18214108, -2618409], [-138081878, -513708], [-356945532, 916321], [315682410, 887857], [-24365652, 3277398], [-198370824, -2061198], [297005554, -500596], [-58700274, -2174448], [-399437350, -37680], [88549234, 22088], [195973026, 1185157], [48538292, -2365487], [7594666, 149141], [-514512488, 815037], [-225928052, 569763], [-255118388, -1255095], [-111395678, 158537], [-203915172, -1363654], [388034188, -329847], [-368319230, -71968], [-332799798, -103352], [-116659276, -1123158], [-230437276, -1149390], [-189603592, -261288], [176820074, -511772], [-347862076, 1532007], [81442798, 2110162], [29255864, -235933], [-4076230, -3690064], [-164531282, -1971720], [-198081334, -2314091], [-52575236, 832265], [278525890, 2374057], [-483898662, 887676], [140476572, 2414783], [-348512870, -276687], [-35923170, 257532], [41380092, -644932], [79089700, -897052], [-59001694, 2051308], [4028074, 642332], [96290948, -1536426], [-452973928, 295221], [-31875086, 4406038], [-489266462, 1330224], [-579414048, 291288], [526086852, 693457], [216128218, -2057923], [448929812, 260029], [200759042, 1379820], [-421990510, -22183], [435225116, -1081823], [779131268, -624622], [-142097102, -1620786], [-244034310, -1446126], [12370404, -3890236], [482655382, -1983460], [195435096, -2647873], [-667567880, 720536]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_720_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_720_6_a_ba();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
function MakeNewformModFrm_720_6_a_ba(:prec:=2)
    chi := MakeCharacter_720_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_720_6_a_ba();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function MakeNewformModSym_720_6_a_ba( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_720_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<7,R![-34560, -8, 1]>,<11,R![-78768, -488, 1]>],Snew);
    return Vf;
end function;