
// Make newform 450.6.a.m in Magma, downloaded from the LMFDB on 24 April 2024.
// 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_6_a_m();".
// 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_6_a_m();".
// 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)
    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+1)]];
    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 := 6;
    raw_aps := [[4], [0], [0], [-176], [60], [658], [-414], [956], [600], [-5574], [-3592], [8458], [-19194], [-13316], [-19680], [-31266], [-26340], [-31090], [16804], [-6120], [25558], [74408], [-6468], [32742], [-166082], [22002], [79264], [227988], [-8530], [-195438], [-173000], [-151260], [-128454], [154196], [-29454], [-203872], [-136142], [171124], [-676200], [133158], [693396], [377174], [265344], [-295298], [201294], [652448], [-1147060], [-701960], [1236108], [105830], [-438678], [-28464], [892562], [110124], [140802], [-938760], [1114506], [567704], [1213258], [-687738], [830908], [-1312626], [-1690220], [1502040], [-810842], [903558], [1121972], [2752174], [1917492], [1836590], [-622014], [-3740616], [-16232], [-293606], [3180116], [-2979840], [-3459774], [3904162], [-5441154], [1969946], [-139020], [4327430], [2799360], [5902414], [-446512], [3495252], [1206126], [-233546], [1744890], [2917864], [-5310756], [-2344656], [-9815312], [5945196], [6478316], [4717944], [1907706], [-8019738], [-1911620], [-11990050], [-4458092], [9026118], [6848988], [5463222], [-10232380], [-15943682], [-9477132], [2453490], [9299784], [-11461702], [-11278376], [-93782], [-14964150], [-5068876], [15591872], [-10970130], [2837044], [-6056856], [-1088922], [-7418028], [767654], [-1422626], [-6162306], [15062148], [-5876356], [-3600774], [9225158], [26392320], [9794848], [-4075838], [-16570852], [14414136], [16794440], [-13294262], [2147862], [-13105918], [-23715378], [8400484], [5410230], [26077734], [19002116], [31017282], [15628960], [15842052], [2061758], [-30390024], [29773786], [8641002], [-33566284], [39019104], [18138178], [-30531186], [43553284], [-13415160], [-3108164], [-1190352], [-47199616], [-1335954], [-14723786], [26919642], [-3731604], [21873546], [-17602496], [-16731684], [55538178], [-38678424], [9584984], [10365034], [-15326638], [-2400114], [-6185028], [-49247506], [-31599384], [-44534570], [58310216], [41260422], [69004868], [-1073502], [-42406112], [10636574], [30311752], [72877812], [17593210], [-4900374], [32915760], [-54190254], [-49039742], [-712508], [-73548694], [-12093696], [-36530498], [-15155628], [-10480948], [-71216310], [-46421316], [-15499254], [80400050], [-15166814], [35567490], [101093976], [53886522], [-71197672], [-2354678], [-46040926], [62451900], [-11026170], [15583880], [95301708], [-87798090], [-83244988], [-38354258], [-75785262], [54179536], [7896900], [68570328], [-96508534], [-89079560], [52890846], [46727784], [-132937194], [80891270], [63682640], [6919950], [66683752], [-50614788], [4946342], [66766746], [92859120], [-62179520], [52396332], [89568658], [94457180], [50557544], [-108395178], [-72794372], [-84509664], [-60806350], [57180366], [-84863508], [57666168], [43822236], [55033220], [-89499248], [87949118], [39559506], [-160722552], [82349512], [-78933084], [-34183468], [-51019344], [-78276158], [104437854], [104077032], [-180401494], [-183988554], [135176148], [-111151114], [35388508], [-24678738], [102038758], [16592440], [90300828], [58884902], [31358194], [50403282], [-17135716], [109142010], [-145435962], [217276876], [-34810626], [88169246], [-104448620], [18036166], [-127777960], [-86618546], [-129914768], [-124533516], [-158124082], [59282858], [74600340], [140748432], [35859680], [-112601832], [-194050570], [-157434596], [-184801104], [47957326], [-86917458], [79612448], [26687934], [-37892550], [55124460], [230903034], [237963180], [198699394], [120638442], [-280168024], [271671582], [-314239860], [-50615852], [-169836650], [-121845978], [165519560], [-280374708], [106271828], [-314137154], [-282596892], [269653454], [-245242968], [-267256694], [224602032], [-274803966], [129917454], [119094868], [-96145992], [-10248694], [268974132], [-380189904], [-338688770], [256543950], [-67703476], [228632518], [81075834], [253261384], [-181632966], [-328443118], [59611340], [-327209684], [344787168], [-177756066], [29330222], [402617526], [68534312], [-173703300], [-359802412], [-260819244], [93198926], [-218038782], [-117341686], [-16163480], [-171839174], [-9740022], [-56169582], [-225865120], [105100518], [60300756], [214202918], [335148844], [-205006368], [262532862], [-114689620], [-82573130], [344564778], [-214957112], [-280015066], [64262394], [536671488], [-34643412], [-133340286], [13732392], [109198570], [289362678], [255576240], [129080940], [-279872732], [389435062], [435560790], [156936112], [475554746], [-34835916], [-483381916], [45054672], [3584418], [531304640], [480935842], [-244960764], [-473633568], [-406618274], [-297322722], [373236934], [-30900918], [19103226], [-118841312], [359587938], [650502188], [-622609128], [16848968], [194291434], [4410268], [-542804304], [159539522], [640721694], [-116268372], [605144452], [284134776], [183521062], [193659752], [632961798], [564867620], [-59527086], [-118691506], [-394865550], [224410888], [-644836566], [635837490], [-17110096], [-168228014], [-371278434], [69505444], [-604745292], [720944878], [142904046], [-661129740], [-265467316], [-450993482], [431408106], [-261454464], [-198750992], [-189979902], [-673839624], [85286058], [-870776246], [112161072], [-274409268], [214654678], [609534582], [369797916], [-395106714], [-812417740], [120774984]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_450_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_450_6_a_m();".
// 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_6_a_m(:prec:=1)
    chi := MakeCharacter_450_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_6_a_m();".
// 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_6_a_m( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_450_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<7,R![176, 1]>,<11,R![-60, 1]>,<17,R![414, 1]>],Snew);
    return Vf;
end function;