
// Make newform 225.6.a.l in Magma, downloaded from the LMFDB on 23 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_6_a_l();".
// 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_6_a_l();".
// 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
        poly := [-60, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
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 := 6;
    raw_aps := [[-2, -1], [0, 0], [0, 0], [102, -4], [73, 50], [-164, -32], [-677, -136], [-1625, 70], [-786, 12], [2000, -80], [-1098, 1100], [1202, -384], [-14077, 400], [-2564, 2128], [-13652, 1544], [13114, 752], [-5000, -1960], [-11198, -2000], [-20823, 1586], [43148, 1000], [-34589, -1112], [35250, -5020], [-45861, -858], [41625, -10440], [-57598, -10944], [-29502, -14400], [113636, 9048], [-80727, 1554], [-108250, -13440], [-8711, 10832], [180502, -2324], [153348, 4800], [43923, -35616], [-18625, -24210], [-262000, 36400], [-71498, -10100], [21602, -44304], [28961, 40818], [-182052, -8136], [-124536, 22512], [-414875, -23230], [302402, -18000], [287798, -56900], [67061, -20472], [562098, -19056], [-66500, -12200], [269177, -88350], [-435964, -78312], [-4252, -49376], [-7500, -51520], [-900486, 16992], [-176000, 140960], [-218423, -17000], [175623, 81750], [-1053102, 136704], [-1431586, 28732], [-98000, -112720], [1600102, 63100], [1066752, 94976], [286098, -45600], [-1101639, 20858], [-1711686, -122928], [-1146773, -139154], [-1859802, 105900], [850586, 147168], [134948, -154736], [-1616973, 220550], [-642173, 136816], [812473, 364994], [-670250, 257200], [-638886, 171552], [831750, 156540], [2309052, 217736], [415786, -600512], [284125, 135730], [-37986, -557508], [719250, -515040], [-3176348, 26656], [1974123, -142200], [-110875, 122160], [-4028875, 207730], [3130852, 157600], [-2859402, -377700], [-1462139, 426808], [-359000, -451760], [-440061, -280578], [106375, 443000], [3668977, -385904], [798948, -644400], [4714836, 324968], [1562948, -412736], [2427750, 75420], [4307702, 359916], [2298548, 521200], [6056500, -143600], [-4372636, 670552], [7792750, -45760], [-2314477, 378400], [-163589, 633238], [-828048, 285200], [-8821973, -423794], [5792148, -206496], [-3552336, 427032], [-9722625, -541920], [-6855148, 736800], [-6189373, 565776], [-913077, 1671534], [5967689, -64928], [3527750, -901700], [-1806373, -465000], [-1121648, -1161104], [-5112914, 1113568], [9115698, -155136], [11394500, 114720], [9524902, -1312100], [-7628202, 129600], [7355436, -1459072], [-15241652, -646456], [1325114, 1563952], [11117875, 292790], [-4828448, -994400], [10401786, -682912], [907248, 1722624], [17356389, 733242], [-4827173, -1378850], [5671748, 1608400], [3200500, -371840], [18584250, 678180], [-6179248, 685776], [-437764, 2039808], [-519500, 1468240], [-1427186, 865772], [-6525248, 2185600], [17730352, -1101104], [9544323, -728400], [3606125, 1263720], [-3028536, -2595888], [-9039548, 566416], [18754598, -976256], [-13785250, 564640], [-5091948, 1248800], [14215398, -2810400], [-1689964, -3170712], [3958123, 324974], [-3361500, 3033680], [-5830000, 1930960], [15349386, -86752], [6309523, -95296], [-5290625, 274510], [4966664, 3112432], [11895252, -2066224], [6518098, 4366400], [-25193389, 966558], [-5956452, 413784], [9108852, 2055296], [3679948, -2198200], [21519250, 2975620], [-10942750, 3521920], [-10717173, 3463016], [18438548, -1863200], [-39946152, 996744], [-5646761, -550048], [-32214448, 12336], [-16922727, -733950], [-2211377, 3261224], [-44473986, -1359108], [-22978798, 1950900], [15077652, 5482256], [-30743875, -3344040], [-4285336, 765232], [23902875, -4011570], [30953602, -102800], [-9561402, 3501900], [-8929389, -898792], [24163000, 1683040], [-23148375, 2761800], [8809377, 349850], [41383698, 1506000], [-25176664, -672432], [-32396750, -636080], [-9410548, 907416], [-42959827, -575150], [-44091314, 3524128], [2922473, -2029256], [-15342636, -1439448], [1283500, -3714160], [6236802, -4294864], [31484911, -635162], [22879625, -5184720], [10199248, 8288000], [-17345489, -827552], [-35416961, -574618], [-4552023, -2176750], [25406098, -7908400], [-45963327, -2086566], [-22534186, -820928], [32968627, 3239200], [-27711414, 8427968], [65265573, 1054464], [-38848786, 1679212], [-56093250, 4570320], [15830652, -3638200], [3587952, -1491184], [-21066125, -2106800], [29155500, 3320640], [-16651002, -4999776], [37235750, -7204020], [-6843236, -4279408], [-21366750, -10883040], [-32485048, -3171000], [24086402, 3233856], [15402998, 1709200], [-53904864, -415552], [-42237227, -5596246], [-35553750, 7677780], [-10625023, -12732000], [-75401498, 4138876], [15169323, -6180600], [-26607802, -4005236], [67175214, -477888], [-40320098, -5387600], [-47642500, 10217400], [46032375, -620760], [-15508214, -5686412], [-99130627, 5238274], [26069750, 3983280], [-113040111, -1506408], [61148000, 3036160], [22104652, -14531144], [-88079877, -2556450], [-101608614, 3910448], [113789125, -5380790], [39734102, 885900], [43652473, 3408200], [-17254264, -2525592], [10095798, 13254684], [78934125, 8212040], [-36166936, -11581328], [-1460625, 13017750], [-19850052, 9996600], [93296589, 1952562], [33506277, 11565650], [-45753314, 13526428], [-37879500, 2489600], [5188989, 12211152], [7468000, -14088160], [-20443198, 16032036], [46374148, 6569600], [-8891875, 3501330], [42136264, 8015792], [-85752848, -1479344], [-19433627, 4064000], [7843398, -940596], [-79125, 20179160], [49804664, -11528768], [117097875, 1591830], [-126323648, 3836800], [61060877, 13579026], [-67667202, 2215584], [-3120523, 12277296], [70704586, -1161932], [-9688177, 9684814], [23729000, 6372720], [46523436, -24848272], [59097723, 9229944], [43625875, 15224350], [129021250, -4273360], [25606898, -4308800], [-45825589, -5491962], [14783014, -16453408], [142890452, 10849200], [34257277, -7501094], [207484511, -906552], [73905000, -12409840], [-134935998, 3464576], [67311236, -11658792], [127993173, -2673366], [-119019000, -13950160], [49457502, -6750400], [84105573, -16176750], [-172357036, -186488], [-106033598, -446300], [-66206152, -11577056], [84038052, 14314400], [-56453823, 11535386], [208530648, 3830400], [-126767714, -8410112], [46135248, -28118976], [-114676000, -756720], [116910750, 12975360], [-131459002, 13916800], [171466148, -2187296], [47445789, 541032], [-25488777, 12008550], [-91979764, -6493392], [146867250, -9285600], [177358502, -1894500], [82837464, -6000288], [-98605500, -14483280], [42921077, -21722934], [-43430439, 35882528], [168662098, 5655344], [-90848000, 20009200], [119730489, 27461802], [-249487823, -9876950], [-199824823, 9465336], [241805748, 4815024], [785750, 25530480], [135944250, -22142940], [137819886, 23450048], [-142055586, 262332], [-13751250, 6557280], [-70752777, -21851400], [92887736, -23908392], [-32282452, -10616216], [22297750, -14754560], [-62322375, 14363850], [163223448, -13056000], [-64190289, -25083232], [-76201875, -26318880], [63691652, -5338800], [47232077, -27572784], [-131793452, -27320800], [-91725314, 34627228], [-104689386, -28381248], [115368802, -16368800], [-107824375, -27911070], [95416636, 4544848], [-293163102, -1109196], [-234522836, 8449232], [81144852, -40536400], [-320620202, 9861584], [-268846750, -10690860], [407655689, -8331878], [78278627, 5522550], [46741448, 36574264], [-22663000, -22844880], [-266086786, 1678912], [-318608473, -1582200], [249141702, 18241916], [210760936, 29519728], [-338695777, -12415856], [4649250, 11289840], [148418052, 4467800], [-151964486, 22192592], [40768500, -29713440], [-63083548, -8856000], [-107122223, 19684906], [223237248, -29043600], [-165079102, 27651904], [-89450523, 16629050], [-168559998, -18310624], [41688098, -809600], [-36360764, -20937992], [380423250, 13105040], [-331370811, 1958472], [-188183500, 2953000], [163386573, -41587350], [122671698, -2939136], [-326528036, 16625912], [43635202, -48067184], [-121938827, 38909000], [255272598, -37818756], [-34281500, -42267760], [36945677, 20019786], [300163411, -22454312], [29008248, -3761376], [-82785864, -605152], [17129477, 7329600], [236913348, 46608000], [-496112625, 529790], [-135706436, -6415528], [46420500, 2022000], [94714752, -15032800], [159520102, -7813904], [-32123375, 62307770], [488693298, 788100], [-447409189, 1824528], [172704375, 42303240], [105300802, 39869536], [-161450602, 1356400], [1326639, -20482608], [7934152, 58663456], [-40326727, -64950896], [337248000, -303640], [-25488086, -42602668], [398182352, 510000], [-232433248, 8683776], [188582736, -30908392], [-106488702, 18060084], [-292261125, -3402160], [-71470436, 49511072], [-138544625, -15207850], [389633477, 15807546], [187745698, 63446900], [171156461, -59112432], [-17600500, 64105320], [-56582625, -14491680], [93008527, 39415150], [-654401202, 10827600], [-61397000, -53475200], [256901739, -15155448], [-284687948, -10036664], [-181310377, 82772224], [70598000, -44991440], [47754952, -69644000], [136376402, 34925856], [383766998, -9718400], [517218636, -3681952], [91479375, 59748030], [-216671889, 3502208], [-468383952, 1968384], [-16294061, -43852978], [181149252, 11066000], [-521350273, -8972904], [-251943302, -14042800], [-56652250, -45210980], [227947702, -33771284], [-137463777, 63657144], [-513068386, 26245852], [610250000, -26172560], [-352755698, 54396736], [244491498, -29534076], [257348875, 12445310], [-309879739, 42213648], [-89866352, -29552896], [547330664, 1545832], [-118171875, -4026120], [-491837773, 50370150], [-422560250, -59764900]];
    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_6_a_l();".
// 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_6_a_l(:prec:=2)
    chi := MakeCharacter_225_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_225_6_a_l();".
// 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_6_a_l( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<2,R![-54, 5, 1]>,<7,R![9036, -200, 1]>],Snew);
    return Vf;
end function;