
// Make newform 138.5.b.a in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_138_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_138_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_138_5_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_138_5_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 := [274129967370817, -70961983286748, 140972261417692, -11255739266544, 32715955056348, -1672125302460, 1790717926120, -26553654912, 29130946113, -175079484, 213396724, -529464, 788282, -600, 1428, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [94737966427549139307384726784829043409838310130, 435772253246348662959239620418707309294970814, -3436193763730798806646815650152902907878939188, -485718419191723182382745061760931124824296152, -785709602012324318265501992160884170306098815, -111747415283798381369189266442057979287567710, -17001413582982515874061884667644917799427320, -2188192192691564637222359384514216469046624, -145062958109329789729936943655562615268427, -17138870989146161093988038133011497194478, -596956958208964236930142645556423124382, -65172016924813452585501744440838011388, -1183489326150675975813198362536022002, -119250914637407661834647687204738812, -902130305625942226938457509239160, -83286912539009664439469714008848], [-28667651306964149985560185065580863937331052753193662084907258342495491329725107874, 10216253013568256309847472383957305181185146580968095342048265286989634059497017302, -11839793604533309707348166090904823322510140598959231179670272340072341902166844136, -393829328839466898106435583899825648506814027148968548808694801615766073469540142, -608964636310899619355661881547641476314015797068921036935603511610140187762837185, -77577189181087856392233001074962609012584110388703198748937534158945065271213030, -10388115655806373468219940713225836362259381779560624252268749494954191416190865, -1386449448341817007411757601337653233064980881775586592073591136083639083365186, -80410391412011390314498131788170160809464162528521723711353258596338670107617, -10226013163377528529560232602749017649203466134930050456615722972312423039560, -313243335391853151187731929250716443229488455791161498649115054934696143969, -37443087801306600733838359150723697816074925930543700956391533102626752600, -599338987570192711780237321391681760282599714796155995642662902196725859, -67016018262023399879090381913373945644583871336617851875788436866362264, -446802041121453042071441173871490251720503923350113280679759710197209, -46272646822348380677884008804281062462031621082801281442705581090824], [26545509059046491027690536414052286610221766236534093376226724384, -14762178463322411585793027552844754849122701030669244629466532124, 8339210575681332050832079438698430230408572017122260143005565638, -7785548136115956591233669047613636021713276395358265003246900268, 926334397371662197748871550388710737257365226473786345714601502, -454647334563426755025855828692256098248666015511981331555727752, 15998099471505062546991198651930023933472810682943353099156518, -7484985949499095504237830214713838038680615204317749243492960, 116663760090590216416013139846860134773214735089649761211986, -55034868575117468369911539777147518253560871137840976198404, 411659436970886970995836698225806477910601806592687897734, -203552341410432770490975846582680653797818596142144551320, 667046420227964013200472359813010217194618747373732218, -368930399676422756394864474566350213974460883689866024, 365670585221505705375530009529798821419734002149704, -258522368857238579551945552397167895044123880383576], [25562607204445307189692443382320779977954314365493907539170999689711094170053561547, -54347997803143324862899675318802671451671188274735944206391552374385838224204236208, 7363432306138495235913722969459700342064038241544830861760186018678716991511668811, -6550523276405190095138129772418660465341046401112923521930573572613710908292153820, 371902660426316835390701492249174813501027180776800294829979142174186395019562550, -236131848420471319058399719252121982549286693620708059759420406659305201919351840, 5254729431352124255968686829476314379778349307735846852195382993911143113456530, -3271951180681892485446544275475358046605683357644961722133955430576698676509512, 33998275316521467141723839512101070897048601764041296404773891755026725983378, -21897348244883448802441250487294426247944105720150270668590216793355913329808, 109770970867761071694316072919902123186826584386673164595868680206003063650, -76117760971382027843736079478483860172821563096516365862866048873786826740, 163428123403468421137213306604662528701965418265897509871854232345677887, -131929108177259523890776722655609203147786622949687193955741194026067670, 78546469847482766777591103224036140085215920087875528371947834464527, -89444206052823940081403427702828446090147687796596869226501696399610], [69410881754292697976504724167653032704227479428765993098183776793425319753798755094, -64008590515025908443323084917238954550150360298849057316247999572938449214000605926, 25248593021847695167580272602926270318981252864974009628567468831156173060967378812, -4266857153635268236373888934301464306275155617599626467487803293841643496478742450, 859286979261642708148738768335928950651434433790631077144984155986248441615466775, 102129600502070692390891501432996709969119586478186295181464733707979589341646680, 12012279581478486238107240690280530115239162470468027165989474778781020012660385, 3123846549364613073005298087383574267060789400754017536667337435489332536604396, 81488961140680023801552656692146436246474949697885539678490386397565791391491, 27631160279227201437517561071583646159289022661911205605734536800966988843814, 291038730659193278906039930709396036890332722799372059759606148561746363505, 111766727575399506673686378279777314918802407924934709210043677511250510410, 539836664417740471653876564810392214566462539757530765181876777242366819, 213273245468977862228199215356526206251026472905186898102036889375503790, 420118908834537557831628441417027775653051168950190494925385062198179, 154158658183198710430191833593271409116031410420149241764165612001150], [118490998167306734836441896338141224507200158925363298489784706937664745642238965657, -29974316349832367814534493999925975843999975568764849401125501448874521157335077322, 49803114646688234185335808423452514272705181223712887232991540217915804233787978447, 3481319986419386220572990279745936048264351472305439429763397323871592382526570218, 2574289444776564616154266085441379249911401354024500139736689684385777697710791130, 400344746558665565665951176422714722953243443540594243755830324605648336354505530, 42767696158069253801308515438185797353006107723213090955789292109284250042622240, 7175418431651986756871819026752796461686849651531113801420188579305497703121418, 320934454168315756845120247665583756129070612483506490682759868098006352866632, 53739088453567106420678174420813232307090871907748446394271473075306982356646, 1219478198615288241953756674923523311227514895198049159617801177924320180946, 198675375532789876842858432097829496162888934870534066798324864923566060510, 2299052532140405306865150867475890853872691378939062983407817886771097957, 357174783710656089389611399245484078447413393012923560203546548213804986, 1709514099817803500547733388771314594875220222870253065192673246169617, 247160432601876735224950360906253326335091873185863082298290311965186], [-19158130121033057963422086732696260930350050356, 11586938566437621561797944149533711169059161700, -5803928128147336964501024613937602282647243958, 6277386394384728336620726951250725290855204656, -550633526229031536917954602775624649727401250, 385865330406745475005247746084544352064464372, -8662545635382602237607429141792254516718146, 6439100162168804620960169270933509005776780, -57759307275952287510970027667133571578338, 47646106226714936114835815715638220617744, -181785575961530428627199947530630158202, 176891450322174405776202336598973723492, -239347491695671329608906280659478502, 321365142064479345498505488526134732, -67256675812132370107491253667200, 225449726432696082240696672376248], [-52797818087025253844561441578537316301092194881961849635957229767422721741477621155, -40930894438394584561424857519724631382710068667577976219391482587982882183249463056, -24721306830962571210522887050340841429342688465947655158566714124028585578979492511, -11412688232213352904902197192140931622876707432109494718350991648202335603901015888, -427809586710728569661542928716526721048974598102200973571934964028804713748323015, -915888049150206213649212428187702589986240260405641496132724347169768069502230070, -6827599646988799291421399702869087436137786424030958149062467651693196017777315, -16280598724338463205269815635494927152987512278167904902834366613606437723641990, -66022530557273258209684317872136098925578264182990131811888152414595920207309, -124096073196840503382936651116866277796502338444677708237351856459527933812404, -344080464842414990664914932952171653105544677735150721343834686300988155381, -469168413841261384903783601172068579379686965347817563447923487282306109420, -907846116835527065838546404959406712821847203282654469309624643172342270, -862903958449027982814166668195458566838937173854771206855503741562204116, -941576290737987566357426876456684305890563301263948916164957172279550, -610234946324348089914040931524517199617622778983422002423651174261576], [-25878177846823614929004275305654003339943033318158598668668650536631651933394598077, -117843051095264254879101958491055813014470063888246306304495129383697783874490099746, -19022438188406073596644832921089503444284201577273931230942228678300327263916716995, -20493424104673567659599192373267618472944147413759347890462562958951319335358782422, -588965948429085026735764178337822691632675547146748947063658029980726952122029450, -1104893132984658319771257446571534288497376394909614573688903423705798546526279680, -10582453097008554299236644134006718225509461282040598298245590602889708665548870, -17926978617881643434728083399462776434220453333012191328882963194003555853067908, -90162797687069732943336066714314421642486963947548725304312915992333855524284, -131170742365179061071404794896568199775781747219089374731985787603437865621868, -402935039575177956685664340480699931094472261035485016169465195693731727284, -484112344233691310210789336668420094487023812145845319816485632541213421740, -942637757286102319362909122105690908028849347611104212384280859342239327, -876087797752108045392310504723043447213036753064679487252608304939712464, -911374781178182785050315726417636041942748209081250103175255897495857, -612630059284432664278235465588894795748223164640272745370196235602284], [-52386698620309412292017027763780120528327651882473190311796610747865736612627709978, -15960568712268069087268416595094483729082065764571601779383762416740512680823577824, -24119007862463461589023170693921510711423760859573555572280118512474379972315294130, -5946039878108275725008120598092188452849745568257538489431505654481766994577121928, -1284161143517362297536991996570190865295640234517501505650788966424260503484747370, -363506643588811526340320543805088589440016518414067334416372432033847603951114830, -21706858329792939223741401722675833979395831399174249371901583719553218036259040, -6044536540121774635314814898245251613567117681490508938593666504027744873367002, -165153118334009849220611290670320465194002475375301446335700196059697978198806, -44683948722785685699236239531680345271697216571369623647918615223788809951642, -639318209975068878345454737693555660673532292167616736242514902849781923316, -165893773265109432543789837779683394016204062183970180775552234953468238730, -1240134140386223639226174204344795249776508882239382101836106354243674538, -301255600850112324588388636263523053436630554313585401853277716039205686, -960688820629860558460345959256321663488325277244335411598943059910328, -210905102080128469536913989620899441017496145159885244231238765603466], [-84262122396813186420068355992869252440397152450244311947575339610753541554832147376, -96838137945650241480241139089997368826132695858804429716541918993164800567206312442, -43317215214436029433841623143277695362005550110169142448957564803804123164190960494, -21021712268430769690690946514552181768680183308279519260741823234879483439602466558, -1984672691376503525578543430095961389647030961882380763537744775476521227217007060, -1206528767015202455600390415684364437626937491587215648326175671237836769441726670, -33966871867561880265227226222789131513795944916108586533800168884559931689295790, -19904124142849959363642679047294184759687864630373442707189442692417383710897354, -265227994924625684324712310044796754716281437232679645737360791891028315098818, -146713502495559544066649140507040563300491143388340490004921273248792308520050, -1064607722807653556634826799765954764189542680471580468733476519804971436096, -543622247019761780607024925255037287857631959951347375310779622116966069850, -2178333241296491244392003461911310468695129276275536607171636883318653076, -985904785775282704497087743479449199591610883629506824603187480225274796, -1815034532221869720269184010099633581093710930408916639121191100193916, -690004789689773946136111422095569556661189491646166489708253681115616], [19140758270837509057539562243547848982939218080235142270415397301567731117434251, -2405013914765156297567592206068297255242204020204763099079996669918000974512406, 1283412810167634166214682406702073754697559783163200847177428370634861578339122, -1284947023303540628345853248894299091306452629218146569042932263991731713447732, 133243000171105083622951296393942905366722369426192433963976274671534489900455, -77251726669055432570083871193504498904855341306276292708101546823797119708006, 2257150363745318473689837580708239048776304463487357434786125906141559121730, -1286114989407171282237545700351369423133424922864120239353613060567123792488, 16035249321974920850732708780162986095699155378184380010020042795992051929, -9530365982913119349905771108743833801595638120892209886240160671989646250, 54560480593165524720505592203676668834487165951001119234186487645558964, -35483689894536725040724904167168844679415558888602856669374401685364164, 82990384444605419032991039252548596827694642465093584737260495322360, -64692768665865920502348499841583691604003604484499739287583978450236, 38937917598547215664842965845664863064125471831893206653339223172, -45552972998183621123244100902791374141908343392222070442391175368], [-31810698375817538480751649802126805714904871037677356872279027326500290242802884, 4271622556207119035393321373435021058940458983317172706502442095337416438950442, -1522808774493514495740337398597541905473078427932563754146055643377419040862972, 2450069810313472327139496378552967848952842403855861730770284926268230487693504, -58628423820448635576480330031254449280651528300803674671063538154396866156855, 168432888403258280550571603396744470824021509579578849562759931047374463591674, -595772600532374760022330033453438037209067304776160804907866182328816824360, 2876750217784068669625552784017012392382802303013751292459606616054135231224, -2989539662027637106255525998612431382803434437447915538024729948903956869, 21486852035522115800118051594887623645226196580717711327444562913852471146, -4220731111099907425829286687499631229244017266839180945482889388365506, 80181376573337467493434066411519462324423716931300901296139422974676892, 18895738423805092457884205891304412081736317644610366846781354163884, 146146187690098882058657507700012171515344459273722219640220666376048, 50074382021648809668312420794959975388084987218151040760132502804, 102749779625151077483314738885897484388487515029617779356287106088], [55953031432842109959241472733242953583235637998611019621329843240783329027167, -1052171649384819355429579757114639031481643870111164182142325618533812904517050, 641548728827273107778728803043748167283045794904549989512433603673898410617424, -544657090734776587001261960552669022791166578319663047249864800493920338696468, 76949600194264301252978164133329854767797582497746608947683919046283701218676, -30307233115212930334933508264305782979301003599816724764519448581335580821320, 1307958879779211648667531434351885132446343757882021510448223743121645158596, -494173077782306186051522988845467124576109836799606831386734426715676414260, 9300612885288810426766860337676380038229619227396985184028440248261528686, -3624577478072959416933938739547100023914869220840728810674789556313940560, 32091329478045784944308284699428404734057920803668826307247759030358818, -13401334629487674147671453867405327759079960856205228409599681369794564, 51308551120070351273973225979248280376507295997434242523112037520063, -24298675512672646308332058108690467906832173152919719855919019317798, 28282716502347042975396949409460726174011965642956398577148496882, -17036644046371470114294383255410382746850540788547827532065032756], [-16802881573940935116548069345306153650882299067488484656229441228699378847750987, 15101300789554094224983916646708922336337290985239768029559491050812877181023196, -7689713516503714135206099333949630770719721302372584333356543523283892517003422, 8153448964842380590077956941239337230113567348551637671758311524335282811644336, -747444928840712007795390258820294030934106355564149926876309989100991176626825, 497941758987418464385537841129559258483924967640485707666839606611329248973786, -11942217695864814623899397744021584221105571236091291448340222899409594623474, 8301915296117228055712420632931741587481691939190607905474390357004413320720, -81973499139880296076719146309087418632831588155599710059462166675075938859, 61462676450443405923895013020683518044329707007128179369624541407669504718, -270252179143048592285034809880841278204048952543091932336032407113501710, 228444900413692927240545014686666263358112321700983831775427918187345132, -388244448200404972999831478842886739776483983223465684706906852507613, 415620089089893100058331750469533193735357076792736521430192768451986, -150973673451717900980946327912329652564143889683539958175746549278, 292025759640879893617507419257309253034551831131009452564222061664]];
    Rf_basisdens := [1, 19774466244634692533869575401536106039340000573, 2962369141121471164742651211822667652024479165537644632750645570790107938014824415, 10576882407535791182933958347752969086565211179845383678850934693, 2962369141121471164742651211822667652024479165537644632750645570790107938014824415, 2962369141121471164742651211822667652024479165537644632750645570790107938014824415, 2962369141121471164742651211822667652024479165537644632750645570790107938014824415, 1611915968905338516148252026714428122609882689, 2962369141121471164742651211822667652024479165537644632750645570790107938014824415, 2962369141121471164742651211822667652024479165537644632750645570790107938014824415, 987456380373823721580883737274222550674826388512548210916881856930035979338274805, 2962369141121471164742651211822667652024479165537644632750645570790107938014824415, 75734862357700911791963472116136204832531743973862830953614868229326548332221, 75734862357700911791963472116136204832531743973862830953614868229326548332221, 10819266051100130255994781730876600690361677710551832993373552604189506904603, 75734862357700911791963472116136204832531743973862830953614868229326548332221];
    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_138_b();"
function MakeCharacter_138_b()
    N := 138;
    order := 2;
    char_gens := [47, 97];
    v := [2, 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_138_b_Hecke();"
function MakeCharacter_138_b_Hecke(Kf)
    N := 138;
    order := 2;
    char_gens := [47, 97];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 := 5;
    raw_aps := [[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1, 0, 1, 1, 0, 1, 0, 0, 0, 0], [-13, 5, 0, 15, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 3, -3, -1, 0, -1, 5, -1, 1, 0, 0, 0, 0], [0, 0, -2, 0, -1, 5, -3, 0, -3, 4, -1, -1, 0, 0, 0, 0], [52, -25, -3, 10, 1, -1, 1, 6, -1, 3, 5, -1, -1, 0, 1, 0], [224, 17, 0, 22, 0, 0, 0, -6, 0, 0, 0, 0, -2, -1, 0, -2], [13, 27, 0, -1, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 0, -2], [0, 0, -7, 0, 9, -10, -14, 0, 12, 10, 0, -17, 0, 0, 0, 0], [-386, -99, 0, -154, 0, 0, 0, 6, 0, 0, 0, 0, 2, -1, 2, -2], [0, 0, -4, 0, 53, 19, 3, 0, 17, -36, 27, -13, 0, 0, 0, 0], [555, -54, 0, -165, 0, 0, 0, -70, 0, 0, 0, 0, -3, 3, 2, 2], [0, 0, 14, 0, -5, 22, 30, 0, -10, -8, -10, -42, 0, 0, 0, 0], [-1142, 199, 0, -336, 0, 0, 0, 98, 0, 0, 0, 0, -10, 1, 2, -2], [0, 0, -29, 0, 1, -44, -2, 0, -14, -92, 28, -7, 0, 0, 0, 0], [0, 0, 20, 0, -75, 1, 55, 0, 35, 54, -9, 79, 0, 0, 0, 0], [-1879, 53, 0, 97, 0, 0, 0, -100, 0, 0, 0, 0, -11, -10, 2, 0], [602, 203, 0, -402, 0, 0, 0, 30, 0, 0, 0, 0, -6, 7, -6, 6], [0, 0, -27, 0, 40, 28, 8, 0, -64, -114, 7, -60, 0, 0, 0, 0], [0, 0, 78, 0, 238, -82, 113, 0, -29, -73, 182, -59, 0, 0, 0, 0], [0, 0, 29, 0, -27, -85, -43, 0, -39, 31, 159, -77, 0, 0, 0, 0], [0, 0, 32, 0, -70, -88, 12, 0, 48, -62, 24, 206, 0, 0, 0, 0], [-1526, 763, 0, -328, 0, 0, 0, -10, 0, 0, 0, 0, 2, -11, 2, -2], [0, 0, 79, 0, 22, 230, 38, 0, -42, -38, -85, -66, 0, 0, 0, 0], [0, 0, -94, 0, -92, -98, -3, 0, -13, -173, 122, -171, 0, 0, 0, 0], [0, 0, -101, 0, 79, 102, -18, 0, 92, 22, -162, 55, 0, 0, 0, 0], [0, 0, 9, 0, -131, -89, 185, 0, -83, 159, 31, 151, 0, 0, 0, 0], [-2786, -318, 0, 3172, 0, 0, 0, 300, 0, 0, 0, 0, -16, 42, -24, 8], [-766, 1554, 0, 2918, 0, 0, 0, -444, 0, 0, 0, 0, -2, 16, 4, -16], [0, 0, -159, 0, -61, 345, -141, 0, -141, 249, -129, 21, 0, 0, 0, 0], [4008, -1256, 0, 1238, 0, 0, 0, -112, 0, 0, 0, 0, 14, -14, 60, -20], [0, 0, -216, 0, -293, 140, -130, 0, -122, 488, -616, -110, 0, 0, 0, 0], [-1437, -443, 0, -611, 0, 0, 0, 848, 0, 0, 0, 0, 15, -8, 60, -10], [0, 0, -77, 0, 145, -286, -168, 0, -140, -60, -480, 133, 0, 0, 0, 0], [-3392, 300, 0, 4398, 0, 0, 0, 392, 0, 0, 0, 0, -26, -22, -24, -12], [9109, 2021, 0, -3951, 0, 0, 0, 764, 0, 0, 0, 0, 89, 18, 18, 20], [16594, -1511, 0, 2756, 0, 0, 0, -74, 0, 0, 0, 0, -4, -35, 16, 18], [400, -2809, 0, 1178, 0, 0, 0, -706, 0, 0, 0, 0, -52, 15, -78, 2], [0, 0, 125, 0, 875, -82, 200, 0, -28, 140, -250, 181, 0, 0, 0, 0], [0, 0, -416, 0, 420, 314, 68, 0, 104, -816, -236, -344, 0, 0, 0, 0], [2597, 3007, 0, -1819, 0, 0, 0, 608, 0, 0, 0, 0, 17, -44, 54, 22], [-474, -1647, 0, -2248, 0, 0, 0, 1566, 0, 0, 0, 0, -18, 3, -78, 18], [0, 0, -93, 0, -30, 284, 656, 0, -140, 396, 413, 458, 0, 0, 0, 0], [-12192, -2080, 0, -11080, 0, 0, 0, -1468, 0, 0, 0, 0, -52, 24, -48, 4], [-4347, 7603, 0, 1383, 0, 0, 0, -1672, 0, 0, 0, 0, -11, -8, 36, 18], [0, 0, 280, 0, -638, 166, 395, 0, 521, 43, -198, -449, 0, 0, 0, 0], [0, 0, 541, 0, -753, -356, -186, 0, -158, 208, -62, -507, 0, 0, 0, 0], [6130, -4498, 0, -10160, 0, 0, 0, -260, 0, 0, 0, 0, -4, -30, -52, 16], [-21132, 4102, 0, -9292, 0, 0, 0, -60, 0, 0, 0, 0, -54, 92, -62, 16], [0, 0, -106, 0, 1192, 150, 554, 0, -410, 794, 480, -72, 0, 0, 0, 0], [0, 0, -342, 0, 1260, 740, 265, 0, -109, -39, 548, -1705, 0, 0, 0, 0], [-5754, -1575, 0, -5786, 0, 0, 0, -1562, 0, 0, 0, 0, 30, 51, -50, 70], [0, 0, -436, 0, 430, -314, 1038, 0, -238, -338, -1036, -54, 0, 0, 0, 0], [23594, 7453, 0, 6840, 0, 0, 0, -1810, 0, 0, 0, 0, -26, -9, -62, 50], [6226, -8230, 0, -10976, 0, 0, 0, -1840, 0, 0, 0, 0, 24, -18, 36, -52], [-37300, -11252, 0, 4758, 0, 0, 0, 524, 0, 0, 0, 0, -170, -38, 36, 72], [0, 0, 105, 0, 589, 209, -887, 0, -235, -1641, -109, -877, 0, 0, 0, 0], [0, 0, 312, 0, -2175, -319, -279, 0, 317, 428, -561, 453, 0, 0, 0, 0], [0, 0, -862, 0, -359, -948, -1388, 0, 244, -692, -356, 686, 0, 0, 0, 0], [9332, 5808, 0, 490, 0, 0, 0, 836, 0, 0, 0, 0, -102, 194, 12, -88], [15966, -4273, 0, 9122, 0, 0, 0, -3142, 0, 0, 0, 0, 102, 49, -38, -86], [0, 0, 1360, 0, 300, -186, -610, 0, -166, 1840, -864, -100, 0, 0, 0, 0], [15392, -11511, 0, 2902, 0, 0, 0, -1730, 0, 0, 0, 0, 82, 127, 92, -18], [-11604, 8352, 0, 12620, 0, 0, 0, -6560, 0, 0, 0, 0, 0, 172, -12, -104], [0, 0, -816, 0, 902, 1198, 646, 0, 474, -898, -1276, -102, 0, 0, 0, 0], [26720, 10191, 0, -5430, 0, 0, 0, 2686, 0, 0, 0, 0, -440, -53, -118, -126], [-37059, 7807, 0, -7875, 0, 0, 0, -326, 0, 0, 0, 0, 23, -12, 240, -108], [-20468, 808, 0, 7642, 0, 0, 0, 84, 0, 0, 0, 0, 242, -134, 108, 68], [0, 0, -874, 0, -3216, 1684, 74, 0, -594, 2594, -1366, -1730, 0, 0, 0, 0], [0, 0, 799, 0, -1122, -1060, 700, 0, -420, 406, 191, -1526, 0, 0, 0, 0], [0, 0, -941, 0, -1029, 2012, -678, 0, -550, -796, -1406, 975, 0, 0, 0, 0], [0, 0, -100, 0, 225, -1603, 1517, 0, 451, -2196, 2779, 1259, 0, 0, 0, 0], [0, 0, 2272, 0, 1532, -934, -902, 0, -210, -830, 1444, 1250, 0, 0, 0, 0], [0, 0, 2832, 0, -393, 616, 1894, 0, -358, 2518, -608, -1282, 0, 0, 0, 0], [16476, 11388, 0, -12214, 0, 0, 0, 5188, 0, 0, 0, 0, 162, 250, 216, 280], [0, 0, -961, 0, 1253, -797, 567, 0, 779, 61, 341, -2583, 0, 0, 0, 0], [24875, -17693, 0, -7253, 0, 0, 0, -6912, 0, 0, 0, 0, -361, 290, -570, 122], [0, 0, 2616, 0, -1136, 1112, 1291, 0, 317, 1797, 188, -301, 0, 0, 0, 0], [0, 0, -121, 0, -187, -1528, -1148, 0, 1102, -2442, 1612, 1197, 0, 0, 0, 0], [0, 0, -282, 0, -4680, -134, -748, 0, -2312, 3000, -1190, 2320, 0, 0, 0, 0], [0, 0, 1398, 0, 2002, -2020, -4, 0, -180, 1432, -308, 1098, 0, 0, 0, 0], [-44200, 13720, 0, 4918, 0, 0, 0, 4880, 0, 0, 0, 0, 774, -374, 96, 236], [91914, 4694, 0, -4054, 0, 0, 0, 6368, 0, 0, 0, 0, -426, -320, 220, 112], [44068, 10499, 0, -14748, 0, 0, 0, -14146, 0, 0, 0, 0, 104, 87, -78, 218], [0, 0, -936, 0, -5176, 674, 254, 0, -1522, -1090, -534, -1772, 0, 0, 0, 0], [-6670, -12663, 0, -13092, 0, 0, 0, 7594, 0, 0, 0, 0, -146, -185, 470, -198], [37074, -3932, 0, 19020, 0, 0, 0, 7316, 0, 0, 0, 0, 664, -8, -132, 228], [0, 0, 458, 0, -2928, 1700, 4977, 0, -1897, 285, -1800, -927, 0, 0, 0, 0], [0, 0, 934, 0, -4538, -1918, -854, 0, 138, 442, -3182, 4166, 0, 0, 0, 0], [-16162, 14288, 0, -3820, 0, 0, 0, -11700, 0, 0, 0, 0, 16, -500, -156, 160], [7720, 6137, 0, -8578, 0, 0, 0, 4298, 0, 0, 0, 0, -256, 141, 414, -58], [-42512, 15648, 0, -59442, 0, 0, 0, -1052, 0, 0, 0, 0, 494, 514, -504, 144], [0, 0, 286, 0, 4454, -4902, 532, 0, 144, 1488, -622, -700, 0, 0, 0, 0], [-167188, -10655, 0, 13138, 0, 0, 0, 8078, 0, 0, 0, 0, -326, -369, -380, -58], [0, 0, 2167, 0, 1161, 13, -3835, 0, 1277, 2203, 3033, -1613, 0, 0, 0, 0], [0, 0, 982, 0, -255, 3433, 3349, 0, -1351, 4332, 365, 241, 0, 0, 0, 0], [-16849, 16767, 0, 9179, 0, 0, 0, -12058, 0, 0, 0, 0, 677, 434, 516, -428], [-135108, -5254, 0, -32368, 0, 0, 0, -15320, 0, 0, 0, 0, 792, -262, -24, -224], [0, 0, -1872, 0, -7589, 1062, 3408, 0, -852, 4608, -1002, 162, 0, 0, 0, 0], [0, 0, -3190, 0, 7968, -292, -2829, 0, 1229, -489, -3636, -1875, 0, 0, 0, 0], [0, 0, -249, 0, -7943, 3257, -2095, 0, 3409, -3937, -2671, -1193, 0, 0, 0, 0], [0, 0, -6466, 0, 3811, 1061, -2613, 0, 1177, -4374, -461, 19, 0, 0, 0, 0], [-183531, 3282, 0, 639, 0, 0, 0, 15558, 0, 0, 0, 0, -1077, -201, -84, -396], [49584, -350, 0, -56828, 0, 0, 0, -17384, 0, 0, 0, 0, -732, 38, 116, -268], [162360, -2513, 0, 17928, 0, 0, 0, -13074, 0, 0, 0, 0, -36, 11, -590, -398], [50500, -18504, 0, -276, 0, 0, 0, 11552, 0, 0, 0, 0, 122, 230, -578, 588], [32583, 33926, 0, 78997, 0, 0, 0, 5306, 0, 0, 0, 0, -711, 141, 540, -556], [57659, -9903, 0, 38057, 0, 0, 0, -19632, 0, 0, 0, 0, 775, 300, -144, 382], [0, 0, 1687, 0, -795, -2760, 804, 0, 2550, 1686, -2150, -2697, 0, 0, 0, 0], [0, 0, 3523, 0, -349, -139, 1157, 0, 2789, 1083, 2665, -1001, 0, 0, 0, 0], [0, 0, -994, 0, -7815, -5513, 987, 0, -2507, 4528, 3257, 3063, 0, 0, 0, 0], [0, 0, 3437, 0, 12062, -5706, -2566, 0, -246, 3720, 1799, 2302, 0, 0, 0, 0], [0, 0, -1537, 0, -91, 5215, 283, 0, -2513, 1221, 1829, 2585, 0, 0, 0, 0], [0, 0, -3664, 0, 9263, 4665, 469, 0, 815, -6656, 121, -2019, 0, 0, 0, 0], [-51746, 54869, 0, 64742, 0, 0, 0, 3606, 0, 0, 0, 0, 710, 207, 142, 366], [-217650, -4633, 0, -3512, 0, 0, 0, -20294, 0, 0, 0, 0, -1038, 805, -858, -66], [0, 0, -1024, 0, 3224, -2758, 2429, 0, 1611, -3023, 1134, 7081, 0, 0, 0, 0], [0, 0, 707, 0, 2401, -2452, -8380, 0, 990, -1658, -6162, -3693, 0, 0, 0, 0], [-132489, -16186, 0, -16343, 0, 0, 0, 26206, 0, 0, 0, 0, -1451, -379, 492, -232], [0, 0, 1468, 0, -11877, 2744, 6238, 0, 942, 5980, -5336, -3058, 0, 0, 0, 0], [-218252, -7216, 0, 12680, 0, 0, 0, -9908, 0, 0, 0, 0, 560, 120, -532, 256], [110672, 3802, 0, -12592, 0, 0, 0, 4156, 0, 0, 0, 0, -936, -1146, 1104, -692], [0, 0, -7498, 0, -277, 8754, 1708, 0, 2188, -1568, -5846, -1312, 0, 0, 0, 0], [0, 0, 7801, 0, 11445, 4892, 10212, 0, 674, 2990, 9634, -5259, 0, 0, 0, 0], [152960, -29193, 0, 39004, 0, 0, 0, 27350, 0, 0, 0, 0, -1256, -125, -426, 682], [0, 0, 427, 0, -3916, 2784, 9892, 0, -6172, -14, 1341, 3384, 0, 0, 0, 0], [0, 0, -1621, 0, -4099, 6316, 694, 0, -2538, -8104, -6830, 1563, 0, 0, 0, 0], [80426, 82712, 0, -13338, 0, 0, 0, -5056, 0, 0, 0, 0, -578, 138, -912, 300], [0, 0, -2556, 0, -8448, 7318, -658, 0, 214, 10254, -10664, -1058, 0, 0, 0, 0], [0, 0, -2163, 0, -13200, -2226, -3350, 0, 334, -5704, -7751, 5356, 0, 0, 0, 0], [0, 0, -1493, 0, 10301, -1916, 2172, 0, -418, -10962, 9884, -7027, 0, 0, 0, 0], [270106, -14142, 0, -20996, 0, 0, 0, 17140, 0, 0, 0, 0, 440, 938, -1176, 356], [0, 0, -3076, 0, -10674, 9840, 1336, 0, 4336, 6776, -13050, -3626, 0, 0, 0, 0], [0, 0, 5934, 0, -11651, -7112, 528, 0, 6540, 4358, 2416, 7734, 0, 0, 0, 0], [0, 0, 4208, 0, -463, -5467, -4717, 0, 6401, -4018, 5531, -2759, 0, 0, 0, 0], [0, 0, -632, 0, 1101, 5984, 7314, 0, -3902, 3896, 3412, -198, 0, 0, 0, 0], [309854, 29000, 0, -78436, 0, 0, 0, -16288, 0, 0, 0, 0, -908, -484, -244, -132], [-121884, -39272, 0, -62072, 0, 0, 0, 26916, 0, 0, 0, 0, 2000, 476, 708, -28], [-62644, -38801, 0, 113414, 0, 0, 0, -18070, 0, 0, 0, 0, 268, -237, -1526, -790], [-109505, -20159, 0, -72115, 0, 0, 0, -16328, 0, 0, 0, 0, 303, -204, -180, 718], [0, 0, -828, 0, -2580, -3574, -3575, 0, 1727, -2139, -2434, -7645, 0, 0, 0, 0], [-162665, -17939, 0, 104411, 0, 0, 0, -430, 0, 0, 0, 0, 1865, -1304, 612, 208], [0, 0, -4466, 0, 18222, -5484, -1556, 0, -6660, -4248, -814, 8552, 0, 0, 0, 0], [-129540, 10434, 0, 104234, 0, 0, 0, 14784, 0, 0, 0, 0, 250, 96, 1152, -284], [219992, -70742, 0, 8126, 0, 0, 0, 10616, 0, 0, 0, 0, -110, -756, -512, 380], [64130, -34984, 0, 144950, 0, 0, 0, -9048, 0, 0, 0, 0, 1858, 298, -984, 292], [138058, 63659, 0, -21870, 0, 0, 0, -29678, 0, 0, 0, 0, 338, -495, 1226, 634], [225118, 44804, 0, -114820, 0, 0, 0, 464, 0, 0, 0, 0, -988, 396, -1476, 256], [0, 0, -6351, 0, 9585, -9483, -13801, 0, 4711, 3229, -2577, 3613, 0, 0, 0, 0], [320134, -66032, 0, -35174, 0, 0, 0, -19876, 0, 0, 0, 0, -1470, -254, -456, -784], [78591, -13794, 0, -77989, 0, 0, 0, 39282, 0, 0, 0, 0, -135, -1389, 1518, 474], [0, 0, 3910, 0, -14123, 4275, 5695, 0, -6825, -2148, 8941, -1975, 0, 0, 0, 0], [0, 0, -3336, 0, 26474, -3816, -5798, 0, -2722, 5618, -900, 6854, 0, 0, 0, 0], [0, 0, -6341, 0, 8500, -6436, -7640, 0, 4616, -10384, 16135, 13004, 0, 0, 0, 0], [-261870, -64525, 0, -35042, 0, 0, 0, -27646, 0, 0, 0, 0, 1098, -671, 1834, 490], [0, 0, 15060, 0, 27582, -11298, -2958, 0, 5730, -12588, 1890, 5814, 0, 0, 0, 0], [0, 0, -2796, 0, -1203, 906, -18038, 0, 1790, 20378, -8082, 6692, 0, 0, 0, 0], [-45448, 85211, 0, -137394, 0, 0, 0, -13706, 0, 0, 0, 0, 292, 1475, -1226, 266], [0, 0, 1915, 0, 23193, -10255, 5171, 0, -9505, 8409, 14065, 6745, 0, 0, 0, 0], [156929, -52989, 0, -26833, 0, 0, 0, 13944, 0, 0, 0, 0, 649, 1428, -600, 1018], [0, 0, 11744, 0, 11442, 15874, 7137, 0, 4799, 12133, 5810, -27, 0, 0, 0, 0], [0, 0, 10451, 0, -12831, -3571, 13799, 0, 27, 169, 4437, 1321, 0, 0, 0, 0], [0, 0, 4544, 0, -14082, 5476, 10534, 0, 118, 33114, -3772, -3070, 0, 0, 0, 0], [67729, 9889, 0, 144543, 0, 0, 0, 13016, 0, 0, 0, 0, -1307, 442, -336, 1194], [-41841, -59977, 0, 191211, 0, 0, 0, 4654, 0, 0, 0, 0, 161, -1270, 660, -900]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_138_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_138_5_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_138_5_b_a(:prec:=16)
    chi := MakeCharacter_138_b();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 5));
    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_138_5_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_138_5_b_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_138_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,5,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;