
// Make newform 252.4.a.e in Magma, downloaded from the LMFDB on 25 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_252_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_252_4_a_e();".
// 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_252_4_a_e();".
// 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 := [-7, 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_252_a();"
function MakeCharacter_252_a()
    N := 252;
    order := 1;
    char_gens := [127, 29, 73];
    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_252_a_Hecke( : Kf := Kf)
    return MakeCharacter_252_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], [0, 1], [-7, 0], [0, -13], [-30, 0], [0, 23], [-100, 0], [0, 17], [0, -44], [-180, 0], [-118, 0], [0, -3], [-412, 0], [0, 54], [0, 54], [0, -158], [-378, 0], [244, 0], [0, 83], [670, 0], [216, 0], [0, 152], [0, -183], [574, 0], [0, 127], [-964, 0], [0, -81], [2122, 0], [0, -56], [-1464, 0], [0, 364], [0, 10], [352, 0], [0, 426], [376, 0], [2198, 0], [-292, 0], [0, -650], [0, -389], [0, 297], [-3246, 0], [0, -417], [3998, 0], [0, 662], [224, 0], [-3460, 0], [-4648, 0], [0, -726], [-4646, 0], [0, -922], [0, 405], [-826, 0], [0, 162], [0, 753], [0, 1173], [0, -443], [-7980, 0], [-1954, 0], [0, -754], [4492, 0], [0, -1533], [2788, 0], [0, 718], [-7166, 0], [0, 594], [2108, 0], [8814, 0], [0, -927], [-8498, 0], [0, 1551], [0, 487], [6848, 0], [1966, 0], [1324, 0], [0, -1348], [0, -1352], [-7002, 0], [0, -2154], [7310, 0], [0, 762], [-11586, 0], [0, 87], [-9718, 0], [1680, 0], [0, 605], [0, 196], [-2330, 0], [0, -1817], [-4880, 0], [0, 1270], [0, -3046], [-8728, 0], [0, 2745], [-2204, 0], [0, -1416], [0, -1599], [0, -465], [-9424, 0], [-8730, 0], [1668, 0], [0, -50], [0, 4070], [0, 4782], [-4068, 0], [7618, 0], [0, -850], [0, -4137], [0, -3501], [-11590, 0], [9144, 0], [-29874, 0], [0, -5050], [4744, 0], [-13144, 0], [0, -4522], [20228, 0], [0, 3810], [0, 3036], [0, 3119], [-27242, 0], [17606, 0], [0, 2847], [0, 549], [29720, 0], [0, 2668], [16658, 0], [0, 2400], [24316, 0], [12570, 0], [7356, 0], [0, -6909], [-27768, 0], [23826, 0], [0, 5429], [23770, 0], [0, -5549], [-40656, 0], [0, 5847], [0, 3832], [-3248, 0], [0, -4750], [-31904, 0], [0, 4647], [25762, 0], [0, -1030], [-17050, 0], [0, 1317], [-10948, 0], [0, 6541], [-16154, 0], [0, -1761], [-45772, 0], [0, -1410], [3900, 0], [0, -2193], [-18416, 0], [0, 7989], [-30910, 0], [0, 4669], [0, 6691], [0, 6116], [-51136, 0], [0, -2040], [0, -8586], [0, 7020], [-49720, 0], [-20554, 0], [30050, 0], [0, -1185], [0, 10951], [-60410, 0], [0, 2091], [-17886, 0], [16056, 0], [0, -11297], [12228, 0], [0, 9440], [2492, 0], [26798, 0], [14160, 0], [0, 3644], [13558, 0], [0, -1025], [0, 11389], [0, 2739], [17274, 0], [22664, 0], [28146, 0], [0, -10284], [-22706, 0], [0, 1971], [52540, 0], [0, -10597], [0, -6645], [0, -12637], [-1210, 0], [3838, 0], [0, 657], [0, 8706], [0, -6378], [76512, 0], [2954, 0], [7350, 0], [0, 10404], [0, 2067], [18032, 0], [0, 3711], [0, -9444], [-51268, 0], [85826, 0], [0, -2711], [-55512, 0], [0, 8152], [0, 8166], [-91558, 0], [70936, 0], [0, 12791], [0, 12017], [0, -7288], [-27614, 0], [-7964, 0], [0, 6432], [-2984, 0], [0, -18948], [-12070, 0], [0, 12125], [0, 1249], [-46692, 0], [0, 8349], [21498, 0], [65548, 0], [34504, 0], [0, -912], [4268, 0], [0, -7584], [-101810, 0], [0, -10842], [0, 297], [0, -4136], [0, -16915], [-110752, 0], [-14464, 0], [84810, 0], [0, 1433], [0, -10266], [-37116, 0], [0, 1946], [86396, 0], [0, 22473], [4474, 0], [0, -19725], [0, 7683], [-60002, 0], [0, -12565], [0, 5699], [-11530, 0], [-80820, 0], [0, 4435], [11690, 0], [61648, 0], [0, 2893], [-31502, 0], [33766, 0], [0, 2283], [-9560, 0], [0, 22878], [0, -13481], [67300, 0], [0, -12240], [65910, 0], [-69820, 0], [-61266, 0], [83672, 0], [56014, 0], [-25116, 0], [0, -9025], [112218, 0], [-986, 0], [0, -4662], [0, -2820], [53304, 0], [0, -25140], [-85402, 0], [-93408, 0], [0, 12815], [53502, 0], [0, -17422], [-24316, 0], [0, -15219], [0, -7002], [0, 22380], [0, -8082], [0, 6118], [28118, 0], [0, -4449], [106832, 0], [0, -22731], [0, -18102], [69816, 0], [86506, 0], [0, 10116], [-111536, 0], [0, -5553], [4892, 0], [-76642, 0], [0, -7943], [102170, 0], [0, 4679], [146210, 0], [0, 34044], [0, -24524], [0, 418], [81212, 0], [0, -3743], [53006, 0], [0, -12660], [0, 6757], [68822, 0], [0, -12918], [-170788, 0], [-153698, 0], [0, -20445], [-167432, 0], [0, 10600], [18902, 0], [-72388, 0], [12724, 0], [0, 22367], [0, 24092], [-47158, 0], [0, 35660], [-208164, 0], [0, 650], [-123236, 0], [0, -13790], [18006, 0], [0, 8845], [25646, 0], [148444, 0], [48782, 0], [0, -14550], [0, -34539], [125448, 0], [0, 8328], [0, 7107], [-8878, 0], [-184060, 0], [0, 8772], [0, -1173], [175028, 0], [-87862, 0], [0, -13542], [176400, 0], [-203666, 0], [0, -13873], [0, -9248], [0, 3888], [0, -17044], [0, -19645], [16606, 0], [0, -7015], [0, -22073], [0, 9299], [48904, 0], [-63394, 0], [0, -11223], [-114360, 0], [-68714, 0], [0, -31603], [90676, 0], [0, -13365], [0, 32674], [76060, 0], [95542, 0], [0, 41124], [0, -15151], [134050, 0], [0, -4021], [144086, 0], [0, -13845], [0, 8104], [171400, 0], [0, 12036], [3472, 0], [0, -47876], [-143464, 0], [-214382, 0], [24772, 0], [0, -45286], [54074, 0], [0, -33627], [0, 43307], [26924, 0], [0, -11213], [246342, 0], [157192, 0], [0, 34499], [202068, 0], [0, 9596], [-171346, 0], [0, 5796], [200608, 0], [0, 4333], [0, -14979], [236864, 0], [170326, 0], [0, 42480], [-177448, 0], [0, -14806], [-61334, 0], [0, -42904], [0, -28615], [133908, 0], [125474, 0], [0, 27053], [0, -14731], [40924, 0], [0, 12867], [0, -30074], [0, 12620], [39230, 0], [0, 3035], [0, -8196], [295274, 0], [0, -41009], [0, 29101], [0, 810], [-57624, 0], [0, 43622]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_252_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_252_4_a_e();".
// 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_252_4_a_e(:prec:=2)
    chi := MakeCharacter_252_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_252_4_a_e();".
// 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_252_4_a_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_252_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-28, 0, 1]>,<11,R![-4732, 0, 1]>],Snew);
    return Vf;
end function;