
// Make newform 225.6.a.u 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_6_a_u();".
// 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_u();".
// 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 := [-22, -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 := [[5, -1], [0, 0], [0, 0], [-66, 24], [-138, 108], [-606, -84], [218, 140], [-704, 72], [2908, 88], [2208, -864], [-5896, 144], [-7146, -396], [606, -3024], [3108, 1344], [2264, -1288], [-10082, -2012], [-26994, -3348], [-16654, 3168], [4872, -4560], [-10332, 3240], [1332, 792], [-33440, 9360], [63580, 6832], [-66006, -4752], [-34968, -15600], [-109848, -6912], [14478, -25176], [39404, 28112], [64186, -37728], [55630, -4988], [-113058, 57960], [40314, 12852], [26870, -38476], [-152036, 23328], [156372, 26784], [-63688, 58320], [121170, -44484], [403056, -36720], [-243604, 32456], [423130, -7028], [-243090, 95580], [-392686, -6336], [157092, -103032], [-419340, 36888], [286382, -41692], [-130592, -89424], [271484, -19296], [567174, -153384], [-222844, 9296], [253414, 13248], [720682, 36076], [-43716, -100872], [-1179562, 81792], [-1357542, 142020], [-788266, -106828], [-996836, -205640], [-603936, 92448], [-422152, -173088], [-577002, -40908], [-1229070, 225504], [68784, 193776], [-1084706, 420100], [209556, 379008], [-1575708, 26568], [-1682124, 14520], [2028074, 131372], [870872, -93960], [-1711572, 262632], [1969388, -72160], [1091002, -752256], [2845066, -368756], [-1347264, 50112], [-477282, -253848], [-3150462, -135876], [1106980, 255600], [-1302416, 569320], [1869996, 88992], [-4396554, 207108], [-1676886, 674352], [1243414, 497088], [2463954, 366228], [952070, -167904], [3057696, 349056], [-3325644, -154440], [-1600160, 212400], [-1542524, -30896], [2932002, -802656], [4393824, 62304], [737268, 51840], [4789338, 524184], [1695404, 590432], [1481340, 1266840], [-2053998, 277560], [-2414886, -861948], [7088896, -552888], [-4364984, -548456], [2580576, 45792], [6629706, -381024], [-1150992, 602064], [1526474, -2327616], [-1051716, -2204256], [-1815802, 1112180], [-3069260, 675232], [-810006, 915408], [1463768, 704952], [7801632, 131040], [-8765716, -992368], [2623822, -3045884], [-2831808, -2578176], [9617378, 703872], [8772042, 1331400], [5550750, -889452], [283130, -961396], [-3071516, 1844208], [-2583808, -3132720], [3791166, -1802304], [5385048, -181776], [-5982352, 2753960], [-1173086, -2332100], [-1904550, -1866780], [2210642, 2501280], [15795372, -1420728], [9841802, -1057492], [4958044, 2151040], [-2515432, 715752], [4791744, -749088], [-1338674, 3644352], [-3248568, 223344], [-6489390, 3215256], [-19516602, 429684], [4728904, -2106792], [20843272, 786616], [16921088, 2306592], [2530710, -2085804], [20533170, 5184], [3883618, 572256], [-9010766, 4703260], [-12241824, 1283088], [2539754, 226892], [25913790, 1252800], [-805948, -3175200], [19536360, 3348864], [-8173830, -3435672], [-6919612, -2063200], [17533330, 1749600], [-19632840, 2538000], [-144474, 7352580], [-8308606, -5015908], [4040740, 2774160], [3188932, -1128344], [-10852206, -3348996], [-11680110, -2135376], [-11893032, 6670224], [4651244, 2924552], [-21156204, -2992512], [-1049232, -2151360], [-33600800, 3576960], [16736034, -4214592], [26904168, 1169712], [-8271204, 4129056], [25362860, -3502576], [-15076874, 1701364], [23414502, 1637400], [-4425894, 7878276], [-14532382, 6872060], [13859248, -4623272], [-7426888, 7038720], [-6183750, 3685596], [7657270, 2884320], [18262450, 347452], [-9154986, -9441252], [-1123714, 5139648], [5374560, -2159136], [-934404, 1037640], [-48036248, 3593664], [-44503806, 129168], [-20479756, -7121376], [16958772, -8271072], [-46632222, -710136], [1187590, -5456160], [-14204766, 7255464], [860082, -12643452], [3108390, 6496548], [-60086986, 2549012], [-21158288, -129944], [38233020, 4851360], [-55099998, 2274300], [44211504, 2766576], [-34801838, 3062304], [-46718820, 684504], [44234028, -7061976], [52404700, -6555248], [-7318204, 6450768], [-59783628, 757728], [-17658772, 13222400], [-29532050, -8827868], [21139118, -6795648], [-2023710, -10027572], [-19982506, -12198988], [3508144, -2615720], [-11004348, 6208704], [-921424, 930528], [-54927942, -555108], [26937166, 9116352], [61821702, 5457564], [37932806, -10744204], [55443616, -8777808], [-27056996, 13939360], [82522002, 2811024], [-109705960, 717336], [64403100, -8309304], [2647668, 570240], [16854222, -4087608], [94671788, 2987360], [23264196, -7679448], [12114806, -8157312], [-28577850, -10779864], [40223274, 10485072], [-28236328, -9108472], [27391222, -17225804], [-25565410, -17280864], [-35053208, -12377376], [22725150, 7467120], [32690610, 10471608], [-5604436, -6612928], [-39444530, 3350880], [-36006746, -14347340], [-37476936, 18061488], [16824426, -2581032], [61486710, -10018836], [-64155558, -12277668], [-2543204, -1966608], [-68793472, 12321072], [91746354, 12517632], [36170760, 19317648], [-14460412, 14626520], [22939102, -18827136], [84287014, 3401140], [-41881386, -11026692], [-34503516, 7427592], [-87807740, -12143168], [64445600, 17076456], [22190946, 8755080], [10522618, -9808704], [-25861166, 14913340], [8536116, -10461528], [-75983562, 17471592], [64471566, 2153196], [-89275976, 9876168], [-71710436, 2960680], [-70335186, 23987604], [-126361602, -3283200], [-1186084, -510424], [53785894, 1914048], [164485894, 5487220], [-89693622, -10097244], [119471402, -6033600], [132267912, -9469200], [11696942, -2619292], [-53148492, -1195848], [-93680682, -14098056], [-52411324, 7674416], [-46034378, -20537856], [-120926970, 11828628], [-55347562, -406060], [3925048, -33600744], [40787964, 844128], [43575774, -19625328], [38139072, -37608528], [71496010, -22759508], [-50060530, -22610304], [29407716, 32283648], [29478756, 10934040], [-83500568, 5606784], [117372396, -14567352], [148240206, 17222760], [60044372, -35638432], [41795050, 8737920], [270758, 38408832], [102268986, 15332436], [-52294652, 15436168], [-48839680, 4216896], [-73082344, -10409464], [-20427322, -19945728], [-69703764, 10249248], [198525996, -2583144], [122764536, 29389680], [-37405990, 18726284], [147419032, -26024256], [-31121010, 49012560], [-121049508, 16879968], [4785644, 33233792], [80592994, -26339780], [-28093650, 31762044], [-24374274, -26144700], [22160580, -62735040], [-177554128, -819360], [46160626, 51685084], [-103275450, -1701540], [-4130220, 33072576], [-89049180, -20356392], [-6478990, 40098524], [-146724968, 13088304], [-7526780, 18585232], [198053216, 27006408], [-86748768, -5855040], [-72192676, 35200592], [-150681914, 40151232], [134966724, 23039208], [-31502142, -14539716], [63407812, 12963016], [-72451296, 8987328], [-21649134, -2353104], [52451196, -75617760], [221291264, -14716408], [-167027114, 17294112], [-78255762, -24784164], [-76598412, 32023080], [-29640588, 34375512], [-99457122, 18637776], [30998984, 36824904], [280882164, -11380776], [-133645608, 15886368], [-112768182, 14334264], [-289561118, 15619996], [-124849402, -42285888], [123917740, -44797680], [301295676, -9330720], [242594240, 15898904], [47619970, -17094308], [238211942, -11106720], [-24839722, -46177900], [178274200, 24779520], [-46782284, -56922416], [73412156, -21380112], [137652140, 17898224], [-234116642, -40104864], [36648730, -27811028], [114426746, -54292032], [274492062, -15597720], [-55153662, 17617404], [183496946, 10715516], [-242936184, -11492928], [-44929408, -6491520], [97615030, 21917332], [185662710, -53457300], [-407154274, -6787872], [-220765332, 25435392], [-274142604, 34190856], [8882642, -43659652], [113191028, 8757072], [198490608, 35236512], [-31313904, -89139744], [-451583466, 15562776], [-269001854, -9989568], [75554530, 26444092], [49380864, -12595392], [103497390, -24596676], [46147022, 57435428], [-68437220, -17471528], [-69482838, -51418020], [-354081810, -16823376], [-373122448, 46469048], [-28372794, 62280252], [-349719624, -6949872], [258085632, -63194208], [-88038202, 47457620], [133280190, 78453288], [-295292662, -37063008], [545609670, 15700284], [-151558364, -5483088], [119474848, 97174888], [32385504, 87019488], [-247624120, 34493616], [-61913466, 97574724], [337870374, -49122612], [-424008216, 12130992], [-302004936, 55120176], [-252561438, 26097984], [-109354584, 74840208], [57623028, 31246560], [70375582, -86908124], [-10369242, -66200328], [-476455702, -24034420], [39073492, 15064704], [-231968828, -12562664], [-34808440, 23296176], [343452126, -71723292], [-101578572, -8333856], [-302681476, 83897912], [-74573006, 98985888], [-459900770, 23445892], [491288598, -20567844], [497046984, 16551024], [78665064, -54297648], [-162220224, -87689280], [176326360, 21268080], [-246474474, -30379968], [-321571576, 89729784], [461821620, -4422816], [-501309602, -795744], [-21803834, -56889356], [-235209786, 34466664], [24492086, 9877556], [-4745376, -27780192], [-117713536, -10514736], [243363822, 98959380], [-517214118, 11248848], [473343216, 14786160], [158257506, 68337972], [-206184696, -39337584], [-401457946, -51289228], [382067908, 14451808], [302390168, 3718152], [-625811244, -41500392], [-513466560, 27402624], [-99206136, -9439632], [-339734514, -61936392], [662707406, -25787164], [-613970684, -53895656], [-486430908, 91191744], [-45280782, 53521452], [-509180728, 3605048], [216745386, -11668428], [-489140676, 38859336], [24235334, 157961972], [353496748, -21160592], [-115439850, -100582560], [-6179632, 45989352], [-60412344, 61409232]];
    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_u();".
// 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_u(: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_u();".
// 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_u( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<2,R![-2, -9, 1]>,<7,R![-9900, 108, 1]>],Snew);
    return Vf;
end function;