
// Make newform 578.6.a.d in Magma, downloaded from the LMFDB on 23 May 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_578_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_578_6_a_d();".
// 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_578_6_a_d();".
// 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 := [-480, -200, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-1, 2, 0], [-132, -1, 1]];
    Rf_basisdens := [1, 1, 4];
    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_578_a();"
function MakeCharacter_578_a()
    N := 578;
    order := 1;
    char_gens := [3];
    v := [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_578_a_Hecke( : Kf := Kf)
    return MakeCharacter_578_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 := [[4, 0, 0], [-1, 0, -1], [-49, -1, 2], [8, 7, 1], [65, 14, -1], [109, 11, 2], [0, 0, 0], [660, 82, -50], [1736, 53, -1], [-143, -191, 94], [1486, -3, -3], [2589, 293, -334], [-4224, -54, -432], [7352, -90, 42], [5102, -274, 428], [5542, -1088, 148], [-11516, 430, 238], [9005, 601, -98], [-10458, 1150, -2252], [-9918, -1905, 1587], [-434, -144, -2496], [33004, 1797, -621], [17972, -598, 2546], [91657, -605, 862], [60470, 328, -2252], [43169, 455, -2110], [-33392, 5204, 956], [-20875, 5246, -4513], [62815, -4773, 3990], [-125132, 2698, -1112], [-188068, -8154, 6534], [-62891, -2558, 235], [54511, -11495, -242], [83219, -6122, 11233], [102102, 5472, -3072], [129312, -7478, -5762], [207392, -5634, 10992], [-206381, 13320, 9687], [191056, -10835, 9211], [379361, -8203, 1106], [-122828, -18398, -50], [-17835, 27677, -13198], [81582, -9726, 30768], [92160, -31282, -1732], [-194105, -7769, 5614], [93292, -13221, 6525], [-315465, 27506, -10987], [-694726, 10392, -12042], [-432933, 7164, -20733], [-62767, -30501, -12678], [160068, 6234, 18384], [550458, 1050, -15972], [203428, 18870, -39312], [685042, -9326, 4372], [-1178883, -5985, 11370], [-671216, 17878, -37238], [-455329, -31369, 29858], [77806, 57926, -64468], [-74927, -20595, 75210], [499924, 6922, 18856], [350509, 44034, 22647], [-593838, 26532, 49056], [-793654, 55710, 48324], [973492, -30659, -16313], [295788, -48262, 36764], [-1938433, -27013, -17662], [4236, 60058, -29990], [-1962674, 37548, -79428], [-1238365, -53068, 61499], [-188614, -29436, 139164], [1279828, 5866, -83672], [943982, -25612, 84710], [2380446, -13015, 83141], [2594765, -78549, 1722], [847443, 45596, -57265], [-632644, 136226, -185662], [1674237, 38007, -28398], [1265089, 88305, -1398], [918556, 21982, 155848], [533934, 199192, -186608], [-1053639, 24048, -37047], [956733, -20165, 22354], [-3239432, -180575, 87211], [174875, 101229, 46554], [-3434930, 19851, -103053], [2728074, -8214, -103932], [1068630, 219132, -201888], [2172683, -160491, 56058], [2797554, -123348, -175908], [2856580, 112148, -108568], [426388, 136642, -114674], [-2954968, -323425, 280373], [6979646, 109057, -30395], [-950772, -69870, 226398], [-5045, 115194, -262143], [418142, 101405, -45463], [-2842390, 193460, -218800], [-2072100, -466362, 337584], [-1314478, 151818, -309180], [1557373, 26853, -229206], [960657, 17834, -23569], [-2199499, 275507, -119422], [-2150728, -102022, 137894], [1820920, -206942, 302056], [-2160855, -16456, -324727], [-5300397, -160691, -88562], [-3078312, -1242, 402966], [2315924, -75562, 54872], [-2997628, 140900, 253904], [-5227694, 150840, 25188], [-3743806, -416531, 245473], [-4143030, -503300, 319288], [4405632, -105834, 401640], [4214923, -138948, -148653], [-6393194, 213296, 301106], [4518250, -288620, 371860], [-4449797, -303732, 297303], [7486706, 166298, 167372], [-4461255, -456087, 381894], [-3414818, -248054, -31820], [2173692, -127934, 95524], [-5185470, 145136, 358760], [15874631, -23449, -125314], [6957119, -344332, 351227], [637621, -574410, 27987], [2390661, 401547, -71142], [2703285, 477869, -424402], [-4336282, -118597, 45779], [1241090, -514446, 5532], [8807996, -617718, 88020], [-18810052, -158118, 174294], [-3091582, -613831, 571325], [-826146, -65137, 391583], [10270837, -8665, 719618], [6441147, -715419, 267030], [17417495, -397167, 515286], [14140921, -476789, 80842], [-2450397, 870542, 86153], [11381508, 234114, -14316], [4837226, -158992, -46936], [22560841, -235800, 542949], [-8035229, 76675, 188758], [24911324, 185605, -122213], [-2915129, -468278, -459059], [10176364, 855026, -469576], [-654644, -67289, -731411], [-6496573, -88445, -57326], [-16092836, -835190, 133708], [10792456, -311998, 237254], [-988904, -365312, 880888], [-2145653, -255681, 1003446], [14705706, 1108488, -358116], [-13360294, 280806, -823248], [-3731868, 515439, -1015383], [-114715, -581126, 99535], [-26928204, 522735, -404019], [-27072106, 171882, 25776], [4793656, -1221830, 970720], [17510622, -1067312, -923624], [11008019, 1042571, 285446], [25690651, 617902, 68305], [13559537, -517405, -515986], [-8497846, -892764, 823626], [8791288, 1188826, -822746], [-2100192, -1508166, 451728], [-16145534, -418385, 1154083], [1022470, -344277, -760317], [-12065957, -852645, 1365174], [-16704162, -856084, 1088456], [16125893, -1196923, 599090], [22137234, -763230, -101904], [-2979079, 183639, 825210], [2978922, -515745, 679623], [-1770671, -2129221, -13522], [32001816, -196106, 712786], [-13369258, -1614352, -164752], [-12451523, 1655976, 502881], [-17582219, 837181, -1260326], [22408658, 554568, -803562], [21378725, -163665, 864570], [55826144, 297768, 430464], [-8398597, 152402, -816643], [-34020563, -570543, -101658], [-40302334, 1111592, 103520], [-15363700, 886994, -1207702], [-27681371, -2275493, 1051402], [-7220047, 133717, -882626], [14609102, 2280726, -2090544], [10863818, 117088, -1356272], [23083606, 1592161, -862271], [-13260330, 332660, -504148], [1324045, 2358916, -1555055], [-12936020, 2288222, -1618318], [-10582891, -4753, -1429726], [-15641863, -146992, 2141477], [-35192254, 1391168, 978572], [-26474904, -2038294, 1930580], [46249759, 1741695, -1628490], [22802582, -1055452, 2180324], [-24801316, -1283440, 1390964], [25197613, -1436747, -377414], [31554328, -2403243, -366873], [26509566, -909824, 2638672], [-18048867, 1449895, -3605054], [-22464154, -1048870, -463060], [-24765059, -2228657, 2746186], [-19027664, -682732, 973076], [-18125848, -636670, -2550214], [-74022466, 804368, -1187416], [-13399382, -4107586, 2095652], [-56783530, -1310720, 912628], [-44820491, -2983289, 1301362], [-37969214, -1849113, 208575], [9179628, -116958, 3249270], [-35114314, 1046663, -4037725], [14571092, 2081650, -909044], [-18586996, 701808, -3957396], [35887998, 299052, -2719080], [24864010, 331267, -1713365], [67947593, 622823, -1051870], [18132540, -179750, 221344], [-46365776, 1751121, 97047], [-4293626, -2860784, -1708136], [97143328, -976035, 1177323], [-45253082, -4728134, 2049376], [-57887675, -2980957, 1152938], [-16322430, 2619804, -2311320], [-28819674, 2809893, 1506705], [65787784, 4741514, -3579274], [-30274207, -648556, -2531347], [-51434556, 1679650, -873884], [-40471781, 1010364, -4452081], [57754070, -466800, 421026], [-35400549, 1959141, -1057734], [46663890, 706882, -835436], [-18136478, 541276, 3598930], [95242660, -2358246, 1519668], [-33248871, -136839, 4324194], [-22666731, -333222, 4449483], [-46962142, 3563828, -1875886], [-119921055, 1221804, 1561725], [-2994014, -4704526, 4190456], [16351658, -2130570, 2134224], [35987801, 2176779, -2204910], [-69386072, -1585994, -1487864], [-46912240, 3077537, -1668961], [1508262, -2586259, 1652357], [-44326923, -1416, -2039043], [37371548, -1961874, -1598922], [-78140354, -2040308, -1719410], [-93354964, -1683798, 279504], [3533036, -2243386, -2330188], [-62525220, -4126866, 3812838], [-71998386, 1036496, -852424], [886829, -2783665, 2366882], [86530086, 473394, 3095376], [55844675, -2652005, 2430670], [-21702713, -3476472, -584793], [127104023, -176353, 2369726], [14524493, 417375, 2593290], [87457264, 4327977, -3219201], [-61755098, -2605334, -640868], [43626531, -3551701, 7573550], [49682553, 1331897, 2881454], [155084606, -368344, 1196876], [104075486, 3515178, -3620568], [-45264840, 5282430, -7904148], [17399686, -8190344, 673552], [52676911, 2381556, 2968911], [15974044, 2968594, -4591136], [163320613, -1646571, -563802], [69717442, 4210586, -393760], [30520460, 1577502, -2221776], [-52422402, 1063300, 784678], [4911878, 2609328, 385080], [14245402, 28652, 4577786], [-86317896, 2849742, -5272854], [-30170755, -4162653, -990438], [43387949, -3884649, 8376486], [-17012788, 4956014, 3164102], [-10498938, 7737858, -693648], [176784868, -3533715, -436329], [44299086, -7250805, 6273543], [-50427450, -931328, 1424404], [-57489383, 1562622, 574779], [-209369264, -3520964, 3128284], [25517350, 3184500, -704280], [29869693, -8834231, -990338], [-29417604, -1751162, -941282], [-62148917, -6480635, -1380686], [29232761, 7710473, -117442], [150176555, 2713076, 2411351], [-51533015, -9062237, 2109058], [-37824815, 228802, 4823707], [23780473, 5138481, 3162186], [127331483, -4759393, 7025822], [35974436, 5469552, -2130924], [2700497, -5747665, 4043642], [-101504497, -3328024, -218725], [6734736, -2974838, 7804654], [-111644851, -1139745, 1860390], [-25180995, -6544545, 8373114], [-9484850, 8301315, -4315161], [-34231219, 2074988, -12025051], [-119735181, 753620, -2004937], [-75886418, -907596, -1853280], [-121974410, 6232702, 2958280], [81296513, -7303343, -657326], [94506620, -4437100, 5107088], [256216684, -434806, -1985152], [-149713492, -5059603, 3702275], [-85362137, 3868135, -9373142], [-52829806, 10910336, -797536], [-68903560, 715554, 835530], [-79503508, 294596, 3471824], [-105471658, -1280688, -2001792], [131478000, 10128534, -4601802], [-85311092, 8351005, 4767919], [-35676188, 3385326, -11603628], [-19634178, 7615656, 5800512], [6247767, -2030632, 3989363], [28980076, -3814170, 11029608], [179625258, -2398980, 3129816], [-10956028, 6935652, 8154744], [20108904, -3342726, -3873912], [2003840, -8838030, 9443736], [-209315177, -1190850, 5349549], [224079745, -4769694, 3415131], [-133589838, -2836749, -8870865], [44907931, 9486043, -3704498], [-209044303, -11030639, 3872998], [55177989, -6037107, 4507434], [-12131030, -1530681, 1915899], [-101615914, -13531594, 4181912], [-109321871, -3427248, 6553569], [142987271, 5021978, -2590651], [36434394, -1652252, 9925612], [-184663040, -4272194, -4148864], [14639320, 11600142, -4027536], [113976002, 9557424, -6457866], [-75451816, 2632134, -6081300], [-78769978, -6147292, -2087800], [-225001867, -6269803, 2058410], [276915860, 1119000, 4155348], [120230461, 5586379, -5305358], [49898657, 3572036, 2435597], [72641155, -12833985, -7202406], [133707962, -9588930, -1467600], [41438498, 8223989, -6818863], [324795329, -2886439, 4128986], [-119926924, -8398626, 11413590], [2979926, 1261504, 3177388], [135396720, 5012742, 4522680], [70245748, -13048923, 15919119], [-5925167, 4231715, -2252254], [-44578421, 12447421, -4631378], [215916602, -5241400, 10764566], [29274805, -7017512, -7017455], [-96735516, 3351234, -12404748], [-150522012, 17149590, 3886782], [91568869, 12008217, -6358554], [29987596, 14322106, -10744472], [127944398, 13886426, -9650656], [90771729, 215676, -9500139], [108916496, -2314326, -2030670], [285267764, 6288450, -8240064], [57251853, 3229605, 1203822], [-106995550, 1693362, 5937540], [13628694, 4336556, -15511144], [133868460, 4434846, 8278782], [-124094559, 210398, 13508927], [-40301704, -5900251, 18451823], [42150629, 10826219, -11912974], [-26505742, -14760858, -4945008], [-162731295, 4089413, -11711158], [-280646851, -10237360, -1459351], [23927092, 6556351, 1521997], [124058161, 5369147, 5702762], [-93956892, -7180710, 10108176], [4313074, 5892536, -12344992], [266862151, -2957897, 8839426], [-101008706, 561040, 4556680], [318259448, -1738121, -6568115], [232333056, 23386554, -16776396], [-184734855, -23351860, 16176893], [-74951294, 8381047, 10569367], [-360171292, -11255202, 3311430], [241949773, 14925023, -14326006], [203934409, -16493508, 6282345], [-76351712, 9163276, -6607508], [97999300, 14877858, -12811896], [33783539, -1290829, -14523490], [288361598, 15175514, -6160852], [400013858, -5668878, 3438576], [-252022776, 8611602, 1615854], [-239969544, -5224846, 6147008], [-424972122, 7323574, -3727052], [-156772954, 2857088, 13997360], [-127766285, -16526802, 9795285], [-159342519, -15872481, 5594010], [105750805, 3666345, -10335474], [-80722261, -17450779, 23569118], [178202504, 1075872, -16928832], [-410855120, -17912198, 13738144], [-175540334, -9145748, -1122896], [300075994, -5062059, 3133185], [-238456431, -23928341, 11563570], [-102505961, 6741625, -10249106], [178775780, -4846278, 16075074], [-277246827, 11639196, 5583333], [-474372782, 1030848, 2933652], [-5824867, 9850583, -5511214], [-199444574, -27859334, 13527016], [79330937, 3196078, 22280635], [-38978834, -15585856, 21444272], [-291686663, -3788891, 4796926], [-353590462, 3049313, 11434145], [637892754, -5226955, -1558903], [11217034, 906568, 9551176], [529492934, -6558946, 3884948], [329302518, -10430976, 17666556], [-212154131, -16575663, 4212210], [-265458242, 10791847, -160649], [-9646852, -25206022, 27287870], [217451668, 20579178, -18033372], [62595600, -9189258, 6829248], [-221441217, -10882638, 17148177], [-253093210, -9318496, -11661400], [80406926, 10301730, 3763560], [-29234732, -12591725, 24359449]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_578_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_578_6_a_d();".
// 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_578_6_a_d(:prec:=3)
    chi := MakeCharacter_578_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_578_6_a_d();".
// 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_578_6_a_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_578_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<3,R![-6228, -798, 4, 1]>],Snew);
    return Vf;
end function;