
// Make newform 539.4.a.h in Magma, downloaded from the LMFDB on 24 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_539_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_539_4_a_h();".
// 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_539_4_a_h();".
// 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 := [352, 368, 18, -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, -1, 1, 0, 0], [152, 34, -34, -1, 1], [-264, -138, 38, 5, -1]];
    Rf_basisdens := [1, 1, 1, 8, 8];
    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_539_a();"
function MakeCharacter_539_a()
    N := 539;
    order := 1;
    char_gens := [199, 442];
    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_539_a_Hecke( : Kf := Kf)
    return MakeCharacter_539_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 := [[0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [4, 0, 0, -1, -1], [0, 0, 0, 0, 0], [11, 0, 0, 0, 0], [8, 12, 0, 0, 1], [-48, 8, -4, 2, -5], [-28, 4, 4, 10, 0], [10, -16, -4, 3, -11], [6, -8, 4, 8, -6], [4, 8, 8, -7, 0], [204, 2, -2, -5, -5], [32, -20, -12, 14, 5], [144, 26, 6, 46, -12], [46, -20, -20, -18, -13], [-166, -14, -30, -14, -38], [-88, -40, -16, -57, -40], [-28, 0, 36, -6, -13], [378, 0, -4, -7, -17], [-34, 20, 8, 53, 7], [64, 24, 48, -26, 5], [108, -158, -6, -48, -46], [-300, -72, -4, 20, 18], [724, 16, -32, 33, -27], [-164, 12, -44, 23, -59], [-236, -52, -28, 72, 49], [-374, -148, -4, -34, -19], [-116, -88, 68, -22, 26], [-102, 52, 64, 6, 32], [-568, -64, -52, 123, -81], [908, 56, -64, 170, 54], [228, 100, 56, 142, -58], [-244, -246, 46, -7, 149], [-752, 20, 0, 46, 212], [-406, 124, -144, -48, -116], [276, -70, 114, 96, 130], [-580, 128, 0, -89, 103], [96, -320, -56, -4, -34], [116, 300, 204, -50, -46], [-828, -344, -60, 108, 83], [1278, -452, 40, 141, 121], [748, -372, 164, -215, 131], [-686, 252, -64, -83, -155], [606, 168, -100, -132, -4], [598, 76, 36, 456, -104], [1530, 468, 188, 114, -79], [260, 248, 276, -86, 218], [-2324, -240, -96, 161, -252], [164, 532, -268, -244, -108], [2468, -860, -220, -211, -229], [882, 0, 276, -152, 178], [-1620, 208, 4, -164, 180], [-212, -444, 292, -88, 343], [-2444, 616, 112, 27, 6], [-266, 396, 420, 244, 232], [224, 488, -60, -94, -254], [1150, 472, 152, 100, 246], [-1056, 1008, 140, -156, 338], [1574, -216, 92, 130, 310], [-1386, 516, 64, -262, -28], [-1444, -964, 172, 536, -220], [-2648, 104, 256, -394, -129], [-2352, -604, -176, 324, -84], [3282, 620, 140, -198, 225], [3940, -492, -20, 493, 313], [-7260, -180, 200, -185, -109], [634, -288, -28, 231, -117], [1538, -740, 232, -204, 298], [-96, 358, 166, 24, -202], [-1892, 48, 204, -310, 187], [316, -984, 152, 585, -75], [-2548, 94, -174, -330, -676], [1528, 200, -296, 937, 386], [1026, 952, -64, -162, -526], [4014, 160, 180, 87, -139], [3136, -304, 32, 861, 110], [836, 548, -424, -1121, 83], [1082, -484, -324, 320, -388], [1082, 916, -132, -612, 72], [-848, -560, 624, -238, 225], [4262, 540, -20, 926, -79], [3458, -474, -130, -22, -94], [-328, -270, 474, 614, 524], [892, 572, -580, -717, -647], [180, 772, 136, 1158, -16], [854, 1832, -84, 33, 261], [-2744, -1350, -98, 1171, -37], [3958, -900, -700, -582, -26], [-984, -492, 304, -10, 449], [-7498, 528, -76, 357, -49], [1952, -88, 456, -273, 468], [4080, -1052, 64, -948, -950], [4122, -148, -792, 527, -187], [-1468, -986, 106, -52, 926], [-1504, 168, -240, -1204, 622], [4832, 712, 500, 156, -346], [3588, 460, 260, 1269, 643], [-788, -1332, 124, -789, -291], [-13272, 872, -204, -1012, -164], [9998, 148, 88, -514, 254], [4476, -1912, -128, 788, 228], [-742, 1192, 244, 1952, 228], [-7928, 1108, -20, 384, -174], [6682, 1268, 1224, 172, -250], [-9780, -176, 64, 336, 308], [-4420, -332, -60, 227, 257], [-3494, 1324, -1276, 758, -701], [-4400, 3908, 544, -1310, -97], [-8732, 1812, -500, -400, -854], [8644, 660, 540, 236, -229], [44, -132, -396, 486, -530], [2030, 776, -656, 990, 968], [-10002, 2262, 494, 2002, 362], [-7756, 2592, 56, -487, -942], [1118, -1240, 548, -793, 263], [2584, -570, 386, -1473, -913], [-5748, -4168, 88, 459, -110], [1784, -2200, -376, 1431, -566], [5352, 2120, 116, 1049, 441], [10096, -1354, 374, -2264, -534], [-7612, 1468, -404, 447, -945], [4726, 3260, 1120, 1026, -284], [604, -356, 48, 3142, 563], [-4396, 3296, 8, 1184, -692], [76, 2336, -920, -2393, -58], [4702, 1780, -1636, 762, -204], [-8936, -4696, 236, -215, 17], [-1720, -1448, 1264, 737, 190], [2044, -664, -64, 309, -1348], [916, -2496, -1464, -1308, -2011], [-1472, -1032, -40, 2010, 150], [-3488, 216, 1056, 2984, 24], [590, 1204, 64, 1933, -1233], [-11378, -3028, -1260, 36, 1356], [-9024, -4472, 924, 368, 355], [14212, -1900, -800, -3256, -507], [6742, -5908, -612, 1500, -362], [-20896, 904, 156, -2770, -1284], [-1060, 496, -856, 1991, -117], [7586, -4264, -312, -1828, -844], [-5352, 1424, -464, -1166, -1234], [1742, 1140, 828, -2584, -652], [-1522, -2576, -468, 499, -1017], [4696, -2974, 182, 2666, -324], [-2268, 2136, 600, -1685, 715], [6952, -1776, 16, -2951, -146], [21976, 1444, 988, 262, 1479], [-19404, -528, 1144, -1580, -53], [3172, -3648, 264, -4777, -154], [2376, -920, 1080, -1788, 1164], [11738, -2744, 464, -2552, 846], [12700, 2780, 380, 3023, 713], [-6396, -1288, 1096, -3288, -28], [-25112, 2316, 84, -1934, -1224], [17528, -2092, -1308, -3508, -862], [-2276, 4012, -460, -1552, 1250], [-2356, -1176, -2804, -88, -1456], [10970, -508, -2172, -2104, -1514], [17580, 1612, -1960, -268, -1947], [3920, 1424, -672, 318, -989], [4950, 2148, 1024, -895, 253], [-2810, -4404, -2932, -562, -766], [-8872, 4174, 1714, -1460, -1554], [-25860, -3352, 1056, -1443, 1166], [11112, -3256, -92, 2959, 367], [-2640, 7016, -240, -279, -1482], [-28108, 2216, -896, 84, -1346], [14672, 4072, 592, 2776, 279], [-14262, 1884, 504, 2838, 98], [-2796, 3296, 1600, -2971, -1429], [8704, 1000, 2812, 1812, 956], [12218, 5544, -1528, 2908, 1756], [-11964, 1978, -1342, 1608, 1042], [15934, 7516, 1736, -754, -816], [6592, 2104, 376, -2573, -126], [-6172, -192, 368, -2905, 33], [12284, 7730, -442, -984, 1186], [-14036, 1666, 646, 2767, 1711], [-2980, -6948, -1832, -438, 1688], [10244, -4612, -104, -850, -1961], [23160, -608, 2064, 2620, 1228], [19124, 6324, 400, 904, 2062], [-33964, 8344, 1532, 887, 227], [-12000, -2356, 344, 3500, -1105], [458, -6736, 2524, -1883, 1389], [-11474, -3040, -2168, -684, 2294], [-19754, 6432, 380, -2854, -722], [-7810, -780, 1876, -2014, 1029], [7562, -96, 304, -758, -1332], [10308, -7816, -696, 3498, 1054], [31284, -3376, 1536, -1541, 2205], [3756, -4856, -1348, -2762, -3114], [-62, -512, 1500, -6359, -837], [27866, 1280, 384, -4780, 508], [-6456, -3906, -1130, -4504, -454], [-7756, -3320, 592, -5595, -2343], [-27710, -6016, -728, 250, -1616], [-1204, -8798, -1714, 263, 1463], [3892, -8812, -1100, 2490, -3289], [-11476, 2936, 60, 2906, 1356], [20406, 3716, -828, 952, 3672], [-9580, -2048, -2500, -3432, -3396], [-17922, 7892, 3084, 3384, 422], [2716, 2408, -860, 266, 13], [-8040, -8280, -1272, 1177, -2608], [-19404, 2468, -1564, 1963, 1779], [-23652, 3192, 592, 5287, 2948], [10612, -6928, -2468, -4522, -1854], [-18194, -5600, -184, -582, -1982], [-7366, -1372, 108, -4818, 267], [9610, 6068, 2516, -702, 3736], [29460, 3536, 1192, 3965, 2919], [29174, -9064, 2068, 2723, 3075], [-18326, -5148, 428, 1958, 2387], [-28292, 2880, 136, -3948, 1790], [12604, 2260, -2812, -1883, -2495], [-33772, 6342, -598, 1410, -292], [6960, -4268, -2344, -1270, -1389], [-15908, 6444, 476, 4772, -398], [3376, 776, 3580, -1335, -2559], [-22454, 10852, 2224, 5002, 2652], [-7592, 3796, -1180, -6534, -1916], [22868, -818, 2866, 2309, 733], [-13758, -4188, 352, -5523, -4511], [-1200, 856, -1548, -7420, -1196], [-16478, 2112, -2648, 2056, -3034], [48946, 6196, -860, 3012, -3554], [11848, -7176, -1904, -4912, 456], [1584, 5908, 4296, 1544, 2282], [-4816, 6146, -714, -498, 4048], [60840, 4310, 10, 4281, -491], [9304, -4568, -1072, 3046, -5178], [-16556, 4248, -2292, 4884, -2248], [10334, -616, -3296, 2362, -310], [-8108, 11032, -2120, -3357, 554], [72256, -6068, 244, 3110, 1336], [11020, -2484, -188, 6855, -2147], [12118, -560, -2408, -2520, -4680], [-55162, -5040, -1308, 331, -3631], [-27804, 8776, 1768, 4627, 3504], [-16314, 9396, -2872, -6473, -2291], [-15600, -3652, 1416, -7158, -4788], [-18790, 3276, 1516, 2478, -3323], [32888, 2594, 2158, 5925, 785], [-35140, 11908, 1048, 8198, 2241], [-5976, -6532, -4328, 1746, -642], [-9974, -7236, 3388, -2046, -2503], [-1650, -10028, 524, -9102, -1535], [-13504, 17328, 2808, -4786, -98], [15012, 7456, -3016, 2318, -1950], [13578, 6096, 2920, 234, 3594], [21412, -5288, -960, 3784, -4177], [-19954, 7840, 3164, 425, 595], [26390, -3108, -404, 6808, 3264], [-8756, 9872, 2256, 2412, -2435], [-78524, 5288, 1036, -934, 1174], [-26206, 8338, 1074, -8154, -618], [24120, -6568, 1172, 1126, 4648], [-26268, 6660, 916, 7515, 1599], [-13556, 14828, 3508, 1096, 5055], [-45952, -6746, -266, -566, 1532], [21952, -2448, 1484, -544, -2100], [25200, 420, -2608, 1458, 177], [59808, -5216, -240, 372, -3545], [-290, -7596, -1756, -1120, 528], [-7550, 8964, -2260, -2778, 3], [1420, -3490, 26, -7205, 471], [-49596, -5216, -3808, -4605, 2705], [37624, -11638, -1478, -10804, -1126], [8618, -13004, -3384, 326, -64], [37932, -6024, 456, 1247, -5633], [46486, -12612, -2624, -5585, -6403], [14474, 7648, -1648, 4528, -4158], [13948, 3256, 3444, 4216, -3096], [6376, -12224, 4600, -5882, 2437], [-56660, -5160, -360, 3237, -440], [-34494, -13384, 1508, -6093, -485], [-4234, 7552, 1624, -3708, 3500], [-21550, 3372, 6308, 7308, 3112], [-37172, 8304, 2868, 3540, 3438], [13628, -2032, 8308, 11128, 3564], [8318, 3580, 864, 6825, 5655], [-21288, -848, 1856, -8418, 1348], [31156, -7232, 1256, 8114, -1083], [-22392, 6744, 3036, -4574, 3172], [-23138, 15116, -1792, -867, 1763], [-14202, 22746, 2402, -3242, -4038], [66234, 2564, 2752, -5392, -304], [-16328, 9424, 1528, 11375, 4318], [-43584, 2008, 1800, 1820, 5569], [-22800, -6750, -4386, 3753, 2301], [51194, -6460, -4236, -4946, -581], [81874, -9892, -1564, -7446, -5412], [-3176, 8068, 28, 3288, -2970], [15258, -8516, -3208, -11248, -8100], [-28268, -9300, 416, -7972, -3225], [-64832, -7224, 1224, -5481, 1642], [39068, 964, -2900, 11129, 6483], [46752, -80, -1884, 1530, -4856], [7252, -20992, 668, -4668, 3014], [-40744, 5444, 2284, 2328, 11629], [23642, 7396, 48, 12618, -1096], [-44296, -7246, 5070, -8976, -7370], [-49864, 472, -2216, -12332, -2730], [13966, -3376, 6204, 10123, 2449], [22544, 2878, -4510, 7031, 8375], [54562, 6132, -9416, -4869, -745], [25292, -11860, -8580, -7249, -665], [-31792, 6528, -3152, 1488, 2572], [-66050, -20004, -1320, 1678, 1790], [-8592, -14724, -280, 5998, 4382], [13070, 5924, 6148, -5840, -3432], [-81114, 19168, 472, -6060, -1922], [1070, 13840, 1484, 12037, 665], [-92848, -258, -94, -7752, -86], [46848, -7436, -7208, -9666, -4593], [-12092, -9784, 600, -2115, -5030], [61348, -352, 840, 15942, 5442], [-9190, -2032, -6888, -8216, -5670], [33654, 4376, 2408, 5368, 2506], [-6128, -3268, 4808, 6888, 3020], [-16608, -872, -1556, 7339, -5205], [6308, -13944, 6996, -2222, 7135], [7234, -15712, 4884, -1403, 7173], [43834, 1500, -324, -1492, -1272], [25876, 2104, 6608, 2741, -363], [17790, 13792, -1940, -69, -3699], [31308, -17320, 3272, -11087, -1638], [-444, -958, -1750, 21716, -1010], [-56666, 5332, 1908, 2738, 10800], [49846, -7336, 5260, -1658, 8178], [-56118, 9458, -46, -16434, -3042], [5736, -13520, -2220, -3822, -3402], [-9040, -4164, 1896, 6710, -328], [-45644, 8066, -5658, -284, -1882], [65884, -14344, 728, 4987, -1274], [36184, 11366, 794, -10655, -1595], [-2372, -3276, -1592, -7734, -3103], [-66372, -1672, -2304, 7097, -203], [-58604, -7584, 5840, -104, 1810], [-52260, -23032, -1684, 2835, -1873], [-28528, 11726, 11066, 8351, 8095], [35100, -2248, 2980, 4236, -1141], [-6402, 11288, -220, -6705, -4617], [49496, 1116, -1072, -3323, 6653], [-69160, -7896, 7084, 6056, -1596], [24780, 3600, 4192, 3965, 5559], [39214, 7092, 3152, -1701, 9041], [-30332, 28792, -172, 180, -3356], [92252, 3784, -3632, 2385, 4139], [11148, -5548, -3376, -19680, -5766], [-20032, -26070, -386, 5851, 3555], [23902, -2868, -1324, 4928, -688], [-57188, 4256, 5508, -2862, -216], [-10742, -112, 784, -22530, 778], [37512, 7404, -4600, 4204, 1331], [19328, -14280, 3832, 8127, -3262], [43040, 8912, -2056, 12414, 12870], [-21054, -18936, -6500, 3074, 2346], [36258, 18500, 1328, -7743, 1637], [-27642, -4024, -3928, 4944, -5284], [15892, 2244, -24, 362, 11377], [98230, -4156, 992, 13031, -457], [-13732, -4094, -5118, -11482, -4576], [-73136, 7056, -2208, -11919, -7976], [-44860, 4066, 334, -1191, 7725], [-11732, 6304, 1948, 3304, -7009], [-3468, 7784, 1716, 7016, -1248], [25042, 10372, -1976, 11338, 4590], [47802, -11680, -5484, 3625, 2195], [-23638, 17644, 9180, -6082, -3153], [67944, 7840, 13640, -10276, 3824], [27934, -22676, -976, 6362, -838], [4132, -9880, -7148, 9964, 10312], [75032, -4294, 3566, -13919, -6099], [-36718, -4300, 3724, -1426, -9053], [51928, -24910, -2378, -2892, -4214], [-78052, 27648, -136, 10222, -1417], [38508, 32672, -5188, 3800, -4695], [-37296, 7256, 7192, -3948, 749], [-35230, 6784, -3880, 11812, 212], [-47528, 4130, -930, -1341, -9845], [84728, -22314, -1070, 13760, 3098], [-133410, 188, -2560, 9896, 828], [126432, 11844, 7660, -2184, -594], [70508, 17936, 4608, 4641, 9888], [101368, -3488, 6192, -9232, 4644], [133212, -12040, 5664, -3021, 6423], [43320, 21416, -3064, 6102, -12242], [-104020, -22408, 2744, -12891, 9548], [47740, 5698, 5142, -7435, -3911], [101068, -18004, 1964, 3033, -2465], [-48750, -16912, 764, 2665, -4825], [42396, -26688, -5048, 49, 1826], [94350, -13252, -6376, 3639, 71], [-4066, 940, -4948, 10892, 4146], [-107036, -14208, -1904, 8404, 858], [-57250, 6980, 4908, -14572, 88], [-26888, 10808, 1800, 3796, 13090], [15698, -26760, -4244, 10738, -1916], [-27376, 1820, 3312, 858, -5039], [21064, 34084, -360, 8023, -5045], [63600, 5768, 2216, -1632, -6608], [-93362, -756, 1572, 2820, -112], [-54492, -8740, -5300, 2244, -11347], [-46152, 23460, -4792, 3202, -8486], [8750, -14072, 4776, -7396, 1092], [-20302, -33312, -6244, 16458, -3298], [-107346, -17548, 1028, 7250, -4123], [67328, 26664, -1400, -1947, -1976], [5340, 10044, -10776, 8636, 1433], [-46762, -7104, 8208, -23130, -9136], [-13940, 11812, 4604, -10380, 3368], [74652, 19058, -958, 18446, -1684], [68530, -10640, 3076, 23812, 1978], [58620, 30248, -2792, -2413, 7695], [-61176, -624, 4488, 9464, -3384], [73944, 3728, -1136, 2669, -3730], [60670, -35140, -2804, -3932, 3104], [66004, 11752, -3416, 2154, -8358], [-28888, 9084, -11384, -9479, -6847], [-131596, 20200, -9360, -20272, -15271], [-8556, -21164, -14380, -8196, 162], [-10020, 17800, 8356, -15254, 18], [69326, -4940, -2124, 7928, -7588], [1580, 10852, 12196, -511, -1573], [27870, -2568, 1268, -21049, -5611], [30722, -5172, 4804, 6822, -1964], [-39148, -21360, -12168, 1145, -3206], [-84444, -3088, -9060, 10626, 4484]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_539_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_539_4_a_h();".
// 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_539_4_a_h(:prec:=5)
    chi := MakeCharacter_539_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_539_4_a_h();".
// 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_539_4_a_h( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_539_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![352, 368, 18, -42, -1, 1]>,<3,R![376, 2110, -124, -97, 2, 1]>],Snew);
    return Vf;
end function;