
// Make newform 450.4.a.c in Magma, downloaded from the LMFDB on 10 September 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_c();".
// 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_c();".
// 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], [-14], [-6], [-68], [78], [44], [120], [-126], [-244], [304], [480], [-104], [600], [-258], [-534], [362], [268], [972], [-470], [1244], [396], [972], [46], [1506], [1474], [924], [698], [-222], [1906], [-2874], [-798], [-700], [-114], [1064], [1948], [-2060], [-1248], [-1146], [1146], [-118], [-1692], [-3350], [-3606], [2696], [-4], [1162], [-2400], [-2314], [-18], [5868], [-4330], [-498], [642], [-7968], [4218], [848], [1504], [1308], [5932], [5226], [-4448], [9132], [2170], [7674], [9596], [-12158], [10320], [-2158], [-330], [8664], [-3782], [-11276], [980], [-4200], [-13338], [7192], [2316], [-12358], [-3306], [-14506], [6480], [-11894], [-12688], [4968], [11508], [-1082], [11238], [2302], [15876], [-4644], [-2426], [-234], [14204], [4920], [4458], [-4212], [11212], [14018], [-18200], [-11826], [-2952], [-3084], [-4756], [11014], [-852], [15546], [8616], [17510], [13894], [6496], [-570], [-2140], [14660], [456], [23452], [7224], [19146], [-27810], [-30598], [3778], [-27198], [32316], [29324], [-22782], [26054], [5976], [5110], [-17336], [-13660], [1320], [15860], [-22160], [-13116], [32846], [-11982], [21076], [22086], [-21384], [5228], [38010], [-38642], [-15432], [-3886], [-27552], [-15104], [-12306], [-47500], [4272], [27796], [39996], [3772], [-5784], [8440], [31920], [34652], [-1404], [7654], [-11298], [28968], [46410], [41506], [18246], [25998], [14616], [-2968], [9052], [-47482], [22062], [-18774], [-7378], [-4824], [26482], [42044], [-40836], [12284], [-1482], [-4658], [-5890], [-6650], [39582], [-34400], [42162], [36912], [38574], [-32780], [58564], [13670], [-25140], [45298], [-31608], [-66244], [-47370], [-12276], [77562], [-5758], [60892], [-23670], [-54672], [-76458], [-26404], [-37820], [3566], [43866], [-66414], [-20116], [-7128], [52764], [-16084], [-13022], [20286], [-37478], [-91464], [53676], [-45790], [57514], [17100], [29400], [-76098], [1790], [-24640], [28296], [-91298], [-56676], [-6610], [75450], [-98712], [-49850], [-43902], [50188], [59852], [-81760], [-31980], [41236], [78912], [-39742], [10818], [-86694], [34572], [-60384], [-51100], [-78626], [51986], [-12186], [-35220], [117514], [39330], [-71956], [-83544], [27736], [81600], [33624], [54146], [76374], [-65634], [89210], [-112124], [-45426], [-73766], [-105326], [81696], [-56338], [33304], [35778], [-58732], [-113874], [28824], [45772], [-21342], [81950], [1168], [-60734], [113492], [-2798], [-116534], [31296], [102266], [-112006], [-43602], [-58344], [25040], [14136], [108182], [-41024], [73164], [-25322], [-112302], [56648], [-112512], [-17418], [-122124], [-21834], [-47766], [30256], [40398], [-91252], [-85362], [-60030], [-47504], [-24878], [140394], [93344], [1572], [-41092], [-69314], [-100932], [-151090], [39756], [-23276], [-21648], [-76206], [-98052], [-84824], [-46296], [26582], [53634], [5940], [120754], [68904], [92396], [28426], [-148230], [3502], [173982], [177590], [-154780], [-26768], [-123552], [-112002], [-41578], [-120018], [36476], [179508], [104348], [177804], [-59434], [-44418], [140378], [-974], [117676], [88158], [43626], [-34384], [67110], [-149550], [-47194], [-62960], [-120300], [26862], [47804], [-14042], [178650], [46762], [-130390], [18438], [149328], [-43494], [-30294], [-127968], [166636], [90528], [-231696], [28506], [-137828], [-117986], [-59946], [-74198], [-167242], [200898], [-203404], [166680], [-169758], [-104848], [-133064], [86994], [88584], [138838], [119028], [-34994], [-211434], [-193878], [40138], [88974], [66980], [97152], [140132], [-56864], [-109064], [121344], [54062], [24678], [-212478], [-233828], [75408], [-110162], [93248], [-113592], [64868], [141270], [-78802], [168906], [219034], [-32766], [210378], [20900], [66736], [21564], [271348], [-24474], [-229418], [-119838], [104628], [-54988], [128866], [34098], [150504], [-102734], [22002], [71136], [3582], [-115124], [139296], [-147594], [-10478], [156930], [-142980], [-185808], [-97900], [52560]];
    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_c();".
// 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_c(: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_c();".
// 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_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_450_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![14, 1]>,<11,R![6, 1]>,<17,R![-78, 1]>],Snew);
    return Vf;
end function;