
// Make newform 225.10.a.k in Magma, downloaded from the LMFDB on 19 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_k();".
// 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_k();".
// 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;
    Rf_num := [[1, 0], [-2, 3]];
    Rf_basisdens := [1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    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 := 10;
    raw_aps := [[15, -1], [0, 0], [0, 0], [-6944, 224], [9572, -2368], [-14814, -5344], [-82238, -7520], [-45084, 5728], [-380768, -26272], [1254818, -168576], [5467584, 152736], [-11083414, -198496], [-13276234, -492096], [3244412, -702336], [-16775384, -1970528], [1654422, 177728], [15573156, -4348352], [170273566, -950208], [144611188, 1026560], [-107415672, -4545280], [116915638, 1168192], [-21902080, -19049120], [-189671220, -7260288], [218344134, 9049152], [-892554882, -13450880], [31369562, 76339072], [-725554768, 18530144], [-942457804, 32784832], [2202285486, 4944128], [-216546110, 67408672], [205274408, -148987680], [3720446124, 73759488], [-171588230, 8056544], [2696557724, -78164448], [-6860733238, 81457536], [1504738552, 74641440], [-4525020910, 218923616], [2734064964, 441527680], [-13602680096, -217991584], [2682470350, 97645952], [10818725580, 91033600], [16580596054, 440736256], [28426831152, -50322688], [5157600510, 197347648], [12222732838, -4988992], [4780779448, 622888224], [-21986291916, 573460256], [39328591576, 217101216], [-9727045396, -1943163904], [21919902054, -707329728], [14527621498, 1740473696], [-47028993136, -1410808768], [-40499632782, -921274112], [-35830918572, 302770560], [62201360466, 2641365792], [-1510369744, -2676122080], [-38313741166, -3901468288], [-39828564912, 2424273568], [-23028378918, 5051951712], [7910378950, 3070613696], [66002099596, -4180081024], [-88535669594, -6094350400], [22000400484, 1678970048], [-226418250088, 3932283712], [39901545894, -11648962880], [-216341820194, 3860016192], [-81793861268, 4094383520], [190440274702, 3914243392], [-123813516508, 9414546240], [-257577440098, -6198789184], [-399369068846, -2493738016], [37959466456, -9968108032], [120067883832, -3874085088], [-69644422278, 22646649824], [407613344140, -2376291360], [416630740936, -4461324640], [273054451546, 6480877568], [-152088444766, -18037391712], [-65817100306, -9219585152], [-107976483366, 1866094592], [431341744604, -20115925248], [264189521350, -30452016576], [383035491136, 24649266944], [-4484168306, -9052740800], [496233153640, 11974154400], [380039739764, -45199767296], [338159137662, 4989801856], [-46597973834, 29185669504], [4115968178, 11951695360], [-286723059768, -14186013216], [1011781915036, -31971974208], [1092091543040, 13139368960], [727692503488, -25724281440], [715821512644, -10952873792], [-483918022684, -75862493152], [-396174700416, 32289155104], [-117777702974, 30038673408], [-1417398505674, 42763842944], [600495544572, -20003822656], [-1687593850946, 60443684096], [-1638827087084, -2027062016], [661172868302, -130537329920], [-778091618740, 65027768512], [-1806128347706, -62047779328], [1256229807068, -108283921632], [442011439358, -51464515840], [3306421766836, 54720855872], [2251058826978, 32900418976], [-714715619128, 208452550656], [2140496646618, -4076876032], [-1998398920792, -50887058400], [3610415134410, -31483876192], [2080848788090, 173577434464], [-1016066784996, 222595998752], [-312390785928, -220860628640], [-2139543556834, -117520033856], [17063976292, 24946663424], [599320024192, 173337176800], [-3811587197554, -141835928320], [-3645082149300, -69801369920], [-1582685534218, -184650191680], [1049018462238, -43437826368], [-819836188122, 236616323328], [-6927667319004, -122231317440], [-2982564299532, 229077560608], [-3197635523806, 141338813568], [-7488785833914, -91615771712], [-2202459315408, 336446406336], [278948208880, -301820692704], [4863102957202, -243749661216], [5023419819444, 113158847392], [-4959462408432, 119784448736], [2904488261968, -54743940192], [14134316039930, -56714993184], [-13049459844410, -137613457024], [4350305156098, 41881066624], [-9402354909914, -141157819840], [-8314102131356, -174431446592], [8665831420126, -536761304448], [1680691003830, 63000724160], [-7643635709588, 234398792480], [8869515159850, -113327739904], [-6499744257280, 120212104928], [-2099710173148, 860390563200], [4753791493950, -315079902720], [-2781427565800, 79514213760], [8842472111194, 541877887520], [-7251772645014, 684658876832], [6538836794380, -648857853600], [-7899671750232, 537881271136], [4626314305666, -149545530016], [-13961335515090, 437788739776], [-5506774559468, -723661330176], [21001407691536, -307880897568], [1465726713804, 287092584768], [4084712329888, 1616765630400], [-10430961274520, 814449574560], [32587300257374, 515939296512], [4843244769142, 1353662945792], [1529199040466, -1718769707136], [-639634079140, -415241439296], [13081531881194, 81863860704], [-9723649623872, -639442456800], [15637708238116, -216554845696], [3210433760962, -812519523680], [5914514882592, 1176613260768], [-10220424948128, 1789201504480], [-4408792187350, -1947530825504], [31750269380530, -53453223680], [10347687550390, -298112270208], [-17849818560956, 1258565941952], [43066576603166, -235237305088], [-715482746520, 58905265536], [-56516996750346, 535363462080], [-45682446297248, 64595007456], [-24030315211066, 100589874112], [-24196786484836, -944891002784], [-3776018142758, 799669425152], [68779220178352, 113024822304], [-17968909518610, -1887438019840], [-19700836929464, 2812345538784], [39137755350732, -362337692608], [9077891217610, -1328839655072], [-16470586157254, 2568374069792], [18286530843128, -692993648864], [-25904089816470, -141471374720], [-12276833939662, -117848641760], [-27494685724124, -2925015331904], [-21616818247638, 1327472715776], [32628648194000, -1023840456064], [22391747643742, 412542904384], [-7041721029660, -1550479897408], [-74308614838124, -600189949408], [14866191921602, 1103936519552], [-51110583530228, -1709016471040], [-74151511889190, -2530007165408], [-25210460178062, 2756313143808], [-37239530483790, 453768457248], [-48992999562414, 2984472342432], [-52391609594064, -2249318792480], [-120857124366158, 489595319936], [50534995615216, -2279849639968], [24299374717402, -383132549728], [7416107267106, -1787213885312], [32394886502932, -1548255574144], [-50491927042946, -2855847930304], [88616555126256, 1967329176608], [86564588280636, 3495831855680], [-73284745291498, 4759663180096], [1723930105740, 460758057824], [33148266953390, 6246717227456], [-141771842718262, 85400461440], [150763092625568, 1548289586272], [-55464594131548, -1495269012480], [-100156080998184, 4391290803648], [-64650306218454, -4017640156288], [-88548823458600, -1210358437984], [-13627043332626, -2582276957952], [74895890219248, 1453069868448], [106707539536798, -3433176131584], [38624389632710, -6713109597376], [-96947068664888, -7652722700384], [-27340107874530, -2293664667840], [57071291826280, -5010647554592], [28579773702556, 620251108032], [127291529402710, -3457665710720], [155846506620746, 453339404320], [-128037722362176, 2221107737792], [42037370803584, -10363781763232], [165513635609860, -2824636050304], [85913395798018, 8394748536992], [38152055504996, 7240527768608], [114415159598208, 4257508273568], [70981136965974, 11189438774848], [-143945750192740, 6619977476288], [-208675515559448, -48272380960], [-221098232204398, -4789894847744], [93014746572886, 17951725440], [105778710943044, -4729607357568], [39648686353224, 10244510393088], [45332767188300, 8021766560832], [139014690269500, -9494083866976], [40448610368784, -7247246538400], [14631597576718, 6468229050944], [147537215910786, 8324628680160], [-115131649086584, -1876702126272], [209353332347112, 7472860315552], [99302026253196, -3818074790336], [-30564802632676, -5563534667808], [136672375964696, 14566580467680], [-367131624110254, -488212931616], [-410578918963202, -797633308800], [-330175368565536, 1610878349856], [-207203531378166, -1896997644288], [148831531939086, -12512380105280], [296939326997228, 2449452195904], [157561661072502, -7439934331520], [-139184672127652, 2968165697600], [330542913096358, -9590353623232], [141346230816422, 19421747820992], [154830528825752, 16960339376544], [-249940568299796, -8036756205504], [-81168909651578, 6131822860096], [-263732406869070, -14497664595552], [327401038747762, 6137907521120], [65848889721748, 20454544164384], [151922898420114, -2858188377728], [-67764282819066, 8030064470528], [-227925033645332, -15010940586048], [-202648583060890, 15351406394112], [-167107741694290, -9818107944576], [-177265507954716, -282377142592], [107589227807014, -6573466941120], [-178933689678288, -9884092815264], [-490871358381586, -5734490547392], [-86926864480416, -8025551409440], [-396449946134812, -7923940346432], [270859469853630, -6690722155200], [-726172497673462, 4172719706368], [-120749738347684, -6424345774976], [159246570596872, -12255684840672], [-247923251665720, -18062591654176], [253906852453904, -8054014053664], [-461362275236762, 15177391779968], [-400711832894516, 2736502948928], [-208035785857984, 595677806464], [-313264434488306, 642332913280], [760157990359510, -3414027241216], [313682518697672, -14538985094304], [-98499998897890, -3499917956480], [733769577792242, -2327844219648], [35997947467676, 24036141339392], [-184934638398774, -20634243753120], [-227746488203900, -25728244013824], [-305455023969726, -11610408385760], [-93770599135870, 41697351898240], [294667333333472, -13737029550240], [-645373102470666, 14881530671424], [-370761227873820, 22989279970560], [-354480924717740, 29601449496576], [-128782244863210, 25724580795328], [-409201694385170, 27249072659584], [379156954304352, 35052830827936], [-280293719622580, -1078409561408], [666323674531196, 2810167575392], [-92345841961602, -12297246122240], [-207734963808844, -1334894782208], [-247879888428114, 10704274006208], [648695493487784, -30944598926528], [1035200497489322, -15335940624416], [817075527681528, 6320422921056], [-658782348966486, -22472015707008], [-330393161012834, -7822881830656], [480911876326724, 32458647220160], [-548485041219264, 10689772248352], [945563027872746, -9900234883712], [-643693256684692, 17107124867584], [198155798251248, 43165133075520], [-345823460355682, -12294216899648], [348724588359278, 6561652313344], [339336604437044, -25113596582304], [-436532616495354, 21757841677504], [241510574414402, 5637070243712], [922577636920472, 32326478530464], [13286122253818, 42508105958816], [-262731920560782, -8602359583232], [713993006117620, -39954192428000], [1106056246413484, 7912318353280], [1387630521367480, 18339918019424], [-1551277617887770, 29202043567872], [-777537738107378, 4005644006720], [-189982469726818, 13635351292800], [-694370303057200, 27190727602080], [1828315959989084, -8851208157376], [861013267359276, 18531622956512], [-569107173034300, 17953317697664], [-187355204868642, 42372796039424], [-1529787319239150, -5390964863648], [1757008501186346, -20178608189568], [-6796408855592, 28717041826400], [357022080440442, -67130236623136], [-67440680553846, 31168004380576], [-380661866638374, 79926297543168], [-777173109687608, -21269318321440], [-2356675106028130, 2161658724672], [2194933641453340, -1156442418880], [782155440785926, 9670934957632], [507793254525292, 78056265690112], [-835387913920704, 3201030475584], [291394895127638, -50197225461952], [887397079306948, 23763474530528], [-559705887612938, 16068734148992], [-214674755442734, -30451535985536], [-342025878847864, 21147209307936], [1299918803985046, -21178439611072], [1919729333850410, 13569358619872], [-409936854388416, 58339312472192], [644783467045380, -84171592685184], [-1245817875186302, 19648241486048], [-297470586211520, 116797683770272], [336137318407498, 17536891684960], [41852557601910, -26847897951104], [2039522376397448, -37333828579232], [602666649526436, -17334813615232], [-375037847370956, -42961148923392], [-2340870407289802, 42155304949632], [192395471108942, 55740967942720], [2931630560935760, -22757730204512], [-1250371580601382, 72270396498048], [-366137886101300, 44435742189056], [33153888601596, 3506941723488], [1202462963990072, -19559526224352], [-83055674857686, 93115564467072], [-754564504898280, -77313520888416], [-849618430338734, -130635454226336], [-2428078869377876, -6158062196928], [-285237310653936, -62459439517632], [-1408540674669154, -99980633175424], [526420431501902, -94749214797824], [201916956121094, -42078523210752], [-187042837304702, 82821647895040], [536858741564538, -55910385440544], [770161903642192, -34750996713248], [638873753955602, -55665259820320], [3403914019106772, -41252698418784], [4243965951320848, -509181847904], [-160414577305680, 45607757442464], [2657596415098554, 38838384958048], [1409077076532012, 26909931943104], [840051194959576, 162240773231072], [-2619745167334846, -43957262513408], [-4028260073149850, -33821488947968], [-4779116808399532, -6243991855936], [-4074056195302684, -55644198070336], [3857554688440184, 10935818133248], [52493417259814, 50710134115200], [-663393591658160, -1823592256160], [2494240326931446, 99035120455488], [-1919549928182836, 43172083562336], [-4605203183453270, -47575237295104], [1373184590436158, 51213960948224], [74391138896594, -33024380922656], [780893017717496, 95793157726944], [-2162257382217206, 104296612631136], [-369371539608326, -64625928579968], [-3125678922567896, -114857869770144], [1026794309204578, 135073806204000], [-4022602194195698, -62451470872448], [-648179948662636, -127449716120960], [-486633949061444, -77226583409152], [4526339917058926, 63605372441216], [-5421112830535434, 56325273616512], [2787088032357012, 99742244571968], [1979671878697028, 104036031038368], [3323053187573974, 90962429894208], [172320494289170, 124244465067776], [-4740914287475776, -41896410087168], [354016184395904, 231607463095008], [299316511923234, -107132360461344], [3864368396123904, -25123001107616], [-2246931735192318, -144506440768384], [-2796716843574358, 119085739520352], [-1990158354682872, -74243515889952], [4673628744124196, 65037656212928], [-595358294447274, -215178432146624], [2859488147696526, 25053528266432], [2175124241536812, 176353986118528], [1007772473049830, 29243258500480], [-494857766143012, 125613290382048], [-4784013211604984, 74017572261888]];
    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_k();".
// 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_k(:prec:=2)
    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_k();".
// 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_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<2,R![-302, -31, 1]>,<7,R![22579200, 14112, 1]>],Snew);
    return Vf;
end function;