
// Make newform 392.8.a.e in Magma, downloaded from the LMFDB on 27 November 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_392_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_392_8_a_e();".
// 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_392_8_a_e();".
// 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 := [-62, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-1, 2]];
    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_392_a();"
function MakeCharacter_392_a()
    N := 392;
    order := 1;
    char_gens := [295, 197, 297];
    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_392_a_Hecke( : Kf := Kf)
    return MakeCharacter_392_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], [21, -3], [-7, 11], [0, 0], [-270, -42], [231, 409], [4564, 174], [26327, -1817], [-57932, 2716], [-34340, -5138], [117614, 8854], [-43740, 8638], [-107576, -7398], [-175186, -22078], [386834, -41894], [297478, 98280], [-403137, 65831], [-1584415, -62917], [-1407744, 102788], [-377412, 178612], [-1953910, 109620], [-2939180, 305172], [-1174173, 297347], [4048198, -520912], [9083060, -292354], [3012009, 23067], [-5824350, 646034], [297684, -669424], [-10477640, -384790], [-1524996, -733054], [3716840, 1725192], [-39614617, 83847], [-2521634, -2058924], [-10550631, -1685111], [7876250, 1686412], [8443024, -4245752], [-11345649, 1081809], [-30955058, -4015494], [-36241506, 3968222], [-110671477, -729971], [-69082628, 2408896], [811951, -2430983], [-105763564, -3619196], [-169168920, -687666], [115575090, -848204], [171822910, 224990], [22668824, -7097076], [-26266380, 9669700], [33424055, 8251703], [-103118141, -10377907], [-8567198, -6775384], [213450460, 1859676], [129976364, -2978362], [-219786287, -1539791], [-222606090, -12841192], [128830812, -1295980], [-292689285, -4509987], [-34115648, -12147856], [-341867186, 16112880], [-171066918, -10226384], [210254695, 30056911], [-26052243, 4988687], [144563783, -40514441], [553089936, -23472712], [330282568, 38391882], [385119402, -20559196], [-512858338, 32874002], [-769766224, 26543174], [483295590, -12238198], [440970859, 19687933], [-786338490, -51753784], [-394220232, -51125984], [-3207428, 23254748], [469081946, 45930668], [-189547614, -1680266], [840057330, 49890986], [221933564, 52876054], [457775339, -25360883], [1825684608, 38415510], [-1940948436, 48255806], [572353817, 11213521], [-510840170, -155450008], [-5415876, 78791804], [821288216, -95922238], [1384979232, 30042376], [-1309532696, -55560988], [-321010198, -196210168], [1878675040, 573902], [1089166239, 108485553], [975883592, -37238600], [1860112611, -58231805], [1679503294, 89377766], [2061341716, 82450956], [-1601762256, -13726468], [2284868488, -30667812], [1062098716, 55283412], [3719359707, -109087859], [-1759219560, -117372214], [108759595, 27550803], [-375154646, 110343940], [5824993810, 17324846], [1805538338, 91075180], [2644505101, -100669531], [621517920, -163630978], [1973260682, -4397442], [-4227860322, -153294240], [3070139149, -422213523], [-3241606662, -95526020], [-5779561504, -204440936], [442243382, -383700384], [-6782230336, -149948704], [-2756201468, 177316062], [2036511864, 414051750], [2716042455, 47703279], [120466988, -503163052], [1953702776, -492941218], [2200873661, -78620667], [2874592014, 537080750], [-3274774160, 328664546], [-158749526, -395907946], [-360904187, 421273495], [128693854, -78160628], [-10552890537, 106498257], [-10502758512, 67972380], [-2848151537, -728141665], [10448817896, -55429654], [-8027330564, 255305302], [-9056710866, -618537498], [-4573593710, 287615634], [-5477647063, -51356605], [-3798129746, 1007420442], [3975307936, -766559640], [4455191612, -175651140], [12960360556, -301498890], [-348224436, 542930558], [10058944280, 248161714], [-2446768163, 1111002719], [-21607853029, 177848347], [-9390069213, -440392171], [-12067017000, 438880582], [12680585883, 722211043], [-6171963450, 932787240], [-26246500744, 292869808], [-5733716220, 760689552], [14783751913, -279232221], [9740133018, -504925878], [4350803555, 192493501], [7765709532, 975193966], [19098920561, 302813297], [4988339548, 340415180], [4028065148, -600983138], [1810729858, -223053628], [-28980364916, -348640432], [-3548295366, 307103354], [-10799266444, 155812944], [-3583222144, 707872144], [-1283464424, -568971088], [22614506572, -618468746], [3192385434, -2109462492], [-2056778199, 362348979], [36653047202, 555976526], [21162693266, -1820532952], [-23563235508, 166774468], [17355002455, 1181902351], [13688750022, 2449377476], [14349582954, -1614603382], [-2044680168, -691280744], [-9735265099, -1059521929], [-13834401432, 820034110], [20491065595, 366821589], [24569361680, -404155220], [13612183935, -453836383], [1673491164, -2837068780], [2534444098, 1687867048], [-30698614842, 109053406], [8764167314, 3401117324], [-44936420020, -501130728], [2197997460, 1577748718], [16801369004, 3057194804], [39461571737, 1693257443], [-2515884740, 762443724], [-2733884923, -352664467], [-41123988008, 2383367490], [33349697710, 269443016], [-16075829856, 3835759088], [56055289815, 158021473], [-10355164138, -2897721344], [-20902368809, -1742117801], [17837614494, 1123092852], [-13124360550, 2228364850], [-42428691074, 143988352], [13076212248, -4979484188], [51445359164, -693616672], [-17985088401, 1849133489], [58767582500, -779147656], [13263703866, -4075467324], [-2949650720, 5570754966], [60796737980, -1965419666], [1915258786, 91084500], [-19194600488, -5120121840], [-2381787602, -4596500888], [-15121578150, -2373512734], [-64417685339, -71527049], [-103974555454, 643238612], [-19235625885, -1580213429], [3945607449, -3241523245], [-116858866838, -695397054], [6414039222, -8984517598], [-58158561932, 4569769554], [-7002993403, 1759881797], [33676089912, 2445449454], [1823028921, 212479483], [-23786367152, 6840566600], [70861551495, 1072121967], [112555963016, -1863229920], [-121523468724, 1273187470], [-88750760040, -3517409112], [1050310016, 5794883050], [-94157271456, -2258229736], [10436188544, 5103969346], [9804691176, 4665543218], [-64410037720, -4956067024], [-124922212406, 599335464], [11480708988, -6829794916], [28795725511, 5935290263], [-41051988520, -1300817966], [4484681166, -3274678184], [34389981124, 5590971540], [-134120137900, 1993136188], [-44957422758, 5888162238], [-36290088176, 1988761250], [-139863436895, -4420502295], [31620111952, 2204134352], [-75924141550, -3496311560], [-78453637549, 7925406363], [155003213736, 2937417976], [-49053265772, -4364098386], [169052354034, -3355113020], [91321422488, 4386507636], [-163084215084, 2437989628], [208056754, 12202499806], [9446045203, 5675321579], [-1469568716, -7652263236], [-5445959762, 10962967848], [-9738292158, 3257526372], [-150136173194, -8143544282], [79836140552, -6853635768], [164052911183, -1201391441], [120640579878, -1283590182], [68373109864, -4505673032], [-170895906358, 885990084], [-9706875010, 7775816896], [-145417924828, 5254029564], [199032661086, -2325962184], [-130056932495, -458328389], [180661685220, -6071013592], [-44243240080, 2241233610], [-132395811947, 2526786181], [-166772512599, 5393054235], [43528027284, 17875969190], [-178208081188, -9550207828], [-157702345602, -1630913718], [-42684429207, 350576443], [76733159321, -4441630413], [151376663844, 3067152750], [207474384817, 3682806921], [279447174170, 5708916612], [-40614366506, -3131447392], [-171845765388, -6416519872], [276637137408, 4541370442], [-3383700229, 15463568029], [-117956277374, 4138373582], [-148436419334, -15225250924], [-47410310880, 19546832704], [73846083150, -749826208], [29872413844, -23358694676], [40710647398, 22867792682], [-166301179934, 3159599548], [171788124500, -1721296206], [288433293435, 8709801339], [174567014916, 6313816532], [5350496576, -7886842488], [33227126898, 3841098770], [268044355173, 7820156039], [200752718467, -8276337269], [-62540032992, 22529144176], [36257424906, 12595734648], [-61440503254, 3977501724], [-327045132078, -6329321134], [19792161606, -31115063352], [52675011078, 16334309376], [-240027064949, 4448019051], [-203245084136, -2549830122], [316618495963, -19673593533], [-240538768354, -8594692904], [292977031795, 20334122917], [-252110669328, 18912210576], [-252786233161, -5008870431], [-148562815191, -1753736087], [255018770797, -19981721547], [85225564564, -11323725546], [-21062404512, 6575235282], [-391943385888, -3946113808], [-234229906170, -13538425278], [133154878926, 22783304530], [137644814414, 19815279484], [-199508791722, 24441255818], [198963715517, 26599558583], [134824253828, -14233652468], [-46931567362, -508780272], [-67565252524, -20662961740], [263584573996, 2129026774], [-442712959834, 13131409844], [-162533196842, 12076990562], [451862504332, 12908399140], [-276100949026, 15891604568], [146998599181, 33746069669], [-368384546680, -25793983320], [-281096394670, -20870111676], [96304760058, -2350128984], [-334079964071, -30036363103], [301085593910, 8444417884], [-626187420999, -495399917], [-326518492940, 22808838276], [40694007760, -1941958242], [-551610846920, -11812053342], [69353896402, -25896544562], [-543803991157, 6365896163], [-393012821592, 1369919208], [331775576760, -5169082366], [-198670503750, 9475636772], [497085560568, -33689377862], [220501111922, -22753187606], [538511497153, 3671993273], [-138436708516, -49874091176], [-273084674485, -34052435485], [360991358032, -40210021166], [784645678726, -16707211896], [-190813587482, -15990151680], [-381009208510, 32690307722], [-245005231254, -41953465988], [-356987461272, 8718488870], [539876786631, -34983149151], [-50574408004, 17696536564], [-277223622944, -36895786270], [32384549658, 2080317078], [-122236315705, 22719758849], [-34854387686, 59119490430], [316429056076, -39467066580], [-262157013139, -42774815681], [147339248413, -31118411611], [198781962802, -39352027624], [-174310761474, -45050776456], [-177946633830, 8363519906], [323422888458, -50953836164], [-318771077478, 43704519988], [44927103102, -25125479386], [-117934059649, 40292952183], [-835259462430, -24149520752], [378496221996, -737531116], [362373344858, 29950496380], [741410918010, -2650908124], [700956421488, -18884544], [246687220068, 59876824784], [118330709679, -47041764465], [134496870992, -37420611746], [-522666593253, -1172813859], [441336542628, 30942832060], [-275361673856, 11671336894], [636681466252, -7333122944], [992043241777, -8091061791], [-484846761336, 24893469720], [-332754425086, 68997247284], [-152528416600, 65639730096], [983847915930, 8955029524], [635467337743, 14711297087], [810230500716, -34689611236], [-684997012910, -8564267804], [507898263068, 35693353142], [628552100876, 36110723966], [-297106182149, -26627507731], [-1044049687064, -30928821322], [-523333642952, -63003792880], [-215580480390, 15116686200], [729512142541, 28847868021], [-54329364096, -69028348936], [485105806532, -44670734108], [-755324487071, -19974718429], [-1129570651336, -4500561996], [155507495962, 24874079666], [-518271778336, 22510107046], [323459376625, 85032789667], [-366194715444, 3298770888], [140195132217, -32415448383], [529896894920, -57904183456], [-478074185266, 68860738772], [1023157230998, 50413107102], [351040542496, 46819908370], [-1618763903588, 10232721912], [-80650385172, -40199956426], [316841992089, -72269284973], [-518231145926, 24410138648], [101259773256, 90486935224], [879681867036, -69925875410], [-1562882009437, -35213961555], [1347022920082, 11773628226], [545637793742, -97543982424], [-899646271096, 34724787678], [255458530425, 11743910433], [-495832737099, 90488022173], [186248262858, 67921128140], [785209168512, -37800563878], [1689639235306, 9540401598], [-114141072488, -133012474980], [-215622688326, 6217154272], [528846297231, -45144227327], [1653954092972, 51250609340], [-115118471062, 48849113178], [-1561591458084, -19164405290], [440506931788, 58233526628], [812404061880, -51897600230], [353294548285, 72324721503], [418969970040, 89499201736], [1168145858733, 14495779101], [-424351399416, 102673689978], [182692526541, -77197939609], [1338232860146, 6237169470], [-219779733054, 23383278072], [310393498093, -73678499907], [991877311390, -36941313778]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_392_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_392_8_a_e();".
// 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_392_8_a_e(:prec:=2)
    chi := MakeCharacter_392_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_392_8_a_e();".
// 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_392_8_a_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_392_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<3,R![-1800, -42, 1]>],Snew);
    return Vf;
end function;