
// Make newform 450.6.a.c in Magma, downloaded from the LMFDB on 19 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_6_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_6_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 := 6;
    raw_aps := [[-4], [0], [0], [-158], [148], [-684], [2048], [2220], [-1246], [270], [-2048], [4372], [2398], [-2294], [-10682], [2964], [39740], [-42298], [-32098], [4248], [-30104], [35280], [-27826], [85210], [97232], [4298], [-124114], [-42342], [-35990], [-228816], [-175238], [-299652], [107928], [-196460], [-138850], [416152], [-433108], [-149134], [-559602], [343804], [-23980], [-651898], [-202752], [452656], [337468], [-561000], [-805548], [-1218554], [564338], [560330], [-293576], [-584240], [-563798], [1019748], [657408], [-562366], [-366570], [1160752], [2515012], [-2086002], [2238026], [-975756], [-87858], [-599352], [2093416], [-2416252], [-1640948], [-2187728], [2745018], [-2651150], [3057664], [-3793560], [3110602], [1415196], [-3902620], [695674], [-498290], [-1095668], [2491598], [-3633490], [3643780], [-1825298], [-2854352], [587776], [6116040], [-2357706], [-5497350], [1160392], [2303298], [-2713434], [4050498], [-5605280], [-7131678], [-5881452], [1757100], [4914114], [5754990], [1619798], [-11911654], [4076302], [-12368018], [130308], [-5916866], [9030130], [-10709348], [1220512], [-14710422], [8520144], [-2901000], [5727602], [8799242], [-1034084], [12985448], [7920020], [16821752], [15515398], [-10580094], [13788318], [-1589236], [9124340], [6503102], [2178096], [3984188], [-5915626], [-15547148], [22710298], [6298410], [-21191120], [-13561038], [-26941324], [2774140], [18553794], [-2192848], [9487492], [-9695802], [9327870], [-9680796], [5523022], [-17111932], [14530890], [-21354548], [-36796702], [33066846], [17730938], [12937530], [-33181240], [5172236], [-10531992], [-11474140], [19272234], [-23052388], [-22669002], [-3673374], [33964878], [21332742], [10351248], [-25901880], [31322970], [20846072], [38292898], [-42508782], [39185464], [18483602], [-39503052], [32904288], [-26579726], [19296352], [51201732], [-14656690], [28293684], [-60158820], [-28418898], [-29367752], [-44408824], [-48286160], [20614650], [-2948548], [-30848502], [-47700434], [1521770], [-63277478], [18298748], [27716156], [46010568], [-15346886], [50364390], [1822252], [-46061854], [10817630], [-77258752], [-39610464], [-11157466], [-26776748], [17944698], [64773378], [-70039656], [-42246198], [-36121884], [-53084352], [-45582446], [-22174530], [-6489648], [15273972], [67047550], [-77639060], [90175188], [-45705120], [1895774], [-55176790], [-3292148], [-54897568], [3251298], [26575886], [-7619142], [14153480], [87048802], [-25060438], [-101606002], [-56155202], [35843804], [117105102], [48046600], [-96986910], [-86367754], [-122525262], [103251330], [-148574776], [5168960], [23912882], [7320148], [-68289964], [7745260], [-123240448], [67551198], [35469226], [-122447722], [-105147210], [141295444], [154700700], [102537048], [-48887346], [17919452], [-8337794], [-85053950], [7658864], [-117297960], [-81544998], [-86795652], [-134255020], [-34700326], [126391932], [195251998], [133632958], [11001310], [-75157316], [52802580], [-72041498], [-96485338], [102229228], [-81598408], [109850166], [-95770702], [67568170], [196098356], [79463568], [102770300], [121973790], [-155775002], [-75622454], [161247924], [77480702], [42227582], [-102076264], [177098560], [86292112], [259888526], [81521578], [27159890], [120271202], [234543948], [62898954], [24370952], [44284318], [-59790698], [65522102], [-179767952], [-249566304], [-19068212], [74345480], [9169210], [125877898], [37047858], [-17107416], [118896948], [-14128124], [-45682650], [284878752], [-322590396], [-9851780], [-16078578], [-141736744], [-125515932], [91070000], [-24451986], [138713852], [245379952], [-74133062], [-88517470], [170959160], [109597836], [-300990966], [-41623770], [19042398], [82759026], [-23303122], [132640790], [-77317900], [-91445152], [-169693184], [122248170], [140327252], [1617272], [18398298], [-68567594], [200489064], [169535402], [-344726820], [236060586], [-119692042], [52226084], [44803702], [255595028], [434450240], [7771294], [352693452], [107797098], [-48271430], [180381504], [-115542398], [178263322], [-336295044], [435464968], [-131293010], [-397145848], [338345324], [344656260], [331883502], [461236982], [-47274352], [-300794292], [28500452], [-325601688], [280551498], [-399719274], [18214490], [-254408856], [426897600], [229203348], [880448], [-400315246], [41403172], [-307462602], [-572627082], [85665340], [70006302], [-27826904], [312479988], [122338686], [398342802], [156903548], [303815540], [-141832006], [388653150], [-513082248], [-216087108], [275182420], [268199648], [577167456], [17298090], [180799352], [-7081902], [160342024], [189979682], [-113573792], [334099260], [311884434], [71747952], [-409589788], [175733226], [-189563722], [-301726810], [281739444], [-185418900], [-583847458], [-238632952], [389383816], [174977120], [-647349430], [148783052], [-378427902], [-560985350], [-571979536], [447268202], [-198134712], [246760110], [345558152], [426553932], [370233198], [-478589614], [-282629820], [69986576], [565661628], [390944694], [274364452], [297611992], [856342498], [745412320], [-226106478], [575528768], [605856114], [332496390], [-306762748], [-54825562], [288902460], [-92094664], [-472561692], [-555462866], [45348530], [541747452], [154235800]];
    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_6_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_6_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, 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_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_6_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_450_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<7,R![158, 1]>,<11,R![-148, 1]>,<17,R![-2048, 1]>],Snew);
    return Vf;
end function;