
// Make newform 387.4.a.h in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_387_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_387_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_387_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 := [60, 276, 251, -16, -32, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [-34, -25, -36, -16, 2, 1], [30, 103, -36, -24, 2, 1], [118, 111, -44, -24, 2, 1], [182, 331, 24, -36, -2, 1]];
    Rf_basisdens := [1, 1, 8, 8, 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_387_a();"
function MakeCharacter_387_a()
    N := 387;
    order := 1;
    char_gens := [173, 46];
    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_387_a_Hecke(Kf)
    return MakeCharacter_387_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 := 4;
    raw_aps := [[-1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [-7, 0, 1, -1, -1, 0], [2, 2, 1, 0, 0, 3], [3, -6, -3, 2, 5, -4], [7, 2, -1, -2, 3, -8], [-4, -2, -4, -3, -1, 1], [-11, -10, 2, 3, -1, 3], [-24, -6, -5, -5, 10, 7], [-81, -24, -2, 5, -18, 8], [42, -18, -6, 1, -21, -1], [47, -18, 31, -3, 6, -9], [-78, 28, -27, 17, -16, -3], [-43, 0, 0, 0, 0, 0], [-79, 44, 9, -5, 40, -23], [-67, -20, 37, 30, -7, -26], [-62, -42, 8, -30, 4, 10], [-208, 46, 25, -4, -46, 13], [-113, 14, -69, 78, -1, -56], [62, 56, 38, 28, -116, 46], [148, 146, -51, 92, 26, 9], [-297, 96, 14, -53, 95, -35], [79, 136, -37, -102, 5, -64], [-576, 2, -89, 62, 34, -17], [4, 102, -3, -29, 22, 133], [153, 272, -31, 46, -19, 18], [-414, 304, -47, -47, -20, -107], [166, -170, -74, 38, -56, 68], [-105, -194, 59, 54, -35, 138], [-258, -172, 102, -18, 78, 80], [-144, -188, 108, -35, -173, 263], [-211, 18, 201, -197, 64, -165], [-740, 512, 42, 78, -130, 64], [-601, -80, 251, -208, 69, -96], [-181, -458, -53, -111, 38, -97], [-734, 38, -55, -20, -112, 111], [1529, 78, 52, 99, -149, 237], [-435, 4, -153, 157, 19, 6], [-1043, -188, -237, 324, 51, 2], [-1140, 100, -2, -38, -68, 6], [-903, -232, 9, 183, -41, 44], [398, -222, -122, -64, -154, -210], [98, 92, 122, 94, -86, 16], [-332, -226, 11, 263, -62, -161], [208, 558, -110, -114, 538, -438], [-1648, 128, 146, -266, -192, -98], [1485, 94, -37, 253, 114, -369], [1150, -174, 155, -304, -232, 73], [-1385, -58, 62, 167, -99, 73], [57, 390, -293, 102, 189, -142], [1272, 184, 8, 302, 332, -84], [315, -224, 302, -113, 43, -119], [-3766, -280, -68, 162, -166, -142], [-1089, -398, -463, 28, 271, -110], [-986, 6, 329, -176, -46, 449], [14, 796, -334, 104, -12, 518], [-875, 174, 379, -162, -87, 542], [-154, 36, 209, 559, -260, 257], [1165, 688, 53, 35, 67, 44], [652, -96, 284, 667, -673, 91], [-197, 288, -347, -198, -101, 8], [-3438, -1014, -68, 308, -172, 474], [435, 320, -155, 258, 649, -322], [927, -390, 211, -322, -359, -354], [1302, -134, -219, -94, -156, -77], [-3873, 22, -43, 294, -23, -232], [3040, -910, 391, -636, 120, 461], [-2780, -672, 0, -813, 1199, -89], [-3477, 328, -267, -747, 1221, -958], [201, -456, -134, -301, 46, -256], [-1113, -2, -413, 390, -497, -716], [750, -462, 926, -489, -191, 1573], [2621, 1824, 107, 739, -1128, -297], [1001, -2110, 220, -359, -737, -3], [-69, -1002, -75, -400, 265, 732], [-5936, -1528, 858, -832, -380, 538], [-1894, 764, 136, -156, 520, -608], [-2578, -1734, 264, -676, 494, -456], [1338, -984, 684, -1041, 161, 45], [-4224, -950, 431, 42, -794, 755], [2210, -1886, 31, -484, 630, -293], [4365, -2342, 492, 259, -157, 709], [-334, 996, 872, -289, -525, -325], [1726, 666, -663, 360, 494, -155], [-2490, -2166, 1096, -245, -791, 1007], [3016, 894, -112, 756, 182, 612], [2784, -690, 299, -1360, -652, 849], [-3572, -414, 123, -800, -12, -115], [-3238, 86, 594, -664, 546, 250], [2192, 634, 825, -254, 530, -155], [4435, 214, 1007, -681, 18, -153], [9894, -2090, 45, -169, -936, 435], [-7351, 1806, -236, 105, 597, 135], [4565, 180, -229, 1137, -901, 142], [1641, 1408, 130, -1451, -238, 68], [5070, 876, -424, 1392, -174, 694], [-1269, 972, -569, -1698, 995, -278], [-5730, 822, -639, -1886, 792, -1397], [-2159, -1628, -484, 417, -1726, 302], [-1569, -1328, 657, 0, 935, 1500], [-4521, 2024, -473, 1068, -465, 1374], [1347, -246, 143, -294, 777, 334], [-539, -146, 1537, -350, -2617, 1070], [1775, -284, 1383, 624, 459, 2010], [6691, 2888, -632, 713, -784, -1196], [-5492, 2338, -223, 1146, -1244, -673], [2522, 2820, -996, -1236, 1126, -1206], [-4764, 1062, -459, 350, 1964, -1833], [15344, 1228, -622, 1233, -49, -1111], [-374, 1164, 86, -730, 532, -318], [5504, -392, 416, 1016, 872, 444], [3894, 474, 2082, -2264, -1244, 256], [-2438, 1830, -1379, 1483, 1128, -833], [4412, 2420, -1136, -324, 3216, -1284], [278, -1764, -128, 424, 1490, -1738], [622, 1778, -2033, -88, 1310, 183], [-3714, -2494, 1848, -1978, 1992, 1458], [2202, -916, 662, 458, -2650, 1320], [-12021, 2066, -1050, 777, -1267, 541], [10601, -726, -1713, 970, 1213, -258], [-2775, 384, -1537, -1188, 771, 1262], [11674, -658, 653, -430, 366, -835], [-11099, -2338, 1870, 543, -833, 727], [-8941, 34, 1643, -982, 1011, -1456], [4042, 894, -2101, 1492, -290, 63], [4748, -3034, -26, -1710, 860, 376], [-5193, -158, 537, -1382, 709, 1740], [11649, 1190, 1607, -1157, -1442, 1911], [-7862, -72, 380, -554, 1986, -110], [-15651, 186, 575, -1549, -1142, 487], [-1579, -3546, 151, -1783, -1654, -2117], [3382, 884, 782, 610, -142, 1196], [-4600, 4186, 9, 60, -2844, 811], [-433, 526, 2423, 169, -1674, 3327], [11634, -1564, 958, -462, 770, 2300], [-3373, -4188, 1223, 2147, -360, 695], [-14663, 356, 1936, -1375, -2660, 1248], [-6394, 6398, -1500, 530, 4, -2154], [-19130, 1818, 1400, 944, -824, 1234], [7475, -2804, 1045, -1001, 2068, -415], [7441, -4888, -341, -159, -1725, -1150], [5939, 1798, 323, -782, -1237, -1440], [6849, -5806, -1007, -814, 355, 830], [3496, -3944, -1390, -464, -2130, -1800], [-1835, 6358, -711, 1567, 686, 1053], [-1912, 1270, 883, -1958, 736, -1231], [1355, -3032, -855, -706, -1093, 664], [-11669, -1198, -2138, -1359, 2959, -1233], [2283, -3270, 1234, -4645, -39, -111], [-2640, 180, -3540, 3526, -950, 1666], [-5223, 5472, -1971, 2538, -1787, 1446], [-16152, -1156, -1768, 385, 3181, -1223], [6817, -5706, 517, 142, -325, 3670], [-4426, -3924, 450, -2112, 534, -1348], [16235, 1128, 587, 4804, -3001, 1554], [3178, 2474, -1443, 4138, 878, -2815], [-10366, 2404, 162, -1015, 2849, -6373], [9706, 356, -2006, 900, -756, 2950], [17308, 4558, 1645, -4054, 474, -279], [-467, -918, -1419, -1068, -2727, -28], [4989, 3684, 4147, -1012, -3331, 2140], [9384, -5814, 969, -4540, 438, 2429], [14668, -1580, -1505, 1519, -578, -3255], [14645, -2714, -823, -2848, -1505, 142], [7325, 3996, -3013, 3261, 1852, -4825], [-5144, -2266, -645, 2034, 2268, -2635], [11080, 5342, -1333, 728, -2198, -3273], [-305, 5580, -2166, -485, 404, 2978], [596, -1624, -4636, 5162, 1596, 2540], [-3176, -2436, 156, -1742, 1154, 818], [7867, 3226, 1841, -717, -1114, -3139], [-6121, -8722, 2560, -4039, 541, 2903], [-12948, 942, 1959, 964, 286, -969], [-2682, 4194, 1341, 27, 2748, 3511], [2434, -8724, -1894, 1864, 474, -968], [10403, 6316, -568, -91, -1349, -2649], [4433, 2654, 2943, -3273, -3804, 2185], [-5673, -2184, -4231, -175, 4221, -1018], [-2494, 4094, -384, 1094, 5438, -180], [4873, -1950, 1162, -231, 31, -5201], [15140, 506, 2167, 1742, -1304, 2253], [11676, 3378, 600, -5008, 2880, -190], [-20912, -394, -959, 2200, 2110, -3827], [-2722, 6, -1481, 5136, -4746, 819], [-5558, -470, -3571, -354, -3952, -1717], [-6976, 2084, -1056, 1468, 254, -762], [-1929, -2728, 265, 1325, 3313, -398], [3393, 3356, 5694, -3535, -1682, 1072], [6371, -5704, 297, 1411, -3076, 481], [-11930, -350, 3715, -4918, 4720, -1447], [2564, -12816, 782, -3761, 2435, -1127], [17617, 10676, 1049, -33, -2285, -2008], [-870, -7786, -372, -3582, -1380, 518], [1401, 3450, 2190, -1539, 1887, -2945], [4190, 1442, -555, 2524, -2034, 5917], [-11978, -3640, -4992, 2238, 5082, -2694], [14490, 650, -5105, 2547, 8088, -4595], [1027, -1226, 709, 5292, 2989, 900], [893, 1816, -3588, 1651, 1569, -3683], [20722, -1182, 2807, -2062, -388, -2299], [16983, -14068, 1261, -348, 1833, 3470], [22446, -5976, -3352, -2880, -234, -1678], [-7348, -1276, -4270, -4932, 5094, -972], [18720, 5220, 1720, -558, -5602, 2], [-27913, 2452, -4666, 4495, -2990, -3060], [-30777, 1926, 1397, -2115, 4206, 813], [11084, -10892, 2686, -1936, 1522, 432], [15851, 256, -1107, -4182, 4739, -344], [-316, 476, 2318, -3602, -4090, -2212], [24883, 12848, -3787, 5180, 699, 3528], [1882, 1304, 2658, -5108, 8016, -6078], [-30859, -696, 1539, 4446, 943, -1786], [2091, -4448, -3597, 100, 3589, -7472], [16627, 10498, -1647, 5632, 2581, 4128], [12778, -5962, 2747, -106, -4436, 1861], [-7820, 5006, -1658, -3815, -1113, 491], [-24584, 3010, -4133, -680, 2962, 4403], [-44078, 7348, 1114, -42, 4584, -4994], [24146, -858, 2157, 4952, -7628, -349], [22509, -5050, -847, -2358, -1989, -1202], [-39681, 2156, 211, 1509, -5719, 3404], [-12866, 14150, -1334, 7358, -3078, -1902], [-16054, 4290, -4971, 3182, 1928, -3033], [-38634, -9142, -3887, 2433, -3140, -3049], [-1951, -13770, 1194, 4477, -4137, 7699], [-11219, -8048, 1309, -2050, 2681, -2534], [-44929, 9718, -639, 2158, -4625, 3370], [-21738, -1890, -903, 846, -2754, 1029], [3252, 9608, 502, 8678, -6638, -656], [-28933, -1218, 1954, -1075, 3581, 4129], [14265, 1596, -5596, 3727, 2034, -7878], [-13913, -1160, -3867, -546, 7185, -3018], [-3728, 3698, 1397, -1363, 3742, 4893], [-36448, -732, 6158, -1964, -1630, 7296], [-7605, -5656, 4287, -1472, -1101, 3154], [21759, -5360, -1417, 5037, -3636, 2575], [-8472, -9672, 3942, -496, -814, 10020], [-27695, 4724, -6319, 9404, -6101, -788], [-7325, -3576, -2819, 3287, 9589, -3222], [-25116, 5206, 1441, -5315, 5082, -2727], [-6417, 7170, 2281, -1571, -1396, 2347], [34545, 870, 876, 273, 2487, -2823], [-29499, -2550, 4308, -2995, -4439, 12503], [9344, 11430, -7334, 778, 2710, -1266], [20646, 2800, 2146, 210, 1806, -9268], [3041, -240, -8504, -2643, 5133, -331], [48508, 512, 5960, -7916, 1180, -2220], [-8585, 13728, -1167, -1932, 3113, -9734], [-10127, 18038, -2501, 2288, 3405, -4578], [3412, -784, -4967, 3793, -4078, -597], [438, -11854, 206, -4132, 4716, -6652], [40123, -11334, -1285, 3786, -2685, 1100], [48087, 3728, 4843, -2508, -3135, -764], [-9182, 9996, 7510, -2056, -6944, 8314], [-22029, 1924, -2346, 1379, 3256, 1170], [21485, -6458, 4563, -9081, -4704, 10741], [3363, 20350, -1032, 1387, -51, -4377], [-5827, -8290, -9205, -738, 11253, -6434], [-16378, 7178, 5579, -10148, -5188, -3399], [282, -6124, 5525, -9625, -6424, -2843], [-15372, -9432, 340, 9374, -4122, -4026], [16543, 5824, -3353, 7609, -4387, -4860], [14958, -5664, 1204, 5380, 216, 3636], [38522, -5842, 2970, 1324, -10052, 10668], [-21534, -11174, 3923, 4714, -10544, 7409], [-5807, 14586, -1435, 2929, 7934, -5075], [1929, -4570, 4515, 2369, -8884, 6613], [57660, 3736, -2743, 2193, -422, 4031], [8238, 7724, 1494, -6748, -1126, -10404], [42299, -2702, -2651, 5138, -7939, 10568], [-13885, -5984, -1625, -5336, -1165, -4698], [-15103, -5936, -1279, -3685, 7591, -7696], [12880, 5814, 1531, 3206, -7094, 10431], [-9006, -5302, 5255, 3372, 2148, 5657], [-29701, -2732, 3131, -6709, -84, 6687], [9566, 3102, -4901, 8638, 1154, 3183], [23911, 2106, 4395, -2502, 13881, -4682], [-22041, 4716, -2449, -4909, 12241, -4648], [14828, -1100, 1936, 7, 3447, -10133], [16881, -5808, 2357, -2739, -12725, 3412], [-15158, -9618, 3618, 3629, -11033, 11843], [-46811, -7774, 6315, 1131, 1886, 7439], [-30750, 8764, -2508, 893, -983, -5323], [-911, 3964, -6942, 7397, 9752, -5862], [2653, -2800, -6094, 3811, 4508, 6034], [-32512, 15622, -2823, -1106, 1344, -7169], [4182, 24236, -2799, 7575, -6800, -63], [-21513, 2156, -1096, -2181, 3672, -3972], [-12458, 8818, -9705, -1502, -4104, -8371], [53392, 3168, -4349, 6013, 8782, -7243], [16379, 1944, 2345, -8720, 405, 1874], [-10045, 12540, -3071, 2122, 1641, 3686], [10285, -10644, -1396, 1155, 1177, -4247], [2303, 7734, -4871, 11407, -12334, 745], [-33797, 3836, -2741, -3438, 6243, -11722], [-58815, 10322, -4335, 2260, 3649, 2752], [62488, 516, -3725, 6001, -5018, 6045], [-30037, -9510, -6065, 5160, -4253, -3320], [-24866, -2494, -6946, -8586, 17110, -7498], [18946, -9600, -8490, -2574, 3112, 5294], [-41828, -5462, -6460, 7163, 4897, -9017], [33395, -740, -11329, -3321, 5149, -880], [7731, 19956, -6665, 6548, -7679, -3876], [-5921, -356, 6529, 4150, -4637, 2200], [-38437, 7404, 2930, 1323, 4422, -13768], [13862, -8208, 3702, 8468, 2722, -1128], [1905, 6350, -7019, -7818, 13923, -3738], [49885, 10574, 9662, -7295, -7721, 4923], [-25912, -214, 3069, 4406, -5206, 12005], [10901, -10770, 5460, 4597, -14173, 16073], [-35448, -9140, 4306, 1546, -5170, 9844], [77638, -4138, -539, -2708, 11616, -5609], [22808, -1070, 3705, -623, 7774, 669], [-16233, 7062, -1276, -8555, 1821, -1461], [-24266, -2954, -10632, -2187, 1959, -8975], [85616, 368, 725, -4767, -1094, 3803], [2134, -15746, 7026, 7274, -13554, 13422], [12338, 23258, -5834, 8158, -2466, 4774], [5236, -636, 10562, -4967, 6941, -6541], [-10836, -18132, 2386, 7102, 2200, 7122], [-4495, 7386, 10817, 9546, -13649, 3162], [-13384, 748, 2404, 8364, -2492, -4420], [35385, -16954, 2881, 8065, -11076, 1283], [62646, 2930, 284, 2338, 6470, -5444], [87354, -2564, 6182, -6074, 4366, -2164], [-16480, 766, 1210, -9657, 5601, -2959], [-80262, 5778, 221, 1436, 6614, 6061], [48793, -5498, 8811, -2840, -4313, 10664], [-8835, -18722, -816, 6473, -711, -12289], [10413, -11356, -5902, -3431, -620, -15606], [31194, 7314, 7469, -4564, -4668, -2229], [-5603, 4550, 3509, 5842, -123, -3140], [-28404, -11642, 10577, -7044, 798, 12373], [-67203, -7744, 2716, 10579, -1992, -1204], [-1026, 8534, 13054, 5766, -10718, 12686], [52253, 16316, -3233, 10962, 3295, 11122], [10016, -2684, 4878, 5356, 4606, 11656], [28070, -6476, 1702, -11160, 10028, 3514], [-14020, -10128, -10772, -8724, 2310, -7182], [-73966, -8486, 4167, -6166, 4892, -7799], [60173, -10452, -5323, -5164, -1401, 1364], [46224, -14198, -11499, 2552, 10664, -7893], [24540, 19408, -1482, 2912, 5354, 4868], [18054, -8558, -10463, 5106, 13444, 499], [-53031, 6234, -2319, 12400, -1875, -324], [-53997, 10648, -1343, 94, 3497, -10238], [-8799, 6368, -11320, 13205, -432, -13784], [64604, -728, -11702, 8644, -3570, 1504], [-10098, -1628, 2978, -5030, -18048, 4390], [-59299, 6592, 6369, -15380, 16895, -19972], [-25728, -7782, -4392, -8024, -660, -9938], [-40690, -17630, -5455, -4390, -256, -10261], [80140, 21026, -12652, 9858, 8840, -1274], [29082, -13854, 9617, -1392, -12218, -399], [3884, -14798, 3608, -17502, -8944, 5282], [11552, 22878, -2747, 14502, -1680, 835], [-5998, 13296, 4578, -9578, 8322, 7892], [2893, -14434, 3093, -2277, 7660, 219], [9508, -4830, -2776, 1439, -31, -14869], [-45724, -24758, 696, 3451, 3343, 18493], [80319, -11298, 5909, -2433, -15260, -2001], [121244, 438, 5311, 7078, -13276, 16605], [-50192, -12414, 8353, -1934, 3608, 15051], [25931, 8590, 2752, -10623, -8627, -10505], [-40161, 10926, -651, 5356, 11527, -8222], [-61768, -29352, 4674, -5112, 2152, 8402], [-2881, -15710, 15986, -11857, 11273, 5709], [-44465, -5956, -11231, 15473, -4216, -1399], [17600, -3310, -5801, 5154, -10930, -7641], [21311, -26142, -380, -735, -11763, 5343], [-80505, -31688, -2374, 7279, -8946, 820], [-27853, 7868, 12010, -11381, -12929, 8125], [42771, -10412, -3509, 373, -3699, 1244], [-21830, 2038, -6986, 11543, 13653, -22787], [-2600, -18676, -6746, 9064, -5062, 1576], [-57609, 25074, -8024, 785, -4791, -5317], [8890, 13078, -4426, 13394, 9430, -10766], [69168, 1168, 1784, 4347, 17687, -2305], [-48184, 31022, -2805, -6628, -4128, -875], [2742, 13526, 2889, -6112, -12076, -8769], [-35949, -4068, 523, 6160, -139, 20312], [50626, 21280, 5787, 821, 3724, -4973], [790, 10468, -14296, -4119, 13965, 6749], [67960, 16810, -939, -12470, 4274, 1833], [65675, 11718, -8495, 4994, -17695, -13632], [26134, 30392, 2894, -2151, -14279, 3219], [44234, -23322, 17353, -12032, 6784, 2503], [16299, 17130, -8195, 11768, -11077, 5510], [60420, -9686, -7096, -3924, 4204, 2910], [-79555, 17410, 2375, 5206, -4281, 13240], [2664, 25420, -14122, 19855, -7205, 9157], [-77843, -28868, 5202, -4011, -8476, -1754], [-2764, 5552, -4142, -1296, 29232, -12446], [-39417, 23392, 16933, 1556, -7485, -896], [-43792, 10190, -10251, -3324, 15988, -14657], [118833, -23320, -3118, -265, 1001, 1619], [-3524, 7272, 12712, -1775, -8401, 9755], [6794, 11974, -6693, -3126, 20072, -4635], [129433, -2308, 183, 5075, -10181, 5986], [8345, -14136, 791, 18281, -481, 1302], [113427, 7480, 7161, 12068, -4645, 19552], [68497, 27292, 8670, -21557, 6677, 2047], [-35256, 16748, -2497, -12037, 14090, 7293], [-25433, 25984, 3672, -5431, 19335, -10697], [-124583, 15782, -6373, 7001, -3600, -2919], [-60002, 12830, -13721, -1938, 3348, 10497], [45605, -10902, 13451, 12793, -14644, 17089], [103785, 7692, 15381, -8675, 2928, 10093], [-120439, 3518, -10196, -20967, 13867, -12239], [25259, 25376, 8639, -1066, -8821, 10730], [-26983, 5700, 5224, 8859, -4099, 3417], [-64014, -10840, -7846, 17016, 12896, -3346], [-95613, 19246, 5683, -797, 14642, -10017], [22049, -2992, 2063, -24540, 20781, -2292], [22530, 22618, -4681, -11344, 4926, -15429], [107819, 3940, -4951, -186, 725, 13822], [-96413, 17250, -15925, -9550, 1385, -22858], [17111, 41796, 364, 13703, -8949, 2699], [70860, -12118, -5768, -16774, -8678, 5892], [-134554, 5378, -4765, 2386, -19484, 5865], [36711, -11472, 11551, -28177, 3681, 17844], [-76066, -5082, -2924, 9552, -7628, 14702], [36452, 19114, 9609, -9996, 6626, 13717], [-49885, -9146, 4369, -8284, -449, -6578], [59920, 10832, 6160, 13410, -12318, -1010], [-12921, -24994, 10656, -21693, -12923, 8971], [-7445, -25646, -20005, 14363, -1518, 18739], [60478, -8626, 9185, -3102, -12268, 18559], [35579, -21700, -8503, 8378, 23359, -14364], [-52770, -28346, -16539, 14452, -2786, -2587]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_387_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_387_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_387_4_a_h(:prec:=6)
    chi := MakeCharacter_387_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_387_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_387_4_a_h( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_387_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![540, 608, 26, -124, -17, 6, 1]>],Snew);
    return Vf;
end function;