
// Make newform 450.4.a.b in Magma, downloaded from the LMFDB on 07 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_450_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_450_4_a_b();".
// 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_450_4_a_b();".
// 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_450_a();"
function MakeCharacter_450_a()
    N := 450;
    order := 1;
    char_gens := [101, 127];
    v := [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_450_a_Hecke( : Kf := Kf)
    return MakeCharacter_450_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 := [[-2], [0], [0], [-32], [60], [34], [42], [-76], [0], [-6], [-232], [-134], [-234], [412], [-360], [222], [-660], [-490], [-812], [-120], [-746], [152], [-804], [678], [-194], [-798], [-1088], [1716], [-970], [426], [-200], [-60], [642], [-2836], [1554], [-2272], [-1694], [52], [-1200], [54], [-876], [3854], [2784], [-914], [-5202], [3152], [740], [520], [396], [-1330], [4866], [1824], [6482], [-1476], [4314], [-5280], [-5526], [2024], [-2054], [7302], [3724], [-7218], [-2540], [-1560], [934], [-1674], [-3988], [-2], [1764], [4310], [138], [11976], [-9704], [8122], [3404], [-2520], [-1566], [4354], [8046], [-2806], [-11580], [-370], [-5040], [3742], [-6208], [-15564], [15774], [-9722], [10890], [-15128], [10668], [-15264], [5776], [-14244], [-17116], [-16848], [3834], [18822], [15340], [18950], [10036], [10326], [4524], [-16362], [6620], [-8834], [3636], [6570], [-16584], [-502], [18568], [13114], [5250], [-10804], [-27088], [-18930], [-20108], [-7152], [-31626], [-28092], [-13186], [-5138], [6078], [32244], [4484], [30426], [13262], [-13920], [9376], [-6014], [-7468], [31248], [32840], [19066], [-6858], [22178], [14286], [18868], [-21690], [24726], [-2644], [37842], [880], [-12876], [-25498], [40584], [25738], [13314], [24524], [5592], [14386], [-47106], [-51548], [34080], [-25748], [24768], [-31264], [6174], [-28922], [-29238], [-2868], [24018], [-25712], [12396], [-46614], [-672], [-38776], [-30422], [-11182], [-28722], [-9012], [614], [-18264], [46390], [-21256], [31878], [33068], [-3582], [-9776], [37046], [16504], [44532], [-58070], [69042], [-8520], [-13806], [27826], [-21404], [-4486], [21504], [-26834], [48756], [47012], [-31110], [37068], [-18222], [-74350], [26578], [11130], [42288], [-23382], [78488], [-16406], [9026], [55500], [70710], [-30280], [-25476], [56790], [59132], [-26786], [-2862], [48688], [83700], [12312], [69146], [89080], [4686], [-55152], [-8922], [89870], [18560], [-28050], [54376], [102444], [72398], [-90462], [-101520], [28960], [-101268], [-73886], [3620], [-81736], [45462], [35884], [-112728], [91250], [8238], [114108], [-31512], [32268], [52220], [-90464], [61382], [-67302], [40872], [71464], [93396], [66908], [110568], [-25886], [37854], [4224], [-105766], [63558], [-78108], [-85234], [27196], [-115026], [13606], [31720], [-32484], [-92242], [-46958], [-8406], [4916], [34890], [-17322], [-13412], [-119778], [-139594], [38260], [-74522], [-109240], [-79202], [62896], [13668], [53462], [-120742], [53940], [-120984], [22880], [-22944], [8030], [-110612], [32976], [149038], [5454], [-46288], [-78594], [-38550], [-27780], [140082], [-92820], [70882], [-6342], [156776], [145566], [38460], [109396], [119350], [-96426], [-5560], [90636], [2348], [-56738], [-8604], [-167674], [-149112], [-122102], [77736], [43986], [-156066], [7204], [150816], [-22246], [-47532], [19536], [-29810], [-88050], [-42796], [182086], [-35526], [-133688], [76722], [119762], [-149740], [-94772], [-111624], [-97218], [68582], [38502], [123608], [-58500], [69788], [147732], [-165946], [53034], [794], [-2360], [-8582], [-111774], [13602], [-51520], [55254], [220404], [57998], [-36452], [-159168], [69534], [-209020], [-127610], [-88662], [-56936], [-149794], [16242], [26112], [-115092], [-20742], [106896], [86890], [188358], [91080], [-143940], [-142604], [-120794], [-29370], [-107504], [-92374], [-41436], [77756], [3096], [53682], [-19360], [-78206], [66084], [-69648], [11518], [-56658], [245398], [32442], [-50622], [-57104], [-142134], [174932], [130656], [-38392], [-213542], [58204], [36792], [199298], [11742], [234972], [-108236], [96216], [203926], [62408], [220662], [-142180], [-32046], [-104794], [-19350], [96136], [90258], [-202590], [-149056], [-114638], [-136434], [32452], [-189468], [-227666], [-191058], [-298620], [-229516], [9526], [-98454], [384], [-173984], [5466], [-196992], [-76038], [-262262], [-47736], [197388], [-152426], [245574], [50268], [140694], [294860], [-230184]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_450_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_450_4_a_b();".
// 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_450_4_a_b(:prec:=1)
    chi := MakeCharacter_450_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_450_4_a_b();".
// 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_450_4_a_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_450_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![32, 1]>,<11,R![-60, 1]>,<17,R![-42, 1]>],Snew);
    return Vf;
end function;