
// Make newform 225.10.a.f in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_225_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_225_10_a_f();".
// 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_225_10_a_f();".
// 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_225_a();"
function MakeCharacter_225_a()
    N := 225;
    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_225_a_Hecke(Kf)
    return MakeCharacter_225_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 := 10;
    raw_aps := [[22], [0], [0], [5988], [14648], [-37906], [-441098], [441820], [2264136], [1049350], [-7910568], [20992558], [-13285562], [23130764], [-13873688], [-57635174], [32042120], [110664022], [118568268], [-276679712], [264023294], [448202760], [851015796], [-189894930], [1014149278], [1315368558], [1827972724], [185367372], [1978689590], [1578746686], [-2400005332], [1968395208], [-2029094538], [-1136729140], [4738537510], [2262162472], [11788859278], [-11460793796], [-13370656008], [10626363186], [-26125435120], [2346889262], [-22406421032], [36595949974], [-5415455718], [262713880], [13449310292], [26646265564], [33631791932], [50045292150], [-32962559874], [7954217240], [-75247743998], [98463127008], [8523991422], [5906543816], [71596101350], [-124754651888], [-112824180402], [-87020807922], [-3276964236], [-149860164294], [184569910148], [-90464979072], [-10793038946], [41831934962], [-12330976908], [21797581958], [-84361290188], [-1232948810], [173387723766], [-63815917320], [-112241606052], [-721003873546], [-204331000340], [-547180000584], [346262180070], [-256757692282], [-20167945242], [-43340521510], [-510680461160], [321228183382], [-447617411472], [141185768294], [-850497697160], [303187912836], [1403278417670], [-335353598362], [-1042749631842], [974083754244], [-197850678508], [908731105320], [-1169629218932], [2491486068688], [-557571087620], [1801366855856], [2401096873670], [-1030077035282], [-1066369079836], [2517486023382], [1103529331028], [-1090720039758], [1030805225676], [4066175272590], [986144387492], [2869473138238], [1141694898732], [-2971762606354], [-1772617523720], [1258381908842], [-174534604492], [-4630369457746], [2505177639342], [544227615740], [-6519747334448], [3362965780158], [-1180819220676], [6631762482592], [825189215186], [440214037640], [9777884642542], [-4225910364186], [-7569770190918], [-1920285453924], [-3998388906788], [-11273616080282], [11267900052070], [9052470846240], [-1344083568692], [-657401165786], [2155870422700], [-7735942623584], [-11244801937688], [11854438840718], [2247651763758], [-14450525662270], [5190224051466], [13993847295788], [20126878481762], [8957747618710], [-1764457434948], [-14808178742322], [3396507315724], [18834421634452], [11894665629990], [12288146871880], [4613545257054], [-4293628278338], [-6404282426420], [-3244207905184], [-28971147004722], [-7504473544522], [-28714133607236], [9998251603512], [-4708461943572], [-26966252086912], [-3966177723440], [-19691225561210], [21130483382598], [-5410718200082], [3442590745932], [-4184403332234], [-14980025803772], [28246046905488], [-46224186526778], [48036293325216], [23121091830512], [13536183450678], [-41987845907710], [-1167615577654], [46523027825880], [367060316782], [41474087908728], [33508800446094], [70346149493560], [52860830823150], [-34661808711348], [-62238513689322], [9398819829724], [28580327680270], [-71531991771452], [-28015218825512], [2939985051614], [-10077896652298], [-75356904130824], [-6257545039930], [82273327426158], [14889847412204], [-46893024564070], [-13042516444552], [-43257136599946], [-10840442879804], [-118601692274268], [-46126852237762], [23917755596052], [72033402706166], [-158865736718], [83065379938974], [132056053534062], [48459354819296], [13339860479790], [-4798093648008], [13784340796998], [-86364229545710], [-49311660661560], [-91650785988318], [-29974559449000], [-140644672891124], [-103673485819170], [89768078333972], [-64356387277802], [-136555186848842], [116840844400164], [-158626634880188], [-71110565286720], [139927069249562], [-81915325688212], [208739652856038], [182183272270112], [-9003952231614], [-82375966495658], [-190930423838200], [94411316392350], [10974971735924], [-241238710064668], [-45976273968250], [215889255582006], [-152272787114720], [-142199752260292], [143206993696488], [236543936294574], [258235934072740], [-58682903434768], [-158019490958962], [-256323984443756], [-145462109989728], [293265229677810], [132706976807306], [141906852830520], [214007320678608], [343383606232476], [248554130611332], [296888764553084], [-91718882836890], [-134351725029834], [-22019431679680], [140026129122748], [-176274133569952], [-221675710145020], [215122827985936], [-443382792756442], [68191185798398], [-408105772689528], [-392360745882150], [-248276606211454], [-30888014916600], [-297213402929858], [517726004334148], [-454868763466518], [543566323416478], [-220480326303556], [235236315224732], [-542265239112250], [-290702731505706], [-15344499280578], [-244941067585940], [134849523663710], [536047897053238], [578362636464004], [-356714523611174], [-358815581200258], [376311542883428], [-333027078264146], [-267986194162440], [-472417645390842], [-345412130151836], [300265118998212], [183152409453030], [172485262105962], [-173489029931352], [261082164530576], [50480761307512], [-307283989728448], [-474021218090538], [889854246476988], [283187390877768], [-6715192961266], [-11210264579478], [430019292135800], [672570398149470], [-413915447358722], [-1031047379657068], [-642895372600434], [252739644217368], [-551214855740906], [-845185232536050], [-272349564569848], [590856010357866], [203551868522760], [54962912722228], [726051717136494], [470318815412242], [1271189367452800], [95512964340276], [391920144638452], [951557215984078], [-172580308238388], [841575353380430], [-258689357399520], [221598197065734], [-1384435463478864], [784267786451070], [348759918748758], [526996236033604], [-445449447101728], [-28916912231270], [277855582824720], [1415451086497608], [-1751871157045146], [-1129027850048130], [953379202162172], [-1113605926526882], [501284686184918], [-1163601531793276], [-1207943400185394], [696342397523842], [231125059431620], [236426209710524], [-319893108748488], [1335989379653626], [-258374703224418], [1198287427746082], [-755139802836760], [-627672437276284], [438607517559692], [2216024620249052], [-1825798832064610], [623858784250886], [-522772646818678], [-1217375618279892], [2063409132125894], [-1225745225329378], [278837276995950], [2053709208008472], [-1172859895684334], [951055370046000], [-1929591201661498], [246489945016508], [-618739089156792], [1246125800977802], [600217425759252], [1169402598146118], [-2752873428297482], [798680090927084], [911888374241550], [589431287521806], [862101490432240], [-787961436179832], [910337769518862], [2423801795971576], [739929215472278], [-3404691083276362], [-2881259263043928], [-1559377311548440], [773976503171788], [-149086016961226], [-1030359881297598], [-2964659572284156], [1193227097864282], [3071726045597808], [2038868830017180], [3874951231958536], [-3607010707044690], [2522218508572632], [1774005964606118], [943162837271120], [1399517652151488], [-919358064863186], [2903766502691670], [4703635600624358], [-1740255847662482], [-3292556819078154], [-4425473832836572], [3833287677350342], [-3303193228237740], [1210997653061176], [-3052167227613928], [-1232475112619282], [739986049990284], [922154354403072], [-1665000027828990], [-3866800146289574], [-622750605505480], [-2894148102987332], [2429582949667448], [817190914315414], [-4664487561777040], [-1577290481912970], [2285367576887812], [2399704641767958], [450349215392590], [3074298609160686], [5023314046819388], [-2308634030325658], [540356250869950], [-1337398217888], [1256332709107078], [-5718115964377562], [-3172483387478916], [-4871841965969880], [-4235748105155586], [-2374711858330518], [2437655501216236], [-4815030434944548], [-746086535556482], [4169725530487238], [2798411369658400], [-3616440877338652], [-3327192753069858], [1874622366446216], [-4488934339666130], [624777126938678], [2748333447276792], [-5850594928028800], [4395801723072094], [23332760054002], [5489326431648116], [4096826205094470], [-3128000820676348], [-56939881916200]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_225_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_225_10_a_f();".
// 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_225_10_a_f(:prec:=1)
    chi := MakeCharacter_225_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 10));
    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_225_10_a_f();".
// 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_225_10_a_f( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<2,R![-22, 1]>,<7,R![-5988, 1]>],Snew);
    return Vf;
end function;