
// Make newform 966.2.q.e in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_966_q();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_966_q_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_966_2_q_e();".
// 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_966_2_q_e();".
// 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 := [529, 2622, 7846, 14656, 21163, 21691, 14705, 8761, 2719, -3225, 1660, 2218, -619, -1170, 1046, -538, 277, -126, 42, -9, 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, 0, 0, 0, 0], [-564202875773429969883625162944448204086780630, -1360691756512598952437112775300559257400476006, -2517594849990809737093354438245214795621450731, -2402105829725697548786452445108917382830329767, -768514518883320757674591268423956993142310293, -424795436260487830196617898777307567508376035, -449758599463135904236456662663971102724471123, 2931059958942588385189137330467471475151062728, -1228097184655197132967008226996908498328496829, -726018036525236953626284569149719789660706180, 355607898560194028951254851120731990772049844, 838785192840971206759891755753019604350137058, -998575995802855027010589030773194209990457406, 610502873275512601719570497048352822204150818, -306901642192318468917724018250835608216814974, 141792957155287377131689546242866264951338070, -53381741765990841772448131916835392357906415, 14579768326072066435638822186200685633925615, -2575375412815295804037042516564570750824651, 227706461905959153851786771496926484304616], [213832038624949876207023548991966443443923076, -249125136415654029652364768020258132971140324, 1179310978402957470686426770059338701311747988, 1520989402846073809904498477369370765366667267, -844290885271849470608290513763263200014262798, 437662458864581738709244132011543152973956847, -544848240283939525606124892571888299009870925, -2341615176935255794856512118977654161270849427, 856131056566915189721000700462037409374204972, 1073363211507546221313203571600627074925434019, -932851700362356143155561459660526235032075122, -318603724726695187687274641705012432757785594, 702235195893872571816392882112786736266233662, -473327992797447746997380000921342577914068965, 247723191315380562471152215410915459911604788, -120475357908425916105559371866818070143887996, 47766371016046843117406820374157570597680864, -13656004266196239915501565997725568178246465, 2515420747894456857276237728966788431440260, -233522134875132636900125217170645312065445], [213832038624949876207023548991966443443923076, 332240705214374863234919070833813303217044325, 1179310978402957470686426770059338701311747988, 1520989402846073809904498477369370765366667267, -844290885271849470608290513763263200014262798, 437662458864581738709244132011543152973956847, -544848240283939525606124892571888299009870925, -2341615176935255794856512118977654161270849427, 856131056566915189721000700462037409374204972, 1073363211507546221313203571600627074925434019, -932851700362356143155561459660526235032075122, -318603724726695187687274641705012432757785594, 702235195893872571816392882112786736266233662, -473327992797447746997380000921342577914068965, 247723191315380562471152215410915459911604788, -120475357908425916105559371866818070143887996, 47766371016046843117406820374157570597680864, -13656004266196239915501565997725568178246465, 2515420747894456857276237728966788431440260, -233522134875132636900125217170645312065445], [235305910727945244839345721475923893476568362, 2272195804312043565421939115251712413045784402, 3032934497880976282590203320017203853431233254, 4776017286472139798823530281339119519326925125, 5576864234212514073125108615866989297972796736, 2853176474914202701848105581369105838422254008, 1119401217177611604408937286418848463949397906, 1408870595418069028525106501312845885297978539, -661259848426408038432787270518361275292720427, -14597238528401889883011348190947567561874700, 635766727341208571939792880300666371296288440, -79309551931677182842123348610768322758662810, -340749210469193521867137584342445491224534094, 284690355845507133073286594416010898608083693, -149059217611515250234737846737400149015214378, 75634809827129083009355528428267528980766324, -33013743937117888108883348394806389154386334, 10564235817158081650956441973276488413694767, -2187941200051566439541910470380962592367734, 235783723251861379945490293394281513582328], [727622442752768001443371563300281242548487443, 1992194078404900239559899818581433917329122436, 4403249459322669830341507447065903705548524797, 9398785088333880151457514270506147590569544570, 8330259563467720274157575908035232130092461757, 6488893850831931831134066835722864765631588945, 5882980943273981438428786812207555883411133111, 242941368804046461331734705415385576871592464, -2376970630345851232216135415644278833161070919, 1603855829128739497604822501865940783457240162, 1215162253403706199836949937856584401677674786, -952446976439891425071870343031552763660918698, 391347823551045367479145872947986554163485, 175090253678376659669767694316110815782806436, -96994654908630857806309568317828331695111276, 64202390229909897353945775222770037784108724, -37275634423300327952333910699793849352820279, 14461792148604399098668921170206350745581988, -3404452057231765067945265975509313083010751, 404219354678544189427265688075550932786244], [414773702591555131653524212526952126585648840, 174446485892169220348770070220354651309598554, 893991655401683694735520588845523321078946231, 136112510197492450209495900852744558132943203, -4488244036736811281546743016721574912393594530, -1556739909859453132175954064590467995421934806, -1342603022942824098785788768920498662821280576, -3833909101596753553625618195684086957876483171, 1652789491142534998002143335672058891505017568, 1158902484798623268307171232136874081864130075, -1364283352706777021903324454325227363700629083, -591488570094864818900841773258907520139865949, 1285447793863365558456938373564542099047641333, -876741969621838867276158069830354062213801483, 451898111417691302359783464726766500883937796, -218327614329528831216916582271867084468704154, 87503740887427403221171659488764025054523238, -25554655260623443488420013762672374363802112, 4839571372562997245551041815111935287453248, -468152219631578542715238311127148309414983], [1144008454220371019076978514699433773132878119, 2618683809329702245467976097196160863358401549, 4657379877632901263161338779679602470623615326, 4095758888763221436202118261380879513814189707, 168457552892914382652837326653781682657907542, -891682285898199134500002574409564219559756561, -366776136322477350375367251538248283442847746, -4568366333296901342185649664318547619582330273, 2244067756898030291248329488529640651010040691, 1057922868453661086557824455024943072503208189, -794144885877179639460731581104708724630797861, -1397509696491151505909728862758901977711444208, 1834192700852876148951459726785508090473217867, -1148670223940173042859414131213003405944748574, 576971622389535107329262719571137926316977696, -268637980989471459142247416289539012820246487, 103039571442587813696275579208135608022421616, -28824245397183031832945464049067540774814367, 5232849819916153139861281806102439900794422, -479877948171824457169440048720788520513293], [-1220964412696693830591523475228001684767621509, -6896311087017634601444042260993291251299875459, -15180955256919783696954631170905093226017505191, -24916767134221869685735655892160755765986205097, -19987803431373432842872007868372791719298299992, -16781735420778153296256609623238420762024654643, -9570022288480235064470568403973053428173187896, 3916366553448762960905064567455023558364739307, 1525519552175853414280979433924136884694273560, -4442058615430952280925201093739293593093105101, -737983280058096242217718297782735249051806918, 2171511799113420600081966228797214878022876266, -923724933039770226706238142393112338055947669, 271962341414232383117878480020913871556443447, -137635167251799076251408689390431530718134273, 39578487167795476866441104968100496017591950, 5975310001982782741472898705798536281748151, -9117107982365109720571303638690277571541874, 3182523548936991124915660076706108396661453, -483142791132993150952508127739829163807091], [-1470504851700909765582109897073185138424971026, -4380771905899861433100833444570939264777217686, -8181692649551900156891906717400798729179486509, -11317971783128377719201079628102097591457928136, -11703807312331930471146913384200138909452537419, -7549688208508931072305381787766606670327898794, -3447388246388486534268983602011811949074329134, -1611918606925657552806898481013310646328804372, 1276233982032856734513469835084424000066955598, -832427779878201467306613900903129716884579772, -730719191650570816651273183376698182394030475, -27797271909016371205715103046263037378779833, 768089062119673476241704917834211588575740560, -611613599287200870485083208275305553307216519, 307991133411529213723043782463267616217095325, -151771985411049415701176836740197750341697782, 66052344551830064224587279693300251246559654, -21381099339116414680938123666100394292176511, 4501452809797371372540473592279254597493837, -495419506074112229959889026986384096244074], [-617743121467097977540781899121206406401036761, -2455168798297009321020709153878336727381015211, -3712541121196118981184382515459779167053448732, -8246263936883734054798783797209890617763489361, -9466999152493289817513523967985494902482247487, -5940864502746216085324579733745151078030182277, -4578247638586272545704198414840009777632860646, -2245765162741768766289710225785508209279546972, 2263832062232936491375149741845750340236473489, -465819583499494213694484112500310263967981009, -1526174569473358585195566010882036704881869466, 324737441797006283875283826559173791567448021, 702441852279703927230956301891175428293073796, -604323232801687466000649974257092265273086742, 315574683454826074784110454794575213442294304, -163675595096009932220243907998690193703295721, 73456156554092114348474563956644287335883626, -23962072648810850716846834808988506429575698, 5016999592247037422573784667227242203048954, -541252576306291761984809409321003784714521], [-1229668991809039189199194508254365027717941332, -5627701651600205832351127901548970026894821783, -12786961795386253993171782136323799658318342836, -17700323397108969845568267219016776581705203881, -17951548702607277978602394362812977796616678115, -14627158370730879159268293745410747585581815575, -6606837041838536105265161489309359008564652711, 919969793508276077345995896160741936497082111, 1277373716802860986804900929523698641616764723, -2500933012272105942476134963128173094152517688, -862606397297475224891191277240141133111544211, 792701260908918673495651290678500521710939230, 341781455175882244675388166887664208248616731, -449209288627945865826116754570187633396608773, 223562599824275609476499230276273852506823916, -119657016915124250736079927600607104490274773, 60836386726815004134459451976373670978641042, -22500566410874450677914226612137437371702133, 5240476157964949250767140718588626041450108, -629926669273459015479855464984545494025420], [1087657943080947916273881649981780056710107317, 4647308894355379098359568761637028565511202492, 7013947245525706934562088493802927901500919137, 14597514124904324052171946971814653119527835609, 14120997446387236932245565321666281580681140832, 8879590832589745652254693755240341617195322865, 7616405335956011933088053281620208166166410249, 2598111946454061435150344380736683338714948705, -3806005130668517207102241079736434558321420053, 1490115931539492695830392227996796609885078089, 2256927199871406552369268053382705653082502406, -1144554957540148639134689101194471060590266444, -406998435406867487843793581469789438819168831, 524662863788399500073968229803257834724100463, -284114453844206237691351162580820916111294259, 162044774559052808187365372542314261472796962, -80612096846781696825671976252651788225668081, 28331022773145834985376934570609757602289761, -6253712697863235200733026096606940518615476, 705890768715219589405253811302261416495354], [-253855434582895137842633785773297127351531997, -2402248434326894745775250322445341273918732365, -6383806190685836936419402719459467595305698427, -11690471086039160507436652133731479027266437534, -14251415905923542423278978012458926973437009466, -10577490126687958683115161423456405481111746005, -6164922941968479508176613342029630974588217004, -3837434567610876718886097015304579944774112227, 3263578192217710643141942171846723632306686606, -696461374043896416876885331405097672354670766, -1854520262418889685459094935901452016555274569, -270224403167927006541086446958000213867686013, 1694554146409510844897612252917070071909172575, -1272735501491841534063214869782185521472665057, 646717890152444660660179840251058613487844096, -318797286273093549372103973359353702280826062, 135711789345876084506312522793880592638064326, -42574949972937932092926133069316254437746698, 8669371573966404631828982002794422913256061, -913948286369733025336321367615343216174785], [4567762570967815562990218815734779469139482518, 12640390811522375072073571875591392089300840502, 25267914563294311417927285927676373378383978564, 34911304520268611507825105747694008144441200734, 32667819005345297780756949567683663512887962184, 21503178700958934309204810879272280275534435834, 14377847621032959096342429330674337004603340274, -1764522103822044179451244301525633701831945140, -2399082867583646318434352421078900331969582831, 3522717767073605358357309849274639545524887204, 2970402121676557998993842416242375934423524295, -2769559616554181704327299423206403693472941662, 320506037821457263906411528756257521371821301, 308254208916516069331936633066029604040230781, -179157128587406620249090505956877697158817938, 128360399663942010494065900162168914564740978, -81429001353859937005198911588234142450886933, 33600460168741732902066231860947471580005487, -8279568892528892092859687140744808405317100, 1032134408398543706695594216944412166346552], [-1435792062538314811333898901902357928073132334, -5850525685582595827570016125955429078225204889, -13229193503611522940087669271552392407521006553, -21802800150290778396667864919465187322715040317, -22709655562608074507696980228685879568307046735, -15233801491743457114929342999147202509933580227, -12275070156770603444074657278589041826765968398, -1671841604055494905054876117135330947629833101, 4165629141193122875884679938707083604745521930, -2126074389645059340873405645993669644428110044, -3204384395989303292207681191312161601825523518, 1658768018683295766817704297054126985661000336, 637356039115627407285800846325946608384759082, -808705556406940034859727627193196190412244646, 432008833328843669744284627035230396293818790, -242051522107808972325404741685456011294339775, 119805037623743011457247322484877714583341605, -42219559903789730160258339040461562654931089, 9371208248795117838497223562151530674071614, -1066546078966786332483223370405384128708470], [573279744288167028531258930794497514670420563, 3752590955928228910020056031485351984043040944, 8736860136258114882143334113750294565884439923, 17501904599258888501602345054417237297000787863, 22804643580684245804815605983089468820054862824, 14875465051941112513177073794151809680777677121, 12323500455472404841756625408667669197396444797, 5791022481050236595041515867256877703817371859, -5885205591303504254062195237895022016668788721, 668996635734309274060014122423078855115980506, 4359299451266783402073042883704788655325962841, -813500686697400234698192596857567657721968945, -1974739051375325386590615385693159939220214217, 1670083821965666624067184005354023082024096819, -874369183142226577272979644461166981382471956, 452544289436767374984668653003185012516570938, -201572808853697986512508538291397325494874852, 65192777374259389486752614125320908462284302, -13536461080403665978322908353403361187274938, 1445591393352316789352698474674940099853289], [295797743714153430786726078111645798898440601, 3796349515562331854843297062030803487002340236, 9769866575564529895877286904975448413560654867, 18380184694927755652950983768902902932973098948, 23054384015809945292137532392832075245617927295, 17109622844022213788689868301780896132389056122, 11423558714713948406788147746644314020572419784, 7049490079702754262066491362181747184310494426, -6426341030072802541800481463976174674130920262, 1153593890905850180421301781260841058020917788, 3589228494288322985575391940669892239337269856, 228585723496214429015850415974747335265955763, -2820351023090994023383882760919378389231162343, 2146354894313204497861515003788777960024776041, -1096834799084265064978541529274397670761685495, 546145468008338540366945478267763938599385098, -234334265005424851599616666034272706600785261, 73796264069388116938109638939203973861678821, -15041622634606006443975325813499952223360636, 1582860602100195324610855287227141949453930], [-12380604177578485604104512142592651907903439, -42408378085135883753721225389908355603770022, -89191501049527763139993152020207447985457431, -151953823768617815986604371115619647641691677, -144140933690801788074885259799303592857152147, -95090870265853481422014496578429914076382490, -76848794638227641977902500681799107793247439, -454410856738575232335638375311194571033822, 22432375556306593375998092221486929333378656, -16589926462128716644929563439540910757737377, -19186939910604794896971718930510641697638464, 15002900622533456233830825626444210981684550, -1142805545071466511017542201918459305373009, -1959505929510747520159443784615110429014931, 1163656010730540025201448364525067790433567, -815231596529310320140910163213008123316614, 489738625456409193576412836111207589408459, -193689168065371948777495374550886589994977, 46216425985603368283089534872625406977486, -5572243477454175864208311364218617211248], [-2356328827212812645050617405943447313878116818, -11965656916511359776233693881674437986298543093, -23196717894857080646406767035833757274922534631, -44019432351319708815400369267152104827974869802, -51362514979992711871181372846310320291664010529, -31336577993484414787849482008915411189677639621, -26561516995492348814400124629663996550279049432, -10862741225355745407773252768420548920184650464, 12185426979422666576971949581844947759149103945, -2600286419216622966142126424140597766090755451, -8761630117954530515694740527628034894101656862, 2537756135692515401212477505234902939529597620, 3211077062432672390428107089206890469919309672, -2947820086711597065689963476372586664382257815, 1555076146477948921391438050734174743854780110, -822456128252292658108671949839998067654517833, 376570324849533686388886528315940530624286787, -124621799151407515473106919660487032689258342, 26356754355318494979161296169202551848513164, -2866790463192374825717612507802394357337208]];
    Rf_basisdens := [1, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 581365841630028892887283838854071436188184649, 1893699809869800954030240517439972104847507, 581365841630028892887283838854071436188184649];
    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_966_q();"
function MakeCharacter_966_q()
    N := 966;
    order := 11;
    char_gens := [323, 829, 925];
    v := [11, 11, 4];
    // 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_966_q_Hecke();"
function MakeCharacter_966_q_Hecke(Kf)
    N := 966;
    order := 11;
    char_gens := [323, 829, 925];
    char_values := [[1, 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, 0, 0, 0, 0, 0, 0, 0, -1, 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 := 2;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [-1, 0, 0, 0, -1, -1, 1, 1, 0, -1, -1, 0, 0, 0, 0, 1, 1, 1, 0, 0], [1, 1, 0, -1, 0, 0, 0, 0, -1, 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, 0, 0, 0], [1, 1, 1, -1, 1, 1, 0, 0, -1, 1, 1, 0, 0, 1, 2, 1, -1, 0, 1, -1], [0, 0, 0, 0, -1, 1, 1, 1, 0, 1, 0, 0, -1, -1, 0, 2, 0, 0, 0, -1], [-1, -2, -1, 0, 0, -1, 2, 1, 2, -1, -2, -1, 0, 1, -2, -1, 1, 0, -1, 1], [1, 2, 0, 1, 2, 2, -2, 0, -2, 1, 2, 1, 1, 1, 2, 0, -1, 0, 2, 1], [0, -1, 1, -1, -2, 0, 1, 2, 0, 0, -2, -1, 0, 0, -2, -1, 1, -2, -1, 1], [3, 3, 1, 0, 2, 2, -1, -2, -3, 2, 3, 2, 0, -1, 5, 6, -2, 2, 2, -3], [1, 0, 1, -1, 1, 1, 0, -2, 0, -1, 1, -1, -3, -1, 1, 2, 1, -1, 0, -2], [-3, -3, 0, 1, 0, -2, 1, 4, 1, -1, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0], [1, 2, -2, 3, -1, 3, 1, 1, 0, 2, -2, 2, 2, 0, 2, 2, -3, -1, 1, 1], [-1, -3, -2, 0, 0, -2, 0, 2, 0, -2, -2, -3, 0, 3, -3, -3, 2, -1, -2, 3], [5, 0, 0, -1, -1, 1, -3, -1, -3, -1, 1, -1, -1, 2, -1, -3, -2, -2, 1, -1], [0, 1, 1, 1, 1, 0, -1, -1, 0, 3, 1, 0, 1, -1, 4, 3, -3, 0, 1, -2], [-1, 3, -2, -1, -3, -3, -2, 4, -1, 0, -1, -2, 4, 4, 3, 3, 3, 3, 3, 1], [1, -4, 4, -4, -2, -2, 3, 7, 1, -6, -5, -4, -3, -1, -3, 1, 6, 4, 0, -1], [-4, 1, 1, -2, -5, -7, 5, 2, 0, -3, -5, -2, 1, -3, -1, 4, 6, 3, 1, -2], [1, 5, -2, -1, 1, 1, -1, -1, -2, 1, 2, 1, 1, 2, 4, 4, 0, 4, 3, -1], [-1, 4, 0, 2, 2, 0, 1, 1, -3, -1, 5, 3, 1, -1, 3, 5, 2, -1, 2, 0], [2, 1, 2, -3, 5, 1, -3, 1, -2, 2, 2, 1, 2, 2, 0, 0, 0, 0, 0, 1], [2, -1, 0, 2, 0, 4, 1, -1, -1, -1, 0, 0, 0, 0, 3, -1, -2, -1, 1, 0], [5, 1, 4, -3, 0, -2, 3, 1, -3, -2, 2, -2, 0, 2, 1, 1, 1, 3, 4, -2], [0, 1, -2, 5, 5, 5, -3, -5, 1, 4, 3, 4, 4, 0, 4, -4, -5, -1, 0, 4], [7, 2, 1, -4, -1, 3, 1, 1, -2, -1, 0, 0, 1, 0, -1, 2, 3, 2, 2, 0], [2, 3, 0, -2, -1, -2, 1, 5, -3, -2, -1, 0, 1, 3, -1, 1, 3, 0, 3, 0], [0, 0, 1, -1, -3, -3, 1, 4, 1, -2, -1, -1, 3, 0, 0, 1, 2, 4, 0, -1], [5, 0, 4, -4, 1, -1, 1, 0, -3, -6, -2, -1, -3, 0, -4, -6, 0, 1, -1, 0], [-1, -4, 1, 2, -6, 2, 6, 1, 3, -3, 0, -1, 2, -1, -2, -1, -1, 4, -1, 2], [-4, -6, -2, 0, -2, -5, 3, 0, 6, -5, -5, -1, -5, -5, -8, -4, 4, 0, -5, 2], [0, 1, -1, 2, -4, -1, -3, 1, 0, -4, -1, 0, 4, 1, 6, 3, -4, 5, 1, -1], [-6, 0, 0, -2, 0, -4, -2, 0, 0, 0, 0, -2, 2, 2, -2, -4, -2, 2, -2, 2], [-11, -7, -4, 8, -6, -4, -3, -6, 7, -6, -6, 1, 4, -3, -3, -5, -2, 1, -4, 4], [6, 0, 2, -4, 6, 3, -3, -2, 0, 1, 5, 1, -5, -1, -2, -4, -4, 0, -1, -2], [-2, -1, 0, 1, 4, 4, -2, -4, 2, 3, -2, -1, 3, 3, 0, -8, -2, -2, 0, 4], [1, -10, 0, 4, -1, 4, 3, -2, 7, 1, -2, 1, -4, -2, -7, -7, -1, -8, -4, 2], [-2, -3, 7, 2, -6, 0, 6, -1, 1, -3, -2, 1, -1, -5, -1, 0, 0, 2, -2, 2], [-1, -3, -1, 0, 0, -2, -1, -2, 3, 0, -1, -2, 0, 1, -1, 6, -2, -4, -2, -1], [6, 2, 3, -3, 1, -7, -2, 3, -2, 0, 5, -1, 0, 3, 1, -1, -1, 0, 3, -3], [-6, -4, 3, -5, -4, -4, 7, 4, 1, -6, -2, -6, -6, 0, -6, 1, 4, 5, -1, -5], [1, -1, 0, 4, 6, 0, 4, -4, 4, 6, 4, 3, 0, -3, -1, -7, -8, -7, 0, 1], [0, -5, -2, 1, 3, 3, -6, -5, 0, 2, 5, 0, 0, 2, -6, -9, -5, -8, 0, 1], [-3, -7, 0, -4, -3, -7, 7, 8, 0, -7, -3, -2, 0, 2, -4, 0, 4, 0, 0, 0], [6, -2, 3, -1, -4, 2, -6, -1, -1, 0, 6, 3, 3, 3, -7, -6, -3, -3, -7, 5], [-2, 0, 4, -4, -11, -11, 6, 8, -2, -12, 2, -4, 0, 4, -4, 0, 12, 4, 0, 0], [1, 9, 0, -5, 1, -9, 2, 6, -5, 1, 9, -1, 0, 2, 5, 11, 3, 0, 1, -4], [0, -1, 2, 1, -3, -4, 7, -9, 0, 2, 9, 0, 0, -2, 2, 6, 4, 2, 2, -3], [-5, 3, 1, 1, 1, 2, 0, 2, 1, -3, -2, 2, 0, -4, 3, 2, 1, 6, 1, 1], [4, -3, -1, 3, 11, 5, -4, -7, 3, 11, -4, 0, 0, -3, -1, -6, -5, -6, 0, 0], [4, -2, -3, 4, 11, 10, -9, -9, 4, 2, 3, 5, 0, -2, -2, -13, -7, -4, -3, 6], [-7, 1, -3, 8, 4, 1, 4, -2, 1, -4, 1, 5, -3, -5, 4, 6, -5, 6, -1, 0], [-4, -1, -6, 9, -4, 4, 0, -2, 1, -1, -6, 2, 6, -3, 1, -3, 1, 0, -3, 6], [3, 3, -2, 6, 5, 7, -5, -5, 1, 8, 1, 5, 5, 4, 9, -5, -9, -1, 4, 6], [-2, -1, 0, -2, -4, -5, 1, 0, 2, -2, -4, -1, 5, -3, -2, 0, 5, 3, -3, 3], [-10, -2, 1, 1, -3, 0, 1, 6, 1, -2, -10, 1, -2, -2, -1, 6, -3, -3, -1, 0], [0, 0, -3, 3, -5, -3, 13, 2, 0, -11, -2, 0, 1, 3, 1, 3, 13, 5, 1, 0], [-13, -5, 1, -2, -11, -6, 10, 11, 4, -3, -4, -3, -3, 0, -3, 0, 6, 9, 0, -3], [-2, 5, 4, -7, 3, 1, -5, -3, -2, 3, 4, -2, 0, 2, 2, 3, 1, 1, 0, 0], [-6, -5, 3, -9, -16, -11, 16, 16, 2, -7, -10, -7, -7, 0, -7, 8, 11, 4, -2, -5], [0, -4, 1, 2, -5, -6, -1, -3, 0, -3, 3, 0, -4, -1, -5, 5, -4, 1, -2, -3], [-2, -1, -4, 3, 2, 2, -6, -3, 2, 2, -2, 2, 1, 1, -1, 0, -3, -7, 2, 4], [5, -2, -3, 3, 1, 1, -8, -2, 4, 1, 10, 3, 2, 1, -3, -6, -1, -5, 0, 6], [2, 4, -1, -3, -1, 3, -13, 0, -4, 1, 12, 3, -2, 1, -2, 1, 5, 0, 1, 1], [-3, -5, 2, -1, -6, -4, 1, 11, 4, -1, -4, -6, 2, 6, -3, 1, -1, 1, -4, 0], [8, 3, 1, 5, 14, 17, -16, -14, -4, 9, 14, 9, 9, 0, 9, -10, -17, -4, 4, 5], [0, -1, -2, 2, 3, 2, -1, 6, 0, 1, 1, -5, -2, 5, 0, -2, 0, -2, 0, 0], [-8, 0, -5, 5, 7, 7, 3, -2, 9, -5, 0, 5, -1, -3, 3, -2, 5, 1, 0, 2], [0, 5, 3, -2, 8, 3, -8, 1, -1, 14, 5, -1, 3, 6, 3, -9, 2, 1, 4, -2], [-10, -14, 0, 8, 0, -1, 11, 8, 7, -10, -7, 1, -2, -1, -7, -3, 5, -7, 0, 5], [-4, 3, -12, 12, 11, 11, -8, -10, 3, 12, -2, 12, 2, -6, 9, -3, -12, -1, 0, 3], [-3, 3, -5, -4, -6, -7, -2, 12, -5, 2, -11, 1, -5, -1, -4, 1, 9, 1, 5, 0], [-7, -6, -4, 11, 3, 6, -5, -12, 10, 3, -6, 5, 3, -7, 1, -10, -11, -5, -3, 3], [-1, -1, 3, -3, -1, 2, 3, 1, -2, -1, -9, -1, -1, 0, -1, 11, -2, 3, 2, -3], [2, 1, 7, -4, -11, 7, 9, 6, -1, -4, -2, -1, -2, 2, 1, 6, 8, 0, 2, -7], [-12, 3, 5, -5, -6, -6, 17, 4, -1, -6, 7, -5, -3, -1, 4, 9, 6, 8, 0, -9], [8, -1, 4, -4, 1, -2, -1, 2, -2, 4, 2, -2, -5, 1, -5, -5, -4, 6, -3, -4], [6, 5, -4, -5, 10, 4, -16, 2, 0, 10, 6, 4, 5, 9, 2, -12, 2, -11, 4, 7], [-4, 2, -1, -1, -4, 1, 1, -1, 0, 3, -4, -2, 1, 1, -5, 0, -3, -3, -5, -1], [-6, 8, -5, -4, 4, 1, 4, -4, -3, -3, 1, -3, -3, 0, -3, 2, -1, 9, -3, 0], [-4, 9, -4, -5, -9, -13, -3, 9, -5, 2, -1, 2, 2, 0, 2, 6, 13, 9, 0, 2], [0, 6, -5, 1, 16, 8, -11, -3, 0, 12, 3, 0, 3, 5, 5, -6, -7, -10, 1, 4], [0, -5, -1, -4, 1, -4, 0, 7, 5, -11, -12, -4, 0, 5, -3, 1, 7, -5, -4, -1], [15, 10, 0, -7, 1, 5, -11, -11, -3, 15, 5, 0, 0, 1, 3, -1, -5, 5, -4, -2], [-3, -5, -5, 3, 4, -6, -4, -1, 2, -5, -9, 1, -1, 0, -2, 0, 0, -9, -3, 3], [-2, -9, -2, 6, 0, -6, 10, 3, 8, -6, -8, -6, -1, -4, 0, 16, 3, 1, -6, -7], [-14, -9, -2, 9, -10, -16, 6, 6, 9, -11, -8, -4, 4, -5, -5, 3, 3, 0, -5, 2], [-6, 10, 6, -6, 2, -3, 3, 8, -6, -1, -2, 1, 0, -4, 10, 8, 8, 11, 6, -3], [-7, 3, 7, -5, 0, -2, -2, -5, -2, 0, 2, -2, -5, -3, 5, 13, 8, 7, 5, -5], [-10, -2, -5, 6, -7, 2, -1, 1, 6, -3, -3, 6, 0, -4, -2, 5, -3, 1, -5, 7], [0, 6, 0, 0, 12, 8, 0, -12, 0, 20, 12, 0, 4, 0, 10, -2, 0, -6, 12, 0], [7, 9, 0, 1, -3, -2, 1, -4, -6, 7, 2, 4, 6, -7, 6, 10, -2, 7, 3, -3], [-6, -4, 0, 2, -1, -12, 0, 11, 4, -6, 3, 2, 1, -3, -4, -4, 1, -7, -4, 4], [12, 3, 2, -2, 13, 13, -10, -4, -1, 2, -6, -2, -4, 2, 1, 3, -2, -3, 0, -3], [0, 1, -3, -2, 4, -4, 2, -5, 0, 3, 5, 0, 7, 3, 3, 0, 7, -3, 8, 5], [1, 9, 4, -10, 12, -6, 0, 4, -10, 5, 8, 0, 0, 1, 9, -3, 2, 4, 4, -4], [17, -6, 3, -5, 9, 0, -2, -3, -5, 0, 2, -8, 0, 11, -6, -15, 3, -6, 3, -1], [-3, 12, -4, 4, 11, 11, -1, -3, -3, 11, 10, 4, 1, 4, 8, 4, -11, 5, 0, -4], [11, 10, 5, -1, 6, 3, -18, -21, -8, 3, 8, 3, 2, -4, 12, -3, -21, -8, 3, -7], [3, 7, 0, 0, -1, -1, -9, 2, -7, 5, 9, 0, 7, 7, 12, 4, 1, 0, 7, 0], [-10, 8, -3, 4, 8, 7, -16, -8, -5, 7, 13, 7, 7, 0, 7, -8, -7, 15, 3, 4], [-13, 6, -4, -5, -6, -9, 5, 6, -2, -3, 3, -3, -3, 0, -3, -1, 9, 15, -2, -1], [2, 2, -6, -4, 4, 14, -6, -10, -2, 10, 0, 2, -4, 0, -6, -6, 6, 0, 0, 6], [1, -1, -3, 2, 4, -2, -1, -8, 5, -4, -7, -2, 4, 1, -1, -4, -8, -2, -2, 3], [-6, -13, 0, 1, -7, -6, 16, 5, 7, -6, -13, -5, -1, -2, -7, 3, 16, 0, -1, -1], [5, -11, 5, -2, 5, 4, -5, 3, 1, -5, 6, -3, -9, 4, -13, -6, -3, -8, -10, -2], [-5, -1, 1, -6, -6, -15, 2, 8, 1, -5, -1, -4, -3, 3, 0, 5, 11, 0, 3, -1], [14, -4, 11, 2, 9, 7, 3, -9, -7, 0, 12, 0, 0, 0, 0, -5, -7, -7, 3, -3], [-4, 0, -1, -4, 8, -5, -1, 0, 3, 8, -4, -4, 4, 1, -5, 2, 7, 0, -4, 4], [-10, -14, -6, 5, -12, 0, -1, 13, 5, -3, -15, -2, 0, 9, -14, -2, 10, -11, -6, 10], [6, 8, 0, 1, -9, 7, -6, -2, -3, 6, -9, 7, 0, -7, 4, 13, -1, 13, 3, 0], [-4, 8, 3, -3, -27, -27, 7, 12, -10, -6, -4, -3, -1, 0, 8, 11, 6, 20, 0, -11], [-8, 2, 0, -6, -1, -9, 7, 5, 1, -8, -2, -3, -3, 2, -1, 9, 4, 4, -4, -3], [2, -9, 0, 3, 2, 3, -2, -1, 2, 1, 0, 1, -5, -3, -6, -10, -5, -8, -7, 3], [-14, -6, 5, 1, -4, -13, 13, 13, 6, -19, -14, 0, -13, -13, -3, 20, 19, 19, -3, -7], [-4, -4, -10, 6, 12, 5, -9, -8, 6, 6, 3, 7, 0, -2, -4, -16, -9, -10, -10, 4], [8, 4, 8, -7, -5, -7, 0, 1, -8, -5, 6, -3, -7, 1, 5, -1, -6, 12, 7, -7], [10, 0, 5, -5, 9, 24, -24, 0, -5, 14, 10, -4, 0, 5, 0, -9, -5, -14, 5, 3], [-4, 12, 1, -5, 0, -9, 1, 7, -3, -1, 1, -3, 1, 3, -1, 0, 4, 0, 3, 0], [-3, -11, 3, -3, -14, -14, 6, 10, -5, -17, -10, -3, -3, 0, -11, -8, 17, -1, 0, 8], [9, 10, 6, -8, 3, 1, -12, -16, -7, 6, 12, 1, 3, 2, 6, 4, -16, -2, 1, -2], [-3, -6, -1, 2, -2, -4, 20, 12, 5, -16, -17, -4, -1, -1, -8, 6, 12, 14, -4, 3], [-2, -13, 1, 12, 9, 0, 7, -8, 9, -13, -2, 4, -11, -11, -5, -10, -13, -13, -5, 2], [0, 7, -5, 1, 12, 23, -12, -5, 0, 3, 5, 0, 0, 5, 3, -20, -8, -5, 3, 4], [6, 7, -1, -3, 11, 8, -4, -10, -1, 11, -3, 4, -7, -6, 3, -2, -5, -5, 7, -7], [-16, -15, 4, 3, -22, 0, 28, 8, 15, -13, -24, -10, -2, -5, -9, 5, 15, 0, -5, -4], [5, 4, 0, 4, 3, -8, -6, 14, -7, 5, -2, 1, 4, 2, 7, -2, 7, 6, 10, 0], [4, -3, 0, 8, 4, 2, 9, -13, -2, -8, -8, 2, -5, -8, 8, 10, -13, 6, 2, -11], [-12, 5, 0, -6, -15, -18, 2, 2, 2, -2, -15, 1, 0, -1, -8, 8, 6, 8, -2, 0], [-6, -6, -3, 3, 5, 2, -2, 6, 3, 0, 0, 4, 0, 3, -6, -11, -3, -6, -3, 11], [1, 1, -2, 2, -14, -5, 5, -6, 2, -2, 3, 8, 0, -3, 1, 15, -5, 3, -2, 3], [0, -11, 4, -2, -16, -17, 21, 13, 0, -23, -13, 0, -9, -4, -18, 8, 19, 5, -12, -2], [-8, -3, -6, 6, -13, -13, 2, 0, 1, -16, -11, 6, 2, -3, 0, -6, 16, 0, 0, 6], [18, 4, 9, -2, 19, 11, -19, -2, -4, 7, 13, 2, -4, 0, 2, -3, -16, -5, 0, -2], [2, -3, 1, -3, -5, -11, 5, 1, -2, -13, -8, -1, -7, -2, -6, 10, 1, 10, -5, -3], [9, 9, -5, -4, 5, -10, -1, 1, -9, -1, 9, 0, 1, 1, 10, 9, 0, 0, 10, -8], [-23, 0, -2, -4, -13, -27, 24, 8, 0, -24, -15, -1, -2, 1, -6, 3, 6, 3, 0, 0], [5, 8, 2, 5, 18, 14, -20, -18, -10, 10, 22, 10, 10, 0, 10, -12, -14, 5, 6, 4], [-13, -3, -8, 8, -3, -3, 5, -9, 4, 6, -6, 8, 13, -4, 1, -7, -6, -8, 0, 7], [1, -9, 0, 8, 2, 0, 12, 2, 9, 1, 7, 8, -7, -6, -9, 3, 4, -16, -9, 4], [-5, -14, 5, 1, -10, -5, 7, 10, 0, -14, -9, -5, -14, -6, -19, -8, 10, -7, -5, 0], [0, 3, 10, -5, -10, 2, 8, 4, 0, -1, -4, 0, -8, -10, 0, 6, 3, 13, 7, -5], [2, 1, -1, 9, 8, 1, -8, -8, 0, 10, 7, 10, 10, 0, 10, -7, -1, -2, 5, 5], [25, 3, -3, -2, 8, 4, -7, 0, -8, 8, 5, 1, -1, 7, -2, -4, -2, -6, 1, -1], [-6, -8, -8, 10, -12, 9, 1, 2, 2, -12, -5, 2, 3, 1, -6, -16, -10, -15, -3, 3], [10, -1, -2, 10, 3, 3, -10, -4, 1, 6, 8, -3, 12, 2, 7, -13, -11, 0, 2, 2], [15, 13, -4, 3, 2, 7, -2, -5, -2, 5, 4, 5, 9, 0, 16, 8, -18, 4, 11, 3], [5, -1, 5, -10, 0, -8, 4, -8, 3, 10, 15, -8, 2, 5, -7, -2, -8, 3, -8, 1], [-5, -8, 8, -8, -11, -11, 13, 11, 8, -10, -6, -8, 0, -1, -7, 1, 10, 4, 0, -1], [-15, -8, 1, -5, -28, -16, 24, 18, 8, -19, -23, -7, -6, -1, -19, 8, 32, 0, -1, -1], [3, -3, -4, 9, -4, 2, 3, -13, 9, -1, -7, -4, 0, -6, -3, 1, -2, -2, -4, -6], [0, -2, 11, 4, -2, 12, 23, -2, 0, -17, 2, 0, -9, -11, 4, 1, 8, 0, 5, -15], [-7, 3, 9, -12, -13, -19, 12, 23, 0, -12, -4, -4, 9, 4, -3, 14, 3, 14, 0, 0], [-8, -14, 1, 13, -3, 18, 4, 4, 10, 4, -8, 4, -8, -8, -5, -2, -5, -5, -5, 6], [-5, -2, -7, 9, -18, 2, -3, -4, 4, 0, -5, -2, 5, 5, -6, -11, -8, -8, -6, 7], [-3, -1, -3, 3, -8, 0, 23, 4, -3, -23, -11, -4, -3, 4, 3, 7, 0, 7, 3, 0], [13, -4, 2, 3, 5, 4, -28, -23, -3, 5, 6, -1, 2, 5, 1, -17, -18, -3, -2, 2], [16, 3, 5, -8, 3, 8, 10, 9, -6, -10, 8, 1, 5, -1, 3, 4, 3, 4, 6, 0], [-19, -2, -1, 8, -18, -6, 2, -13, 7, -4, -5, -6, 5, -7, -3, -2, -13, 0, -6, 2], [11, 2, -5, 1, 10, 6, -10, -1, 0, 12, 5, 1, 2, 8, 3, -10, -12, -11, 2, 1], [27, 4, 0, 0, 10, 17, -23, -9, -2, 27, 19, 2, 2, 8, 2, -19, -13, -15, 0, 10], [-1, 10, -1, -9, -9, -35, 2, -3, -8, -25, -1, -2, 0, 0, 0, 7, -2, -2, 0, -10], [-2, -2, -2, -6, -2, -17, -11, -4, 0, -2, -3, -8, 7, 7, -10, -6, 4, 7, -7, 7], [0, 10, -3, 2, 4, -13, -4, -4, -7, 14, 2, 14, 14, 0, 14, 5, 13, 7, 10, 4], [-7, 4, -7, 7, 4, -5, -24, -6, -4, 8, 17, 2, 9, 2, 5, 4, -4, 0, 2, 7], [10, -2, 3, -10, 7, -7, -6, -1, 4, 12, 15, -7, 2, 7, -9, -24, -1, -8, -7, 4], [-9, -6, -6, 0, -26, -1, 26, 5, 5, -2, -1, -5, 4, 5, -6, -4, 9, -9, -1, 0], [-12, 6, -7, 7, 1, 1, 5, 2, 3, -5, -15, 7, -1, -2, 8, 1, 5, 10, 0, -1]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_966_q_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_966_2_q_e();".
// 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_966_2_q_e(:prec:=20)
    chi := MakeCharacter_966_q();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    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_966_2_q_e();".
// 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_966_2_q_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_966_q();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![1, 23, 231, 1286, 4696, 13728, 32077, 47037, 59510, 1770, 22923, -20879, 8459, -3409, 3389, -1683, 527, -144, 44, -10, 1]>],Snew);
    return Vf;
end function;