
// Make newform 25.34.b.a in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_25_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_25_b_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_25_34_b_a();".
// 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_25_34_b_a();".
// 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 := [346979902500, 0, 1178101, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, -589051, 0, -1], [0, 7068604, 0, 4], [848232720, 0, 1440, 0]];
    Rf_basisdens := [1, 58905, 32725, 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_25_b();"
function MakeCharacter_25_b()
    N := 25;
    order := 2;
    char_gens := [2];
    v := [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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_25_b_Hecke();"
function MakeCharacter_25_b_Hecke(Kf)
    N := 25;
    order := 2;
    char_gens := [2];
    char_values := [[-1, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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 := 34;
    raw_aps := [[0, 6084, 1, 0], [0, 1895994, 312, 0], [0, 0, 0, 0], [0, 3357654003340, -801594864, 0], [66935907720957132, 0, 0, 134661178300], [0, -149080523912972197, -3738595861728, 0], [0, 3968057463058776267, 2662090686805056, 0], [680348221520848585900, 0, 0, 488470315076892], [0, 1308192702683731578972, 164629195362887632, 0], [837259985815199964554850, 0, 0, -608514536018417392], [-3119150612861816168547808, 0, 0, -3291649706447157600], [0, 5240137075837909004908681, -201328064188470297504, 0], [138783306511001091366094122, 0, 0, 323626334271537550400], [0, 78383059468353605688414590, 8895966303666004296552, 0], [0, -271053073071562563023848632, -4940382341410102637984, 0], [0, -1343370739277145154648758561, 204581426965700223902112, 0], [152893204817649216513331997700, 0, 0, 31330798946480292948436], [-2872946991706632429533681218, 0, 0, 6384714394462819038000], [0, -79945316861224767087510478298, -2836410062756385218812344, 0], [-1334880968978052357868405042488, 0, 0, -1894061461076775433191000], [0, 47315716059599943548258326817, -59188764472986488593013568, 0], [4267599986382818234865053095600, 0, 0, -1186492107239835272362512], [0, 1453630290187397272220199166146, 242837964943800314244215192, 0], [-66359733827802158132469298863450, 0, 0, -3802546107466626986646816], [0, 18389366546526786357541993892803, -5319399073608078217805640384, 0], [340126539554326484284435470019302, 0, 0, 1398744628835973828762511600], [0, -104954834666997618043769324383516, -5829124730760176311484795088, 0], [0, 21596657852680359399333089437410, -8352268618133224626364082664, 0], [-2487966392024688857661784523629550, 0, 0, 1755507608035780108534371216], [0, 1035322798553786945529608786838693, 29825884460290943093542799872, 0], [0, 4502065160566736832380530566664384, 237043214665017190242816197376, 0], [-77950002990996603542948277456392508, 0, 0, -43818778131223387565992158700], [0, -19242124607905058713496295195597249, 935019467763736362925073389696, 0], [221978591569820301049713867971269300, 0, 0, -126429171940622135038050523836], [-351272726084513428370471609181033750, 0, 0, -160851907350682940421508992560], [-938083463547871541099982625997059048, 0, 0, 379440801937375527347050332600], [0, 73487158237975578433496329815739645, 18509113610828446500788408307936, 0], [0, 221449802857484275467297377088977738, 5422728801970526061984505671672, 0], [0, -306662234486619894067955713184196228, -33589604166942793751856009940144, 0], [0, -1041872294765835285817282158593599893, -34728998318951105614878766079968, 0], [6751456946251614125495540626726169100, 0, 0, 12785801825649513518343309069948], [-10936347132839848508090783468526214858, 0, 0, -12060751280031432039204723762000], [19999401746418853264927419405135867072, 0, 0, 18727409483681933220882181969600], [0, -2282661972345340668540193258985422675, 266899672179525232301337727733952, 0], [0, -2302491719363918251925186438301441927, 1013226747506436795808330928238816, 0], [-2974870165371742335918148220367965000, 0, 0, 92410085563361444432688157384920], [-131557645284599234463366585520587276268, 0, 0, -68377683889658532350202134247900], [0, 717068369800941388786479390447077552, 4148636977175103093020090176544832, 0], [0, 25250957245689855920625884501355544854, 84080393616690669915829833853576, 0], [-631190439610210095447029915062934114150, 0, 0, 262191278960331871730539067342928], [0, 70739219099360968075662524634866481, 639418260447900696668134136486592, 0], [1733503598612941644978685574408129782800, 0, 0, -88922423449150332450420996182576], [-1708845425865624574971093413733067115278, 0, 0, 1216333618797975810836180272452000], [2490501263091794955136270766641836888252, 0, 0, -491832977382590039310062845396500], [0, 427824814875812521468581398514710772915, -12363328410246633299975428727332864, 0], [0, 206511349798369676434769748441327728628, -69618408416595121109638924138931728, 0], [10292510137757593577409701367379811233650, 0, 0, 472056172395032479548726424626192], [8843351839429231633571516877447304132112, 0, 0, -13603544561421775482994272857655600], [0, 957005760704908876223061889275872543089, 39933603789444117300214410339694176, 0], [-20915659915861791959743063662210500739558, 0, 0, 7308250554509977505659016274954400], [0, 1164303596863981652882832848074391989526, -241925970540535221538681420149823608, 0], [0, 250194008206168575827233867204334183415, -149588544564215771137982724918388448, 0], [0, 8908717466094180125319804511363668945550, -541694125822272931429011446213058264, 0], [-116152900659148309463160961539842117488968, 0, 0, 98420356876114635013823119108573400], [0, 4575186491126739163211043003174752335673, 652231336244609827342041367715955072, 0], [0, -4447803499809744779700459650370178267923, 1219228072392771949757123191146722656, 0], [162393835324816047907372086068399615214092, 0, 0, 410595313831893280733181945172328700], [0, 5905884854615704749097611893588219672491, 4618332397755556580622331899329700096, 0], [0, -65146034584500514728734631514079145610422, 1505979730874198541086017990232218616, 0], [345578251419079578630919907857052987049250, 0, 0, 799959857695335755556710631679766160], [0, -40750396305562320229468873546986666343491, -5158133817731697793970687481821433088, 0], [-772732672039102635109360884210681769741800, 0, 0, 369796484365583678271862459390169016], [0, -103634003462191093936652707622593093648088, 2890579113125914515357164968026284256, 0], [0, 62694124533442908789635407492744490604287, -11831697402846235361445410702047356768, 0], [157945971917340313961034520633047993276100, 0, 0, 4795489183146678671442192331132766868], [0, -594718931296579209346903930270111892625984, -7942260306604651729602562644392715008, 0], [-5273146222171315079801992186528556333266950, 0, 0, -2024195124666241196566467041379181936], [0, 207247476268711620014913144780222344381413, -96092461124465645872134003977058554784, 0], [4970952251449394255517025986620479680461202, 0, 0, 293679506767702877582825845222320800], [-17719198331854924395586068037450566911313050, 0, 0, -336149344631460761482957326044599104], [-12774139245551747014196090329215499432688100, 0, 0, 2878300248333940955500674224810470732], [-20127999655491574982411470511430482275454938, 0, 0, 531481252220874986990499897504260400], [9306340665962342638785357605543327673481392, 0, 0, 27897248390902925197999695320616418800], [0, -1932783764940404083832422624411497395732539, -62552317377866149082885030920930886208, 0], [22847671822592890952669566499071855528601800, 0, 0, 34253459689808092649874801537182463144], [0, 3824900754998681298496505334673509249690150, -252267318096191824371975044010919621048, 0], [9250259562977458917513608409944533568370750, 0, 0, 5610043270799338928304721561154807520], [0, 513962640465995165372771059703996389876255, 691034362076272294426645485114809233536, 0], [-19536367537299775801168882419830539808868018, 0, 0, -103572233161494297412986557740432624400], [0, -6189014911469994315559039471493503493975992, -59562687514975496005296169072639002528, 0], [0, -3934384849203728314269966070263393574220418, -674303243094127376825685550490636507544, 0], [267114889314041860189437929162241487043565600, 0, 0, 21177515597797265162377570499720224928], [0, 15075901213388323369844344156048378900930396, 45723822805794520026355292641995538896, 0], [58767498555430526231691462986798957723724972, 0, 0, 77105653856168176314857749369842412700], [-253870167652338261530868027144677401791048500, 0, 0, 70299534526207829458185753753770576700], [0, -34165673272350918727832509672439544158679156, -885165745334497327403589216648684872688, 0], [193771973031362282034646413312736391130936450, 0, 0, -491820921566004801274402648160289044144], [-157630562223813270638902983098702099684539638, 0, 0, -157755695121234382260751861549049649600], [0, 104452609046097843121459228049709128454069422, 163592702574408322609040323248174910632, 0], [-661164534341128271001334252845137918007265378, 0, 0, 968074177772996843343338435821256170800], [0, -132141849386109570271783080370541313913814282, -5127340496219607673530799515189472596984, 0], [0, 97396078945135213223086584054524819052755925, -25303262092766729729906656019308346943264, 0], [0, 277244230673862931164660149616104990445888498, 7032398979684655697423230751922806650072, 0], [424609051461789478547902170743371107877566150, 0, 0, -2545761622147211163129734414648159000128], [1339043540203870527076436672641625147739926012, 0, 0, -373842639196215038429610239236130793300], [0, 298212991163755587009537701866599802836094099, -6820982384018445841791435439865215636224, 0], [0, -413150844359356179317442557772162950033965134, 20094082913424346830931758143830553755096, 0], [0, 803897806895379783744146001562836574049475285, 7544101065842671031664399948530384420352, 0], [4171148144946610161604023953545820513470953000, 0, 0, 1992191262254495668453141492166559143560], [-822051316182665517888879312523144487190700198, 0, 0, -6617099048090225009154818715671017356000], [0, 127674425251800856560486168500229051514153360, 86761665680766852490413195851768567814336, 0], [0, 420293209832207035943561482209230338384081943, 40739361571656641971073788639618344355872, 0], [0, 111673250748437415169720924858073874270742287, 91855024569122672515833744769068661384256, 0], [11169515865756351088879696980497714259785650900, 0, 0, 362864622498569307165908101118729841252], [5191976508387901244882114518045036507318911992, 0, 0, -17703826556994322953160633193157374759400], [3376442096948916821096876511042424045225889922, 0, 0, 9088794184388414194717027862294158381600], [0, 1742414399994369776454824689908974423692727930, -157737244507895561834628820913506706779848, 0], [0, -1055290086616028008186923004083168660362649012, 219372672339475326518110445878389050067216, 0], [0, -61625387762734122155216587860122970707595621, -113986603410750719233442260662240098600288, 0], [-5699080127841251492479638793278337315472121300, 0, 0, 23257246067562230543831214926916918957596], [-9088890040115185531465805151988060903836381418, 0, 0, 42660102936117992270205781078591317620400], [0, -2598295308481546725304233040164423202427902243, 251990272424828138057905464315180148900032, 0], [0, 6290596462225798003320680814753257027561117769, -280063884009819373843003083103850766533024, 0], [0, -4225259293310376370308003088175662375662862914, -492834643383043533892829638000006574093208, 0], [-71768688110267179638722691269180032812818876428, 0, 0, -26807023870575731417017066552377487947900], [77561410032170808631610270152262835951447102, 0, 0, -97090834832205915706588886445372822555600], [-48207561727074827071669745954840860621284532550, 0, 0, 46830629262879223123229929146648346232976], [4935053439620440127794283939019115531116260400, 0, 0, -67340826045947754666534699605712787897488], [0, 1993716988720397291171705147936764066198718404, -1388192308996707597730416070718904993593424, 0], [0, 6505464431901196654461177819181788391614362531, 173042061639312407621401808803369943570592, 0], [42397113254152044956963861064421845144875182300, 0, 0, 255264851273253882404884078694047100598924], [0, 40768064067601368009688050182167137561044438820, 397714086587581147778101298093838806600752, 0], [102592119503312427530142847242019008541925088752, 0, 0, 113798071501029216111266877410574735524400], [0, 9253763826726599004744224038456308183494048065, -281470450941971204193053141931065655288864, 0], [-291599550341422501535821300647574277491901210118, 0, 0, 114483166900487726983530205149928327553600], [211651358033600122360267989096019372623465361150, 0, 0, 3762674757476649928316278123193141152992], [0, -16147195116835268990532534357540526052373230553, -2001318054168514925035161759240175499062368, 0], [0, 19251863141897815107981050479597505010056992606, 3922548058564706003449643307672900885035496, 0], [0, -34335573286364064894458404849415203653460816707, 1691687401479025770640534288281076979170016, 0], [-526883422266622126009652706386449729511230507050, 0, 0, -113771381537556469553280382729848642214464], [-110023260989739191161930775587117330168299304468, 0, 0, -311467672230672997698269092818945766107300], [7421978939262112514308120118794631169410318262, 0, 0, -358381813602414231587153113234114410640400], [0, -16878232956815002193241596009508484044851674708, 18040589532418579172171593980001567498476432, 0], [0, -9120701362155343463604387695021539714953930726, -5985360114395745315664818956860544417233224, 0], [190500939201810227087671429750610061484725078850, 0, 0, -1812387038295286574831145128677464199208112], [1526213040425095635434271817472863278467435743800, 0, 0, -1210402216232345463494957746476873412719016], [0, 396828433378641381237911869287135306151848544559, 2879865274218714507133350257606033122410912, 0], [0, 122513191486943179407352371219085743906346431735, -3262863621503473950677809943221805119585664, 0], [-2623943149211381350123114565229132862780946006300, 0, 0, -239882131863846816818927598108742930567884], [0, -1443677870688338628225071624697109121752322832, -436980231088280228434410569526257239720128, 0], [0, 312517108094385591784021153175785069944386742709, -10109944521583335948627445392611276417790624, 0], [-3188505227858588772450465389529223544451791791758, 0, 0, 917896117400829913211233302185532947702400], [0, 636350567488451524399679511031562707569478850066, 14354576175110321689690733386468129037563992, 0], [0, 628098955997334776342845148558895249620138513076, 10479924662894908123729542074382073259411696, 0], [0, -834416094173226702427352650212554235820428050030, -5657643944152243230049518654786879465425064, 0], [-4186615956348459091789854405845287969653996429168, 0, 0, -5827779486280995964338599011770620042817200], [-923865656299249242896838304913063346523215224600, 0, 0, -7208361339783182149720380570377838206749368], [-4157169008312431590284060012257551259502924383650, 0, 0, 10419890177707136190261114071194274198337248], [0, 187814621658947660879223430898942685894888822511, -54751413983522926427302096893152741349760704, 0], [4602885924608802750326743029468214668796449963822, 0, 0, 8885385309517754182160868676242012934866800], [0, 37780011597994898150565388442408189404714821198, 92418565807887589095457908890066421694603816, 0], [0, 338357225265018022683937773155519419057452509049, 104744605767658072644358846496762276562160512, 0], [0, 2023169779853274221258753173121853801412438642732, 33751835207121241780632484246874559622701456, 0], [-16497693855051730962439351112358380712202031356788, 0, 0, -14805126089352372478443563530408435830173700], [0, -678113551807341097987932936309971257146967190421, 44666652433046894378157328995520067998784576, 0], [0, 1472954136995732226116885288363626208186381383356, -193881083294987373233719292954174761813759408, 0], [17239525132037310843194787022253366360317856725472, 0, 0, 4997076654842879642516360882449997315157600], [0, 1285763490202747086998078080617923969140436513833, -337120202620519704711346381050522209078791584, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_25_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_25_34_b_a();".
// 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_25_34_b_a(:prec:=4)
    chi := MakeCharacter_25_b();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 34));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 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_25_34_b_a();".
// 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_25_34_b_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_25_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,34,sign)));
    Vf := Kernel([<2,R![72471856579614867456, 0, 31832103168, 0, 1]>],Snew);
    return Vf;
end function;