
// Make newform 576.8.a.bf in Magma, downloaded from the LMFDB on 04 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_576_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_576_8_a_bf();".
// 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_576_8_a_bf();".
// 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 := [-10, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 16]];
    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_576_a();"
function MakeCharacter_576_a()
    N := 576;
    order := 1;
    char_gens := [127, 325, 65];
    v := [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_576_a_Hecke( : Kf := Kf)
    return MakeCharacter_576_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 := 8;
    raw_aps := [[0, 0], [0, 0], [-90, 8], [624, -14], [4520, 75], [1250, 120], [-8610, -240], [-37080, 155], [-9552, -1302], [-122514, -2200], [-125760, -2200], [265370, -2280], [-363450, 1696], [-22248, 6109], [-247456, 6228], [659670, -18200], [1309000, -27945], [-418350, -19272], [-1187064, -1505], [1418000, 22110], [-85590, -79440], [-1249440, -1900], [-4765992, -67803], [-3659034, -103600], [-4658030, 127920], [-408858, 95400], [16878768, -35670], [3400936, 25827], [18086050, 3288], [-3130770, 181120], [20450304, 96128], [-20281480, 47505], [-30146010, 160800], [-10231080, 463525], [24432150, 124296], [9134160, 1293750], [-16573070, -40200], [-59631288, -545833], [-8494384, 815718], [-17827650, -1548600], [-17048040, 1581885], [-50666678, -16200], [-2751360, -2102160], [-13823310, -1767120], [-81156570, 873800], [17902320, -1434910], [-14936280, 2882075], [-31643328, 2529496], [-93989064, 959769], [30591226, 2979000], [-73612170, -3854640], [119716320, 3895620], [125997250, -3316752], [263092680, -2235705], [-325078530, 125440], [-446080368, 1359726], [-80174850, -1216920], [38895840, 2359140], [-73203190, 5807640], [9301350, 7020048], [-216185352, 9399745], [-214850490, 5908680], [503452776, -6703629], [-4135440, -10827390], [-609285590, 6311520], [213299790, 5457000], [413117400, 9524485], [265199090, -11219520], [542218504, 2806239], [-528685294, 4733400], [-702606690, 4969280], [505391440, -11550570], [143578656, 23980476], [222444970, -17110440], [1050325560, 576185], [-1378016512, 11169696], [-1328250, 1295208], [1713667010, -1495080], [-222161058, -5407600], [326245450, -8806944], [-1359780040, -8383335], [-1086633350, -33010824], [-454100640, 24627540], [-2284995710, 10097520], [-1968868080, -3196130], [-696184632, 11838567], [1250249550, -2447920], [843049370, -13723680], [-2759824962, 18561000], [2228001888, 9117428], [-237138856, 25637109], [1408969920, 10172520], [3931955376, -5298902], [37449320, 13023795], [587704680, -52481325], [-4003555728, -11467662], [1462398126, 75793800], [-698435802, -68949600], [-1770684072, -24315819], [-260826958, 80124600], [312680904, 92958279], [-1623459330, -65090680], [876555672, -96305715], [2672443350, 49245088], [-348248520, -152363335], [1533570690, 113023680], [3833382696, -107774565], [4205790030, -95771520], [-3236781520, 46492410], [3218772250, -121256784], [-316426944, 117525080], [-3783612870, -116013960], [6905655990, 54276240], [-3702457320, -2199555], [-902206320, -43863250], [-1516398450, -37211056], [-5076275832, -13286193], [-6367998576, -29844210], [11367322110, 27783400], [-5444965800, 2806965], [6238532650, 22503096], [-3296077870, 133715760], [-3559199130, 7026280], [3274221288, 12876579], [10805021160, 19731395], [5497551150, -75000120], [3729517754, 7061400], [-8100895840, 154046220], [3493277904, 74134182], [-933819950, -133242600], [-7544391480, -13658905], [2766109008, 86634390], [-12497549280, -5202820], [5933005770, 192843000], [-8328390762, 28010400], [1254802546, 157162800], [4240531590, 159857640], [-631205976, 8893707], [-1945745010, 27951240], [5237763654, 459101600], [-3793302120, -194289715], [-7028812650, 181764008], [-1589077488, -401347970], [-4173589816, 332503335], [1957263250, 172678008], [-6672521200, -114549570], [-29939784630, 96754200], [3155326710, -33535840], [-5910883080, 98769505], [19332797888, 205706568], [2106341090, -480812520], [-17864164050, -32567232], [18153464808, 161999107], [11826197616, 468762546], [-8858422824, -332882491], [24907852320, -381285060], [17863797840, -110713290], [-27124189650, -19565616], [11033606090, 620600880], [-6832509282, 212108200], [-23517406056, -181789203], [-8223191850, 219712800], [5752536816, -130987422], [8710138280, -723319605], [-12870374370, -714452720], [29108699952, 358531290], [8882533440, 684124280], [9223735770, -346452840], [18859865794, -419274000], [-28313079690, -476713400], [-41557803960, -256847625], [34199074098, 58368600], [31650059920, -42650130], [-6809376470, -428946960], [14811713760, -880262300], [18874328934, -788431600], [15176490360, -141349295], [-41696445018, -150096600], [-1226889168, 51165754], [-21995285950, 566910648], [25113365376, 592698512], [-4042351240, -506551215], [-20545510630, 534773880], [-20095044330, 547728400], [-12167287392, -1278719796], [-14336801706, -527905400], [-1210184910, 367140600], [-44690281272, 922826599], [-67142258950, -325596960], [-10977258240, -1410613920], [13402968130, 1629827520], [-36039011032, 974743131], [33485169960, -348936485], [-37023810450, -617706776], [12738066616, 360449001], [81890970870, -287161200], [992564050, 302921088], [15597172370, 1517650680], [-82332217410, -330832640], [-95677220848, 278897598], [95116592094, -628491000], [-62009650080, -1302143500], [26281061770, -311344680], [-6836934366, 1118016000], [2677727720, -1081768125], [-15574286130, 2083940520], [-48612119040, -298151360], [34670987512, -1052615199], [-21312672234, -393396400], [16421645400, -1697117195], [-74994287710, -460327440], [12535041750, -2220967224], [5813014608, -899756874], [4006144776, -272549601], [319820240, -752443770], [44323985850, 560204640], [-33811276896, 77050892], [115044586782, 24582800], [-120823611344, -836149446], [16743791790, 264781800], [-121066847750, -1232719560], [-101739792240, 89766830], [38116977294, 1936894800], [91599284448, 1691244388], [-82069912104, -14811963], [-11177136950, 2335467096], [-39151102170, 2604060240], [21758886720, -433674600], [-14765117904, -177527174], [-61584610840, -308885565], [-8772387550, 2981239320], [176344147560, 538950835], [97035676800, -1411940240], [35432064150, -909935088], [-135928353192, -1107358667], [62845038496, -662201460], [-25289691550, 230464368], [-18291236970, -1154522040], [-50827027320, 2019448815], [-88542288560, -727232490], [-112258816872, 103192941], [-120846813000, -1741873815], [51645298032, 2835275922], [99691794594, -1477869000], [-70758377010, 3330701120], [75662115760, 2110550730], [-133626313536, -349659800], [151914728760, -801720615], [-42409795560, 2166560765], [-55225552288, -1440905676], [-13979431950, -568812840], [-127724728962, -1458545600], [51319831824, -3828827874], [147568334250, 2478609840], [-42674912130, -748424920], [11944913880, 1978042245], [-108583445718, 3490615800], [-36092755464, 521756609], [103181193510, 1793405160], [118583910250, 3917004000], [39650418432, -1280060384], [-215966361864, 1815428385], [-176338547654, 2350906200], [-55258205230, -4313490600], [263551140270, 60167760], [95624842440, -4358734105], [49720660254, -4250039000], [160721472198, -44452400], [2465178552, 5278004617], [9548976390, -947230680], [-104916137822, 1693812600], [-211240249944, -4184311093], [-37597283110, 3875393520], [196401714240, -4044725640], [-21208779950, 1233512640], [274735972752, -996500850], [138022061384, -1688036649], [-262033625774, 635931000], [7616732650, -3341044560], [-211710895400, -5268193755], [150253424448, -6182548968], [-381632656080, -635653990], [215040687344, 5422967202], [169805155482, 2779774200], [11465924184, -7055197387], [-159176638560, 1244746380], [-130216561310, 4435580400], [-256682006730, -3174399640], [89264771280, -6283443290], [-149817118050, -5006979520], [-87104292450, -1020477336], [-160601081064, -598708707], [-173443956090, -3146303280], [-260511246680, -3191183445], [444491941890, 451693080], [-105063827250, 9751586376], [140457009600, 4894127560], [-380562963210, 1129485960], [201237917640, 6398918535], [308382500616, 5134389919], [189964338970, 754351200], [-180081474210, -3391751800], [31192145760, -4589220460], [322481958872, 4049878533], [80211283320, 7297069265], [-246223933550, -3695635920], [21163961064, 4938885411], [-325482672126, 911830200], [-626317510800, -231830190], [53572053370, -3707821800], [212070574368, 1860669276], [-65384242986, 5841440200], [464148300462, -4306276400], [199221726408, -1851005977], [266536064976, -5713041978], [-597088287926, -1844341200], [672708834840, -1752299715], [303251451520, 6433961520], [292538737090, 116705280], [133415139150, 8001515136], [486988878120, -3348597285], [-361472549110, -8902139040], [-515586200850, -578699992], [-143753218752, 3623333464], [-97006636410, 6189106080], [323108723650, 11407817328], [-160693338360, -9857168865], [-282766297608, 13252991169], [513784066624, 3579081144], [-21002665530, -4263496760], [154264242050, -3678571656], [-794599504050, 4067051240], [440565179520, 4180864880], [-27363316232, -8916432447], [-3704063400, 3222790325], [166922059016, -1276940193], [-28362168750, -11003556456], [-32224135650, 3284959040], [-379351472950, -8487177360], [300838058784, 10866918684], [199989836170, 7634234040], [-626823947370, 10377468320], [353313241350, -4621362584], [132427336560, -9469648430], [-60561456690, -8302171960], [-942013367880, -4496268855], [385521949050, -7835136264], [-52359907944, 9872445133], [-583506958240, 3244175220], [544587498870, 7442635400], [243441945480, -5792558705], [557230498970, 34692960], [299369891550, -3910026104], [-727903281312, -2217966444], [-208992629334, 6028980600], [447832765350, 7163270160], [683097658560, -3458023320], [143238609000, 6567152115], [51922185150, 3559309840], [221964619888, -5417999310], [573578929850, 6754574040], [-143181061482, 12005298000], [858253110304, -10095484164], [-19650085240, -10780781265], [-315084899256, 3216202871], [-839267562230, -7279170960], [415183269630, -14351679480], [236952530928, 19284013378], [-1256952950, 10704814176], [707005562040, -2520858135], [-336219012840, -18669461155], [-387098196768, 13209876708], [-562233249450, 19187856168], [-226108187760, -581804210], [930141588850, 1972070040], [-124308448680, -11247782475], [262285391680, 20179812120], [571704577250, 9842423040], [-741153346050, 4607119248], [1113342542250, -5962025760], [-516719671218, -705307800], [354938986470, -27712099040], [-24200960304, 856853734], [995710136670, 9773679360], [188009186760, 16982975815], [-9176219312, 12846035862], [-20835356640, 30408290940], [-255951357590, 123115800], [998302003512, 390292441], [1117823405824, -6393396192], [1700591427650, 3890944704], [776813735430, 8821575400], [-33905672280, 836961675], [-30264613464, 9832016203], [91711038640, -25718811990], [-684901958070, 4421288160], [86325524160, 5693447720], [391202657094, -8875116000], [424159385880, -2041352995], [-87471225450, -30325626328], [-1415903371150, -10175628072], [810844860750, -128454960], [565639772256, -12378953356], [-38193059850, 6497394720], [517945854150, 3302799112], [-1409242639440, -13613782070], [888948139330, 8755436280], [-55008228162, -20315135600], [-628628517528, 4564793427], [-280264440200, 28817764785], [-38664616910, -33894669120], [1176463360950, -6683369560], [-354005469048, -21401404689], [904115021640, 5940189975], [-378701650550, -2897562000], [794128087038, 11116453000], [209790797440, -2127545040], [532840441584, 13868761186], [1732623755550, -3404913520], [-242018974672, -27062536518], [-811579950450, -22719902776], [-774270674150, 13957717080], [-821469822496, 35352749892], [435098364360, 7421901255], [661725893210, 1094782560], [-845666717730, -14333771320], [346989705432, -4058443419], [1068822330150, -22740533168], [1609192763640, -2511048095], [87696806640, 27175618530]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_576_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_576_8_a_bf();".
// 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_576_8_a_bf(:prec:=2)
    chi := MakeCharacter_576_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    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_576_8_a_bf();".
// 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_576_8_a_bf( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_576_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<5,R![-155740, 180, 1]>,<7,R![-112384, -1248, 1]>,<11,R![6030400, -9040, 1]>],Snew);
    return Vf;
end function;