
// Make newform 144.6.i.d in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_144_i();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_144_i_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_144_6_i_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_144_6_i_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 := [442368, 0, 498609, 0, 124623, 0, 8800, 0, 175, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-207097728, 389674035, 0, 56550029, 0, 1847072, 0, 23021, 0, 99], [-61649294112, 0, -13835630451, 0, -609253100, 0, -9472484, 0, -47225, 0], [-198138592512, 89923920885, -110092975560, 35591574291, -10174989216, 2848921216, -217698528, 58481419, -1280856, 338269], [3943792512, -331549576551, 22460575104, -144232448121, 2918015232, -11456638240, 64407552, -234685369, 375936, -1356343], [1147556557440, -1118204357445, 503333827632, -507612794859, 40623828672, -40189663904, 855338304, -822538331, 5053584, -4752101], [696632164992, -305274835917, 598444064160, -423981840819, 48528039040, -42541455328, 984567424, -929563411, 5651680, -5525341], [-594055313280, 1852676757009, -23644711200, 580333224015, 7683913600, 45271460064, 219429760, 927771087, 1430176, 5368449], [815163765120, 1369631277027, 530214202656, 571331339613, 52372017792, 45643692832, 1128424320, 936462397, 6627168, 5415571], [-308242564992, -485122677687, -423179263248, -495164989401, -34014091072, -48239297760, -677985472, -1046526249, -3841840, -6201879]];
    Rf_basisdens := [1, 414195456, 427139064, 6834225024, 13668450048, 13668450048, 13668450048, 13668450048, 13668450048, 13668450048];
    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_144_i();"
function MakeCharacter_144_i()
    N := 144;
    order := 3;
    char_gens := [127, 37, 65];
    v := [3, 3, 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_144_i_Hecke();"
function MakeCharacter_144_i_Hecke(Kf)
    N := 144;
    order := 3;
    char_gens := [127, 37, 65];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, 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+1)]];
    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, 0, 0, 0, 0, 0, 0], [-2, -2, 0, 1, 1, 0, 0, 0, 0, 0], [0, 4, 0, 1, 1, 0, 0, 1, 0, 0], [-6, -6, -1, 0, 0, 0, 0, 1, 0, -1], [-33, -34, -1, 0, 8, -1, 0, 1, -2, -3], [0, 37, 0, -7, 3, 0, 1, 8, -3, 0], [222, 8, -2, -56, -19, 7, 3, 0, 8, -3], [89, 9, 17, -28, 33, -3, 1, 0, 9, -1], [-20, 63, 0, -61, -120, -20, 6, 4, -25, 0], [-1243, -1243, -2, 65, -160, 45, 0, 2, 45, -27], [-18, 487, 0, 255, 24, -18, 12, 6, 39, 0], [-1515, -72, 23, 266, -159, 3, 13, 0, -72, -13], [64, 3750, 0, 140, 426, 64, 51, -23, 71, 0], [-328, -283, 162, -432, -477, -18, 0, -162, 27, -54], [5140, 5084, 33, 100, 278, -2, 0, -33, -58, -87], [11659, 0, 53, -162, -225, 45, 27, 0, 0, -27], [125, -17926, 0, -57, 656, 125, 138, -182, 100, 0], [235, 307, 120, -645, -486, -75, 0, -120, -3, -87], [-81, 2863, 0, -1227, -720, -81, 75, 195, -333, 0], [-23217, 340, 347, -2542, -1505, 437, -129, 0, 340, 129], [1586, 72, -690, 336, 1419, -255, 141, 0, 72, -141], [-5165, -5579, -122, 1608, 3555, -141, 0, 122, -555, 112], [45496, 45386, -21, 1810, -910, 610, 0, 21, 500, 129], [59847, -280, 529, 1150, -1135, 115, -375, 0, -280, 375], [8090, 8414, 749, -2478, -855, -519, 0, -749, -195, 605], [-79738, -79962, -1033, 2951, 1953, 334, 0, 1033, 110, 354], [-288, 2482, 0, -1287, -2328, -288, -681, 609, -552, 0], [-65389, 57, -749, -1776, -2481, 519, -9, 0, 57, 9], [-3517, -648, 525, 4206, 219, -303, -705, 0, -648, 705], [1060, 81650, 0, 187, 6149, 1060, -318, 1467, 380, 0], [25918, 198, -522, 2520, 4086, -738, -1098, 0, 198, 1098], [-222, -33700, 0, -3127, -226, -222, 585, 2657, -1290, 0], [-119156, -120108, 1147, 7234, -1125, 2243, 0, -1147, 1291, 87], [-1413, 26928, 0, 4931, -3360, -1413, 1366, 1082, -78, 0], [2208, 40823, 0, 2645, 12431, 2208, -549, 734, 1707, 0], [13973, 14873, -2862, -4944, -729, -1383, 0, 2862, -483, -1440], [-864, 11654, 0, -8007, -6447, -864, 1758, -849, -1950, 0], [-72456, -1224, 1084, 6808, 4092, -1308, 2012, 0, -1224, -2012], [1606, 55922, 0, -6179, 932, 1606, -2307, -4401, 608, 0], [-16734, -17046, 4119, -651, -3555, 768, 0, -4119, 456, 684], [172778, 552, 5398, -9372, -6306, 1482, 2718, 0, 552, -2718], [-57177, 72, -643, -1642, -471, 123, 985, 0, 72, -985], [-344498, -345366, -1721, 9700, -1356, 2732, 0, 1721, 1864, -957], [-1908, 95726, 0, 11388, -7098, -1908, -981, -1251, 1383, 0], [-188672, -2960, 2326, 16508, 6580, -2500, 2832, 0, -2960, -2832], [-94381, -3006, 5903, 10718, -8397, 477, -125, 0, -3006, 125], [-1170, 113159, 0, -10265, -5514, -1170, 2402, 3790, -3513, 0], [-162166, -164974, -1617, 16188, 18612, 1200, 0, 1617, -1608, 939], [-590131, -588200, -8463, 1016, -10562, 1157, 0, 8463, 3088, -2037], [2448, -154990, 0, 2463, 7491, 2448, -1236, -8313, 3624, 0], [-223651, -3784, -7555, 23410, 3542, -2222, -1608, 0, -3784, 1608], [-264, 803127, 0, 13947, 6996, -264, -450, 5400, 1551, 0], [-56265, -53349, -7538, -2322, -10530, -108, 0, 7538, 2808, 2020], [740785, -2741, -2447, 20240, 9553, -3007, -255, 0, -2741, 255], [-1624, -4979, 0, -10936, -4484, -1624, 7302, 1722, -3506, 0], [-939929, -938409, 5032, -24608, -363, -5761, 0, -5032, -4241, -1974], [173589, 7720, 5735, -24070, 14965, 95, -7095, 0, 7720, 7095], [-66566, 8316, 4386, -30012, 14202, 486, -4710, 0, 8316, 4710], [279184, 273784, 7197, 33933, 16623, 6702, 0, -7197, 1302, 6126], [-82919, -79539, -5774, -10601, -21126, 77, 0, 5774, 3457, -3009], [1998, 199774, 0, 50037, 37722, 1998, 663, 11091, 8988, 0], [1376, 187332, 0, 52243, 21699, 1376, -6342, -19, 11278, 0], [265417, 15435, -9255, -82128, -15555, 9285, -7467, 0, 15435, 7467], [-11288, 978565, 0, -22209, -59672, -11288, 3732, 6962, -12607, 0], [-235209, -236577, 2506, -11622, -378, -1428, 0, -2506, -2796, -11732], [-610665, -600889, 16616, -52407, -73870, -1573, 0, -16616, 8203, 6459], [-636557, -629267, 15466, -45978, -68103, 51, 0, -15466, 7341, -1454], [-10296, -71859, 0, 61492, -17328, -10296, 9002, 4354, 5250, 0], [-1593, -30027, 0, 28581, -18696, -1593, -6939, -24843, 9729, 0], [-724494, -725070, -1541, 29451, -24111, 11058, 0, 1541, 10482, 3490], [-1597606, -1602526, 1573, 6692, 74177, -10545, 0, -1573, -15465, 9675], [110860, 3458, 1716, -17564, 32636, -5144, 19164, 0, 3458, -19164], [-340759, -358741, 21108, 74736, 56457, 14445, 0, -21108, -3537, -4974], [13248, -975569, 0, 34721, 79515, 13248, -1313, -3250, 15543, 0], [-1023804, -8091, -37328, 8302, -54312, 7626, 1184, 0, -8091, -1184], [3170, 196026, 0, 73957, 59616, 3170, 2181, 18947, 12904, 0], [-2279904, -2269864, -41467, -48159, 13631, -18382, 0, 41467, -8342, -12702], [-1600153, 8136, 26169, -48666, 12507, 753, 13863, 0, 8136, -13863], [-11836, 3038276, 0, -28848, -62938, -11836, -915, 18439, -16559, 0], [-18792, 2017065, 0, 90970, -87390, -18792, -11608, -24086, 11736, 0], [3854, -670895, 0, 87179, 68878, 3854, -7296, 35436, 12661, 0], [-829341, -850869, 3136, 144867, 17766, 38337, 0, -3136, 16809, -14783], [-476348, -9546, 59540, -6564, -87972, 13776, 3420, 0, -9546, -3420], [1366004, -7488, -9612, 113436, 137439, -30483, 7965, 0, -7488, -7965], [-1894243, -1895125, -9780, 48084, 19845, 6177, 0, 9780, 5295, 22422], [243682, 242363, 4992, -5240, -17143, 3172, 0, -4992, 1853, -11868], [2270420, -21200, 30564, 58652, -85505, 8621, 285, 0, -21200, -285], [-1845266, -1822802, -795, -189762, -15939, -48243, 0, 795, -25779, -4215], [-1953423, -1912559, -3806, -125979, -310916, 12469, 0, 3806, 53333, 8733], [-11466, -2753131, 0, -36917, -94176, -11466, 1646, -35720, -7119, 0], [-64177, 7251, 5479, 23844, 56787, -8457, -27477, 0, 7251, 27477], [-1155109, -1162649, -13440, 40604, 49129, 2819, 0, 13440, -4721, -8634], [-2927200, 3798, 6584, -49324, -5904, 2700, 26032, 0, 3798, -26032], [18463, -506490, 0, -242569, -9000, 18463, -11676, 6160, -38668, 0], [1593, 1488934, 0, 28539, -14688, 1593, -10638, -39582, 14580, 0], [2238601, -21448, -50019, 133126, 24569, -13493, -6855, 0, -21448, 6855], [35048, 983801, 0, 98715, 256085, 35048, 36687, -3896, 41551, 0], [1973575, 31084, -30077, -205114, -88382, 30110, -9552, 0, 31084, 9552], [-176069, 17424, -20757, -20838, 36183, -267, -48057, 0, 17424, 48057], [3411624, -14832, 55910, -94372, -343884, 62844, -34832, 0, -14832, 34832], [-4577209, -4585552, 30033, 47232, 91746, -3897, 0, -30033, -12240, 51687], [-129495, 16736, -5417, -93662, -95953, 25885, -50937, 0, 16736, 50937], [25715, 2079271, 0, -69043, 97840, 25715, 399, -14433, 4507, 0], [26883, -51613, -10930, 381714, 453482, 32744, 0, 10930, -45752, -8688], [-67563, -4600797, 0, 12881, -316416, -67563, 4225, 42557, -46473, 0], [1326752, -9468, 61716, 331068, 410709, -85929, -35409, 0, -9468, 35409], [-1410420, -1368071, 54166, -147384, -414761, 28066, 0, -54166, 70415, 20046], [-5266139, -64664, 54319, 169634, -221633, 18461, 33639, 0, -64664, -33639], [47910, 4377802, 0, 58597, 220708, 47910, -18747, -55193, 51504, 0], [7065670, 7076650, 8589, -69780, -49635, -10617, 0, -8589, 363, 3963], [47430, 2808432, 0, -260839, 183768, 47430, 5875, 59321, -35574, 0], [-6698677, 25560, -24147, -161010, -18525, 13929, 16983, 0, 25560, -16983], [-14908, -3662968, 0, -533166, -352564, -14908, -35817, -43265, -106925, 0], [4716875, 4633292, 9741, 319416, 501930, 13647, 0, -9741, -69936, -32469], [-3248802, -78768, -24194, 632068, 346614, -100830, -14506, 0, -78768, 14506], [4601603, 4633895, 20290, -152662, -73318, -35244, 0, -20290, -2952, 67284], [17901, 3785563, 0, -201771, -45360, 17901, 6561, -107163, -8181, 0], [5625752, 63598, 29136, -376012, 1336, 25172, 46104, 0, 63598, -46104], [-26144, -4631138, 0, 64923, -48101, -26144, 21192, 67811, -16264, 0], [-678565, -677227, -123782, 201818, -43291, 48219, 0, 123782, 49557, -13050], [112392, -6029926, 0, -39735, 593205, 112392, 10230, 24051, 54678, 0], [-7501801, -7436605, 143264, -423441, -572364, -9333, 0, -143264, 55863, -727], [1270138, 1197994, 71027, 190747, 288829, 23670, 0, -71027, -48474, -74142], [932539, 11069, -81717, -153704, -14257, 7279, 87591, 0, 11069, -87591], [2790230, 2892740, 13149, -496854, -503244, -60228, 0, -13149, 42282, 46791], [-2347429, 81152, 194297, -95186, 575909, -82721, 18741, 0, 81152, -18741], [10068776, 10029896, 168905, -12909, 47691, 11208, 0, -168905, -27672, -21940], [3312776, 30436, -9384, 85352, 318472, -51520, -52536, 0, 30436, 52536], [10706243, 10717907, 138420, 65376, -528471, 111771, 0, -138420, 123435, 26910], [15984, 13498415, 0, -330783, -94449, 15984, 37299, -137586, -29049, 0], [-1710110, 61641, -58746, -357942, -22638, 29184, 23826, 0, 61641, -23826], [-15416, 3015638, 0, -109151, -139384, -15416, -120693, 175221, -66124, 0], [-58158, 8223114, 0, 596573, -37440, -58158, 9829, 27539, 78912, 0], [9796778, 27936, -111684, -213096, -34968, 18168, 46848, 0, 27936, -46848], [22724, 1040911, 0, 594329, 398293, 22724, 26301, 26826, 127135, 0], [-71964, -4104560, 0, -117781, -306063, -71964, 61072, 90317, -84798, 0], [-628925, 60032, -191871, -165074, 215849, -19157, -17583, 0, 60032, 17583], [73854, -15315224, 0, 339369, 592302, 73854, 14289, 97041, 92778, 0], [42784, 972353, 0, -43121, 346601, 42784, -10605, 253296, -33613, 0], [187536, -13588, 176704, 99004, 64559, -18347, 10389, 0, -13588, -10389], [-12242765, 86463, 206955, -159660, 345051, -34425, -82917, 0, 86463, 82917], [-1099743, -924487, -90838, -668043, -956296, -47503, 0, 90838, 127753, 37149], [57186, 6606095, 0, 410215, 428532, 57186, -88324, 92338, 97887, 0], [-16208902, 104744, 176174, -530060, -19402, 45778, -26250, 0, 104744, 26250], [-13682075, 84384, 237739, -414806, -119097, 57573, -95449, 0, 84384, 95449], [9244928, 9379210, -199953, -677860, -339476, -148246, 0, 199953, -13964, -44193], [-5435363, -5419883, 102702, -331311, -324756, -10599, 0, -102702, 4881, -145491], [-6877697, -6934813, -167568, 91831, 752384, -97841, 0, 167568, -154957, -108519], [149733, 5921805, 0, -347731, 651624, 149733, 97951, -143077, 48909, 0], [-1782322, 82400, -16666, -191564, 319190, -30878, -45402, 0, 82400, 45402], [-103248, -6627375, 0, 758155, -176211, -103248, -53977, 185656, 52551, 0], [7987751, 74168, -3895, 13966, 435761, -57485, -138183, 0, 74168, 138183], [19118975, -57033, 295799, 285980, -27261, -17361, -5765, 0, -57033, 5765], [-103310, -7805663, 0, 993147, -53132, -103310, -32214, 198392, 96965, 0], [-1642316, -1851161, -102524, 1333992, 1235457, 145014, 0, 102524, -63831, 106060], [8781065, 8631271, 71616, 1028024, 471421, 201197, 0, -71616, 51403, 98070], [-16866956, 51642, 304044, -570108, -640236, 148704, -82572, 0, 51642, 82572], [-1212789, -1257945, -199692, 345039, 584472, -20793, 0, 199692, -65949, 6309], [-18298515, 30312, 102815, 272834, 679839, -123843, -22553, 0, 30312, 22553], [-211552, 10613388, 0, 455149, -794703, -211552, 71976, 85553, -53012, 0], [27939485, 28093978, 22083, -903760, -986084, -76231, 0, -22083, 78262, -111243], [-9914048, -105148, 140064, 1330252, 1152719, -272603, -91851, 0, -105148, 91851], [41220, 8019985, 0, -640833, -136488, 41220, -22596, -119838, -79467, 0], [-30726591, -75000, 65817, 318126, 58605, -41721, 107037, 0, -75000, -107037], [-107868, 661535, 0, -217066, -467026, -107868, 182610, -3160, -107502, 0], [-7088815, -7184305, 194416, 248924, 266249, 53829, 0, -194416, -41661, -46278], [21101746, -147960, -98886, 1052988, 625050, -184194, 91434, 0, -147960, -91434], [-13596530, -13412858, -112593, -794733, -800199, -109110, 0, 112593, 74562, 45582]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_144_i_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_144_6_i_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_144_6_i_d(:prec:=10)
    chi := MakeCharacter_144_i();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_144_6_i_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_144_6_i_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_144_i();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<5,R![4234048679706624, -457491118694400, 53123350023936, -900082524816, 74758828257, -926555355, 91398294, -323055, 10422, 21, 1]>],Snew);
    return Vf;
end function;