
// Make newform 1872.4.a.s in Magma, downloaded from the LMFDB on 11 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1872_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_1872_4_a_s();".
// 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_1872_4_a_s();".
// 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 := [-10, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 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_1872_a();"
function MakeCharacter_1872_a()
    N := 1872;
    order := 1;
    char_gens := [703, 469, 209, 145];
    v := [1, 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_1872_a_Hecke( : Kf := Kf)
    return MakeCharacter_1872_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, 0], [-12, 1], [-4, -3], [18, -8], [-13, 0], [6, -18], [-60, -9], [36, -16], [-42, -8], [-184, 21], [78, 30], [108, 45], [-52, -42], [-330, 34], [618, 0], [-234, -58], [-326, -84], [128, -87], [-378, -8], [-562, 54], [160, 12], [330, -42], [1056, 3], [-58, -102], [462, -34], [-1360, -18], [240, 68], [-254, -12], [186, -20], [-1336, -102], [552, 176], [924, 333], [1556, -252], [456, -369], [408, -153], [206, -264], [940, 297], [606, -222], [-3306, -158], [252, 132], [3510, -24], [2280, -164], [-1366, 276], [-4020, -51], [-584, 42], [2212, 432], [216, 177], [-2154, -36], [-2046, -468], [258, -190], [-1002, -552], [-3426, 102], [1392, 96], [4290, 294], [2148, 192], [-3642, 264], [-3340, -51], [3510, 768], [3132, -643], [-508, 918], [-1032, -661], [496, 759], [4404, 840], [-1162, -672], [4548, -603], [-1352, -1659], [2414, -444], [-1356, 156], [2446, -510], [-4548, -1027], [-2514, -294], [-1016, -72], [7730, -144], [-8980, -621], [-6798, -1014], [2490, 510], [3374, 486], [816, 1431], [3238, -654], [5832, 1656], [2290, -1596], [2130, 834], [8470, -348], [-6968, -570], [-1848, -276], [5304, -1885], [-3194, -1866], [12300, -999], [284, -1023], [-3336, 1952], [8010, 420], [-3944, 1125], [-984, -1832], [632, -819], [-3396, -2972], [-13956, 305], [-3390, -1020], [3468, -1884], [-1534, 288], [-1060, 2460], [-48, -1233], [18300, 1040], [-1950, 158], [9516, 1002], [11634, -1116], [1842, -1618], [-11832, -353], [15948, -1580], [-21530, -1224], [-6216, -1260], [4646, -978], [20436, 941], [-19384, -489], [-6352, -897], [-9690, -3274], [2032, -471], [-14832, 1372], [-1194, -3780], [9060, 3300], [-14002, -1206], [-4982, -2880], [-6030, 2868], [-10350, -1316], [17720, 861], [24138, 78], [10010, 408], [-13524, -1876], [23288, -1638], [17834, -3000], [2064, 4803], [-26106, -728], [-13368, 3306], [-23046, 1284], [-25908, -759], [-30582, 480], [-14088, 3547], [10960, -1221], [15762, -534], [-29646, 1884], [4516, -5253], [-28800, -1433], [37368, 1146], [-18582, 3576], [10546, 4260], [-22470, -1480], [-22562, 546], [16530, 4118], [4564, 1332], [21810, -2786], [23262, -438], [10314, -714], [-2932, -6114], [-15912, -800], [-11028, 1194], [11928, 3456], [-28584, -2988], [-5796, -4179], [34950, -2508], [-31944, -2845], [3582, -1950], [12138, 730], [6496, 3249], [34884, -2508], [-8448, -873], [22650, -892], [-13728, -1404], [-1858, 5616], [-23362, 4434], [34470, -2186], [-9066, -2988], [174, 6], [-34572, 988], [23398, 4074], [-31296, 906], [21774, 3416], [12232, -1401], [5832, -517], [-12304, -5418], [-51526, 2520], [-48684, -3327], [17820, -6164], [8650, 1788], [-11448, -3125], [-23106, 6370], [-3414, -5626], [-20450, -7008], [5340, 10011], [29582, 282], [27966, -294], [-23774, 192], [-74334, -486], [-29716, 6456], [3432, -4241], [-8460, -1340], [42, -12078], [-37102, 7212], [23338, 600], [8688, 235], [4032, -4316], [18396, 4329], [-20864, -1644], [15914, 8880], [28258, -5976], [27270, 1930], [-29166, 5100], [-21616, -6591], [61056, -24], [5736, -1821], [1068, 4158], [52022, -4668], [-17910, 5388], [-13568, 9792], [35682, 8524], [-57750, -42], [-40718, -1584], [-11968, -2808], [-474, 3988], [17166, 2608], [-8712, 7419], [4030, 4776], [-8156, 12381], [31560, 5079], [31496, -4179], [11064, 3708], [-60610, 2892], [-10962, -15296], [8076, 4800], [-42904, -1146], [14022, 2454], [19390, 7392], [-35452, 264], [20988, -1761], [-63426, 2174], [41860, 816], [23766, 3416], [-6386, -2766], [24408, 3263], [20364, -4428], [89568, 1856], [28818, -2034], [101396, -1134], [-19032, -5508], [64838, 1398], [18384, -8657], [-21372, -10584], [-23996, 13185], [58638, -5546], [49228, 6783], [-50676, 3228], [54770, 2472], [9036, -8147], [-63318, 4348], [-12250, -7572], [26430, 164], [-75774, -5732], [-20910, 10104], [-95060, 2583], [15450, 10014], [45682, -6408], [-7576, -5202], [7284, -11700], [-5110, 6900], [-4442, -5160], [-4776, 10419], [-64420, 4296], [7860, -15643], [66108, 9661], [74664, 3579], [-32898, -10890], [58258, -2160], [8816, -4611], [34902, 3630], [-25400, 1350], [114398, 3072], [44796, -1941], [-68778, 3776], [37974, 5790], [-10046, 9660], [126024, 864], [-55272, 7316], [55260, -6135], [13488, -3028], [59702, -4566], [7104, -4473], [16800, -5036], [-5674, 12300], [74232, -5729], [-2624, -4305], [54210, 4714], [-36630, -2436], [114444, -5716], [41328, 8079], [-17778, 7358], [7582, -11400], [-139590, -1974], [1584, 12216], [714, 7774], [-5316, 4060], [-93536, -2145], [92618, -5496], [110244, 5041], [88968, -12990], [2124, -15520], [8516, 3984], [-2650, 4350], [-20508, 21856], [38214, -15984], [-85542, -2804], [-7590, -9996], [77628, 8496], [9036, -14147], [41538, 12708], [-31420, 20100], [-18282, -15706], [-52426, 13944], [-22674, 5004], [138, -2206], [-33058, 1854], [25902, -2186], [-43412, 8910], [-26630, 4476], [34074, -19848], [20272, 831], [65640, 7507], [-130250, 84], [27308, 14313], [-61272, 16473], [68544, 12676], [-75354, 892], [38410, -5328], [-101922, -7988], [-96056, -9672], [-21006, 16692], [-1220, 13995], [-10494, -18094], [-3034, -1746], [43620, 10021], [-13434, 16398], [16264, 25302], [27726, -10806], [5874, 11424], [-50616, -15469], [-1096, -10734], [-252, 10201], [-38916, 22168], [-52670, -20832], [-58124, -9675], [60630, 13154], [-59766, -10230], [-126112, -1863], [21310, 12078], [59568, 18099], [-31688, -9906], [41514, -7536], [16746, 30900], [-71298, 5634], [114678, -8520], [-51558, 1554], [79386, 16362], [-62570, -1782], [10470, -32334], [-17556, -12868], [-104346, 3680], [10180, 13326], [52210, 1344], [26436, -2595], [-6040, 4083], [-106206, 19704], [79464, -10380], [-137332, 3894], [-127554, -2842], [-35694, 5232], [-15624, 27780], [-157146, 3528], [-21198, 1314], [-27144, 17820], [-52990, -10908], [-124506, 13204], [-4670, -25788], [-121824, 9087], [-39372, -35399], [-77316, -23103], [-114984, 5915], [123836, -1311], [-101790, 20460], [-11580, -19521], [-153430, -3012], [-101996, -27093], [-4692, -1684], [-49602, -3342], [164856, -7705], [-187782, -7992], [58876, 6948], [-8586, 2610], [152302, -5844], [196308, -5169], [96630, -1382], [52260, 15564], [102276, 12021], [-118058, 138], [-77970, -22418], [22508, 28605], [4896, 17975], [-15612, 1701], [163072, -6756], [-149750, -13920], [-213888, 4719], [17336, 4551], [59898, -11724], [-83918, -11688], [95730, 4020], [-16716, 14612], [117956, 8226], [39842, 2772], [141786, -9036], [-137586, 9720], [-67792, 2364], [84264, 22719], [67788, 12636], [-70482, 8062], [-84074, 10722], [-184386, 11700], [40488, 39624], [-37918, 25164], [93648, -24877], [-43008, -30544], [-21408, -20049], [-106396, -7707], [41256, -20408]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1872_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1872_4_a_s();".
// 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_1872_4_a_s(:prec:=2)
    chi := MakeCharacter_1872_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_1872_4_a_s();".
// 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_1872_4_a_s( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1872_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![104, 24, 1]>,<7,R![-344, 8, 1]>],Snew);
    return Vf;
end function;