
// Make newform 16.16.a.f in Magma, downloaded from the LMFDB on 27 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_16_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_16_16_a_f();".
// 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_16_16_a_f();".
// 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 := [-58, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 640]];
    Rf_basisdens := [1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_16_a();"
function MakeCharacter_16_a()
    N := 16;
    order := 1;
    char_gens := [15, 5];
    v := [1, 1];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

function MakeCharacter_16_a_Hecke(Kf)
    return MakeCharacter_16_a();
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..(prec+1)]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 16;
    raw_aps := [[0, 0], [2036, 1], [-70130, -36], [-63096, 90], [-10341316, 17307], [249903238, -2340], [1569758450, -175896], [237334276, 285813], [20388001304, -407250], [17626578678, -19501524], [17194596640, -30813336], [435114282222, -65307348], [450042726042, 384323472], [-250353999268, -376557597], [-604029559632, -356149188], [618367101022, 1167361452], [-7220987952532, 884641527], [9168151708630, -1334372868], [38300710757428, -8202370383], [72938586943432, 1679200362], [-13208634962054, -17753485176], [-128953916694064, 12009529764], [-127756403291324, -35231817627], [-359897305856406, -61727093496], [203817795209378, 259618417416], [-700061111459154, 11344936140], [-1491771650147608, -75009908718], [1428783527299740, -221728962861], [1905438535148326, -389993202612], [1258035194181522, -214252752960], [-6448340332999552, 318610383840], [9681105860535412, -504941450175], [-6135500803531206, 782476424784], [-4925036497209156, 2326019127003], [-3013542087585538, -2187465461604], [-28428378648477032, 401736959694], [24488778070932598, 3355407234972], [8359845104119956, -1716966034551], [42863855436636456, -8417567340126], [42694335890899686, 10705833865404], [-56675917381199964, -8234763016419], [54929854097906142, 20436084899388], [69292585779599040, 10870279807536], [-139828134565047742, -19645990016184], [-19407181374537906, -6856994320452], [-3432254550092728, -66861248940342], [106806363073196996, 21426812436933], [137803765626664928, -57494606425128], [-175950623318921004, -10592811601767], [-283265076670678994, -121992139337796], [627254885467457242, -16549866469944], [-96755762972337296, -178661569284756], [-696150742608913902, 110156718749544], [806660092057792300, -123090821474841], [438937351506202370, -150831098551296], [236627133303315080, 475992566789850], [1979767828225197446, 61517521764396], [-1916389905783062384, -131286666696876], [1241858045501260414, 144878944725036], [495529113466223018, 173280813441768], [1207142072109609292, 307658179794159], [789840643254311406, 171063011504124], [-5578601401978997724, -693298255451427], [5021327375067665976, 181802123812566], [555669796667701386, -656845663420656], [5707565180235318486, -130599915553620], [-4134215392837592708, -361953640559637], [5650650212576620722, -303604677843552], [-3832291221366945396, 227508990649119], [6199944565007316918, 220831072710732], [272634012012459170, -2168933858772192], [1331848862046852072, -3935345946784686], [7843329254647412720, 3806206893718092], [2674938089017130270, -58904410933044], [15499099636608940, 5287731145439175], [-3863042326085231232, 614169714739680], [2311555351817676430, 5142723927532524], [-915408555535938298, -4398203284772148], [-34910427904858084494, -873731971525464], [-40644166003942265814, 1292668188521040], [-28923775818550080108, 5733200958669801], [-40415959120893748882, 10837676752228764], [-50464689795227569616, -10155083988743460], [34196011665276695890, -14510947034798424], [-15796484433702174024, 414242227828854], [-4751854186832898068, -9349795948601097], [53988467609558004034, -6408460185932088], [-25233066337481956102, 7767314662447440], [-12087367176318265658, 5166890493120108], [13417242761318657872, -1226078883421308], [-49575045584991373116, -13313649370475547], [-17600609922689646368, 30482626291276824], [-183198960009799403416, -12291622523374158], [-119977891884743286756, -20253122953985709], [-54313507735918251804, 11037205011741165], [-85056718998716026632, 5005168518892806], [13395962355773763606, -45829472877062820], [-247403057442623834950, 5868448348109328], [-139411806505014530500, -9900465174053541], [334908445660956160758, -6305978930146308], [-255913927604580663788, 30996662595917193], [-22216110612203138714, -17640949574301732], [40160548320862999844, 9071008050224925], [33573390779495315338, 48786146012488464], [-217774234035119566740, 75396878837853975], [-279461411238127350334, 138738020343907104], [165715618240461701756, 118956369802329963], [601946774194257980338, 48173337208224576], [651184022690471839320, -66636091805147586], [13694439790428521578, 162115175134496520], [137810919599685270880, 210965775121667448], [-936615588118721411410, -73179511263497700], [186915824827835648346, 124720205265911592], [819658299784728900764, -12037893103647981], [-352685690605508043400, 262588034241020070], [1415262494328864728194, 1368114685057800], [406240238572149902964, -201854563965642879], [-121017098420100419576, -138421100776948038], [67216064609078009862, 6635446292135916], [1285791853715328183684, -277467785172232011], [-403330898478553781506, -62245835730898884], [-923906824552656616862, -267721136406581688], [442865602860134434414, 113613781877519724], [2285388957953344500956, 134302547409345603], [-2873829921973281867356, 78383455456465053], [845822048167789286742, -201807137729160900], [865964844933298968398, -272299827901734036], [-1475617880888837904304, -251179094183979708], [6498769257894105816, 675345079812331998], [2909018077966717572662, -29170935214218900], [3353182444972878779092, 457328292490680345], [2226421713063421522280, -18097381546698510], [3092621944624928079216, -523994360686117524], [2092356242921302910366, -579941163310003236], [1909971705588350686922, -546609351803522544], [4361346603826951234562, 121825103611048776], [2204201587684611901710, -26687808283852116], [-6375013043189674592764, 426531211232481045], [-6859228932145594438154, 524551701340604124], [1200354748167938683802, 1209845526480674064], [2217178324340140710236, 934283006509962627], [-1009474253977422153378, 1904779867000998348], [6672852323455880849464, -1210291543145103786], [-9270981975888789853844, -118820501278237161], [605998373015911812310, 1281210033579093468], [-10365684308947186412856, -427068659998044054], [7167243717711789371966, -1169181710463348180], [5476312933564096402026, -2273258194198790256], [2432316877496045960076, 871669933272838431], [-4849510714793380598176, 1852005312614510712], [-3687363995318195895258, 1222114732088601708], [-2701236963107322402670, 1025393256091661472], [4687708530529849228900, -502992973234236051], [-20518024775682109919624, 101769600818466342], [2668715261044529492924, 2093694442109395803], [-20552539412056423856368, -1232257580870643468], [-1542850729114607321704, -2400257502109195506], [12852558909553938096482, -2705460515313464376], [11869108376726592461850, 5087843912139146568], [-2691135086310073623066, 4171389703426735884], [-5258585049960158165340, 467337245041764477], [12315659151088115113482, 713373939805036752], [-7849050247305804599480, -1612463944643418870], [24533792805965751930876, -1120127202393047253], [226445766372907023666, 6645703220126610408], [8036118124271810034648, -2153554156124418402], [1973063973709375154912, -5077925721301932072], [-2361234226603104106706, -4844594465995713300], [11405792065341138376466, 2858292649442734056], [-33802000811502271836002, -4974632807765156676], [4344848648268456357420, 4736801890297036359], [36298666800191091488790, 4913041322915005068], [22443941581598477530504, 3140339842724435226], [770128381120256522170, 4944033586675961064], [11717374871670860573584, 8670404488242578580], [-54703961132216979945814, 3657278194529585256], [-74996566713254860259252, 2813146945723363023], [10280386545862768385262, -101717783285008500], [28868839503982973302952, 12844096424370673794], [-21897324377201729787034, 5456211913997092476], [24755305582243079278144, -19122309904065763248], [-6988813005235058641868, -2315083191055252911], [-58081837303865421669426, 7191280440810407196], [-29061454046988345401478, 3056716657091369448], [-4377025555837836562992, 2448209580051399012], [67683531763503561780030, 7941713492824217244], [35552125756616115770038, -10878490942932018276], [12038252674460574649428, -1142337035157161031], [13276683888495489659482, 13097187023303191248], [-131456307597668397467520, 4465729199596745376], [-54314756602698563932286, 3261400122365332128], [51757208756374606167228, 25237595600269032411], [-33056823501241986770044, -5575689035755722027], [68866516324552337972854, 17150454964661914476], [24413924307266440488084, -28265832182093310711], [-99113454037881225642214, -4214267246055029976], [62202639865529829289810, 5144230230401535552], [73476840980266798159702, -35632130335268026212], [102655847812698773342018, 2647309140797120640], [-93463116990381148680120, 1417638512804371722], [-161920691242147788741178, 3898709857942237980], [66384753723140622293584, 17172208683708700356], [101879778216828217348286, 17613952353278952588], [209274805490949211385122, 16310720612634066432], [-20383182410359343720676, 17670936365443750131], [228433779792466566070038, -4944165633661294836], [140727720131577522834688, -12730134238774036416], [225388613677227119031540, 22455182929157831169], [-99728235189170724384070, 22619417837610711816], [66020220318428933441852, 6887210302557178587], [189369838561749310527474, 4063886329178440296], [-357467895080509992151938, 1761877690681046652], [-100834137454758806615272, -8428409607007681362], [-101314378848747332235956, -43617900071320631505], [6696178073150092702120, -71399268737363012670], [37210152643617496424858, -21308273929229974128], [-70234806993589328899664, 30662945581837656636], [28041657590411612720050, 10359220981186156968], [27814989916202073739608, 18613612135274534910], [-314717007851960629559370, 27563312803726777068], [324857298960647604707246, 35858679114613321980], [-44004710141332747806600, 10036957878651127014], [-121630884268338253438590, -81978113608975663992], [235687097824093886259472, 88065862578394741044], [329811023351076343501956, 55748773024065996885], [-169330291147834963931650, 70981419996322127820], [697784801367979498373418, -34707059997560459640], [-272976558075674435812704, 124156150140214814472], [-140883108580023574600152, 94263038294267137698], [394912282529198914297820, -24141263840003460285], [-586930751836786258518042, -38611990616528627604], [194335197585003380760740, -62510539066306261443], [214393199731751326321600, 104681096343135290160], [-204038046965889496166918, 176942202209231914728], [350953908576922756567548, 82224091138567210155], [-320515847170044792130736, -151615491434995432572], [-321348100197060090543310, 176553973335552927912], [371192816253233170633150, 148154403420625991868], [61300394451679680045580, 29367033284021069151], [332156904634417259695208, 42950174273362045746], [-825268069564459647040284, -81244692785467818387], [339164628796916714780716, 225489057063750201735], [47129252641011934373768, -181084810235824868454], [-546713595564915490974074, -50219899588886760900], [-175689529439091341873166, -192417985297632197088], [460822363323490771072024, -22738480589987883666], [-952257701377820241047776, 86519225880815755752], [696127463747813312277012, -71804836550595540663], [336168040107314545164380, 120352852625372645283], [997745991178769333336752, 21174452518601575548], [492841658439030918632406, 86191118427202998732], [836781314486294587914690, 90072620714201012640], [-212200844334231687105080, -261639818516399294358], [369282012612365693815162, -94883510435827133304], [-902851155358678424628666, 67234378437256064076], [-455657240041654991836860, -192022302997015821531], [-1629930873442973338574530, -48740571053023312548], [780984412904443600012940, 83651157570685439007], [-1333908094190128316792658, -148930187166573615828], [-52129808192597122507958, -101049767681323773744], [-766466866646521778910592, -346658460971098885344], [-2466836775392202901586316, -37577241765811553247], [1077975432887063695601038, -17131191758976438324], [809111272464521482827894, -10201388882126426100], [-20953224009883963799966, 2162061247729724424], [423637813942631421018772, 118046585334956255145], [-1818673141474504106165530, 159326391275126576460], [320060563994044044897290, 141474386419636485960], [816899660239327347470572, 25516430953152572439], [37601637231133112794958, 33956531781401801484], [1063688023195949956312006, -573772766458263260580], [916376911176546615410116, -189053522629580334555], [138553924080078299718634, 204633734581996652520], [2506806365661407189956064, -350823256557006158568], [-436859528900517024457454, -501868420049190808800], [-3324001110269490984559112, 47465348962623950790], [-2306585765250299937797844, 513543441904388596935], [746047209236812635075350, -701652734278086037284], [-1816543076164789673553734, 91227318030033133320], [-54319293185054771841532, 679639313356688956725], [31368215347948514838560, -557077085381383623000], [364000280609645214993320, 846801074099857202946], [2611455489488004875289656, -260279310871285621866], [310023645756438064294094, -331671106851056896932], [373650957114892915827580, -768779006627496845493], [2244598736720535551764688, 589242399071415206436], [1804478200994632427213234, 803560087337115154536], [-1002762603547762645850562, 57774735295935185772], [718204978568615741037400, -210518040067163363394], [1055437177873841895915170, -602064025334229978720], [-2703715778587092229494746, -19026580501169474004], [-1085955370019740370097564, -1190666448497357298387], [2202312536295540793703242, 368369265021366068424], [-3243205172854061865204804, 700388780996863415547], [-1871630130746513335860474, 1212603359872427562348], [5221742414627010979242358, -361168000384404882564], [2037151307312763364789408, -732899577982815425592], [-3353765779975676680278306, 1200377097792572583708], [3153363569493622394914284, 575469429584123184183], [-3043182789687334722362444, 412528685158903478481], [1958904587375696138594042, -244897828431729383664], [-1170470387453997944474938, -913965425642724927012], [-6111189428905025018073776, 666315517143190352580], [-4844974121284430222675260, 880178194902291226821], [2499988752728332626048012, 1037461418145004914783], [-3391550965823811452952286, -1493114935533190561080], [2327986524049891186201116, 980052786941550047091], [2999537984811306173970854, 951720786280655079804], [-666986652296369978347784, -431653304655607913658], [-3579903567867411403342834, -1724097116824712145108], [12103183339323399650811792, -281345890818362449644], [4572614054994715508529534, -336584707815066706692], [-6583413171007347778337566, 600045590731774992840], [-716454163611542625199084, -2035197291366908655543], [7624734199971896487763112, 1183436570296159745922], [-5091513014783844211628134, 1912428185994284334408], [6570000396150361527076644, 463801424946777251901], [2820669662024146766856768, -833193028682999621424], [4809628328063106453179330, 254946897831104105472], [11889019491678560475243954, 873100297967279667264], [8832712097756847784858436, 1602172877117418557541], [9784947192313429045210474, 254932157984281616016], [372929427575580967717046, 1105986160205278104780], [-10649756198816775785573536, -1107250631514302030856], [3359996069072079551440474, -553630307383219086576], [-13226675142145729172069742, -56472713564985584856], [-10779230370764449601908620, 1260218573002647275553], [-366739880526778926925620, -1529200551308805367281], [-12407439561191172599478880, -1453790742361765691256], [381495845181581950586478, -1414083621809432665476], [-14108560573037508471855386, 1212967951990959443292], [4619466807746330898069846, -3304126707682486491540], [14315202336837281397561024, 1245242530771536648816], [-310128698299002911019852, 2360232824807200818897], [-8270059918126064277236484, -3073348237077005155605], [8069432517398403868406028, -2652087257981975593665], [-7626084226033823444731850, -3153989629981095952212], [-4476743290138532353522398, 2868200909106401092896], [11999839282632074811658970, -1998645567505506367704], [11162821220192784566467440, -3797138436070611782484], [99157229583048259052446, -4750823991797641321668], [1200575535334567542714570, 677665827997191306000], [11562891453885569552251662, -698227109272751514516], [-6966804865474585093213560, -80806341359001420198], [-13037419677364470275445770, -1747165644759163686084], [-2324767378944725817308908, -4992604745529718487511], [-2834754178962032796301842, 6308258379829684827228], [-4120722154684950465634468, -232425210752107571709], [-10154069272037780665789008, -1583426992982177153988], [-23435303620163420221802146, -374213097264383757540], [15361471030999247696982324, 2726313706081593809361], [-4243636609285856084613766, -1881318267453091758192], [3036611229021782397646150, 4747038273778807873116], [-4811687267665259282128176, -2684286325443342506652], [4505849469350055664787006, -3889932680302603849188], [-13872484401947627605106326, -1626339966809022474264], [-14377889848329696293880736, 1737048781247296839480], [-2060019200781821251926116, 3544941962761746762483], [-15655428098979958719616622, 1458683032481413556328], [15459897264977725419635832, -2684974790168105780826], [31716068346357441096895118, 1181562751690422555276], [26615106211607226363313722, -452227981167161319672], [6968530257137856129658128, 767625031715735412468], [1717457979786296510113228, -2166033941963188628625], [-35950080950963914732240492, -1389965925171060556407], [-8657364332015725905786342, -3643459141106221548120], [-1717259912230448014838298, -3758778255035284575588], [-15329740524296741867463352, -3094657334091191384118], [-8820914354044750732223510, 7425119591525874789648], [42832439667713019491913172, -621695940236421503175], [-27590540387491865873517540, -1718749963003361192973], [-9833147888736234265119632, 3348306214481422969452], [13711397453252190919651486, -376912344971126316276], [-26457714440370686197487368, 6408751144430739347334], [-46744928323830153253712362, -2482068324777519537108], [33522619996387225401343236, -1289422787080335822891], [-26296850958417250041195744, -1631611337504447036952], [-31552564319417521232221214, -4780478713036857941376], [6114261435602907017622738, -11272313790807426328536], [-27124380847671055448230006, -11046536769305744312112], [36267472400204980049052630, 6157517783727362772780], [21180668712836873906470010, -3920445209599892187696], [-21848172189733832676719016, 6725905797914163684990], [28819934248661396835635106, 11171799930930918585984], [49387430644685337630431828, 7123301078908218479865], [27461915661019632485860584, -7420171998899948290542], [-12545929031882629464495888, -10867167979832683092852], [5346474734285862819430430, 19694066052779008750764], [-30305159914874322686848852, 6817839519958377155271], [-20330232975453243607179648, -12390562813329016340832], [4096436235086383433775490, -869600786176100058336], [39129843865137287886740878, -683980364818483193556], [-8334099845590396016443716, 3178421805465684173691], [-26931474225160936015743612, 6922278484639987673781], [-14015406918040779513838440, 9631039163902094071566], [-11376384614495869459213526, -9154218895355905338672], [13021939318221371014262688, 9624516204740549949000], [43662166650981998021825562, -423386285411642612400], [52755376162215012511743196, -878536072066931686845], [-23041113245011945645820450, 9556480215321886389132], [43361557125582949987277654, -6926503418045748086580], [-25983459072367171882653630, -14484694291391292196536], [11488736780314231114420304, -11089074044447579480508], [-26317126720062026569862422, 100514429784251149392], [47451353083915160941644334, 16480660453122627439452], [-73976924907448938415500952, -2149171966311628619214], [-552137052548371129431386, -7655476906377057640932], [21347303472792129511766034, 14397668204824881284904], [-106810916245919177409902108, 4610810330342352867501], [-37676826918324903393714444, 5829920385535183630689], [95712451191972588858751730, 9025932428480937489696], [85998971624931829844374654, -5907303092067611375412], [-16859839155193951001766068, 716810055649230099087], [17708424051231888950465300, -28898112915645861106071], [105050599998881256399878298, -7955800734370297129560], [5169069710616143870906470, 2167605256167730859868], [-73690156307667418494350016, -8506911850085623081968], [1348041131837524938498760, 10227339007814695226922], [-30517831457731123808991822, -11031820760714367478104], [92493831656820006423242584, -592473884881329448578], [-17867192542261611354214474, 13929916558306850659260], [21698187947206793027862446, 17934454164045253372236], [-91055002792129975894855184, 1838562386508860245452], [57762944712138247298079148, -15168372810188124308409], [-572699432101220661454022, 14261352301740665047824], [-134254727292965480776776442, -261800518272547241412], [-13719437889603117896465788, 13838331256779400803477], [53259491513621734015261482, -21898333555551946991736], [61603596833782332039476172, -17673471553262472555633], [-127169541140535932075057992, -20247047510060451064842]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_16_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_16_16_a_f();".
// 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_16_16_a_f(:prec:=2)
    chi := MakeCharacter_16_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 16));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_16_16_a_f();".
// 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_16_16_a_f( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_16_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,16,sign)));
    Vf := Kernel([<3,R![-19611504, -4072, 1]>],Snew);
    return Vf;
end function;