
// Make newform 80.10.a.k in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_80_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_80_10_a_k();".
// 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_80_10_a_k();".
// 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 := [-22, -19, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [128, 84, -12], [-15488, -3144, 1272]];
    Rf_basisdens := [1, 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_80_a();"
function MakeCharacter_80_a()
    N := 80;
    order := 1;
    char_gens := [31, 21, 17];
    v := [1, 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_80_a_Hecke(Kf)
    return MakeCharacter_80_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 := 10;
    raw_aps := [[0, 0, 0], [-28, -1, 0], [625, 0, 0], [1840, -17, 1], [-1852, -292, -1], [-27698, -28, -16], [122354, -1596, 0], [-496372, 378, -81], [166640, 1417, 319], [1744894, -6128, -380], [-4236304, -6022, -238], [7241478, 50680, -1544], [9146826, 3188, -556], [7739420, 162615, -1134], [9567176, -115901, -2081], [-15209994, -175444, -5104], [89573956, -183246, -5775], [51990046, -362224, 12800], [175638868, -277043, 4270], [79964808, 772366, -12320], [66120810, 460180, -4832], [137946576, -298676, 29392], [-123983276, 2169743, -21868], [251642202, 2366280, 20184], [-301150334, -1338708, -18648], [331105926, -2780080, -194020], [133201856, 4798581, 89151], [269075340, 9256133, 18368], [-785923186, -8596168, 125072], [-147036750, 2634696, 114072], [1903505208, -2675917, -409309], [-2912721876, 4943068, 288781], [-2902868918, 18875024, 169400], [-1775576460, 7416378, -826371], [75004022, 2149800, 927936], [-65422856, 21648478, 1131412], [-1867585730, 45307160, -642184], [-5646945820, 6008275, -1052612], [3462859824, -61337789, -1270211], [8014474190, 5286680, -537352], [-5719279604, 25859822, 1334075], [12230102678, 52168072, -1305044], [-10459751696, -15487058, -2198882], [6638047138, -35171436, 2963280], [11980865926, -61437572, 1727080], [17220166456, 9709644, -2190114], [-2141118308, 55445452, 496081], [27800159944, -79038279, -2169759], [-18333308364, 154115917, -3063002], [-23483901626, 202821416, 4302836], [-10921789878, 124653452, 297416], [-27294101136, 147601828, 3738640], [-25569733294, 23139476, 4501388], [-72495853356, -100481180, 2132131], [106032298050, 79137688, -430232], [-95666505216, 94899281, -6512893], [13482931694, -640452256, 3720464], [48200445216, 227167094, -5129206], [80606998262, 77727688, -7332416], [-32968748678, -205900836, -3113940], [-2402057492, 203462935, 19419358], [31739399110, 238364000, 155528], [-4808811676, 59167829, -14898958], [52291570360, -180653078, -27382712], [-6437154886, -470590104, 12711120], [184115947902, -561681500, -8947160], [229470304932, -459332112, 691443], [188391516178, -502881608, -12800912], [67933351324, -1338375123, 4990356], [-109165488642, 798590712, -36163884], [-49245802846, -581533960, -53672944], [-114159661800, -2050505076, 45420822], [91680552040, -54260561, -69589061], [-100574618666, -879145256, -63032000], [-177943515100, -921095290, -16678075], [-298359002712, 1326455641, 11894857], [143980693542, 1495714144, 45225472], [178976664142, -1962918044, 11763328], [65113431570, -1811718608, -3100952], [-193945278854, 2413894908, -86058324], [14823833820, -348429458, -31829225], [377375347974, 2974686728, -26652208], [-602645084864, -1726784162, 68816986], [236014018514, 289802204, 146406680], [410034560072, 1493286068, 106009970], [145971005676, 284367979, -101681126], [-688294002270, 122063924, 93726020], [83258634634, 2996532432, 165520944], [-520195158738, 4242557968, -60077492], [-19748175720, 3755521017, 7364253], [690080368996, -2513792887, -33630850], [176059952960, 3192528964, 27546172], [361189000112, -820246085, 134989381], [185898600804, 990564156, 18838311], [506653050412, 367145642, -202653241], [-106468540560, 340586517, 45638691], [-411623821538, -1128026008, -29989516], [970578308170, 4435072448, 221675168], [1069688858876, 8758029471, -82419870], [1637303241598, 6191697472, -200339108], [-541332767180, 7624571445, -235003266], [-1535199586354, -619092728, 97231168], [2077601305076, 2729499311, -133531588], [-638134399846, -12658733716, -12917428], [1315754213492, -5344508592, -95556609], [-647621845438, -6252078592, -499085512], [-893316834996, -7300650631, 16348412], [248740690002, -4878971120, 209710912], [-211322702712, -7799773072, -461583610], [-457607613638, 15193388236, 456098812], [-479495934696, -14257135173, 226224003], [466663843686, 12947833684, -397289192], [-2274961363254, 1171577580, 499803336], [1245458005492, 17399082470, -2455471], [3172947077528, 22980766302, -468620916], [-3125921505438, 9180671572, -452272196], [482346363204, -109046069, -259495076], [-1917332105712, -3297225781, 659739869], [-25779462514, 6349823548, 540238408], [-501721811412, 1121250814, 394010947], [3227509805622, 7175013488, 1001865440], [2744685988482, -18585366572, -21582920], [2676781985446, 3976220180, 129126392], [-4527384120996, -5803309937, -96435638], [207823171228, -28167918456, 741936165], [-2737492350370, -18489833768, 262818064], [7110345418214, -4046229296, -388780268], [967361044880, -9321222348, -780688104], [3228688500640, -3658270417, -928745515], [-992390405826, -34285967808, 343809864], [-3173273056740, 906970718, 84782711], [3973314620928, -2341268083, 1670878199], [11085291006432, 15287214250, 261363334], [1700084644118, -7780475968, 608846336], [3818627577786, -15276960928, 929061968], [2030592454210, 1111200392, -42500440], [8253773592006, 12929625756, 764579880], [7022636407972, 11133018585, -504221010], [-3211578357858, -2086152292, -684492952], [-1614909460374, -79356427392, 607674720], [-905430657500, 87211617948, 888148359], [16618960984342, 2833259688, 97297008], [-2853340165360, 20492699969, -824751169], [-2835773456388, -46737180187, -232298332], [-7398229708514, -739702704, -562998720], [-3685617871976, -14032281384, -111962022], [-3863440955242, 338969820, 207756360], [-4927640018214, -55657960216, -309684280], [-10908038032796, -52650564246, 1553074929], [-19027197801816, -23445138091, 532764797], [-4199942685362, 131060248352, 1801831208], [13210459477650, -26176172468, -1057847468], [6485657785972, 4881115495, 302972548], [1088825690048, -131764112937, 848056197], [-1838494790964, 9708236273, -472711180], [2479769996288, 93135852626, 1842722150], [-12821353260920, -15699478120, 2919339134], [-12175422563966, -60635529900, -2114704236], [-14372800022966, -159889591388, 2790739768], [-2678049441842, 48312125080, 3437610076], [989003602916, 7249763893, -4784168078], [3696731831802, 65293155440, 4608688064], [13250050017072, -116283913977, -1502216919], [-8035824145436, -87207110136, 396330891], [28251994542002, -63292105404, 288065736], [-9436606179216, -76857205871, 3065871319], [8815698404848, 4890992882, 1424425226], [-9912817488282, -51077058940, -6094180480], [30500816200754, 57902368024, 2189796424], [30625819383542, 44263957924, -1480588904], [21955969478692, -15223575146, 5146679317], [-29933436777314, 28483604632, -1081908404], [8446138108648, 160028738882, -3758420332], [-4287461327638, 80201028220, 4448325088], [-31238248497104, 13039115520, 1778447940], [-30327375865446, 50853700024, -5962822376], [21025032431444, -150760233448, 3458407391], [27612560135174, -42081731112, -357712404], [-45506475088288, 35624739601, -3214704725], [18489079065358, -228584588000, -1716671984], [-12550601388392, -8969968441, 6180734279], [19848993188844, 291751149612, -6822004755], [6706826349638, 19055709652, 4877571616], [10843906567402, 143570569668, 609163200], [-52942624972616, 120565443421, 1627841281], [-4701066053770, -109999038144, 3044167956], [15804063126398, 46413089736, 2253107424], [63713964283108, 120433760523, -860085516], [20147485044554, 256446714636, 1340912220], [52133872344656, -33657620670, -3827610366], [-37863771617278, -229842518576, -1657716776], [63365123591964, 65445053763, -6220537722], [-52433680969412, -115872463704, -707677251], [-28678952405122, -34068971408, 8322302368], [-14144942066092, 164936276793, 10091148018], [4272826811594, -53868632524, 14401900520], [26795991895890, -329491251108, 2919705012], [-40455002099202, -47180402268, 6197772600], [-20878967934142, 94884175728, 12098927136], [-36299915809184, 372915340325, 2568761639], [-39165001267794, 46230431232, -12069559836], [46431654178592, -217523333202, -10634249310], [-12520453447978, -122032985724, 3924675936], [38583868319202, 138822272704, -5541112640], [43873504020180, 352694789250, -6842828499], [-112464082716322, -25736806304, -5197281896], [-65121864507520, -321044191792, -194975680], [11971504285508, 68206068379, -11499594164], [26133363949194, -9416243480, 14306993176], [-67543734940892, 547313133496, 14182193995], [6590180906290, 167624253180, 1938383808], [58514383043318, 308093629096, -2338003280], [103718014219312, 126980779921, 9699401863], [-79156125859908, -238582296839, -6194119568], [109577988065336, -473008954056, -6063530622], [30699847355850, 796241078420, -1030590652], [75594237922760, -265642107581, 6146189791], [2776071392978, 141487328080, -18320336648], [22046102519616, 139618890595, -4893848375], [72001950505822, 145899365772, 18499990560], [3311170031750, -404294291184, -14752351008], [100555018677992, -694788689136, -7594260738], [-44301396664382, -88796414296, -247219864], [101833699433016, -27984392363, 15701737417], [14940903842916, -719653745919, 19682912022], [39073479840694, -22449360384, -3095652528], [83980788925562, -804260972788, -3069672976], [-62006612313056, -176172944312, -22416290912], [102283662449872, 707877133895, -24144018751], [-226220320167740, 100152805840, -5931530645], [-72530164898258, -629410565940, -23461936848], [-87853813313172, 89427159210, 6959143287], [167618338342384, -489620104594, -8944230178], [116938707459754, -25390231684, -4077510676], [190255305471132, -619684842373, 8685426974], [-39671212172760, -196289031021, 5466747927], [194721976182450, 802756992228, -12545069292], [93765877712982, -234224062188, -12382112880], [-7034469087100, 1561818735054, -572224011], [-74977990131384, -45896142022, -2209128700], [-161630087675980, 261536886047, 8090365580], [-27053760619180, -588942508524, 44455964307], [57358567761248, 542387576269, -17860382465], [282093086803246, 106770419128, 25175920276], [89137237837778, -785943977320, 41560153424], [-223530826637528, 371388631500, 3995198274], [190137742163288, 351601484219, 35528968979], [69225718797676, -582691462952, 54600748609], [-206379086135980, 1225326858682, 18321169717], [-213454083970952, -560315679503, 8057041645], [15809813629182, -900604920556, -38812945216], [-204035697870014, 19939066464, -8846385312], [-147192411457584, -9792718117, 18895317917], [-143485565234518, -125652229940, -34274517644], [120309369429806, -82666132256, -5088017240], [-142456926564852, -177523792222, -37717062265], [79484938847990, 838690788752, 10892514812], [290560863950364, -446442193315, -6343380604], [11513626147398, 1836147535000, -1052248064], [243989368568634, -597822774688, -31805576608], [302254735554056, 77305216981, 57883321189], [191109722996116, 353475202333, -4245739970], [190038679613670, 257805169256, 58350418148], [14187758088830, 2688280084752, -4285275216], [97470235275842, -27276931236, 22459905600], [-105242673409540, -38960730942, 14685323691], [-115978399137458, -1306825574712, -52234820844], [88520326047738, 1532791130272, 31863297784], [118776147954156, -543618110293, -30238707238], [231643714297894, -1227338941048, 37912221032], [188563072791662, -1262718501656, -31520954852], [211724486208740, 349655496537, 84186044814], [-18945348449478, -1149053195300, 2690347960], [-28859519719520, 2161089010464, 40436262120], [26927433342578, 1896168899904, -20937304632], [-118659907584464, 1800564744013, -8509351109], [-11057962869220, -705410873263, -16452041296], [161095617298142, -184811883888, -45729577500], [437633996424554, -1611791232308, -11603125796], [-142832930500836, 861831621604, 6121480873], [-192569509703064, -1999240660891, -67373372227], [-28237502075064, -1397794804510, 59393166284], [212320646425600, 1115905502935, 27675372757], [-314483877874394, -3508300180584, 48438978924], [-150563446855732, -224700937879, 2101259468], [-202836380938048, 723501812482, 65337368758], [71527792682162, -474549867372, -25015550592], [-697468688856234, -860192442236, -23137930856], [159319641397128, -2357380670544, -65889737082], [-812181722326206, 82269000356, 3370981052], [-112404917859314, -3393718286136, 9800988912], [548568983212356, 2298818310217, -18053133962], [193843339954266, 1968556937132, 13444403072], [19063999006212, 736927327956, -3443038425], [-168948314737298, 2730993671360, 46705441256], [-33134762164674, 2578543166040, 54887438256], [-112040183294480, 374514812266, 3488116594], [-125726393377194, 2548253325680, 23052641096], [568236252162404, -2424955626, 101968558101], [-237278898398988, 2918546270177, -91677671278], [-7057725568374, -1161697595152, -15873678472], [-265322545894290, 4519352036040, 92241587304], [-153311871956720, 1006335789956, -25533171688], [252581583229108, -100913842885, 7721348192], [-484571880380748, -2239364534612, 34841910883], [15555481075906, -2323777028748, 10447171944], [87371958554604, -2531908059215, 47850762988], [72906790713934, -2273000270672, -144454477100], [-256006028791992, 2312407743324, -44340395190], [542412605044838, 1726047105576, 99562413336], [709302495280472, 2651467905497, 69571848941], [253354823804790, -3066267651272, 9947208724], [-289352085455454, -5175148817952, 90337311336], [-919563797901244, 384167154623, 1204444520], [82329281900080, 3043555939443, 73246920717], [638811184728106, -2973833591880, -79892724072], [-143373176375764, 1950793759474, -218813175761], [-184378241599536, -3047138380950, 60317082954], [-895466639983742, 43356449368, -74859662360], [496764049876402, 2841939707300, 60041516204], [836618771120956, -661867461984, 140508506661], [376970022198554, 3467614678336, -105775410920], [190774893175614, -609654835728, 193956330864], [820925910868424, -2409304811415, -83577182127], [675195520668778, -1369059682584, -36960561240], [377225975282514, -859849189692, 23441647932], [-260974136379172, 1898355406474, 93992074891], [-1265356439283380, 405628110787, -9099346838], [-693403020026408, 191976467451, -98304562701], [1206394868988582, 3628555661364, -1272583104], [-676142868968626, -3706121926808, 89203831072], [-350404246455266, 810075767808, -219613165464], [1332747672729824, 2757806479396, -55631021612], [586643722672100, 8807553217655, -102465083656], [-509271488590204, -2351940500660, -124678366385], [-865804436801892, 5363268390493, 153278985076], [1239941826393854, -696989312952, 70577370384], [329913828518754, -244526899760, 152618588872], [-917831025162806, 497063347612, -47316401012], [-1269203882676696, 3741416095063, 48104969059], [-578735173658218, 3501634282672, 152277531448], [577929379890618, 1194503251552, -131303776496], [682712639953510, -41544372856, 126048791072], [1146760235829448, 2553192483214, 88046446336], [284673932839486, 9694827247752, -192207800544], [190726804427900, -6082601963806, 126146795147], [185908410251590, 5921768396016, -119592119856], [10684371717068, 5778004035493, 237735807904], [-1216516040792544, 7394628476058, 181532622534], [512815378217334, 3525443011324, 114813643288], [-897735768069844, -1393219995756, -313973732283], [509616644353866, 1513419721608, 198952558560], [888385172550190, 8201010504896, 54461128496], [884464565325496, 5385162327645, -102431145279], [-1242819199242442, -2408821635736, 101764896020], [691989781003258, 10639218598292, -39533695744], [-1151495785963392, 7124423223228, 162189717156], [57441156367172, -9986429757480, -121119875613], [681540266269522, -8561064011100, -6113234616], [997241048703664, -5118646369811, -1250548709], [-966450839517946, 4789886537284, -268478156624], [-317907576992822, -1715358963248, 207817473976], [-1166156441770616, -1276530069657, -162932943525], [1150307639035620, 3488794759042, 118761949129], [-691988759681004, -12440516565839, 269738326666], [-2383923879076790, -4271627977756, 21420485528], [-403259701140306, -3019176841316, 188805113104], [820002452811136, -5385518764071, 22480412187], [658408048844666, -11992393673308, -328983965644], [872996212459404, -10134246814172, -109484184419], [568690215583348, 7385327519910, -225440313183], [2304640181621368, -181168369943, 95645217493], [1257871417261782, -4598044567032, -266952719040], [-234733615048296, -5370926241778, 207205835420], [-1080847678184770, -516015783980, -349476257504], [283900521554316, 17650612944394, -70620643073], [-1302306398019536, 13319452264930, 108448486282], [1393952149684514, -5397483574464, 289089733200], [1590819747535890, 912632764708, 2177463220], [886475841581114, -15212485189640, 90030940024], [1762398355177694, 871152564696, 35701727532], [569142122394058, -8531579220776, 87441088216], [791425535135520, 5211133674223, -22171418219], [-2304990903622302, 2971997355392, 76081082096], [-122687844781380, -3772570453198, 412729855499], [67062926116064, 3061771323817, 224929463155], [1676133463104512, 2326378109358, 141383676618], [1242397656446166, -3228800497128, -225193990344], [-3477792605468820, -4826253569453, 160779586546], [-2450590835309128, 3185165625443, 331362962195], [-648927028109726, -11325816588348, 143946260988], [-688525989758874, -4566971127560, 248174178208], [-705814581076428, -15876180118702, -245985030763], [1189671462247076, -6171844305623, -393351488978], [-3673918864220360, -1599534729754, -62965202164], [483336365644250, 5181831438256, 47850032008], [-753403725037760, -16772638396388, 206308887364], [-1561902361586454, 9103339465952, 307112001824], [157155713709028, -8841020078492, 548766690511], [-3228699793939242, 3667893418784, -303473141824], [-1941792635470626, -16162948242328, 305364174944], [-43776803710494, -6826735259764, -27324610480], [-11316476641912, 266758481679, -65575228461], [-3269832753562086, -14036223293584, 215126387048], [-787844040951546, -2050590065680, 242941878032], [-2464645308207000, -9648464633906, 141237378952], [-1072851676214162, 16414521355916, 281646542696], [588126613673970, -7317534357632, 10208874712], [-2720921963396428, 3604535929567, 16123731916], [-759238777644996, 1202128301046, 340650641031], [-2965828020022958, 5760629445256, 215498709664], [2711717578470390, 228443376424, 622704864952], [3117471695401708, 11735387037399, -264715937538], [2059248729513740, 16679675660924, -175764484171], [1996595432378698, -10009854106252, -252992453584], [-5286090211576434, 8556966104752, 114719607676], [-2243112259737664, -10381278327872, -483742537472], [-861039500627632, 3375917188171, -311203307507], [250783476147954, 15763876383564, -589005422184], [1202466423751440, -14938212200347, 261068790155], [176856198686526, 2168024411888, 86824222736], [4919959215053542, 6468126052132, -105193439768], [951730311278792, 4058760052939, -322950008681], [-4063462843547068, -5126107550566, 68632079369], [3851405722154058, -4688718099472, 106579205504], [-4323618172359762, -1196623106216, -281226398408], [1323980088923124, 13194479853883, 646334078800], [1028721379537914, -12487281426020, -207015725516], [-3318401260619756, 3323833514880, -962354586297], [1540511322753736, 19568286773508, 145195812114]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_80_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_80_10_a_k();".
// 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_80_10_a_k(:prec:=3)
    chi := MakeCharacter_80_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 10));
    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_80_10_a_k();".
// 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_80_10_a_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_80_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<3,R![-691200, -49536, 84, 1]>],Snew);
    return Vf;
end function;