
// Make newform 24.9.e.a in Magma, downloaded from the LMFDB on 11 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_24_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_24_e_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_24_9_e_a();".
// 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_24_9_e_a();".
// 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 := [30633, 2884, -658, 936, 2079, 144, -78, -4, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [-10631678772, 1513490626, -138768366, -356737260, 32119854, 8175192, -759906, -14134], [10880913, -113453212, 25987890, 41574963, 2154414, -1422267, -68427, 17611], [-59720251260, -477576806, 18189038634, 2325486552, -575178978, -57670500, 7690446, 123374], [7308583167, 6015844520, -2275859670, 2846090037, 385353606, -118604085, -8139321, 1598449], [-134348701677, -74094140896, -143382703398, -4358693679, 5971966230, 131294271, -84180717, 2094373], [-77404449, -1519133552, -22273518, 246555357, 15590670, -8157405, -306225, 90977], [6097404135, 10473206396, 694439742, 2483495733, 240389346, -103901037, -6796125, 1492189]];
    Rf_basisdens := [1, 6908733, 4605822, 20726199, 41452398, 41452398, 1535274, 20726199];
    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_24_e();"
function MakeCharacter_24_e()
    N := 24;
    order := 2;
    char_gens := [7, 13, 17];
    v := [2, 2, 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_24_e_Hecke();"
function MakeCharacter_24_e_Hecke( : Kf := false)
    N := 24;
    order := 2;
    char_gens := [7, 13, 17];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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 := 9;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0], [7, 0, 1, 0, 0, 0, 0, 0], [0, 0, -1, 0, 1, 0, 0, 0], [198, 1, 0, 0, 0, 0, 0, 0], [0, 0, -1, -2, -7, 1, 1, 0], [3154, 8, -52, -4, 1, -1, -2, -1], [0, 0, 270, -10, 81, 5, -10, -7], [19742, -10, 683, -16, 4, -4, 25, -4], [0, 0, -1806, 0, -112, 0, 66, -68], [0, 0, 4617, 76, -203, -38, -212, -294], [100694, 127, 5922, 144, -36, 36, 222, 36], [-498126, -304, -10548, 36, -9, 9, -390, 9], [0, 0, 3690, -112, -1498, 56, -160, -1596], [870334, -950, 7031, -400, 100, -100, 253, -100], [0, 0, -1724, -420, 3106, 210, -96, -2600], [0, 0, -22389, -480, 4565, 240, 576, -3416], [0, 0, 71707, -24, -14868, 12, -2361, -3568], [-6447950, -4640, 33772, -44, 11, -11, 1250, -11], [7275086, -392, -91831, 1952, -488, 488, -3365, 488], [0, 0, 47030, 2364, 18306, -1182, -3102, 2020], [-14606846, -1656, 183416, 2096, -524, 524, 6832, 524], [21556822, -17329, 30354, -2064, 516, -516, 1086, -516], [0, 0, -33579, -1930, -17283, 965, 3815, 16904], [0, 0, -70544, -4682, -1609, 2341, 6406, 28165], [-42165838, -13852, 240600, -8484, 2121, -2121, 8754, -2121], [0, 0, 1169451, -1908, 59427, 954, -42420, 32706], [70894822, 15053, 434868, -768, 192, -192, 16092, -192], [0, 0, -146353, 1180, -128958, -590, 12367, 34904], [-85107854, -28064, -1324068, 1380, -345, 345, -49014, 345], [0, 0, -991920, 7420, -36218, -3710, 36316, 11442], [45231094, 21179, -947866, 17072, -4268, 4268, -34790, 4268], [0, 0, 186593, 14372, 479390, -7186, -36223, -87752], [0, 0, -3738130, -11100, -72988, 5550, 135156, -133678], [-69913650, -2032, -1601711, -19136, 4784, -4784, -59677, -4784], [0, 0, 1398243, -38512, -501051, 19256, -33136, -181672], [-22592890, 123961, -872056, -11104, 2776, -2776, -32504, -2776], [147937234, -157176, -1440628, -47812, 11953, -11953, -54242, -11953], [-337013826, 17634, 1100415, -22416, 5604, -5604, 40341, -5604], [0, 0, -2527986, 30600, 225036, -15300, 63654, -146796], [0, 0, 2999385, 25360, 314143, -12680, -141008, -126384], [0, 0, -3306315, 57544, -934724, -28772, 156121, 260448], [297559698, -33704, -4633444, 119612, -29903, 29903, -169394, 29903], [0, 0, -2772416, 84476, -725070, -42238, 107804, 107872], [444431426, -151768, -6190920, -59760, 14940, -14940, -230400, -14940], [0, 0, 83003, 37060, 1451247, -18530, -10268, 804542], [-16810490, -155847, 5470280, -36448, 9112, -9112, 201928, -9112], [-1042729106, 69268, 3279725, -47968, 11992, -11992, 120583, -11992], [569543062, 467927, -10013878, -237904, 59476, -59476, -375290, -59476], [0, 0, 5045617, -50090, -788083, 25045, -148877, -119000], [485204626, 924856, 21754588, 112348, -28087, 28087, 807806, 28087], [0, 0, 10310716, -209410, -1332721, 104705, -154642, 1406633], [0, 0, 15109076, 94532, 1932302, -47266, -696712, -435896], [-423418878, -968872, -7942696, 182624, -45656, 45656, -290792, 45656], [0, 0, 19382467, 461018, -3617765, -230509, -671455, 1007544], [0, 0, 1135396, 495100, 5118306, -247550, -527300, -1639974], [0, 0, -11897946, -210700, -1693946, 105350, 392330, -2500316], [0, 0, -16401055, 78512, -2704777, -39256, 743792, 861208], [4087744406, -952441, -5996070, 434736, -108684, 108684, -214026, 108684], [-1529062862, -1695984, 16009452, -160956, 40239, -40239, 589962, -40239], [0, 0, 37988228, 76274, -4406647, -38137, -1551742, -3795425], [178355054, 2403356, -2815611, -669120, 167280, -167280, -116673, -167280], [0, 0, -1480085, -895540, 8184819, 447770, -129172, -2645270], [-1151232594, 1534444, 44504277, 385152, -96288, 96288, 1655439, 96288], [0, 0, -63245638, 310436, -6156338, -155218, 2294606, -2249236], [-1026362094, 850260, -14792128, -958684, 239671, -239671, -565610, -239671], [0, 0, 11774101, 380760, -9351929, -190380, -495720, -3672524], [-9060146290, -1163240, -40443383, 1787296, -446824, 446824, -1464805, 446824], [-2348932878, -1283828, 62481584, 792140, -198035, 198035, 2328802, 198035], [0, 0, 132517451, 937210, -17860533, -468605, -4540727, 480392], [2526290706, 3340104, -9358916, 1773388, -443347, 443347, -313786, 443347], [0, 0, -112034304, -1251240, 9327676, 625620, 4133208, -1498396], [0, 0, 13196366, 574964, -4333370, -287482, 529778, 14314580], [1808349142, 3310079, -168575902, 554576, -138644, 138644, -6233282, 138644], [2047363346, 3809256, -31854516, -2227236, 556809, -556809, -1221042, -556809], [-15420697954, -113298, -143413037, -2038448, 509612, -509612, -5349343, -509612], [0, 0, 158350896, -2686500, -4446846, 1343250, -4787316, -437616], [0, 0, 44612135, -1041816, 8294221, 520908, -2244216, -8792364], [4299943730, -7199568, -60926980, -484012, 121003, -121003, -2265518, -121003], [0, 0, -54266534, 1723690, 11196599, -861845, 516970, -6368345], [4142806914, -8389408, 103379248, -1930448, 482612, -482612, 3793112, -482612], [0, 0, -228131519, 1566842, -20621013, -783421, 7579319, -14612960], [13545563090, 2378952, -276668132, 2105452, -526363, 526363, -10207978, 526363], [0, 0, -6336028, 3651172, 7358206, -1825586, -336152, 13316104], [7221049330, 1977684, -14251176, 321804, -80451, 80451, -521862, 80451], [-6685122618, -11424687, 235180912, 2685088, -671272, 671272, 8760128, 671272], [0, 0, 61571219, -292330, -8844979, 146165, -3516835, -22502720], [0, 0, 4189058, -397826, 8874593, 198913, 423838, 10363965], [18708307202, -76160, 41197392, 3603888, -900972, 900972, 1592568, 900972], [0, 0, 96465445, 4636044, 22671321, -2318022, -7893588, -24973846], [24182997878, 12116571, -214548218, -5860496, 1465124, -1465124, -8054758, -1465124], [0, 0, -15123083, 1486770, -74654033, -743385, 4086963, 17347600], [0, 0, 426862984, -4051368, -49885516, 2025684, -14564736, -27379200], [24833506918, -11121955, 54910372, -4689440, 1172360, -1172360, 1946876, -1172360], [0, 0, 254168751, -4649848, -15609508, 2324924, -7593589, -5320608], [16677710958, 25860436, 70253741, 3421472, -855368, 855368, 2665351, 855368], [0, 0, -21936822, -2873300, 16057834, 1436650, 4248262, 40763868], [0, 0, -518236795, 1822088, -12213473, -911044, 18366056, -8628460], [0, 0, 380834414, 854052, 24076164, -427026, -12000972, 44498914], [14353054078, -10553614, -578872945, 1251920, -312980, 312980, -21416555, 312980], [-37951771662, -7227888, -17718132, 7898532, -1974633, 1974633, -509958, 1974633], [-15464741314, -18478030, 153381487, -6647984, 1661996, -1661996, 5557685, -1661996], [0, 0, -681586043, 3655380, 109818909, -1827690, 23171604, 44296142], [0, 0, -434620931, -1781390, 26291983, 890695, 17366971, 21828032], [0, 0, 350943450, 5869460, 107939680, -2934730, -20122492, -14332142], [77921907822, -4773028, 218016325, -2323712, 580928, -580928, 8031647, -580928], [-37701541582, -11121220, -191890896, -8172996, 2043249, -2043249, -7258422, -2043249], [0, 0, 278445271, 5033340, 136786386, -2516670, -17302761, -2063080], [0, 0, 484089324, 5040440, 97207312, -2520220, -21545128, 23731180], [0, 0, -380418110, -9532528, -27815352, 4766264, 16469954, -27051860], [26135941762, 11221832, -1281514440, 30768, -7692, 7692, -47462928, 7692], [27785941622, -817845, -638584106, -1248848, 312212, -312212, -23674390, -312212], [-49610208526, 46024336, 117952668, -1079532, 269883, -269883, 4348626, -269883], [0, 0, 2557264, -22462390, 38175465, 11231195, 5556410, -11318453], [-34640416562, 53628144, -607422287, -6262880, 1565720, -1565720, -22613101, -1565720], [9697026598, 13864341, 1125595948, -22091552, 5522888, -5522888, 41279636, -5522888], [0, 0, 687277278, -8641390, -98960633, 4320695, -19495630, -10079285], [97073545854, -81700950, 281167351, 10325200, -2581300, 2581300, 10604813, 2581300], [0, 0, 185389942, -2659160, 158530044, 1329580, -16640114, -65312556], [0, 0, -265357723, 25363100, 86835745, -12681550, -2957572, -8713486], [0, 0, 27567837, -9150192, 208488120, 4575096, -9509847, -53818368], [-66566825998, -8979920, -482189348, -14915084, 3728771, -3728771, -18135070, -3728771], [211340359090, 26627972, 896736376, 4512220, -1128055, 1128055, 33296018, 1128055], [0, 0, -1034174045, 16107460, -109009481, -8053730, 36863044, 2569766], [0, 0, 1169338359, 10245210, -214040101, -5122605, -41675643, -36307304], [-120830835490, 56785566, 451535299, 19754896, -4938724, 4938724, 17089361, 4938724], [0, 0, 1677331569, -41164388, -17055131, 20582194, -49991012, -40271286], [187644846002, -14728240, -566912980, 189380, -47345, 47345, -20993270, 47345], [0, 0, 480328460, 9418632, 228815548, -4709316, -39849612, -138659256], [-384458596314, -153291, -1097913588, -11269248, 2817312, -2817312, -40872156, -2817312], [-40178487214, 75797560, -950737444, 43352924, -10838231, 10838231, -34409666, 10838231], [145639791374, 5089152, -360085503, -31578816, 7894704, -7894704, -13921293, -7894704], [0, 0, -460654306, -15681520, 193473768, 7840760, 28623614, 178341300], [-24637040202, -37615277, 2799146766, -18818160, 4704540, -4704540, 103323618, -4704540], [-53093671342, -27307672, -622897732, -55682836, 13920709, -13920709, -24101450, -13920709], [0, 0, 798836070, -1261448, 399192158, 630724, -32245016, 157714520], [-40518324094, 48694968, 486139832, 27951968, -6987992, 6987992, 18522808, 6987992], [0, 0, 1472350755, 14159260, -323425133, -7079630, -49533092, -26977446], [276494017822, 92862742, -1703023797, -788592, 197148, -197148, -63089559, -197148], [0, 0, 1054014657, 18650820, -294480487, -9325410, -24980412, 131122918], [0, 0, -1912887038, 5937208, -163005870, -2968604, 53120776, -292614240], [321370252222, 46821162, 3448462807, 13246864, -3311716, 3311716, 127966157, 3311716], [0, 0, 3585121095, 14591572, 75414523, -7295786, -127977644, 171879582], [96081536102, 84518061, -2755208300, 50049568, -12512392, 12512392, -101117908, 12512392], [0, 0, -314642373, -44784580, 476702706, 22392290, -4205461, -188470312], [-28994806958, 226652776, 965247820, 33370204, -8342551, 8342551, 36367886, 8342551], [0, 0, 1138034678, 22863348, -129798586, -11431674, -48306630, -39420556], [30562056914, -45719400, 1200074060, 34959308, -8739827, 8739827, 45094582, 8739827], [0, 0, -2678105078, -54040340, -136002580, 27020170, 127411420, 56308726], [441921587550, -89124010, -1102450965, -21050160, 5262540, -5262540, -41221335, -5262540], [0, 0, -2339780840, 15920540, -312751582, -7960270, 75237332, -234939664], [-154473118254, -70066024, 3094640380, -56543204, 14135801, -14135801, 113569214, -14135801], [0, 0, 1973270888, -23647292, 464616034, 11823646, -102944924, -283137650], [448343653982, 73670158, -3223004653, -28949200, 7237300, -7237300, -119906639, -7237300], [0, 0, 7586815754, 9682060, -146923526, -4841030, -281073914, -28561940], [-181990255106, 362607042, -1370798465, 35064496, -8766124, 8766124, -50120971, 8766124], [0, 0, -3150214100, -48147492, -73249758, 24073746, 150280968, 188360552], [114773050726, -281888979, -3128845036, -6547744, 1636936, -1636936, -116004404, -1636936], [0, 0, -329532498, 46556746, 40277027, -23278373, -21143702, -208923169], [-556552971822, -64681764, -2728112616, 40736628, -10184157, 10184157, -100286826, 10184157], [0, 0, 92345301, -9240556, -1068244675, 4620278, 45703412, 85153734], [0, 0, 1158526869, 18812900, 236328254, -9406450, -46521115, 158753784], [0, 0, 5374492242, 2160060, -373179732, -1080030, -179460564, 88198926], [401720737766, -110518195, 234921652, -49413344, 12353336, -12353336, 7785740, -12353336], [0, 0, -5565416113, 50151762, -765000769, -25075881, 212715381, -55329928], [0, 0, 1348523006, 42506710, 1077618609, -21253355, -83715050, 284824505], [0, 0, 6379574898, 10012140, 238242186, -5006070, -217914162, 414625020], [243492219382, -25132837, 8046502342, -46944752, 11736188, -11736188, 297149258, -11736188], [345152333938, 311952096, 4076415948, 34338036, -8584509, 8584509, 151614258, 8584509]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_24_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_24_9_e_a();".
// 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_24_9_e_a(:prec:=8)
    chi := MakeCharacter_24_e();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 9));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 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_24_9_e_a();".
// 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_24_9_e_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_24_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,9,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;