
// Make newform 300.8.i.c in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_300_i();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_300_i_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_300_8_i_c();".
// 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_300_8_i_c();".
// 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 := [1831773137685647789586721, 567417098903075834864, -559914287081811190962, -15005055667263471212, 7501118196131608896, 1662723272081664, -506171935260830, -41201367881396, 10299424335549, 551013008, -49457570, -33135588, 5524236, -784, 132, -8, 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], [51696753313793325928362747543089343, 1611351920858187960485940331725082, -1611312411360702025050329347065403, -77526357845150826006522794058, 35031584283286251950704707794, 4477919399634508344917218354, -1492651709261143673520544469, 14585233568523692863986, -9117910351391012676864, 3647911715052036672562, -729761235766306475869, 99890680330701154, -18575791285636901, 889543644855404, -127077663550772, 0], [95896918236212887991115332894775895060366142611497, -24109169816385257263630605451125109242820954883, 24348865590509606907352656243849058978504571106, -479494531778936666546170745808521334898563731, 240004904541192917003055217714430278772948023, -309669995556284220772732082155222102852494, 104062988667893485327650195386369288529881, -720307994696941624749859508930889454097, 180830012572994292103578176062215453587, -502512149234312356014795712281759676, 101005629888612532186603304894544259, -274875754930010835442335038307721, 46148463225437661058624839129392, -155001878662702377647230497587, 22143125523243196806747213941, 0], [183256291220677775701573453469107852152808167, 546858180872809779319607498529879613569880, -546300142767804854378334231844706185300910, -1114803951196579231927020915460442835425, 554221811230805408730603577639780206260, 3814846657873229264253021778864784761, -1269367223189468141358997825500574535, -1921854948573112701667999905820785, 473858603092330841625660058101060, 4402530112449064314280061961175, -879616251872022106889926252631, -481743436448496976062328175, 77302246543607900568628355, 1379227475911505588504465, -197032496558786512643495, 0], [4328218361487738856422375599813923389645405578855483093610915, 325944632876450122398971306763116434759141751702601194165366, -32280057407473146838869144187850157370674588921041237544025, -193473900686208726590200887565908939802362445450541892970, 8084857948988818935648928251712131315684131122709862440, 1015608680384479078144019712834299100651728487522899694, -76576320880905315493635672162754449879927350336303957, -327708170648093408084181586905075562304859292517090, 2561845585358069163392500414011833626044928567170, 891980173416610688881689993548535534314209665790, -49242256437220123729057241026894746883674719113, -147500069929039282073655150445255068227023458, -1178252814154940342967752678542528430062175, 215315827813746618961041879931209876573740, -9462856723387982895934399937981683424510, -36861473163740780877866236909570472452], [-2384219274594591070917148559207458277608264533179522132636295, 277116947302204378061913289789680021903505648009834295540966, 16532212623206642602390501456578505172235371602020165009275, -162759349546993294007824903106587013187258766842007605220, -6981086573075366537125259871035990037267180323510401360, 666036363972089661410883371227187165128377669927474264, 39906442153169292418248300978692680006394404713403093, -292722389106350855461786373768488778015466907052540, -5621358591455061034868565241371742130218980300630, 516485576803091391547776124615218076429814095540, 25857329325697273402178890703948857722400844417, -148129466147965866906157781319267218664083208, -851783965018202989264187340945391264115825, 113052991206528212059598714425773525910790, 5146119934786075232843195134223509527340, -36861473163740780877866236909570472452], [385811465228283680167501595800317130701675654198166563100536771, 1252720600367212926348449028524055461705824108622307450432175, 17605630919201632529158155397516864966259047004991382719398, 3350063902946454438401364383539854144055444993279517651007, 913522144085661602517935008171915871971459440554327111789, 2159192368858412451783375481885166967684423879026004774, 92311436873603608488052462543477921735898251101372755, 11098697382543303533718506276081887352241924396813109, 565157379477107401937826706261906625228949511872001, 983601355179782981684980566518045887487877200012, 56666660837929666633250040128851111632987793985, 9799828817994729839798804447131752712423392525, 103217884180680450540779274079626760294759616, 680445816645972305485834844787813451515519, 3606487461160569788013968668706547099863, 2372313289044017481001439948588399546432], [-112366460868203879296120555277279609348926262349719988689917767, -1605344176882501141640863785553846078251584171626426018962065, -181505570036890405193285216492652674743256315756233619817156, -5923910659269948901588587966137256036807613340646882988811, -390988702895858340314138568787138266838795200962148787351, -20796764496166594530968176328361792453394936332299034468, 130982581673176302664462848975528979456122601186108325, -7781934141504448833453927926984863827844061491291383, -298828177255742725647673331624771194235401621942503, -23921657179028776454385750116296986814644628469058, 303423904266143379312832301629863255852392661635, -3477754148409803519945081979288846415808737395, -39579794568064963960337421491202166627080202, -6117206093401835090827907398909004131745887, 88259564131670711608937228797922280265383, -219677110188754547862158590343431142194], [1253100374835061586525236271356034163612443614215061815, -2508780234057847788122783875193700607941291938559782603, 7739060708745546833245962310440033946604257076507928, -5161401143113162077541212100164720279176972984552137, 3048654848106332257700342571680013191631975027395, -1234760161785915984680537854525053151839094977348, 15299098467014687042220349237411667891011159531, -4372426345268907053499796541231580993383520861, 948577310496874719767682511859382702994539, -218640148649236077036397428105390045052830, 4706151313347573385232014430991184468901, -854787493027090641497651702435718181521, -439121281067420340672855289913201474, 68272672133922482653959596651733491, -306665129873129444695522307015355, 40888683983083925959402974268714], [227422699716659542476579625667639839321611268833129371656280229, -2179019299682444307227294680409181557424147553257074044429961, 393496899679201971035810495735264553923624341096056744896928, -8578301480135604553591312858550694948870387501624569560787, 935450387298342434472276632365359822501428709968216587217, -19892562721075537393371409880865649878982564187902259580, -164783040850108284409853863363707597883635835546694143, -12606809256021100947985739996369536321118743916875791, 901019158861197457161740741841839414676636473156889, -19676571973777886796258365571575331270782856386394, -543053716207218040189152147755369446893579690433, -4858163630430206843256288774592901508749192907, 186547607081196485036115028768122914321527826, -4298354391491478988328515572131726651068399, -171576393284094445890975889313117359831401, -219677110188754547862158590343431142194], [387723353349036916178557809094095651157608671927623321143464211, -2578831661998005322530841858929170479641596282529085991719217, 40937456075429910057538050668028854779540399707977916340598, -12217048190472007124613644579891913989185941410353756728033, 932435325998133284239125286757923812876191160350058663149, -5546484092898708472519227074100696026424353888072098554, 232733089224144848578079173680181538509409553603805859, -29047573121986229070626556163701958993516061154507371, 584764447034878401902896140209755761223142362808161, -3660508820754916891780515844432865962240057987348, 228890419350204627084800758749026531954082477521, -21544018165402397845970084579724809806767618579, 118597966963497870204600443041179148968883376, -1810267213000749329777689823521137320691201, 56983536464650963110546367511945536894583, -4744626578088034962002879897176799092864], [-281949539831939889967332343281119382923973786578287944659375, 563641970217540438206788497877170752639114437747775110923866, 770657575316727581974221178242943417526980630249787782425, -511536421492547855196085405182023281171934146667632296170, -3350900851790642624010308925443363938276024636690999160, 1336277474196912247142251721480015225949205337541694374, 4079167865429613135285864882577318017915682698836593, -1160196182836330131902929351590037709151338053258290, -3954241375463362735135410155823640775072277682530, 872031655927155450228608208615171091285221840590, 4010940015897247010361212770894617124071465157, -727219411934481381513400060392490393954761258, -1017839400545363188158336674952491961622125, 154002085985970772459972403737967592526840, 1109396151860648384737322021255117155890, -147919486914753117964976269500682287452], [-162482438356774575461566135453709093010682289028370663948305, 325301755970998621150477049453669376151335075057143028185254, -1011045911269365664661237973851882143346259825923732444025, 675391906813403355856549541375568029190122833279139823530, -2044876023917114617299039307178075208340685864788519720, 823805513830452257626731686534393860857660284141805786, -5857341471369512701924997712115641585748108516486673, 1676727517284416241671370571251413263306853853290610, -2410437791951544088225587276778912306840299308670, 546099580011642907851208539658880013530240456370, -6269954155788189358871870012083179297572181157, 1141734064614481452266561994537513098341237098, -876394362321572163600010829585986818364595, 138825593789239438132810145272187601244040, -1712439382976979182192644924169181739890, 228325251063597224292352656555890898652], [385438374424205320225904488839446625122208563441980799, -733064554018582044168246599886370277575459233722998387, 13634298297511625888041432512593614284047908636447832, -1042366525321960283038194750221210071806947293315713, 108479393566991724874114217539717553576895908460715, -463533668490631497499448262620502909975545276708, 65363533542701182685101069103072398657468490899, 990847455241541002585076600264946775885133451, 117103075905752867318824627643125328798396691, 129410967243642231484885801858657163083090, 56208987598160600392953401165257248616573, 2485522840929784501054028098240677928951, 29912984312245041676183385502662343374, 208932235886009219753188394327881819, 10183811782744971493093374075013405, 735547367588619265657814635880410], [-1199741081635273703464649917995199459203194567929781749, 2396534196985282298098725400587958735761568602474249457, 8844801328685274140860990411780827357180764647209528, -5899546020142115969922295569643721335539507979561717, 4530156248356071826563796089804710529606518381735, -1836977479090358367018570723139517885319145549812, 24927910114549001630640385146686330843902493231, -7140748488332077768872989313308311490829505401, 13895226890967532400657032274480742891684399, -3119931714235569966634223158273681960945670, 19274524157052978297349361402318909429537, -3515755452924050092207310784825655278621, 5660725512833169996460794896398020006, -880471520286757633736683804913235049, 4110288067961843263361527617890625, -548038409061579101781537015718750], [-309670061023821861564498350999087347864032896726908799, 696204308547538905211978634430968524219211078366142067, 23548815588669077345454706387857963793249500747285928, 396420379742778584009459017525290316072673664966273, 215017322856673751511772360322893501500682822278485, -165833950721185150757967346096488064022151040732, 146085070682357984155447961306255710486676776301, -2414456643858733383227412980176843322434591371, 240385140142685227861345292239402231866796269, -1187732884347432822066000634656893185467730, 156498723714279096644693574264616872289667, -3055468024617374782318115437136884741111, 65792248610991184395172648744946091826, -538640993718861155449255055054327899, 36917439336233876463487577457336035, -735547367588619265657814635880410]];
    Rf_basisdens := [1, 732556427722701533593390872197008000, 1137049101076540554539753508448326922051136000, 4887590702701773360298115149795077897400, 147741725267689237731417853951756441312390952528941772376000, 36935431316922309432854463487939110328097738132235443094000, 2363867604283027803702685663228103060998255240463068358016000, 118193380214151390185134283161405153049912762023153417900800, 12096564671237628746602310753527712719555505363126400, 59096690107075695092567141580702576524956381011576708950400, 1181933802141513901851342831614051530499127620231534179008000, 9233857829230577358213615871984777582024434533058860773500, 9233857829230577358213615871984777582024434533058860773500, 24193129342475257493204621507055425439111010726252800, 13354004224050642099775396474730159781351835580534400, 12096564671237628746602310753527712719555505363126400];
    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_300_i();"
function MakeCharacter_300_i()
    N := 300;
    order := 4;
    char_gens := [151, 101, 277];
    v := [4, 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_300_i_Hecke();"
function MakeCharacter_300_i_Hecke(Kf)
    N := 300;
    order := 4;
    char_gens := [151, 101, 277];
    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], [0, -1, 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 := 8;
    raw_aps := [[0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 6, 3, 0, 0, 0, 0, 0, -1, 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, -16, 0, 0, 0, 8, 0, -26, 0, 0, 0], [0, 0, 0, -1, -60, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -7172, 0, 0, 0, 0, 0, 8, 0, -4, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 24, 0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -36, 0, -9, 0, 0, 0, 0, 26, 0], [54544, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -44, 0, -22], [0, 0, 0, 0, -1464, -732, 0, 0, 0, 0, 0, -322, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 252, 0, -63], [0, 0, 0, 0, 0, 0, 1994, 0, 0, 0, -997, 0, -1326, 0, 0, 0], [0, 0, 0, 7, -1632, 408, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, -8, 0, 0, 0, -7248, 0, 0, 0, -1812, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -432, 0, -108, 0, 0, 0, 0, 91, 0], [797054, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -302, 0, -151], [0, 0, 0, 0, -5038, -2519, 0, 0, 0, 0, 0, 6266, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -46, 0, 0, 0, 0, 720, 0, -180], [0, 0, 0, 0, 0, 0, 38632, 0, 0, 0, -19316, 0, 6292, 0, 0, 0], [0, -1300936, 0, 0, 0, 0, 0, 444, 0, -222, 0, 0, 0, 0, 0, 0], [0, 0, -6, 0, 0, 0, -87588, 0, 0, 0, -21897, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 504, 0, 126, 0, 0, 0, 0, -872, 0], [0, 0, 0, 0, 43688, 21844, 0, 0, 0, 0, 0, -4412, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -1118, 0, 0, 0, 0, -5220, 0, 1305], [0, 0, 0, 0, 0, 0, 124766, 0, 0, 0, -62383, 0, -13975, 0, 0, 0], [0, 0, 0, -272, -216732, 54183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 3119618, 0, 0, 0, 0, 0, -2870, 0, 1435, 0, 0, 0, 0, 0, 0], [0, 0, 279, 0, 0, 0, -395244, 0, 0, 0, -98811, 0, 0, 0, 0, 0], [0, 0, 0, 0, 352090, 176045, 0, 0, 0, 0, 0, -16809, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 3107, 0, 0, 0, 0, -1008, 0, 252], [0, 0, 0, 897, -472212, 118053, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -5669156, 0, 0, 0, 0, 0, -2072, 0, 1036, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -17064, 0, -4266, 0, 0, 0, 0, 10680, 0], [12110224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7116, 0, -3558], [0, 0, 0, 0, 415112, 207556, 0, 0, 0, 0, 0, -86034, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 837654, 0, 0, 0, -418827, 0, 30224, 0, 0, 0], [0, 0, 0, -397, -1103784, 275946, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1574, 0, 0, 0, -1677048, 0, 0, 0, -419262, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 9216, 0, 2304, 0, 0, 0, 0, -11479, 0], [-17759186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16312, 0, -8156], [0, 0, 0, 0, 0, 0, 0, 0, 5902, 0, 0, 0, 0, 45936, 0, -11484], [0, 0, 0, 0, 0, 0, 796808, 0, 0, 0, -398404, 0, 247952, 0, 0, 0], [0, 0, 0, -3758, -1017912, 254478, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 60536888, 0, 0, 0, 0, 0, -35844, 0, 17922, 0, 0, 0, 0, 0, 0], [894764, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1888, 0, -944], [0, 0, 0, 0, 0, 0, 1068470, 0, 0, 0, -534235, 0, -554619, 0, 0, 0], [0, 0, 0, 6832, -578676, 144669, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 83880958, 0, 0, 0, 0, 0, 29832, 0, -14916, 0, 0, 0, 0, 0, 0], [0, 0, -10471, 0, 0, 0, -1102020, 0, 0, 0, -275505, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 80064, 0, 20016, 0, 0, 0, 0, 12582, 0], [-136220386, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73222, 0, 36611], [0, 0, 0, 0, 0, 0, 0, 0, 41769, 0, 0, 0, 0, -71136, 0, 17784], [0, 0, 0, 2665, 3134796, -783699, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 9101, 0, 0, 0, 4929888, 0, 0, 0, 1232472, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 6696, 0, 1674, 0, 0, 0, 0, 11128, 0], [-239617288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -29924, 0, -14962], [0, 0, 0, 0, -1901416, -950708, 0, 0, 0, 0, 0, 1424670, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 58656, 0, 0, 0, 0, -103356, 0, 25839], [0, 0, 0, 0, 0, 0, -3965134, 0, 0, 0, 1982567, 0, 768768, 0, 0, 0], [0, 0, 8378, 0, 0, 0, 6960792, 0, 0, 0, 1740198, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1436094, 718047, 0, 0, 0, 0, 0, -1223010, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -158990, 0, 0, 0, 0, 163872, 0, -40968], [0, 0, 0, 0, 0, 0, -6544128, 0, 0, 0, 3272064, 0, -208000, 0, 0, 0], [0, 0, 0, 6, 11735640, -2933910, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-195478708, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11744, 0, 5872], [0, 0, 0, 0, -8917728, -4458864, 0, 0, 0, 0, 0, -545324, 0, 0, 0, 0], [0, 0, 0, 12602, 2651052, -662763, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 766930234, 0, 0, 0, 0, 0, 21304, 0, -10652, 0, 0, 0, 0, 0, 0], [0, 0, 10823, 0, 0, 0, 10603092, 0, 0, 0, 2650773, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -337392, 0, -84348, 0, 0, 0, 0, -107224, 0], [0, 0, 0, 0, 5208010, 2604005, 0, 0, 0, 0, 0, 1722487, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -11297368, 0, 0, 0, 5648684, 0, 747370, 0, 0, 0], [0, 1020111148, 0, 0, 0, 0, 0, 252416, 0, -126208, 0, 0, 0, 0, 0, 0], [0, 0, -13033, 0, 0, 0, 17870808, 0, 0, 0, 4467702, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 170568, 0, 42642, 0, 0, 0, 0, -151944, 0], [0, 0, 0, 0, -8030128, -4015064, 0, 0, 0, 0, 0, -2296254, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -329316, 0, 0, 0, 0, 157968, 0, -39492], [0, 1155370138, 0, 0, 0, 0, 0, -252538, 0, 126269, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -34848, 0, -8712, 0, 0, 0, 0, 271635, 0], [-1562487818, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -236038, 0, -118019], [0, 0, 0, 0, 0, 0, 0, 0, 201968, 0, 0, 0, 0, -496368, 0, 124092], [0, 0, 0, 0, 0, 0, 25825144, 0, 0, 0, -12912572, 0, -713076, 0, 0, 0], [0, 2761518248, 0, 0, 0, 0, 0, -192476, 0, 96238, 0, 0, 0, 0, 0, 0], [0, 0, -16028, 0, 0, 0, 387852, 0, 0, 0, 96963, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 881964, 0, 220491, 0, 0, 0, 0, -135464, 0], [0, 0, 0, 0, -9962416, -4981208, 0, 0, 0, 0, 0, 3081804, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 325982, 0, 0, 0, 0, -211932, 0, 52983], [0, 0, 0, 0, 0, 0, -9059710, 0, 0, 0, 4529855, 0, 7474393, 0, 0, 0], [0, 0, 0, 36320, -45866868, 11466717, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -337680, 0, -84420, 0, 0, 0, 0, 64858, 0], [0, 0, 0, 0, 35245270, 17622635, 0, 0, 0, 0, 0, 5429507, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -44629, 0, 0, 0, 0, -1230768, 0, 307692], [0, 2424199028, 0, 0, 0, 0, 0, -173048, 0, 86524, 0, 0, 0, 0, 0, 0], [0, 0, 130721, 0, 0, 0, -17545704, 0, 0, 0, -4386426, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -22572, 0, -5643, 0, 0, 0, 0, 811998, 0], [0, 0, 0, 0, 0, 0, 0, 0, -153348, 0, 0, 0, 0, 752904, 0, -188226], [0, 0, 0, 0, 0, 0, 15108238, 0, 0, 0, -7554119, 0, -7762508, 0, 0, 0], [-1497452806, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -405512, 0, -202756], [0, 0, 0, 0, 55301386, 27650693, 0, 0, 0, 0, 0, -7589192, 0, 0, 0, 0], [0, 0, 0, 120258, 25820280, -6455070, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, -45268, 0, 0, 0, -26545092, 0, 0, 0, -6636273, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -657972, 0, -164493, 0, 0, 0, 0, -768716, 0], [-2474668996, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -947624, 0, -473812], [0, 0, 0, 0, 3429712, 1714856, 0, 0, 0, 0, 0, -10490084, 0, 0, 0, 0], [0, 0, 0, 4194, -103516668, 25879167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 136109, 0, 0, 0, -78925092, 0, 0, 0, -19731273, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -271584, 0, -67896, 0, 0, 0, 0, -661024, 0], [-1313509706, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -914, 0, -457], [0, 0, 0, 0, 36568590, 18284295, 0, 0, 0, 0, 0, 15155231, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 60339248, 0, 0, 0, -30169624, 0, -8172946, 0, 0, 0], [0, 0, 0, -184925, 61302228, -15325557, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 788830628, 0, 0, 0, 0, 0, -820480, 0, 410240, 0, 0, 0, 0, 0, 0], [1564158824, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -142988, 0, -71494], [0, 0, 0, 0, 0, 0, 0, 0, -293800, 0, 0, 0, 0, -2118564, 0, 529641], [0, 0, 0, 0, 0, 0, -97060578, 0, 0, 0, 48530289, 0, -2201958, 0, 0, 0], [0, 0, 0, -155823, -90130320, 22532580, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 122140, 0, 0, 0, -37031808, 0, 0, 0, -9257952, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2371968, 0, 592992, 0, 0, 0, 0, 1382277, 0], [-1653243158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1335246, 0, 667623], [0, 0, 0, 0, 0, 0, 38308232, 0, 0, 0, -19154116, 0, 3547492, 0, 0, 0], [0, 0, 0, 112568, 142802544, -35700636, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, -112390, 0, 0, 0, 136775748, 0, 0, 0, 34193937, 0, 0, 0, 0, 0], [-3386395988, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2909064, 0, 1454532], [0, 0, 0, 0, 0, 0, 0, 0, -139880, 0, 0, 0, 0, -3034224, 0, 758556], [0, -570999362, 0, 0, 0, 0, 0, 1063560, 0, -531780, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1280592, 0, 320148, 0, 0, 0, 0, 1540084, 0], [0, 0, 0, 0, -44132454, -22066227, 0, 0, 0, 0, 0, -33516171, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -77345560, 0, 0, 0, 38672780, 0, 9320838, 0, 0, 0], [0, 823749244, 0, 0, 0, 0, 0, -3926872, 0, 1963436, 0, 0, 0, 0, 0, 0], [0, 0, -108687, 0, 0, 0, 249209136, 0, 0, 0, 62302284, 0, 0, 0, 0, 0], [8068505632, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2413316, 0, -1206658], [0, 0, 0, 0, -88327144, -44163572, 0, 0, 0, 0, 0, 22766354, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1335568, 0, 0, 0, 0, 1135728, 0, -283932], [0, -4783234462, 0, 0, 0, 0, 0, 1495768, 0, -747884, 0, 0, 0, 0, 0, 0], [0, 0, -283366, 0, 0, 0, 93006984, 0, 0, 0, 23251746, 0, 0, 0, 0, 0], [0, 0, 0, 0, -50737822, -25368911, 0, 0, 0, 0, 0, -12435982, 0, 0, 0, 0], [0, 0, 0, -460350, 196036488, -49009122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -6161400, 0, -1540350, 0, 0, 0, 0, -175084, 0], [11857829884, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -459584, 0, -229792], [0, 0, 0, 0, 0, 0, 0, 0, 374720, 0, 0, 0, 0, 4743792, 0, -1185948], [0, 0, 0, 0, 0, 0, -188860574, 0, 0, 0, 94430287, 0, -34400197, 0, 0, 0], [0, 0, 0, -811142, -46947036, 11736759, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -11288688866, 0, 0, 0, 0, 0, 211118, 0, -105559, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -9590832, 0, -2397708, 0, 0, 0, 0, 703876, 0], [0, 0, 0, 0, 0, 0, -97506800, 0, 0, 0, 48753400, 0, 28054966, 0, 0, 0], [0, 0, 0, 454961, 209541036, -52385259, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -7422054316, 0, 0, 0, 0, 0, 820712, 0, -410356, 0, 0, 0, 0, 0, 0], [0, 0, -630235, 0, 0, 0, 93145008, 0, 0, 0, 23286252, 0, 0, 0, 0, 0], [0, 0, 0, 0, 30679368, 15339684, 0, 0, 0, 0, 0, -30981262, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -2979860, 0, 0, 0, 0, -218340, 0, 54585], [0, 0, 0, 0, 0, 0, 45362282, 0, 0, 0, -22681141, 0, 35293180, 0, 0, 0], [0, 0, 0, 1160807, 26537232, -6634308, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 102241906, 51120953, 0, 0, 0, 0, 0, 52818428, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -1069744, 0, 0, 0, 0, 9235440, 0, -2308860], [0, -7064333552, 0, 0, 0, 0, 0, 767300, 0, -383650, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 9408852, 0, 2352213, 0, 0, 0, 0, -3077080, 0], [0, 0, 0, 0, -126778536, -63389268, 0, 0, 0, 0, 0, -43482400, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8713170, 0, 0, 0, 0, -6480468, 0, 1620117], [0, 0, 0, -383846, -114914532, 28728633, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, -937481, 0, 0, 0, -201705132, 0, 0, 0, -50426283, 0, 0, 0, 0, 0], [0, 0, 0, 0, 257360210, 128680105, 0, 0, 0, 0, 0, -2894749, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -441389, 0, 0, 0, 0, -12769488, 0, 3192372], [0, 0, 0, -550867, -274449300, 68612325, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 602051, 0, 0, 0, -440959488, 0, 0, 0, -110239872, 0, 0, 0, 0, 0], [17615217464, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8134716, 0, 4067358], [0, 0, 0, 0, 399781056, 199890528, 0, 0, 0, 0, 0, 47980998, 0, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_300_i_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_300_8_i_c();".
// 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_300_8_i_c(:prec:=16)
    chi := MakeCharacter_300_i();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    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_300_8_i_c();".
// 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_300_8_i_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_300_i();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<7,R![3062695070691995222016, 0, 0, 0, 415661203008, 0, 0, 0, 1]>],Snew);
    return Vf;
end function;