
// Make newform 354.6.a.b in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_354_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_354_6_a_b();".
// 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_354_6_a_b();".
// 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 := [1, 10, -9, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [7, -30, -3, 3], [-18, 3, 3, 0], [-21, 24, 6, -3]];
    Rf_basisdens := [1, 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_354_a();"
function MakeCharacter_354_a()
    N := 354;
    order := 1;
    char_gens := [119, 61];
    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_354_a_Hecke(Kf)
    return MakeCharacter_354_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 := [[4, 0, 0, 0], [9, 0, 0, 0], [-25, 2, -2, 3], [-42, -3, 4, -6], [-175, -12, 20, 3], [-194, 8, -17, -26], [-634, -31, -27, -35], [-1158, -47, -15, 20], [-298, 23, 13, -43], [-1143, 193, 21, 122], [-1792, -15, 220, 21], [-3628, -471, -77, 288], [-3409, 95, -145, -354], [45, 708, -78, 424], [-2823, 559, -183, -530], [-13089, -726, 228, 237], [-3481, 0, 0, 0], [-17508, 295, -616, 2144], [-11641, 1724, -1980, 3344], [6380, 2164, -413, 2437], [-1548, 3583, -780, -370], [268, -2696, -1729, -478], [10601, -4551, -1601, -4274], [21091, -3187, 2229, -5399], [-68238, -3442, 957, 486], [1626, -2346, 1196, -6040], [30884, 5286, 1676, -4602], [-9437, 4463, -5170, 1922], [-33342, -7007, 3837, 2550], [14274, -298, 7005, 5295], [-45812, -7632, 2689, 3632], [-32944, 4990, -146, 12544], [-2621, -3886, 4378, -10581], [35276, 7230, 2437, 6176], [-37759, 5159, -1802, -440], [54534, 9251, -8950, -6585], [31322, -31898, 8663, -17424], [207472, 27351, 8342, -2962], [35999, 7129, 7985, 3163], [-8333, 10155, 9259, 17769], [13881, -26638, 20022, -11543], [65620, -18215, -20596, -15905], [141773, -19058, -7174, -22921], [202922, 4028, 10774, 25110], [267998, -1202, 19380, 11256], [-89658, -34193, 22690, -3022], [71729, 43199, -25738, 16835], [153966, -35184, -15182, -20098], [-16900, 7227, -6685, -12455], [315524, 32799, -17558, -25798], [536384, -38582, -7342, -7342], [61904, 25944, -30717, 3361], [465504, 35108, -13832, 25858], [332764, 33114, -51011, 26727], [287448, -10716, -31764, -48150], [1257477, 50097, 4869, 6829], [196600, -68030, 41891, 409], [-864638, -5918, -21507, 320], [-142517, 2084, 25678, 76484], [867310, -42266, -27542, 41102], [-1328397, -60751, -12108, -23245], [385536, 12637, 44483, 102511], [290834, 5924, 63370, -150864], [509957, -34927, -38638, -97028], [-407076, 65979, -7623, -30022], [1250187, -2114, -35064, 70553], [172150, -37234, -57832, -75002], [212852, -69649, 31781, -59412], [1382487, 29399, -4141, 85350], [783036, 87706, -82399, 102586], [305093, 17297, -118780, 7014], [806332, -87664, 66620, -17438], [-208129, 142994, 5802, 151106], [-998937, 3037, 167938, -23973], [-1922318, -140948, -27577, 41806], [-133910, -64466, -47523, 104759], [-966674, -30620, 67736, -225190], [-2353488, 126094, -69433, -79258], [-1976363, -32803, 10938, -26676], [-4542974, -100380, -35540, 22760], [-3243776, 60212, -92570, -68724], [-1244578, 182030, -178113, 96590], [-1567377, -142383, 146279, -178178], [-4991307, -57869, -37644, -130133], [794258, -7449, 133841, -244638], [-450056, 86327, -200149, 227111], [-869723, 97672, 158920, -71645], [-1873474, -108525, 138132, 79334], [527866, 238145, 33181, 262463], [-213951, -45399, 184610, 168525], [-1259432, -114840, 10340, 112010], [-2518265, -151983, 214214, -86212], [-1095362, 175017, 168135, -71888], [-2127241, -145429, 149395, 33755], [-1061988, 95688, 252031, -373332], [3735811, -216187, 39611, -64448], [-2571675, 324117, -142649, 265619], [1013917, -47697, -6471, -177554], [-3799542, 263800, -234341, 52498], [-604320, 134360, -174337, -234698], [-87812, 167319, -13117, 290668], [-2037232, 16408, -254026, 265536], [-1467971, 391500, 17776, 136597], [-3061371, -88029, 342627, -430851], [-1184437, -444166, 83408, 758], [-5738785, 199164, -8892, -337232], [-1498925, -9130, 393572, 159637], [-1405975, 80987, -239975, 14294], [-3672112, -376490, 35428, 17242], [-1204458, 163177, 458627, 63826], [3461058, -381438, -16327, -338696], [377024, 105870, 463256, -223616], [-3782156, -781097, 83593, -298705], [-4461344, 281242, -260491, 860804], [-480156, 125828, -166959, 343436], [-4625207, -48064, 374548, 14629], [1596138, 36205, -578457, -18142], [1571688, 365744, 268424, 330364], [5206119, -573945, 364899, -533790], [-4835388, -157117, -256173, 246513], [-1737496, 167397, 122998, 634745], [-971948, -652864, -140002, 385188], [820664, 658966, -63872, -198070], [8934979, -39918, 281290, 34837], [10676464, -271134, 70670, 16620], [8600913, -53463, -67733, 81791], [9386162, 669266, -371020, 100154], [-305952, -813551, 205103, -142273], [6536466, -677228, 447168, -1144642], [5926241, 414708, 294570, -21936], [7793189, -337641, -24030, -91779], [768853, 1307735, -476076, 98482], [-103418, 319982, -329216, 252102], [-9240001, -277821, -147316, 357361], [-8276977, -666474, 614722, -498291], [8665626, -197709, 603755, -1218288], [-7137086, -494722, -131700, -519286], [812136, -1000302, 873394, 32218], [-7455836, 1069258, -454970, 1370776], [4708747, 1065551, -359372, -451324], [2630894, 1494562, -1054702, 599568], [-11028907, -500101, -167435, -562887], [-3729835, -164776, 738334, -905476], [1711514, 1535446, -418767, 1204265], [7981758, 300511, -771334, -230171], [-1970995, -129296, -497856, -326567], [-8670541, 440815, -21434, 876857], [-14015268, 1661978, -103497, 1582459], [6181528, 350116, -838810, 1369114], [1064540, -628951, -325329, -889853], [-13861470, -40144, 22612, 319714], [-4324570, 2214714, -1424860, 992538], [-17808120, -903676, -69284, -934804], [14568053, -1366538, 1002728, -1567697], [1380270, -415696, 252869, -785262], [-12440561, -211103, -579455, -470905], [4431874, -1289810, 617688, -1354376], [-10827940, -1889328, -200639, 479671], [-5416466, -110258, -297627, 2122150], [2255624, 705578, 774755, -1253087], [8899031, 618641, 705771, 748551], [-11372624, 1068048, -448684, 1145310], [-14219621, 430031, -173578, -340477], [-5301207, -42429, 395048, 944558], [-1114802, -1654630, 251287, -2204015], [1063359, 732480, -838422, -29291], [11727091, 1090871, 34700, 50237], [-7166964, 1032833, -361886, -1912263], [-11657234, 1274688, 1997442, 1049698], [-13015974, -1793640, 450880, -381568], [15539588, -1366944, -865751, -555175], [-18372238, 66888, -758592, -1131460], [-16829939, -2007751, 904820, -36322], [-12771950, 1323512, -1061355, 2765152], [-3338828, -49904, -641560, 2106368], [-20780447, -53890, -5694, 1573879], [5595498, -806326, -233561, -1660290], [16942162, -592286, -285224, 852320], [-7292432, -2448101, 104241, -363656], [39964728, 452088, 287546, -404056], [-9085338, -1616644, 5264, 825086], [3331422, 3039744, -991506, 112786], [-21968164, 449334, 133965, -3247176], [11127730, -649810, -141252, -722926], [21373310, 1414048, 363405, 1502595], [5648097, 611271, 679112, 441998], [-7454872, -858998, -744642, 824976], [-15563318, -479182, -868094, 1330800], [8359566, 609670, -1046451, -154534], [-5044382, -1435591, -1246073, -503583], [-21646128, -286862, -936385, -1317388], [-16206537, -5095436, 878084, -1674977], [10436764, 3051508, -3077164, 1802364], [-11190007, 2598595, 1195879, 539382], [25661586, -1186752, -727170, -89698], [19953889, -510043, 1811014, -4448038], [5663445, -2159779, 2632056, -1438867], [-17906182, 1978887, -237576, 2013564], [-27995701, -457037, -955107, 551239], [-10892546, 1188633, 1221049, 2520555], [48541878, -1452780, -676838, -1863444], [-21266912, -911532, -626683, -642314], [-19559071, -1844777, 1501206, -3214943], [-1283484, 3805359, 2177489, 3172478], [-16916964, -1943686, 1590866, -1856132], [9659453, -1895073, -980603, -1721029], [22569927, 1479540, 8898, 1759174], [-8337984, -854651, 2526007, -2702467], [44947219, -368337, 81302, 2472908], [720376, -2767866, -851740, -2250102], [-38259914, 1368989, -1949427, -554488], [19206827, -934460, 2816352, 3282843], [3344206, -3031699, 1008935, -843144], [-26764980, 1311240, -561466, 368000], [11960288, 3067590, -4388393, 1190823], [-22734920, -1271325, -309703, -3056836], [34026918, 178624, 2332349, -2939000], [-3798407, -3794863, 356337, 2189222], [23035488, 2192613, -1375671, 4020471], [30794333, 5700574, -2133924, 1326715], [-15140084, -3198694, 1737125, 489876], [39146221, 37082, 2172318, 768408], [55684938, 4805576, -883250, 97322], [81402976, -858725, -1672614, -193458], [-55986644, 520418, -625112, 4414508], [29204312, 2618247, 1090134, 5496626], [-14954760, -1910025, -2529763, 3925303], [-16325310, 6486470, -3946448, 1342972], [-28848924, 589908, -1946644, 562484], [-62596835, -1303855, -434058, -3640046], [-209134, 1087745, -2620212, 2830006], [60921237, -3401304, 116256, -3452334], [-21732867, 5889853, -3200052, 4354023], [38499782, -742754, 1053417, 5238777], [-7250752, 1969504, -2889790, 6701620], [-51197980, 726424, -1991193, 1164309], [21539086, -2496540, 2934375, -5160866], [-40916677, -99195, 1391279, -4856353], [-40067355, -636864, 1669774, -4669107], [-7784919, 6033233, -2461291, 4002175], [-17363832, 1673898, 2372631, -6762031], [-5808310, -1386636, -1422886, -5170020], [27987368, 8181600, 803867, 5706806], [2828660, -3436370, 3984480, -894712], [98012152, -3950155, 2762055, -6612987], [-27466901, -3250323, 6142925, -2823537], [44983821, 6465710, -1742854, -466402], [-79368245, -987312, 3854492, -2585625], [64561710, -3425955, -279904, -1104272], [54877176, 1477086, -3560801, 4302691], [-1549513, -1685315, -231808, 4090851], [-1783215, 1540713, 125068, -1693292], [-38043521, -4474633, -1196517, 3490460], [-2765623, -10294878, 5222472, -3985488], [-44210093, 1902336, -1020858, 1962773], [-5436274, -1851542, -1971093, 6678929], [-56488987, -5699622, 4807754, -262390], [75877462, -5864042, 4638658, -6047016], [-4553604, 6297418, -2468635, -2542429], [12801889, 375505, 5950352, -1814519], [25887791, -2055480, -20868, 2725944], [-23423222, -265444, -4289707, -5169655], [-79340280, -905186, -453026, -7724722], [52132734, 2668978, -290928, 3490648], [79118245, 4068360, 1978270, -3038063], [-23681834, 1039704, 1111334, 4268314], [87389076, 408921, -5030437, -227575], [-56817458, 2561498, -2880306, -6709828], [26681846, 10086988, -3734197, 5986728], [20103427, -2747212, 113784, -102679], [-74788684, -746280, -327326, -3608366], [-19020006, -5220933, 6379002, -2760524], [82555596, -1659673, 1598269, -3566182], [-18133886, -10454700, 5307515, -5738384], [-67410439, -5915450, 10214636, -5927398], [79783261, -6948539, -2575684, -3600177], [-92727041, 2419487, -2148927, 8626415], [170138125, 1229604, -3301136, 518442], [-51534778, 617958, 8484669, -6212202], [-24397708, 7282612, 2713995, -1201081], [-24296494, 1431716, -5321139, 51053], [-44658348, -963038, 560170, -8897240], [-48428726, -596962, 1311186, -1162614], [76231080, 969296, -5208570, 4159500], [36102141, 6273336, -235098, 8566222], [-13627673, -5465917, -5818267, -7120206], [2334250, 1058672, 267239, 10140384], [37404966, -1738735, -721227, 6561993], [73191473, 5153736, -4250368, 6977768], [-11754126, -3535056, 5435220, -6150892], [-39316460, 11380824, -7634501, 7177477], [112102222, -4721518, 6217156, -699984], [-45946470, -2662077, -4712909, -1306895], [-116804177, 1121450, -13002, 5711981], [128934653, -11681416, 7261420, -11646180], [74983060, 10600196, 3432779, 3844323], [101979448, 3233, -3489634, 8491858], [-17495949, 12277592, -10720000, 5858919], [167784397, -3147727, -6367909, 1955134], [-7403045, -2722972, -5829156, 9786294], [-113606216, -2624641, -1802748, 181391], [-67846964, -5241908, -4997929, 5350525], [128551065, -361456, 2290558, 7091032], [79052264, -4468468, -2258982, 13880722], [-211307622, -419404, 6759226, -3394952], [15890112, 5224082, -457735, 7313310], [9084554, 1973704, 2927743, -8848489], [-118544856, 1406539, 9547754, 35754], [-2817981, 2948301, -6057725, -6570852], [4779416, -11540706, 5594682, -10678180], [23143198, 3831696, 2076155, 1683957], [183621144, 8273715, 1503649, 1679109], [-38323567, -4109436, -4927022, -3734957], [78205808, 9768651, 1024540, 11800283], [-20168525, -6558379, 7723344, -7723294], [-90754846, 5531010, -8875071, 137678], [-43592203, -9899691, -3480121, -4953138], [-101509030, 19526818, -10070525, 15152325], [-27991908, -4392558, -6288852, -520562], [113952393, -732846, -417192, 4355043], [-54251536, 2566952, 5462858, -7466546], [-72152348, 7027766, -692278, 354486], [-5906977, 16661431, 2578815, 7879778], [188111398, 811672, -5749168, 8739174], [-28464271, -8948824, -6358628, 854271], [-70632500, 11305156, -7442954, 12728688], [81701455, -4862244, 7964708, 9104242], [190091858, 15034874, 3188960, 3829686], [-277093048, -1173568, 3732664, -1183414], [146940119, 283775, 4670247, -8288221], [131488240, 3468455, -10941405, 7455974], [-127491598, 4129534, -10216414, 16523528], [142478724, 10550956, 4816012, 1446984], [-140763230, 773188, -4254295, -6039951], [-4067456, -15640249, -6779615, -11888754], [-206301217, -2315371, 12727839, -2724641], [-61801834, -12919219, -7896018, -10528893], [35777540, -5644832, 13335502, -7978870], [105155564, -13077845, 11556186, 7998024], [80029874, 15764610, 2036855, 12381666], [-31119544, -3271234, 3582978, -1797946], [204618752, 17521598, 4584763, 9765023], [14558648, 8970722, -15444242, 20606332], [-11826928, -12662228, 6032236, -16404404], [267084204, 12776082, -562374, 3541470], [-12523293, 15425032, -9372892, 17381143], [-207784702, 6468158, -3837709, 11145740], [-213906590, -16922648, -2833910, -11207980], [-184333969, -2530878, 12968384, -9632727], [148972036, -13230754, 5450177, 302309], [-150378045, -6563809, -4668168, 3822117], [26633020, 5731531, 4638252, -3836607], [-86438275, 13663807, -13158501, 22714654], [76620432, -9044899, 10234828, -5704785], [25826174, 1095311, 13565048, -23389467], [104738248, 7020920, 10808744, -13191322], [-93124222, 12592728, -3029244, 24463898], [-263832333, -3313503, 2856501, -182263], [-107851084, 18748127, -11028523, 28232253], [108876650, -4594526, 1084697, 8297681], [-11598786, 6740584, -12160815, 20205430], [-279649114, 5470457, -5782847, 6127915], [38052834, -5966672, -16530398, -2928834], [-122360207, -1492872, -13150620, -6980901], [-252034860, 4062597, 2232500, -11619980], [17193570, 15381337, -6382366, 10634130], [-169602854, -8964676, -1204042, 7940988], [-71835414, 7799146, -13217178, 24396108], [-191882490, -12945420, 6159288, -748910], [-210442955, 28556159, -11334127, 31846205], [-256529329, 5952002, -1578646, -14820130], [101206637, -4893568, -878336, 15523015], [-130495670, 27425885, -11073659, 14745435], [-88855788, 20335214, -5509248, 11808192], [-141298046, 24071, 2560978, -11181717], [-75535908, 23460423, -6509359, 161091], [-106356744, -7398733, 807173, -29310333], [65496068, -9593277, 8104986, 4219922], [145328472, -11070060, -11220422, 8744260], [-68243683, -19966810, 10192516, -22378798], [-203906908, -8226658, 1438376, -21370382], [301251235, -1900777, 2775049, 2341659], [-181864328, -191561, 58379, -11964112], [147489592, -5980700, -2036257, -17291907], [-105931068, 6344482, -1618937, 2702310], [223995759, -14693820, -5072978, 96649], [97304796, 1902662, 4636393, -6211904], [-155311394, -3294793, -4425890, 3034007], [101926370, -1320535, -12742717, -4586338], [207334251, -18007880, 1677804, -30701303], [65363832, -11995640, -260563, -22226174], [190254175, -15137827, 13954912, 14744032], [-124085326, 22645197, 2784573, 5183849], [-67533862, 2424030, -151412, -15333970], [117380515, 38855209, -8382879, 4567324], [-297375264, -11138866, 2420964, -4447640], [-208534422, -17471607, -8516796, -9649680], [209724030, -7769688, -6965068, 2762566], [-287654504, -2715365, -3378125, -3455250], [172604721, -4280390, 6971658, -2660045], [-254701277, 11438136, 6314486, 11300754], [272824376, -22054208, 7564998, -34595818], [149879508, -4902778, -21082398, 6800530], [194275135, 17748831, -19189731, 1142206], [-194070290, 23457645, -14641349, -104335], [74274333, 1088732, -796138, -8151508], [-34706638, 8644658, 5889384, -7268068], [320561282, 3320646, -2122404, 4322016], [-330547005, -147266, -7157292, -21452174], [-217595210, -28857880, 18964627, -4179215], [231849435, -13699645, 6040862, 1420715], [478525517, 3153549, 7381391, -1620466], [202149392, -8694755, 3638949, -6793037], [82707276, 11306150, -4177743, 11804410], [-217149449, 36871062, -18930882, 22251858], [-118211306, -29999820, 16799714, -17569180], [174858070, -12724632, 8800478, 8413758], [16777120, -1067779, -7321636, -6167323], [361896694, 2256230, 5699311, -20791907], [396459835, -2863721, 14423413, -2915155], [-106456319, -22659861, -3273456, 20836122], [-433256637, -14663426, 8115700, -6590914], [-53353475, 16551773, 17655516, 22038734], [-84802370, 21279742, -8622974, 17709172], [218379986, 45311480, -7514430, 12271726], [73325132, 32625496, -3725068, 34770832], [229279336, 32179297, -19855853, 17193943], [437730863, 19477955, -3259817, 4685726], [-173494286, 16812597, -2023864, -20438486], [60251418, -42791998, 4034333, -32497563]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_354_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_354_6_a_b();".
// 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_354_6_a_b(:prec:=4)
    chi := MakeCharacter_354_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_354_6_a_b();".
// 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_354_6_a_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_354_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<5,R![-4341815, -226264, -426, 104, 1]>],Snew);
    return Vf;
end function;