
// Make newform 225.12.a.h in Magma, downloaded from the LMFDB on 16 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_12_a_h();".
// 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_12_a_h();".
// 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 := [-151, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 6]];
    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 := 12;
    raw_aps := [[-10, 1], [0, 0], [0, 0], [-28950, -176], [309088, 8800], [-1707130, 4288], [658970, 42176], [2662660, 91520], [29471970, 11152], [-47070190, -766080], [122271732, -2402400], [-10501610, -6344576], [372871658, 7550400], [-314975050, 4636368], [-701030770, -6835024], [569160290, -62251328], [-3658757780, -58605760], [-758212838, -17856000], [-7867145070, 30563824], [-16469235772, 18268000], [14991424430, -113205952], [-1651411560, -191878720], [6649551210, -366939408], [6337385430, 485093760], [1540351870, -1515290176], [-43118460702, 1036841600], [4872759910, -1218168272], [148271607750, -61005424], [-8108731270, -3976538240], [-229226954470, 85930112], [152862492410, 367246224], [431249652768, 1816144800], [-30837648990, 435141376], [-21666125980, 6642546240], [-924273719650, -1764835200], [868794124252, -5119989600], [-795446852450, 2415217024], [-779038591130, 6534787088], [-1633753407930, 18720243376], [749035993170, 14329697152], [142249751860, -24039964480], [-2024990248018, -28961248000], [3737955510308, -9520738400], [-3465547847450, -4183114432], [-2308525846470, 17330070976], [2645579186200, -20380646400], [4053832556912, 39483426400], [-5176459851170, -22074969552], [5954557006390, 27792548176], [3605577513990, 114701230080], [-113554278390, -141881436608], [1480945470280, 45197066560], [-5118617279858, -106454392000], [-8499532462752, 46088460000], [-6031088410950, -82280471424], [-11466739254470, 7102111312], [12876374355190, -342313061120], [1058656645372, 168313781600], [-26175460828290, 55308714624], [-27178583660982, 271617006400], [9299004926190, 8286427408], [-22935790250550, -606579776768], [3547753353650, 326677792624], [42944218312188, -417356965600], [-26762254375130, -745495530112], [50932617480370, 342317645376], [9539232167832, 962577368800], [-28249674994210, 1455550327424], [55676928860030, 1145800045776], [-30880259434850, -921676064000], [-41944029649710, 196918291072], [19505926968120, -2405589455360], [147988652664930, 644861446224], [-6304516136770, -1048287873152], [174951505636540, 1450630826880], [107087900001810, -1111078674608], [217099562743230, -990965738240], [6813364590470, -606246893376], [49300384860798, -837002099200], [-315044811955570, -1655970962240], [-371786087869660, -1940013837120], [-395507050960478, 65441481600], [99646338864468, 3111436064800], [434573403047390, 1698366531008], [32093314391320, 1270304048640], [154460651669850, 2424412266032], [-278766447290150, 5248420529600], [-259329563665450, 5973024487424], [15644846809338, 4868697449600], [-200520869270730, 2403208866288], [-619557688080530, -1598067629424], [-308612783574840, 8789407795520], [72805954563490, 3454012529424], [-300174480066592, 8522549727200], [695424367984900, -5569188358400], [-547411997009510, 7151243573072], [1096427185874770, -5489419215360], [-208453684250122, -3954465689600], [615747463502030, -4428035319152], [1195136775326742, 174198851200], [84926225889770, 22541084975024], [633793458946650, 2451171176576], [-425917167217470, -6351106078288], [207058311595890, -10383074371520], [-439184274871528, 22208850520800], [-462730429250090, 29394900269824], [-1007598778754490, 25568574245776], [1002412880460850, 29292988831232], [-1054192307502400, -11015124696000], [-1113459935079898, 26735500504000], [-2810806823305150, -1337002240176], [2879403210701270, 14576925873088], [-508630992912630, -12706141369024], [-940111201298740, -45181644807680], [2729136620643532, -7203996421600], [1495393658151858, -11198404782400], [-438447096269250, -40586511325232], [-1914550262232370, -2854685486224], [1277925799623490, 47231195246272], [-757551780381980, -7592550208960], [-2944713244585838, 6638214265600], [-575896550741970, 19484830083648], [440497844973690, 19795828243776], [259006655391210, -35397716134608], [-4202996166280808, -32601538165600], [-1096032534452602, 25733793590400], [3424880494195030, 9263710943360], [1125729986746440, -44140917865920], [-998777606209190, 75998027724624], [6088126720024990, -29022720340992], [-4530310531234580, 88793996738240], [-5508934195095550, -22343038253168], [402106419657652, -8915910722400], [6358661705048750, -9292016453376], [-6114091486087962, -33610928806400], [3509957552231810, 120145650581120], [8346713263588170, 3797996661952], [-1666188982550710, -138708453024976], [-10515532289392670, 56755380701376], [-7928743033849930, -36902867087360], [13175778647288112, -86550966495200], [-15276928441267122, -68262691894400], [7962692451983230, -82389030756752], [-5070125214041410, -80704558987824], [-3998578876123110, -60399656401920], [-9269145734351920, 53784365991360], [3519205024610310, 12457298187328], [-19084895335263550, -29776361066624], [2183194093990180, -92218671829440], [-2758517311676270, 120160333928912], [-2832260906338290, 25766705799424], [4892535016086418, 104603781742400], [-20498884353986210, -17967890626992], [-12516801470275290, -198031209439824], [-28106562176703150, 53407449490224], [14622622353980188, 83817469192800], [-11794170715568240, -13108409772480], [-6785946428311990, -268817956322880], [17099516572041990, -48397868182976], [3647871907970858, -423459852403200], [21935476044890430, 331839551522576], [-5784594199913110, 149960639542272], [-1548045950206670, -404509002395376], [7358602534659528, 445785957248800], [17777563250648690, -459632849218624], [-16416451484239590, -237167869455408], [-10650329825322508, -422947903525600], [-11650817390732130, -377650838118976], [1344895397702930, 18300578188160], [22920738243797530, -243908791274688], [28752190619486340, -135674931739520], [-11438057504327978, 541257574835200], [-20296052760225732, -320875573269600], [37990719042441390, 66429185462208], [-2538151313061680, 754701159383040], [-37020906381385050, 499305708713600], [12817358597804952, 310831614053600], [6996142125460338, -831370789760000], [17520165162066670, 614557186751088], [-11669452202102390, -541188266132480], [-29095667890462910, 194774888028624], [-38438888110716592, 513849618733600], [8058478351657550, -642287231501632], [21057085197620530, 990849816131776], [-24214553161567710, 551665948325072], [-49998599374803830, 83373520883840], [-30659507731307370, 352773730193024], [45925865994226430, 185456423453648], [-42611539065023410, 427218506630080], [-50231175769039652, -34573076708000], [9644740362868310, -12316310563072], [55933324200027530, -576170324673488], [-89933320469635128, -496366895180000], [96655890250318918, 113409710905600], [-61764022917562890, 1306903855287376], [-47287286680815350, -472832116648768], [33679025948127502, -157741668532800], [19205895886020270, 1496628033924288], [52489396432617570, 586237982846976], [-33946326136055030, 238949490972752], [8276988032589810, -228847622698880], [20095526561610732, 280855821320800], [-99080277055113810, -157717118643776], [60368688067714450, -334384858547200], [30115936138467420, -361301217997760], [-59649621733540110, -1279170267156224], [-16739386851120160, -1397631768360320], [142515502102412210, 466451796694192], [99840713298221430, 1868736067544960], [-135968123042214808, 441208200892000], [-133409406148953530, 127389738437824], [-67856426287010002, -309346813372800], [13982233441711110, -3218875515013072], [-173765920558221850, 396685798146576], [-69591948923786160, 1645954494857280], [-148909192587529978, 1447280658664000], [100716240845075210, 919879052347024], [58163009184226638, 2598224891558400], [55567480766220070, 1229088914185776], [3589561608212970, 2950107651765952], [218474046198997282, 696232379910400], [-72970807079000800, 457775208718400], [-136490964856432530, 634312976595840], [111400836492017030, 1487541148913648], [228371136362752390, -2049989645717424], [267141858512108690, -1137983590328320], [-34862746842268590, 142646250512192], [26795440232814080, -1413185361991040], [52139426695456370, 217684349188624], [138291347136562248, 2698566313952800], [77672393840105910, 2727056911044928], [-65352575670953420, 2250957866642560], [60454935385117772, -2190056317901600], [223053678752641018, -3385396531652800], [-170701960145663810, 4845756591777808], [391825819668986310, 1818779814881776], [407547549393862470, 1315452422469440], [-183110645415536750, 950464153108032], [85119735200206500, -1963583763840000], [55908646113487788, 1104736450029600], [162780423053112570, 6443165759325552], [17699737690974432, -2590039782917600], [334415348904157550, 2087741388694768], [-218234434829482050, -2410953930080000], [4182777083145090, -826955114080128], [-333397860442817480, 371686460749440], [-300583547508288470, -609345240257776], [-312783258208896872, -1584933392730400], [97043550314525540, -3541885243744320], [-613212721968247990, -792081286004208], [77976262311727670, -3974241294854976], [69218103885260398, -7948407789888000], [211185564602543550, 5983436890945776], [234505729881124830, 3669334047572160], [445934066973997330, 4472226948269312], [230872226174118540, -316027124197120], [-79775444247950978, -8025169210883200], [-62336167038283790, -7559370622826576], [-391484274378837390, -4938552706884224], [520500312081419350, -300643721163776], [505454841502337870, 3463187890391088], [-35192083894886330, -8832540706642224], [240823639458279110, -504720558830080], [305319598587328950, 5517897705639168], [862345678698583530, 3782094963078976], [-332708942000523500, -1878597207859200], [-426373783329230, 1756287288035840], [-80127450075428122, -4405919437548800], [-483431825816098970, -6061322240392752], [411057339539030810, -9973667099207808], [-381751855934532058, -9465643421356800], [638339305357403570, -6574686011340176], [-534484638805636490, -5470883834667072], [18833092065212880, 8682596046600960], [363169810935531510, 9504278459085824], [617152002071431390, -3157469701483792], [782576990205628110, 6568889798186576], [463141251504123870, 8681544664218240], [310539286668291702, -10004783762382400], [149119069937567088, -9933272749900000], [-735615475045829630, 7194511926019152], [198412238619254932, -9101230999728800], [485400963335371630, -3747188905479824], [319791131827228062, 2066869661478400], [-527968694598090870, 4903667617015024], [-1040649858146469972, -5030368640029600], [335518278875657030, -13018004163189952], [634289589504195690, 4972058098682176], [714676533796865840, -4633727569129920], [778936800433613130, -1864629563544640], [-206897838177168202, -17723350734499200], [-229531184465437850, 6778400875037776], [-916380909535892670, 14175054345371712], [841545484328221968, 3814998387560800], [1881080532414646990, -1677465778542592], [-734956994417102250, 12930022826595200], [1809890937983844452, 4079563126692000], [252169142383598970, -12141779968405248], [737280274291895460, -20326316993729280], [584154484042678690, 10841466724282224], [-60069462432566850, -1166675606866432], [-169178638678623070, -14377889391389824], [1107722414409614200, 16999793822484800], [-24412959824520510, 20578119601841072], [-958059587789554688, -3224655111999200], [-199825050945946370, -20209546221635776], [-2201571029485902210, -2425918952200624], [-273268032838337410, -4928382577896320], [171534726023444280, -4916576918976640], [-321351739581867690, 18234365114745728], [-687241859454735870, -30256584553299888], [2049678183927870090, -2543363932350720], [-139577903146024482, 27011126955001600], [-1802598835445282210, -21558176248300592], [1212514985005411510, 6368960306697776], [27848321994076570, 8095821112442240], [1057716538742439900, 33614993134467200], [-32107373415442212, 41300190115596000], [1431750738705557670, 666773536546688], [-1117533563058863190, -7546507929340480], [424049569747390232, 2373950052439200], [1594005617920035790, -25553176639058176], [-1074049365894093242, 4576210020083200], [-1630056487571546650, -18323337885506832], [81806714162727090, 3302525836012672], [-625092194049819938, 34883716919643200], [415670631278356340, -43885072205374720], [-3573546006571493290, -964727421437872], [711206699048733150, -34302723394700624], [-595135672254637870, 16623618329973312], [-2698250448700758678, -7370800984630400], [828457166184103010, 16708981011672576], [-605579117017346680, -3681410151764160], [-1818875232578001350, 9112844931515632], [1433307232109131952, -15087547091631200], [-1975301409173306330, 36527119530792976], [-2727512961772356790, -15512021197777280], [796735166746535770, -29706427715995648], [-1937652943154696218, -1493293037563200], [1514681182030051290, 55305774583195024], [2763775602955676150, -6834533469496832], [-2266999281303306470, 25110778099314176], [1136618748906996270, -29419608640978560], [1583259782979171612, 38186452167872800], [26707694969005610, 54787040856192], [-1514285423033408820, 49670677533717760], [-1816301078129933758, 731233912640000], [-3144188545774790830, 41182439836127024], [-5997097014506631252, 4806524318498400], [-3079160961738942950, -30786986680956224], [-711163932013231728, 50047431598760800], [-3307264445915030490, -29338910446837376], [-1460789939971191082, -8552147405401600], [-124780734978598810, 92037491702170608], [-368594772024326730, 84343952346442240], [4404510544396246050, 29687317437866432], [1114892133801996200, -77969079940500800], [-2338609405084935912, 34772086588874400], [431111478222111570, 58341367527453376], [636482875072825970, -9578567401633648], [2775907010522705390, 64873546565042624], [422044408225397158, -34132865668672000], [4434835616530994430, -15124149239673424], [-136887175947885380, -56672031693901760], [-3860153851383814070, -62252668742672976], [-1258430406018350170, -2575657615983552], [1003270794200980890, 13384286034378176], [5439580038205304310, -15145378983089872], [4716851334276067622, 51855210074721600], [1294607561861721168, 8334647100964000], [-1998057868357518180, 31647073197623040], [-3408918332917165750, -66653252748899568], [309054451409985150, 117862748072918400], [-6889231132136414148, 16362621949591200], [-2536708340061003850, 11945320553330624], [-6910743972292285940, -6903862265921280], [3758397013725730908, 51713126530389600], [-188907277494837650, -103129864729874432], [-6798280713519743430, 5250360718389440], [-414490082431949170, -12112705083682176], [2801423871618856778, 73870402513510400], [7694549809821932610, -21289489572513408], [-6375045893470975630, 24297157085070224], [-6049029058437983150, -29089170525319424], [4365995659167181380, -25142058693325440], [-1127801008940763070, -34335950643163888], [-8182286395345044628, -49840769114084000], [7639591770973813510, -17861383494798976], [421243770480225990, 36690818330067408], [-5718322548308106690, -66715591640319824], [455695918725227670, -76852237937536960], [-1502982776259830350, 55595547973903232], [5170730652236021500, -84567993806292800], [-5984113436923656350, 44411729608931824], [-6359639390666547212, 511120296162400], [-1757149480745382530, 615565867481088], [-11274957442794398440, -21645378027254080], [-9401045041244559690, 8910475157637120], [5200597409395109632, 49072452912330400], [5437195010267239758, 34235668488121600], [-1987743517353624950, 85906478306531200], [-518496947981673510, -138642252708564928], [1378586812718164130, -196914082197337776], [-3627109988650674110, -158952425742004224], [1606649866946336030, -160172372742192640], [-6358758112295886308, 77648660037540000], [889599889295111470, -98582287433290176], [8840267608241443598, -55781058710022400], [2541143366423384310, -52409505647852272], [3301659897448118340, 165084093818409280], [2918222542217694990, 153641068667982208], [-4079713136545913190, 176121260742062976], [-4473838910357452750, -115772799246545168], [10281229969358876352, 6962283038780000], [-13737872931119598050, 13294226247196224], [-9668464697300802662, -57694183406652800], [-15692502154944219040, 28825644230133120], [12855301346147733290, 91865683387087824], [3290364350093604930, -135172987372185024], [-8481165300134895710, 149506803324307472], [2955374294859337670, -36519401953199360], [-384755773992905770, 1058306252293824], [9846428385721768590, 77517895674515376], [2371552422927629980, 100213848029786560], [2193317332320246310, 27792321668054528], [-5051786386468031950, 136022943147342976], [-3550678569224692670, 128010682759240112], [-2664164089948816110, -159997956044125120], [-6797016619519406728, -162532420602765600], [-8992226965380601400, 120829953912182400]];
    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_12_a_h();".
// 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_12_a_h(:prec:=2)
    chi := MakeCharacter_225_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 12));
    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_12_a_h();".
// 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_12_a_h( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,12,sign)));
    Vf := Kernel([<2,R![-5336, 20, 1]>,<7,R![669716964, 57900, 1]>],Snew);
    return Vf;
end function;