
// Make newform 1216.4.a.x in Magma, downloaded from the LMFDB on 09 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1216_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_1216_4_a_x();".
// 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_1216_4_a_x();".
// 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 := [2, -9, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [5, 3, -1], [-7, 1, 1]];
    Rf_basisdens := [1, 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_1216_a();"
function MakeCharacter_1216_a()
    N := 1216;
    order := 1;
    char_gens := [191, 837, 705];
    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_1216_a_Hecke( : Kf := Kf)
    return MakeCharacter_1216_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 := 4;
    raw_aps := [[0, 0, 0], [2, 0, 1], [-1, 1, -2], [-11, 2, 0], [9, -1, 0], [38, 7, -2], [-43, 0, -6], [-19, 0, 0], [-62, 11, -4], [106, -2, 23], [-38, 3, 23], [-4, 27, -1], [240, 7, -23], [185, 37, 4], [73, 57, 28], [-84, 50, 9], [-36, -9, 100], [-53, -75, -28], [172, -58, 65], [-306, -78, 34], [61, 14, -34], [26, -75, -89], [8, 42, -80], [594, -21, 39], [-744, -68, 14], [550, -14, 62], [150, 186, -118], [340, 93, -32], [484, -92, -183], [1144, 105, 49], [12, -33, 131], [-949, 105, -206], [-343, -2, 204], [-827, 65, 24], [657, -77, 42], [-1014, -8, 224], [1970, 76, -92], [1552, 118, -166], [628, 389, 51], [990, -254, -146], [760, 413, -165], [842, 274, -234], [-627, -12, 138], [-558, 127, -247], [-926, 42, -80], [2109, -164, -6], [2528, 31, -44], [-440, 231, 243], [1586, 169, -24], [797, -643, 170], [3833, -147, -194], [433, 148, -378], [1612, 231, -203], [-1289, -331, -88], [3596, -106, 134], [-5071, -441, 22], [-5422, 369, -281], [-898, -87, -678], [2981, -183, 108], [1978, 782, -20], [1989, -387, -34], [2702, -277, 340], [-1978, 401, -959], [-4449, 50, 830], [-3832, 123, -220], [-6444, -185, -134], [-2064, 624, -607], [-7024, 552, -784], [-2305, 249, 944], [-1555, 39, 1340], [-3420, -769, -552], [-1743, 740, -700], [2944, 100, -1328], [4510, -529, -124], [-6388, 253, 830], [306, -341, -695], [-4789, -751, -232], [-2367, 681, -1372], [-3058, 9, 821], [4606, -79, -135], [-1816, 1506, -1090], [-8656, 266, 1161], [368, -1600, 74], [-5440, 887, 1179], [540, -131, -725], [-7057, -739, -252], [5216, -1236, 130], [-7433, 414, 896], [-1511, 53, 508], [-131, -259, -1472], [-1793, -1651, 420], [4476, 96, -1616], [-11998, 298, 98], [2384, -462, 626], [-6793, 173, 502], [642, -935, 118], [-7016, -96, 1018], [-2050, 679, 595], [1456, 1383, -1498], [3059, 1013, 1252], [3116, -676, -2100], [1661, 389, 1136], [8540, -405, -2403], [6656, 988, -1324], [7956, -900, -732], [3447, 230, 1014], [7063, 2733, 458], [-14430, 662, 1738], [-16062, 583, -893], [8854, 458, -244], [-10908, -82, 924], [-2691, -2295, -718], [16807, -1063, 1968], [-14684, -312, -1642], [1595, -2183, 878], [-12688, -156, -1838], [-6387, 477, -1758], [4029, 3340, 938], [-2803, 767, -1346], [7560, 2301, -1128], [-10026, 1221, 1922], [-998, -3722, 1480], [-8078, 726, -3343], [3136, -2074, -866], [5991, -2597, 2274], [-3942, -872, 2542], [-1314, 1400, 2800], [-6043, -1962, 1516], [13403, 1024, -732], [10198, -2056, 1322], [885, -791, 264], [11558, 935, -537], [17372, 622, 1398], [-14961, -321, 2138], [3317, -638, 1288], [11699, 3002, -172], [20192, 2231, -446], [1758, 3095, -1146], [3812, 4634, -1915], [4127, -828, 3114], [-7410, 449, -270], [29161, -531, -932], [-14719, 68, 1640], [28832, -1824, 1303], [-1558, -1689, 5412], [9286, 616, -2422], [18890, -2850, 3670], [658, -1276, -5550], [-1295, 1645, 2078], [-1392, -1791, -1471], [10976, 495, 1958], [651, -2647, 2184], [14989, -2697, 3852], [4470, 44, 828], [2396, -3028, 3221], [8026, -50, 4192], [-4306, 1111, -658], [-5824, 3147, -3192], [-10539, -998, -1478], [-13644, 1215, -924], [-5524, -624, -2728], [-8942, -4067, 779], [-28520, 456, 3392], [-10340, 264, -1256], [-654, 3005, 1397], [-7776, -3966, -1908], [-31152, 2363, -4043], [5081, -4563, -852], [-10694, -3397, -2177], [3261, -4293, 34], [15626, 3664, 819], [-13816, 2902, -3543], [-8752, 1460, 668], [6708, -4349, -1554], [-35540, -3780, 872], [7165, -1745, -6228], [32424, -978, 1646], [26737, -3979, 5358], [-44048, 1324, -3056], [32107, 3337, -98], [-3817, -810, -1992], [-26030, -2721, 876], [-6726, 3564, 4188], [35110, 1804, -2434], [42813, -2906, 2344], [-4939, -2753, 5172], [-5900, -4421, -2166], [8534, -1418, 5328], [1552, 2927, 3683], [-23326, -1475, -2238], [-34340, 2119, -1157], [-17123, 3643, 1946], [19574, -513, 3111], [39418, -2538, -1747], [-12784, -3432, -3976], [37656, -2878, -930], [16309, -1880, 1708], [-31562, 2540, 3910], [-8340, -2603, 7184], [-2597, 1364, -6354], [10104, -4126, -7688], [7928, -5005, -2671], [-19364, -512, -3413], [27064, -2555, 7999], [5468, -4116, -3046], [-13847, -5237, -1390], [-45101, 5230, -6030], [-26810, -3271, -3468], [-4975, 632, 3092], [14912, -3273, -3780], [-29176, 677, 4714], [-14282, 1828, -2170], [17187, -417, 4100], [27190, 447, 1812], [-12176, -4429, 2773], [-23764, 4643, -5293], [-42298, 2045, 2162], [-12360, -8034, 392], [42238, -7071, 7291], [35631, 5455, 2398], [20278, -1274, -1886], [-19148, -6391, -5799], [21584, 2583, 6143], [20667, 858, 7954], [-30448, 4631, 1462], [31975, 4395, -498], [-9826, 4106, -1742], [5766, 8907, 3897], [35338, -5372, 10616], [45665, 395, 4376], [56195, 2479, -3078], [6420, 2610, -4739], [-39822, 2355, 991], [15406, -8242, 2318], [-70341, -1187, 2848], [-36763, -2892, -3012], [4727, 2593, -6356], [15683, 2255, 2000], [-61500, -8214, 404], [-6146, -5695, 7913], [2650, 3048, 1966], [-12393, 7907, -6266], [25022, 3497, 7020], [25040, 681, 246], [18560, 3291, -7735], [-58427, -1673, -4266], [7637, -1077, 6958], [-27314, 4959, 9787], [40760, 292, 424], [8871, -522, -6506], [-64794, 3256, 6652], [-3465, 10090, -1766], [17594, -1251, -3066], [-3566, 2789, -5917], [71075, -2935, 1618], [24500, 10848, -1738], [-179, -5719, 2894], [15096, 11479, -1411], [49160, 2567, 8371], [-61578, -650, -2430], [-196, -12829, 993], [27290, -6248, -5586], [-68869, -3265, 3344], [-23988, 657, -6258], [62309, 1473, 6094], [-6924, -8704, 2971], [-11736, 1744, 3777], [3763, 10154, -3338], [17460, -1721, -14934], [7375, 2797, -272], [-65816, -3430, 2773], [-5230, -4532, -5929], [49277, -6366, 8938], [-29003, 3306, -4950], [-85474, -7597, 1029], [77494, -6675, 4748], [31693, -12115, 6906], [5872, -9676, -4117], [-14522, -4696, -7930], [-14923, 4383, 7446], [-25034, 1456, 12712], [15170, 13209, 1210], [52287, 3972, -10444], [52316, 12039, 3280], [29989, -605, 3670], [-29913, -6169, 3148], [-35061, -2498, -7492], [-32092, 2076, -13954], [-8479, -6748, -6868], [-1756, -2806, 9896], [14142, -1690, -4650], [-22191, -11249, -5414], [78244, 434, -6988], [-65738, 2514, 7936], [-47014, -642, -5902], [-72982, -16082, -4412], [41940, 1370, 7128], [19011, -479, -1016], [24640, -5398, 627], [17435, -1025, -3706], [34899, 2283, -12602], [10588, -4261, 17822], [-21771, 2426, 456], [-66172, 3524, -685], [-132481, 4485, -6478], [12654, 7801, -7369], [-274, 35, -8966], [5570, 4018, -9355], [23167, 2311, -13836], [21002, 4298, -13440], [-13989, 4873, 7966], [518, 13416, -5128], [-28056, 904, 11510], [-29640, -13831, 3771], [-25324, 6778, 15746], [-69246, 2601, 8065], [-19629, 403, 14218], [16338, -2435, 9451], [29787, -6338, -1078], [38707, 11665, -12184], [-27194, -9986, -3699], [34325, -4570, -888], [32064, -11177, 10668], [48910, -1101, -7107], [59576, 1575, -3146], [-54922, 3433, 4203], [18346, 17137, 4904], [-39734, 4438, 8045], [-72136, 3397, -11125], [36697, -6759, 14080], [-21905, -1753, -2528], [-44328, 10259, -19294], [31990, 7861, 12266], [-53399, -1853, 14084], [-46635, -11275, -5986], [-20553, -1579, -13294], [44608, -7636, 3097], [-73992, -5053, -2959], [10991, 2966, 7562], [50402, -13217, -6018], [95112, 19870, -145], [-66811, 2560, -258], [53662, -552, -10919], [-65730, -13037, -9419], [38952, -7019, -12502], [79700, -11818, -9046], [-6206, 6582, -9278], [36378, -11454, -19499], [-153636, -5354, -332], [20141, 851, 15414], [-53576, -5377, -10767], [3992, -15470, 19024], [-134849, 2361, -7726], [-18850, -3878, 12792], [92642, -15015, 12775], [22996, 10230, -1666], [98, -13589, -7168], [25804, -11908, 4700], [42573, 8314, -6276], [31044, 7353, -3123], [-113867, -7777, -2878], [53546, -14856, -1684], [73712, -2417, 4299], [3536, -14074, 21225], [-87521, 12643, -13914], [69948, -14647, -6049], [92414, -6468, -9268], [-50914, 11060, -7488], [-35110, 18225, 1975], [121768, 7678, -668], [-60938, 1256, -6717], [-117969, 11400, -1268], [5898, 18408, 3109], [96863, 7371, -6020], [-39395, -14805, 11982], [67490, -8819, -7206], [-69140, 13466, -15438], [8285, -1045, -768], [158103, 3322, -6512], [-135532, -12194, -4910], [76806, 10816, 5596], [80821, -4909, -28076], [-90401, -9734, 9080], [87557, -11817, -8884], [66726, 25124, 2085], [-102844, -18242, 7284], [63186, 3191, 6194], [49306, -6470, 15040], [-30429, -3319, -23820], [-121860, -9291, 9975], [49350, -2214, -646], [-111700, -16051, -12820], [104932, -10234, 5532], [168303, 8939, -1078], [-28386, -16852, -19210], [-49690, 4550, -24930], [12862, 2133, 21355], [131348, 21131, 3013], [37860, 2481, 20735], [54270, 9688, 2846], [-60294, -2757, 13577], [49537, -6777, 7900], [-120748, -7310, 10616], [-10986, 24638, 2544], [40650, 20097, 3211], [-139009, 5798, 9498], [-62367, 11775, 37300], [-70624, -14373, 12209], [128878, -142, 533], [-116633, 6309, 24754], [-46626, -4045, -273], [13727, 11589, 4488], [124040, 15529, -1054], [-110173, -11661, -7026], [-84400, 3585, 10646], [135530, 424, -2846], [-11064, -20032, -19858], [-171726, 7635, 4447], [-44724, 3291, -20910], [68714, -18718, -13792], [-62418, 2775, -28987], [57238, 11494, -15167], [-36881, 11868, 1262], [9554, -10158, -4379], [-35040, -17010, -9016], [39250, -3673, -12184], [-22622, -11820, 2225], [90523, -1328, -9208], [-141727, -8569, -15554], [-55837, 16620, 7096]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1216_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1216_4_a_x();".
// 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_1216_4_a_x(:prec:=3)
    chi := MakeCharacter_1216_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_1216_4_a_x();".
// 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_1216_4_a_x( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1216_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-28, -52, -5, 1]>,<5,R![-1516, -279, 2, 1]>],Snew);
    return Vf;
end function;