
// Make newform 850.4.a.s in Magma, downloaded from the LMFDB on 25 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_850_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_850_4_a_s();".
// 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_850_4_a_s();".
// 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 := [-317, 349, 50, -42, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [-17, 0, 1, 0, 0], [91, -84, -28, 4, 1], [-133, -66, 34, 2, -1]];
    Rf_basisdens := [1, 1, 2, 12, 12];
    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_850_a();"
function MakeCharacter_850_a()
    N := 850;
    order := 1;
    char_gens := [477, 751];
    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_850_a_Hecke( : Kf := Kf)
    return MakeCharacter_850_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]];
    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 := 4;
    raw_aps := [[2, 0, 0, 0, 0], [-1, 0, -1, 0, 0], [0, 0, 0, 0, 0], [-5, -1, 2, -1, 0], [-22, 3, 0, 0, 3], [-17, 5, 5, 2, 1], [17, 0, 0, 0, 0], [-4, 14, 9, -4, -3], [7, -2, -4, 10, -5], [-82, -16, -7, 0, -3], [-14, -42, 13, -5, 3], [-108, -26, 14, -16, 2], [-158, 5, -42, 13, -5], [-29, 7, 10, 8, 0], [-29, -73, 3, 10, -7], [72, 74, 3, 0, -5], [-268, 52, -23, 26, -1], [-138, 89, -45, -37, -8], [-57, 33, 100, -32, -20], [-14, -11, -55, 4, -10], [-102, 13, 37, -13, 36], [-82, 40, -58, 63, -2], [123, -75, -64, -20, -10], [-465, -164, -17, -5, 24], [-540, -76, -51, 24, 3], [-437, -100, 36, -13, 53], [-251, 117, -152, -28, -56], [-33, -52, -144, 6, 69], [-812, 229, 103, -5, 18], [248, -171, -277, 11, -4], [1041, -275, -115, 120, -69], [-226, 150, -80, 135, -106], [117, 135, 38, -106, 182], [-744, -259, 130, 14, -15], [-1152, -82, -182, -44, -84], [-408, -36, 170, 46, -68], [262, 228, -160, -12, -140], [-697, 547, 150, -105, 116], [1019, 131, 96, -9, 98], [1010, 242, 74, 44, 88], [-1558, 148, 280, -224, 22], [476, -162, 148, -206, -12], [308, 28, -286, 4, -16], [-48, -213, 126, 41, 157], [-266, 168, 192, 48, 100], [-388, -178, 55, -11, 255], [-1804, 162, 310, -215, 90], [1453, -395, 11, -382, -153], [311, 185, -17, 27, -5], [-177, -28, 246, 219, 207], [1024, 566, -159, -20, -83], [-422, 800, -166, -50, 68], [192, 41, 310, -247, 29], [100, -234, 230, 302, -114], [2093, -201, -458, 406, 22], [3537, -459, 103, -116, 73], [-104, -995, -641, 223, -94], [1752, 350, 114, 42, -84], [-590, 539, 166, -453, -121], [1054, -146, 915, 114, 51], [-1903, 285, -185, 57, 377], [1052, 338, 701, 166, 211], [1563, -163, -904, -258, 202], [-732, -85, 190, -416, 255], [-1008, 131, -526, 179, -163], [-4590, 573, -256, -273, -101], [-952, 1430, 163, -108, 195], [-5170, 958, -345, -6, -175], [-1445, -675, -299, -359, -155], [2226, 1008, 434, -292, 348], [2130, -350, 432, 28, -304], [2606, -616, -232, -304, 262], [2875, -985, 224, 411, 106], [-1321, -1049, 444, 80, 210], [436, -810, -6, 165, -406], [-2309, -611, -937, -224, -259], [-389, 128, -196, -737, 627], [-4228, -1585, -122, 193, -199], [-752, -400, -356, 144, -706], [6920, -1686, -761, -232, 39], [1160, -1132, 490, 585, -368], [4307, 678, 862, 261, -369], [-6726, -1172, -174, -51, 86], [-355, 1741, 162, -48, -124], [-2906, 2977, 650, -440, 479], [4601, -845, -362, -230, 232], [-5668, 545, -588, -209, 159], [1203, -1929, -658, 344, -192], [-1518, 320, -748, 1072, -606], [-3309, 75, -843, 796, -79], [7997, 847, 1208, -418, -8], [-790, 898, 1367, 521, -231], [1035, -2877, -928, -41, -674], [-3128, 832, 145, -614, -431], [5220, -1020, 1442, 501, 192], [825, -45, 80, -539, -848], [4404, 870, -198, 116, 742], [-4124, 2562, 1830, 282, 82], [907, 173, 1780, 40, 652], [4190, -2152, -2608, 28, 176], [7297, 2416, 423, -326, -486], [-3935, 487, -1471, 166, 897], [615, -385, 1072, -570, 104], [-11492, 748, 1293, -394, 359], [3730, 2176, 1072, 151, 1028], [-4547, 861, 1278, -1100, -56], [7015, -2633, -360, -926, 140], [966, -624, 1536, -1332, -544], [3864, -584, 774, -932, -88], [7436, 2401, 2296, -347, -565], [2889, 1636, 732, 304, 1003], [-7346, 1380, -641, -202, -371], [-1328, -2243, -1345, 663, -340], [-448, -2889, -1640, -302, -1083], [1474, -612, -1872, 1636, 140], [-2000, -2361, -284, 537, -375], [-1467, 296, -428, 1634, -373], [11157, -471, -139, 678, -1085], [-14962, -1434, -1624, 104, 102], [-11084, 184, -1783, 244, -1019], [9616, -2044, -464, 418, -932], [-7136, -1223, 825, 1139, -1038], [-1318, -1067, 1704, 833, 451], [-597, 206, 451, 1936, 62], [-3326, -2941, -54, -376, 445], [-14183, -2172, -1402, 625, 279], [-7172, -2252, 1097, -744, -313], [-21228, -803, -707, 78, 384], [3101, 3227, -1307, -282, 683], [-1120, 1748, 970, 824, -730], [-6996, -676, -1317, 1210, -1147], [11967, 1622, 1324, -298, 331], [6942, 3379, 3959, -210, 518], [-13299, 1663, -183, -270, -355], [-11371, -476, 2614, 481, -779], [-12577, -204, 1841, -1969, -218], [1843, 1973, -832, -458, 412], [-2885, -3119, -1495, -223, -747], [-6192, -2038, 1750, 958, -1376], [-1802, -852, 932, 98, 1544], [-6740, 3917, 1830, -820, 149], [-13010, 1703, -3237, -977, -986], [-17929, -578, 2758, 100, -487], [-8005, -20, 3164, -262, 373], [-20490, 3060, 2308, 1020, -96], [7822, -4509, -1661, 958, 594], [5060, 1964, 2128, -1950, -890], [-16850, 4331, 1351, 57, 656], [1070, 5488, 2887, 368, 1285], [4239, -2479, -2650, -256, -182], [-14404, -2339, 966, 113, -1505], [-2996, -2881, 836, 739, -1391], [-28221, -963, 42, -458, 116], [-4127, 878, 1010, 996, 1367], [-325, -3951, -3349, 291, 1067], [-2198, -1523, -3954, 1968, -1329], [-5538, 1324, -5132, -450, -460], [-3186, -579, 624, -763, -915], [-11084, -1770, 2114, -1656, -106], [-9740, 3434, -2515, -1686, -1159], [8439, 1325, 2751, -1777, -1641], [-5049, 1825, -3310, 3438, 62], [18983, 1287, 2866, -672, 1544], [9794, -666, -1933, -2574, 1963], [-13608, 8, 1020, 1982, 430], [-9867, 5965, 972, -637, 86], [1772, -5653, -1343, 1162, 190], [-3498, 3840, 2730, 1902, -506], [24558, -1168, 1052, -1274, 744], [-36456, -4648, 284, -302, 478], [15846, 360, 857, -2502, 73], [24719, 1468, -3806, 379, 1391], [-20856, 2530, -1291, -1279, -1043], [-939, 705, -542, 1396, -1604], [14140, 4414, 100, 936, 604], [-19026, 2782, -1362, 2358, -1388], [-4244, 3805, -3140, 572, 771], [-10944, 124, 1777, -758, 1123], [1161, 3187, 2305, -1300, -977], [13411, -3028, -1556, 2367, 667], [8651, 563, -3619, 4112, -11], [-64, -3323, -1356, 3504, 583], [-44, 5271, 2718, -459, -975], [-11246, -6272, 3504, -1178, -1054], [23173, 1433, -2130, -368, 1472], [34831, -2262, -2572, -199, 207], [8600, -185, 3980, -1505, -61], [38057, -2435, 1062, -1098, -1440], [6950, 55, 1062, 1813, 789], [-31684, -608, -2270, -1797, 336], [-13032, -3920, -3216, 478, 1770], [-2265, 4984, 517, 3084, -2458], [20718, 248, -1005, -2928, -263], [-18733, 746, -1286, -1159, -477], [-16461, 2087, 919, 1001, 1001], [15644, 5299, -2982, -1631, 1001], [18928, 4741, 670, 1975, -2495], [14250, -5757, -3998, 813, 531], [-9090, -1413, 4541, 879, -162], [-11793, 6523, 825, 542, 1107], [-13922, 1058, 4156, 158, 2170], [12860, -3694, 3409, 4217, -1851], [10862, -1912, -1774, 1198, -3760], [-10011, 2572, 357, 3337, 2456], [8608, -6800, 238, 3096, -1248], [3367, -1971, -2084, -366, -4360], [22628, 5476, -2838, -520, 1402], [-9301, -2465, 518, -2894, 2582], [4766, 5788, 3092, -320, -1264], [-1488, -4920, -2577, -1664, -3307], [-24028, 552, 49, 698, 2627], [-17675, -8608, 336, -1399, 593], [42223, -2980, 448, -2238, 621], [32143, -635, -5242, -3306, -402], [4996, 1508, -915, 1569, 1455], [7406, -3891, 1130, -1427, 2163], [21855, 4061, -1269, -3022, 3349], [-2178, 376, -873, -92, 2359], [18873, -6376, -5164, 1992, -1217], [19003, -1833, 4817, 364, 1851], [24942, -2268, 62, 816, 1282], [-30538, 4949, -7633, -2222, -2532], [2848, -3658, -6302, 2016, -236], [50777, 10469, -7240, 1819, 1322], [-18301, -5385, 3566, -824, 126], [32095, -1080, 1914, -3997, -2859], [-35410, -5016, -75, 1632, 665], [1876, -4297, 2149, 386, 1982], [4739, 12699, 3801, -658, -1751], [-33966, 1386, 2348, 3137, 3394], [30668, 9732, 1687, 736, 771], [10830, -5668, -2734, -2321, 846], [29970, -308, -4450, -2384, 216], [817, 2730, 7879, 2055, -474], [50567, -319, 2860, -1184, -996], [-36991, 1337, -2802, 1132, 1852], [39766, 2541, 5454, -1951, 499], [-13312, -299, 6296, -7267, -35], [-44872, 3168, 1402, -585, 332], [7922, -548, -6802, 3864, 1206], [-34389, -13554, 2729, -616, -4720], [65626, 908, 2822, 1606, -3154], [62599, -6043, -2866, 524, -66], [-39303, -9518, 3580, 1599, 2381], [7344, 8258, 6707, -2436, 471], [-1628, 3671, -5325, 5072, -3796], [23721, 8834, 9544, 450, 3029], [-30938, -298, -986, -295, -4204], [24902, -9106, -916, -2306, -5232], [28215, -2731, 7895, 2696, -171], [3266, 3346, -6599, 2582, -2809], [-13462, 6710, 1886, 732, -380], [-32857, 7557, -2797, -3344, -1711], [24960, -3125, -5098, -593, -2393], [73029, 2399, 2113, -766, -115], [-41992, 394, 709, -1146, 2199], [-5694, 12980, 817, 3452, -2211], [-2709, -3772, 2540, 722, 2193], [-40074, 4250, -5820, 5690, 814], [17609, 2345, 7572, -152, -1650], [-19867, 673, 9410, 1711, -2732], [-15465, 2073, -4804, -284, -5928], [-9668, -8970, 1520, -2864, 4440], [-41162, 2487, 8928, 5311, -1523], [4316, -5150, 1413, 6832, -171], [-18746, 1966, -5276, 5864, 2640], [-31608, -9450, 866, -416, -270], [22470, -7076, 5167, 3488, -3355], [65097, 14821, 4059, -1431, -3079], [-78436, -1576, -3856, 1414, -2262], [-21250, -1308, 3943, -5220, 2039], [17703, -18135, 1644, 882, 1498], [29534, -3730, -2496, -4478, 1962], [-880, -204, -4624, 2606, -2052], [-5776, -9904, 1486, 3718, -1892], [74761, 8107, -115, -968, 1387], [-941, -7793, 2662, 2244, -3736], [11835, 1310, -4570, 2325, -3639], [-44281, -11244, 7281, 143, -52], [-30770, 626, -3135, -3898, 5983], [26103, 20033, 6124, -846, 9182], [10078, -12813, -4591, 1202, -3528], [-11523, 10910, 1570, 432, 2935], [-6108, -5046, -13234, 1488, 3748], [-23933, 16040, 11772, -1898, 1301], [19258, -918, 10958, -6772, 3684], [43920, -14891, -4537, -2683, 284], [36004, -2636, -7736, 8314, -2194], [-28922, -704, -5532, -520, 3704], [7275, 15062, 1189, -3779, 3374], [-2400, 789, 10653, 2705, -1780], [43497, -13412, -13305, 1426, 186], [-58393, 14115, -5386, -1376, -2444], [19420, 41, 894, 5998, 289], [48068, 2653, 1978, 549, 355], [-37194, 459, -4273, -4851, 502], [-69660, -1182, -3948, -2130, -1380], [41623, -13755, -14351, 894, -399], [13318, -8363, 1378, 3156, -7525], [37013, 9329, -11600, 5046, 3544], [32383, 10563, -1582, 4832, 3252], [2849, 4701, 2455, -7740, 7705], [-33572, -15750, 379, -2329, -4101], [-45723, -5179, -313, 317, 1201], [35920, 18398, 6484, -1777, 5440], [23058, 5554, 8756, -6718, 2850], [-55357, -2279, -868, 1074, 1930], [10726, -12564, 6215, -1342, -857], [23590, -4204, -6332, 10322, -2684], [-11914, 8012, 4171, -5932, 2511], [-7233, 3266, -3904, 8486, 5667], [7244, -626, 8188, -8694, 1592], [11880, -4814, 13854, -2024, -1662], [-84669, -14545, -8730, 3034, -3174], [16963, 21013, 139, -2726, -3747], [-13956, 7914, -321, -6580, 6645], [-37750, 2142, 3107, -3002, 517], [74960, 4875, -7842, -3980, 3423], [2558, -7062, -3228, 6706, -5558], [-21248, -4350, -7575, 4816, 1621], [-8164, 10191, 2024, 4080, 1845], [-23510, 20650, 4501, -3626, 6447], [-4236, -11670, -14146, 2592, 2364], [32811, 8275, 5672, -4688, 2164], [-69734, -8958, 1629, 1060, -6041], [34436, -3312, -3413, 7174, -5655], [-5892, 9683, -9536, 2084, -5511], [-78779, 157, -3529, 6345, -6199], [51023, -3673, 5922, -6009, -4340], [71502, -11317, -7542, 1849, 991], [11638, -557, -6180, 1717, 7567], [-51044, 9762, -1614, 10468, -334], [62002, 7977, 16546, -5544, 2159], [-82467, -4643, -7400, -514, 4802], [-19506, -20454, 8646, 4289, -864], [38687, -23138, -12432, -1692, 623], [2510, 25602, 3882, -2018, -1576], [62794, 2133, -2070, -5649, -5107], [80024, -5211, -1014, -9153, 1397], [6965, -23889, -3026, 8114, 2458], [29602, 25272, -4553, 2146, -2391], [28066, 254, -8834, 8124, -706], [44048, 15493, -3939, -5845, 8236], [-14558, 8296, -7198, -5642, -3804], [14667, -8611, -9184, 2762, 1776], [64402, -15058, -8252, -9209, 614], [-53850, -9211, 5488, -1937, -3355], [-17975, 1859, -3712, 4638, 1166], [41338, 19056, 1889, -3103, 601], [-49096, 5306, 8886, -638, 4810], [45464, -3362, -17400, 6644, 1098], [-10806, -14524, -3816, 1146, -3864], [20782, 27500, 15688, -2908, 624], [112581, -5877, 10440, 235, 4716], [25615, 5048, -10112, 6787, 7133], [35583, 16543, -5564, -1072, 2034], [11108, 11598, 18162, -5456, 6064], [49578, -11933, 7194, -3190, 6209], [-9248, 10849, -9146, 7111, -6525], [-27355, 5767, 1349, 6794, -4363], [51708, 15110, 15660, -6930, 2956], [26468, 642, -17930, 6904, -3234], [-83763, -6307, -18568, 4172, -8792], [30192, 5560, -6980, -3371, 6206], [-26707, -19917, -16986, 7376, 2072], [11378, -7022, 5144, 10880, 8260], [1606, -1243, -3562, 3007, 7617], [90155, -307, -503, 258, -4137], [-36978, -2745, 13386, 5013, 5421], [60984, -9490, 1347, 5908, 3891], [-26134, 33909, 996, -1184, -3775], [-143173, -18556, 2464, 1368, -4015], [-67919, -19718, 1838, 3083, -5803], [3518, -3996, -7306, 9458, -1422], [5542, 10580, -7968, 8876, -7824], [-25428, 15809, -2198, -6170, 13301], [-61192, 11673, 6579, 6026, -3270], [-93215, 13509, 1438, -6776, 2564], [26366, -6890, -20453, -8662, 751], [29802, -4368, -2302, -11094, 1816], [126854, 13140, -13309, 374, 4603], [63098, -23450, 9092, -8746, 7434], [40033, -13014, 542, 2532, 3055], [18088, -17596, -16869, -3724, 3677], [-16130, 5180, -5314, -3255, 6782], [15103, -30834, -6498, 7928, 1185], [-56586, 14520, 11366, -13440, -772], [19529, 12263, -5408, -10494, 1748], [-72299, -9789, -1209, 5027, -11577], [-51261, -9309, 20638, -7574, -3632], [-8336, 8033, -11120, 16667, -233], [30098, -21211, 3610, -9957, -4759], [14026, 9038, -4985, -6964, -7161], [14123, 4097, 16838, -7016, -2206], [32624, 2666, 1344, 416, -512], [-71616, 2389, 5398, -2969, 4799], [-104442, -8060, -6434, -4718, -1040], [79886, 11400, 22642, -8352, -3284], [70784, -10144, 346, -12097, -6308], [-89539, -33280, -4890, 2233, -9193], [-24132, 4821, 9520, 569, -4141], [-7665, -24963, 6628, 7514, -516], [3313, -23991, -9491, 2906, -5869], [-25918, 11664, 24371, -8654, -893], [53112, 4706, 11634, -11952, -7200], [-31564, -14966, 290, -10731, 1950], [-13493, -3711, 4577, -1346, -9023], [-44265, -8026, -2026, 1281, 661], [56907, -22143, 5702, -54, -3750], [76196, -16003, -15908, -6626, 5363], [-5894, 28294, -8141, 9468, -3331], [-3719, -1721, -5583, -3454, 6245], [-92569, 13019, -3542, -12472, 1834], [-28122, -44, 20962, -13615, -3526], [75246, 16298, 164, 7258, 2642], [197880, 5858, 10409, -1888, 5213], [-47562, -16559, 10166, 4518, -11437], [3125, -40952, -3114, 2542, -7379], [73968, -20830, -20125, 8674, -5325], [28109, -18911, 1621, 7630, 2183], [48734, -28226, -10232, 5470, 3362], [65350, 847, 1646, 1405, -4157], [16207, 12349, 21772, -4641, 8764], [13508, -1620, -27579, -1142, 1217], [-1866, -15514, 15035, -3502, 11705], [-2430, 26340, 5063, -10396, -3061], [-75929, 4425, -5982, 7671, -3334], [-48988, 30067, 32908, -7205, 85], [-69234, 8436, -13465, 11526, -5595], [-109060, 23529, -8470, -2658, -3015]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_850_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_850_4_a_s();".
// 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_850_4_a_s(:prec:=5)
    chi := MakeCharacter_850_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_850_4_a_s();".
// 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_850_4_a_s( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_850_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-118, 936, -230, -72, 5, 1]>,<7,R![438464, -18846, -9946, -284, 26, 1]>],Snew);
    return Vf;
end function;