
// Make newform 1200.4.a.be in Magma, downloaded from the LMFDB on 17 April 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1200_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_1200_4_a_be();".
// 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_1200_4_a_be();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_1200_a();"
function MakeCharacter_1200_a()
    N := 1200;
    order := 1;
    char_gens := [751, 901, 401, 577];
    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_1200_a_Hecke( : Kf := Kf)
    return MakeCharacter_1200_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], [3], [0], [8], [-36], [10], [-18], [100], [72], [-234], [16], [226], [90], [452], [432], [-414], [684], [422], [332], [360], [-26], [-512], [-1188], [-630], [1054], [558], [8], [1764], [1622], [1134], [-592], [1908], [-954], [-2564], [-738], [2440], [2554], [-820], [1944], [1242], [-1116], [1070], [576], [1342], [-1422], [-872], [-1340], [4880], [2700], [254], [-4410], [3888], [5138], [-4788], [5886], [2232], [-666], [5536], [-2126], [-2934], [2036], [-2286], [1244], [-1224], [-1898], [9162], [4348], [-7154], [-1836], [5894], [-11106], [-13176], [-6112], [13618], [-692], [-8064], [12654], [106], [-4014], [3914], [-4428], [-15490], [-6768], [-1298], [2248], [-9612], [162], [-1370], [-15354], [-13024], [-14436], [-12096], [6056], [-7524], [-5276], [4968], [10998], [-8838], [22436], [-4762], [-6004], [5274], [-12420], [-21366], [-21140], [-3266], [17028], [-9522], [10296], [-3382], [-20656], [22114], [-19962], [604], [-152], [4194], [-7252], [-6696], [-28422], [19908], [14318], [-30050], [-22158], [-3132], [20932], [-21834], [12446], [12528], [11576], [29338], [-2540], [-18792], [-4832], [20818], [12042], [13058], [11826], [11996], [-6966], [-40806], [17980], [-12834], [-37864], [42516], [45638], [-17496], [-32174], [38934], [-29780], [-48096], [-21302], [-7470], [764], [32328], [-36316], [13392], [-38072], [-12798], [-34874], [17190], [40284], [-15498], [37160], [-18468], [-10386], [44136], [28432], [39778], [-31726], [19458], [2988], [31142], [46728], [-42074], [25984], [-28278], [50956], [26190], [-19000], [-3274], [38672], [29844], [48994], [21222], [51120], [-59490], [37018], [53036], [-23878], [-42624], [-38402], [-11772], [38404], [28854], [66924], [17478], [42002], [-20870], [41022], [64440], [6534], [-3104], [-43406], [-22366], [19836], [35082], [38224], [-6228], [52506], [-63908], [-44594], [-50850], [77912], [-49932], [-6264], [-30790], [34976], [-9774], [3816], [12618], [-46018], [-66296], [50850], [44768], [35100], [18926], [76086], [-67968], [10376], [-31140], [8938], [-69500], [-63920], [1818], [-32284], [-49968], [13490], [3618], [48492], [115848], [18108], [-109268], [-100216], [-17578], [38862], [14328], [18800], [-42156], [77020], [70416], [-51014], [56322], [-117864], [84122], [77274], [59652], [-102898], [-54412], [-73710], [31318], [-40528], [75276], [-95842], [-101510], [-82818], [4948], [-102042], [-40662], [14132], [-78894], [99926], [-121348], [-134858], [-15344], [-39890], [51704], [130932], [4070], [-103462], [89028], [50688], [-41672], [7272], [74942], [-141148], [-29808], [51022], [-71838], [83656], [-11934], [112806], [71964], [65430], [87804], [-61526], [-152586], [-60560], [-44190], [42444], [106028], [109414], [-73926], [23488], [-77508], [27244], [-11234], [-87228], [24470], [-173736], [36226], [87408], [-40770], [-183870], [59660], [32472], [1082], [-37404], [-69408], [55870], [194994], [15940], [53686], [-33066], [-69712], [-80154], [48914], [-170156], [-133036], [90720], [50994], [-146026], [117162], [124624], [-31860], [-61508], [-42732], [1862], [175518], [15482], [-102976], [-107918], [101430], [-44658], [128728], [65322], [-122508], [117182], [160292], [-5040], [60066], [146260], [-38618], [-22554], [-175264], [-108370], [-188874], [-135648], [13212], [14670], [-7416], [171586], [195354], [-222480], [235692], [170540], [19270], [-16326], [-58744], [47690], [164340], [46396], [13968], [45918], [51688], [-208070], [99684], [-49248], [-4706], [-83790], [-23210], [174294], [26118], [-121672], [-8226], [-71756], [125784], [-108128], [219538], [161684], [-111456], [-147454], [-156078], [27900], [89756], [109080], [-44234], [14320], [187866], [65788], [-174978], [-279898], [-30690], [36704], [197910], [-17874], [168856], [-6614], [136818], [-18244], [-58284], [136654], [153378], [26388], [104500], [-147770], [-177210], [-207936], [263816], [-211986], [-223416], [-149706], [-43742], [-147888], [-266868], [172582], [-39654], [-258084], [-48438], [-144020], [-256680]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1200_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1200_4_a_be();".
// 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_1200_4_a_be(:prec:=1)
    chi := MakeCharacter_1200_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_1200_4_a_be();".
// 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_1200_4_a_be( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1200_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![-8, 1]>,<11,R![36, 1]>],Snew);
    return Vf;
end function;