
// Make newform 245.6.a.e in Magma, downloaded from the LMFDB on 16 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_245_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_245_6_a_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_245_6_a_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 := [1168, 58, -82, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-43, 1, 1, 0], [-48, -52, 1, 1]];
    Rf_basisdens := [1, 1, 3, 6];
    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_245_a();"
function MakeCharacter_245_a()
    N := 245;
    order := 1;
    char_gens := [197, 101];
    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_245_a_Hecke(Kf)
    return MakeCharacter_245_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 := 6;
    raw_aps := [[2, -1, 0, 0], [-4, 1, 0, -1], [-25, 0, 0, 0], [0, 0, 0, 0], [228, -7, 72, -9], [-14, -41, 0, -39], [-418, -55, 144, -9], [-92, -226, -24, 18], [-1488, -274, 72, -30], [1814, 333, -168, -141], [1368, -576, -456, -48], [7326, -528, -264, -240], [-3842, 1474, -504, 270], [-2300, 370, -1464, -210], [-10304, 1149, 144, -429], [4534, -158, -960, -402], [-3884, 4128, -1344, -288], [-7254, -186, 504, 330], [5956, 5404, -1968, 372], [-18424, -1968, 4464, -672], [18054, 604, -768, -1068], [31064, 295, -2424, -87], [48476, -4704, 1536, -1392], [9934, -178, 4872, -510], [-49042, 5437, -6480, 2499], [-13310, -10964, 7608, -252], [-26008, -9391, 13776, 1311], [-77684, 12378, -10512, -4458], [-22106, 7491, 5976, 2877], [-33398, 20160, 1944, -3216], [-36528, 3476, -24096, -4596], [-4748, 12466, -19800, 12318], [-115310, -12302, 22152, -3138], [107124, 8990, -6480, 8514], [28470, -49796, 13680, 996], [-26096, 20783, -14184, -7647], [-138446, -51964, 23328, -2532], [60020, -48014, 5472, 8478], [137384, 7513, -15024, 17463], [-15198, -631, 18096, -1689], [-286492, 18000, -45936, 9984], [-253270, 38998, -44976, -1110], [362088, 26249, -35352, 13479], [-148022, -30966, 1032, -4602], [-120386, 51182, 9432, -1038], [155048, 53684, 42192, -22548], [-43860, 48303, 33288, -6303], [-357248, 68993, -23040, -21297], [533324, 29229, 31248, 9075], [-375086, 71438, -60312, 21858], [-395398, 36062, 49968, -24702], [-113400, 75779, 38904, 18957], [499558, -19028, -15432, -20700], [-89436, -62558, 56592, 27102], [672718, 22136, 52032, 408], [268040, -111922, -14352, 44370], [363314, -36540, 6000, 36444], [171976, -116304, 84600, 11712], [28374, 157604, 12768, -17076], [684002, -8959, 135672, -6753], [-162764, 675, 155472, 25053], [-888566, -133947, -66480, 40395], [659964, -30093, 183120, 45], [169616, -49318, -62424, -12330], [636518, 31915, -33696, -38667], [360862, 9224, -19296, 113256], [2005116, 7920, 164112, -22368], [1164274, -69592, -11136, 72504], [-1197548, -12610, -8856, 45570], [-1118086, 31960, -53880, 62904], [891902, 158749, -263328, 42915], [673256, -128304, 1104, 22176], [-2784416, -225171, 134448, -13725], [1323422, -105018, 36360, -60294], [2865740, -57032, -180624, -264], [1062624, 183140, 48720, 3708], [-132578, -399049, 81624, -40503], [-2583662, 384761, -31872, -74793], [533658, -242801, -222984, -15759], [-1105674, -55592, 112944, -107256], [1812556, -78172, -133440, 80028], [1103534, 315651, -193560, 12861], [-415224, -680243, -52296, -47517], [496078, -548476, 295536, -109908], [-795912, -450378, -29328, 121674], [15540, 113898, -431928, 178326], [858954, -722843, -5736, 153723], [-25598, 722818, 58008, -29202], [-938414, -239890, -113808, 101586], [2541528, 344648, 376728, -181272], [-445956, 646351, -118992, -89967], [-1345592, -543970, -46008, -158574], [2321544, 480610, -533424, -3810], [502260, 639235, -185640, 172653], [-286260, 437021, -887160, -61101], [-1933912, -161065, -675936, 235833], [-2693934, 823604, -699264, -105204], [4410734, -810816, 499992, 144240], [2377460, 120328, -507888, -73176], [-2406186, -1322939, 184632, 77019], [-179732, 532388, -324456, 113148], [-1349938, -450350, 584160, -68706], [494092, 669312, 479760, 88464], [-1301862, 350960, 5760, -519792], [-940100, -451864, -292608, -96600], [-6266498, -238641, 22848, 51633], [-3937180, -4676, 3552, -108], [-7691218, 524743, -283968, -252999], [-3446992, 861757, 415416, 105075], [3251622, 830872, 519552, -135480], [2194336, 934983, 670464, -135543], [6178582, 465252, -53712, 82188], [-9376486, -372020, -204048, 245364], [6065276, -29022, -763176, 40974], [3372608, 757693, 209736, 225747], [7972226, 373440, 546432, 130752], [1534140, 562481, -111648, 271791], [-4904808, 99688, -272880, 497592], [834550, 345556, 716904, 378156], [-1652132, -284563, 363960, 153891], [208442, -566866, 656064, 130866], [197194, 142850, -493176, -8274], [-17113590, 29135, 46032, 79041], [1150596, -454356, 595368, -160620], [7103148, -920248, -202896, -606216], [-7894890, -239927, -679560, 371895], [6714382, -932827, 12168, 315771], [3465768, 214582, 48216, -21990], [8726216, -2138840, 846864, 98040], [-5530238, 807531, -383424, 42789], [-2922372, -296111, 1046856, -816417], [4386568, 479936, 856272, -345504], [-7077320, -755809, 1134312, -368655], [416166, 207786, 803856, -211674], [11548782, -110572, -1912056, -261828], [-9992418, 782984, -1277568, -155304], [-1750022, 2125871, -2018880, 188001], [-1453204, -3025291, 689472, -259797], [3621842, 2076513, 318864, -91377], [12953426, 2029871, 131832, -435567], [9108452, 475466, 524928, -393450], [-7280194, 234015, 569832, -532383], [-816672, -2862296, -942312, 647112], [6589228, -2763786, 535968, -121542], [-18711782, -450610, -408408, -449694], [161408, -2075582, -30936, -789234], [9947450, 1322412, -943488, 1008180], [13272454, 1841444, 754416, -438708], [32499700, 466952, -239136, -186216], [-3934520, 1601884, -1310184, 506676], [-958570, -2221756, -179544, 683772], [-7523362, -2325454, 925392, 356142], [20466220, -1515992, -1590072, -133320], [-9111656, 940456, -834336, 61752], [-18072236, 1197810, 1506360, -422034], [16989440, -1840520, 2133312, 1296216], [-15083920, -695381, -2102184, 453285], [-8517954, -1281822, -367296, 1066494], [712502, -3480923, -1152384, 424347], [14461946, 1480558, -303624, 2274], [946156, 2850576, 183720, 1102032], [-16538622, 1705858, -3681432, -592242], [-2187272, -282446, 74112, 251214], [-10778436, -2700792, 4816920, 189288], [-14052886, -788740, 1394328, 564468], [-28227448, 1288239, -2687328, 220065], [21362304, -1610200, 2422128, -1241976], [-7191254, -597819, -1812624, -485493], [-16256502, -4236869, -10104, -479259], [22515370, -5472, 65040, -157344], [14539788, 256876, -4500624, -611004], [-13925758, -1252240, 2343408, 940656], [-11772832, -1238215, -2982696, -248073], [-17854278, -3166020, -3015888, 704196], [39333512, 2262514, -1391688, 506526], [-20896778, 1326990, -2322192, -1303086], [15073860, -1793563, 669624, -568053], [120862, -4837617, 1991928, 408369], [3513976, 1527660, -3797232, 908052], [1083626, 2346302, 3010728, -254094], [7860600, 602148, 347496, -781332], [-13093484, 661648, -5437464, 47904], [19454814, -233816, 5398296, -416040], [-4261610, -10736, -195696, 498240], [11106296, 525716, -2097192, 1148028], [-1895118, -5140236, 4994328, 802620], [-912818, 5789166, -1456464, 2138082], [-2451012, 4150649, 43488, 963975], [4232082, 441303, 2080440, -2655831], [26088408, 424056, 1175352, 433272], [-8337218, 2210580, -4183440, 2701596], [1490068, -731686, 3295896, 706374], [207244, -1340797, 5457864, -1409235], [32044026, 4213810, -1601304, 160062], [39447764, -5914472, 1107648, 1071960], [31679286, -2310369, 3248640, 139809], [-20177382, 2353581, 5039736, 1855539], [-14552138, -3594998, -3683880, 465846], [-36848946, 1125945, 3118416, -866649], [16961640, 5183281, 2126256, -1625793], [528222, -2730952, 3171936, -3230232], [35259008, 1283594, 3560784, -137418], [-4447958, -803480, -5634288, -26952], [58491462, -4490156, 1320840, -411492], [-23847316, 7452706, 1529160, 584238], [-38192638, -6953739, 1006464, 980475], [-7029200, -5960874, 4995312, -1644918], [-8818596, -6465136, 11695848, -104112], [40965066, 862092, -2632608, 1117812], [18456380, -2817996, 9653208, -1168260], [45020938, -4687834, 1036632, -676758], [62006842, -8769828, 4439136, 3505956], [21479824, -5709296, 5524680, 2500896], [15257812, -2984675, 4680624, -3041469], [-25567336, -2758486, -5639424, 513654], [-65627554, -3757178, 1605096, 231690], [8199144, 6279526, 4057224, -2838774], [5409286, 139042, -2800392, 272238], [26121520, 9936362, -1152312, -1378938], [17610030, 4416316, -8429232, 1357332], [60995174, 5170036, 2540592, -912756], [-33260648, -4289190, 1027920, -3370458], [13215578, 12955499, 1294728, -2045259], [7059424, -4200726, 5378400, -353514], [-317956, -4154603, -2504592, -2174133], [-24164138, -522544, -3480432, 1098768], [40399366, 5174157, -1498176, -691341], [52702264, -8643859, -4762248, -184029], [6258952, 5396865, -151440, 2538255], [-55581012, 9453704, 1552704, -2339832], [27088662, 4193110, 1325064, -2201526], [28318524, -1639310, 11700864, -1737330], [-19275984, 10486208, -571584, -1128240], [20890466, 6262295, -8795736, 2602185], [-25855068, -11813523, 1569168, -920589], [-5226512, 5928793, -991872, 989175], [-67752138, 5669710, 2271720, 2105442], [-27307290, -156302, 2633424, 3758334], [-12847276, 14546331, 270696, 2366517], [11642448, -5683370, 4440, 2490810], [6590036, -9210740, -986640, 1301412], [27233156, 1163388, 11039184, -2356764], [-55930600, -14206235, 7144992, -2197653], [54407870, -7452944, 9039360, 526704], [-8257874, 1639351, -11280768, -2590263], [98743472, -1986954, -5421432, -1500102], [53626176, -10882792, 7639728, 3586248], [1467532, -5793930, 2287488, -4685334], [-14146412, 9881215, 9467352, 976881], [-37999896, -1088850, -3479352, 630882], [-35600586, -5749948, 3622776, 4391388], [-77427058, 5537780, -10035504, -1152852], [-40575416, -13669312, -5519760, 1772928], [-18541322, 89754, -6927168, -4381818], [38807538, -9421828, 6316080, 658980], [11943788, -568011, -8525400, -1922661], [57720758, -10681688, -10031952, -1174344], [8581284, 8375352, -11217936, 1414776], [38685018, -10563873, 9560064, -395535], [25063670, -5603521, 12476976, -4734207], [-18023064, -3084226, 13238712, -82254], [-8382620, 3804330, -11204688, 438630], [81225546, 3655950, 2284800, 3030546], [-48369134, 7891723, -2173104, -260379], [-13218226, 9831140, -17218848, -305940], [-82134156, -11800950, -7678584, 3433638], [-7303802, 1054071, -10413864, 4122921], [20055814, -5766124, -17562912, -45588], [-125588004, -3271516, 1463856, -4159188], [-21547762, 3774772, -1297176, 1902348], [-87182294, 9087922, -5539512, -2414082], [64615228, -8574740, 15492024, 4266996], [2707142, 149621, -8565504, -1090101], [-111770112, -712740, -4513104, 1203252], [-21140066, -10176920, 2227008, -8392536], [18342440, 11309941, 178368, 1290555], [12036860, 6801624, -4686096, -321096], [40165262, 6709796, 651936, -2894340], [58010802, 9277887, 10473912, -6080319], [-64836068, 1132310, 8110656, 4727178], [20200816, -15458047, 24970992, -2077905], [38460144, 5715143, -15918168, 576297], [110650648, 14172504, -9523872, 5071944], [45207418, 1843112, 1934544, -712776], [-26839036, -10536211, 11336112, 1730451], [-7241272, 3076797, 6994488, 4202451], [119039402, -20480084, 8413944, 2776548], [-26191426, 7374692, 3747816, 1327548], [87110536, 4760400, -9975072, -1473072], [57270958, 5807050, -4026000, -112842], [-94692202, 24048887, 8067432, 1946697], [-87237348, 2779287, 234576, 808617], [-41782270, 31796842, 330792, -4630938], [-49640596, -21373052, 9014376, -7189908], [22239910, 14898052, -29182632, -1551204], [10566570, -5740278, -2605224, 2063622], [4829440, -738362, -3356736, 9866490], [92963178, 6420791, -90816, -2712903], [47175076, 18024464, -10576080, -1015248], [25169756, -18187135, -738624, 8386623], [-108425994, 21338137, -22658880, -3684537], [-185867170, 9929868, 6044112, 3099012], [-60797784, -21009543, -6446280, 8030679], [131563252, -9429980, -1700016, -3460116], [-51155036, 22371739, -6882408, 7074261], [-38825142, -25476756, -11220888, 4540644], [-142881580, -17859262, 17298648, 907806], [109576402, -13009098, 19564944, 3879306], [217676776, -9901912, 14870208, -1654680], [160387574, -26441674, -1513776, -160230], [90579440, -13454016, -4838544, 7289184], [-21368898, -28681711, 6605736, -2436273], [54054882, -17036308, -18309888, 830676], [139827444, 6916874, -17055456, -96378], [-9204880, 40413838, 492120, -1811166], [-12345714, -36627938, 6451224, -1062510], [3664044, 16220710, 22397712, -2216358], [-52935032, 26805677, 6048744, -7582365], [16178158, -17016207, 21186480, -6968721], [-55180038, -10627453, 27046872, -3091587], [-96612, -4949214, 7897344, -6007170], [-130780782, -13628566, -15936456, 3375462], [-77480830, 33815460, 13831824, 2811708], [-144198232, -8756848, 7786008, -7814496], [-138114390, -2580380, -13353024, 7467900], [-155578162, -26418334, 12039552, 990942], [141537916, 5594115, -3064440, -4181619], [-38245804, -8564184, -1332480, -1295256], [-191438664, -24460500, 18977352, -2086044], [-82514914, -19118454, -6043752, 8686038], [-204260322, 23188528, -20079360, -5352912], [-249032090, -10103014, -2417208, 2099334], [168667232, -16302006, -1440096, -1515786], [259595468, 7074219, 7433616, -4308363], [-120410484, 4320720, -17920128, -9246528], [-15164316, 1013825, 5992800, 9413727], [50454150, 20368659, -10976568, 313869], [113947454, -25238796, 3015600, 3421404], [-33399090, -9022560, 19867896, 2985456], [14131920, 13624557, 5841984, -501213], [194730054, 7563456, 8818896, -11279952], [18526090, 15708674, -6019056, 6833214], [-181848830, -21062604, 22950744, -3530820], [18266048, 31995241, -27578472, -5989593], [92791542, 28847228, -8732808, 4131588], [79865684, -21927024, -1961712, 11203200], [111699770, 23991488, 21700080, -10885536], [167000804, -2506592, 2062824, 13147104], [21430792, -29781594, 15106584, 1702794], [-333976022, -16390551, -6374976, 3162183], [25541420, 37086528, -23764416, -2060640], [160341058, -8785810, 11075352, -5063742], [144678246, -15647257, 15767832, -17250951], [105378352, -4450771, 34704384, 3093123], [261170526, -17353729, 26005992, -207807], [46235926, 29207352, -14944512, 9850200], [-35094272, 25951758, -20120736, -5740494], [30897132, 18975102, 5523816, -14925294], [-7849990, -20808704, 40434408, -2983632], [-142726760, 31864902, 23589264, 8747610], [203118750, -43189158, 7656504, 10247046], [-18073082, 26768054, -15658032, -9497142], [27069096, 22175356, 10337064, -9665292], [47606356, 8525685, -20890200, 15114651], [112940796, -23555696, 27673392, 7258848], [1371922, -37404952, 23739240, -4534200], [-198844302, 33255369, -20485248, -12965625], [-300328752, 6346610, 16083096, 2010078], [2583042, -15544661, 21632760, 12738261], [-68378404, -14117795, 29503272, -10683213], [-205609284, 22068260, -14207688, -20836116], [100839552, 21572180, -45161280, -502452], [281170942, -15786359, 10742760, -3133449], [87117752, 10460006, -36213168, -3573414], [291657326, -10850740, 15604656, 3750852], [-39652756, -28131340, 3565296, 4460748], [-459188664, 6735825, 687816, 2730303], [96345806, -15876337, -5347344, 130641], [6520654, 26922204, 2358720, 7546980], [206949878, 29882939, -19951632, -6939771], [-5452062, 11999260, -41945904, 11119044], [191375354, -17487928, -17619600, -8219592], [115416712, -36464896, 32075040, -13680480], [-161373134, 30380864, -9898608, 6357792], [86537508, 37346992, -46387272, -940512], [-94563240, -70625727, 20284320, -7603089], [24634392, 55497101, -41375832, -2731869], [-7554310, -33692225, -30412944, 3614577], [-141844852, 47024304, 4653216, 15441024], [-261314064, -51881429, 19048080, -3446427], [-220494038, -79667993, 29183448, -273063], [493046618, -74411, 15226944, -4509861], [-22165788, 5309023, -7669176, 28368945], [149642988, 40372360, -32538960, -139704], [-137276800, -4816923, -5107992, -10097877], [-187489990, 57254366, -3885024, -6687486], [185860056, 16621092, -7719432, 19924236], [98732510, -43308298, -6088536, 2676954], [-63191260, 12089417, 19568232, 6958119], [-176048410, -31982548, 2439456, -3148620], [164317834, 2255962, 31825560, -15149898], [40203826, -13188882, 18274224, -12870030], [7895176, 9672326, 11064648, -16903446], [86760694, -14607427, 63157200, -6843261], [-502124518, 2127538, -23139024, 8031438], [304902824, -21832958, -22905648, 5788062], [346242750, -35217656, 1540752, 6481416], [135796362, -43784467, -7785624, 16118931], [229113356, 35946648, -12394896, 2050968], [8793996, 41651016, 3841728, -21674088], [71754190, -63514091, -13216800, 9328875], [20575638, -4746272, -71308416, -6211152], [-15212748, -9413370, -64554552, -1006950], [555028116, -34178680, -4401936, -2847480], [34563298, 28185816, -42327048, 8962872], [-7423502, -85295002, 13312560, 3216282], [265411880, -9836475, 5213832, 311403], [-209514408, 50647204, 4604592, -4368996], [72101150, -8752668, -33503520, 13835436], [74308600, -1700071, -55091856, 7367031], [260804774, -49163621, 20150952, -3884667], [-124724726, 71076124, -44824896, 1055844], [-130574544, -5363766, -2185296, -2319210], [-19532956, -61036520, 1090320, -812856], [476185798, -10892565, 11313168, 1950549], [-85479614, -39702679, -36355248, 15099111], [65580548, -43974376, 73367904, -742824], [-77522454, 35189976, -38512272, -10052088], [-147019444, -6672840, 37242360, -16418952], [126548528, 33208592, 18896424, 4085472]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_245_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_245_6_a_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_245_6_a_e(:prec:=4)
    chi := MakeCharacter_245_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_245_6_a_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_245_6_a_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_245_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<2,R![964, 250, -64, -7, 1]>,<3,R![-1584, -11976, -775, 14, 1]>],Snew);
    return Vf;
end function;