
// Make newform 1840.4.a.u in Magma, downloaded from the LMFDB on 05 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1840_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_1840_4_a_u();".
// 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_1840_4_a_u();".
// 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 := [-4032, -816, 1328, 105, -80, -2, 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], [40584, 44176, -5583, -1888, 86, 17], [24132, 8248, -2643, -796, 32, 11], [-15234, 1264, 1503, -307, -22, 5], [16320, 19704, 539, -1448, -30, 19]];
    Rf_basisdens := [1, 1, 4824, 1206, 603, 1608];
    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_1840_a();"
function MakeCharacter_1840_a()
    N := 1840;
    order := 1;
    char_gens := [1151, 1381, 737, 1201];
    v := [1, 1, 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_1840_a_Hecke( : Kf := Kf)
    return MakeCharacter_1840_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, 0, 0, 0, 0, 0], [1, -1, 0, 0, 0, 0], [5, 0, 0, 0, 0, 0], [2, 1, 0, 0, 1, 1], [3, 3, 1, 1, -1, -2], [-6, -1, -1, 2, -2, 0], [-23, 5, -1, -2, 1, 3], [-9, 3, -5, -2, -3, -2], [-23, 0, 0, 0, 0, 0], [-53, -8, 8, 1, 2, 2], [34, 7, 1, -1, -9, -2], [-62, -2, -14, -9, -8, 1], [-107, -13, -6, -1, 5, 0], [29, 2, -9, 3, -6, 8], [-52, 48, 1, -9, 12, -3], [-96, 10, 6, 17, 1, -34], [-181, 2, 11, 0, -6, 25], [-208, -25, 26, -40, 8, 5], [217, 8, -23, 18, -5, -14], [-56, 39, 17, -4, 17, -4], [-164, 16, -17, 5, -21, -26], [160, -44, 16, 16, -43, -17], [214, -6, 14, -3, 41, 16], [-487, 54, 35, 19, 4, 6], [-35, 125, 41, 9, 17, 4], [-25, 2, -11, 34, 40, -5], [87, -35, 37, 7, -12, -51], [139, -66, 79, -26, 55, 16], [-362, 139, -32, 3, 72, 67], [-592, -46, 62, -75, -14, -31], [-169, -70, -22, -26, -17, 8], [246, 10, -59, -97, 47, 58], [-865, 109, 11, -26, 8, 45], [184, 90, -163, 72, -22, -10], [-1301, 79, 85, -84, 42, 33], [119, -133, -20, 4, -31, 73], [-456, 144, 42, -29, 96, -1], [757, -189, 32, -73, -52, -22], [389, -318, -79, 97, -11, 47], [-1059, 31, 5, 125, -54, -121], [77, -54, 74, 20, 88, 77], [-574, -265, 74, 15, -68, -5], [50, 14, 72, -96, 188, -28], [-315, -302, 156, 32, 28, 39], [502, -7, -129, 69, -122, -170], [1260, -420, -84, 96, -13, -57], [-826, 322, -38, -83, 125, -32], [-569, -394, -5, -63, -87, -63], [249, 104, 183, 105, -2, -38], [-263, -494, -305, 157, -140, 126], [-2734, -128, -117, -117, 19, 122], [-1230, -20, 41, -226, -34, 8], [170, -188, -100, 74, 126, 34], [-1407, 337, -195, 238, -234, -261], [-729, -78, 28, -48, -90, -25], [106, -357, 192, -7, -93, -217], [499, 136, -4, -205, -12, -82], [-2181, -41, 63, 135, 107, 223], [88, 466, -205, 31, 39, 132], [511, -188, 17, 37, 130, -80], [-2058, -10, 44, 45, 123, 22], [-514, -74, -62, -25, -43, 46], [586, -339, 140, -46, 75, 222], [-3027, -428, 108, 72, -194, -349], [-2649, -103, 83, -179, 269, -41], [509, -57, 403, 68, 130, 101], [-4248, 578, 113, -30, 68, 102], [-217, 245, -247, 236, -303, 190], [-4216, 283, 198, 42, 223, -58], [-2405, 706, -224, -59, 300, 110], [-2284, -194, -241, 231, -145, -382], [-1126, -1016, -386, 96, 133, 23], [300, -74, 260, -37, 307, 148], [-3560, -354, -138, -132, -390, -112], [617, -623, 179, 129, 180, 205], [65, -416, -373, 118, 79, 186], [1141, -529, 83, -281, 496, 341], [644, 1021, -93, -177, 92, 116], [-1734, 534, -204, 118, -288, -454], [724, -759, 161, -173, 142, 259], [-3942, -140, 344, 174, -35, 319], [1984, -13, -18, -151, -674, -167], [-4632, -994, 234, 180, -455, -377], [-77, 483, 97, -181, 157, -139], [-5030, -871, 255, -236, 314, -84], [1882, -633, 59, -530, 301, 231], [910, 429, 708, 418, 372, -112], [-532, 1142, -444, -147, -547, -386], [3296, 2176, -283, -181, -72, 183], [4749, 866, -447, 197, -547, 209], [-714, 624, 84, 145, 59, -510], [-1394, -744, -742, 232, -166, 162], [1121, 750, -256, 172, 795, 392], [-2532, -266, -943, -170, -588, 44], [-297, 294, 38, -107, -283, -561], [459, 823, 49, -165, -55, 199], [7373, -1202, 34, -210, -391, 134], [-2424, -232, 616, 16, -298, 236], [5183, -298, 297, -473, 50, 92], [3357, 1320, -282, 120, -281, 122], [621, 1269, -668, -585, -86, 268], [12762, -550, -304, -199, -146, -395], [6298, -830, 370, 669, 507, 264], [438, 24, -656, 420, -18, 234], [-3745, -1173, 321, 295, 492, 935], [-2292, 666, 543, -631, 141, -244], [1039, 1159, 330, 84, -206, -240], [-6899, -952, -513, 339, -363, 199], [-370, -2151, 60, 416, 27, -260], [415, -721, -72, 448, 251, -508], [6441, 1506, 661, 253, -177, -259], [-7058, -1372, -270, 22, 18, 496], [1629, -1531, -149, 672, -714, 240], [4161, 1597, -935, -196, 86, -219], [5408, -258, -766, 986, 33, -429], [-10581, -290, -407, -45, -554, 6], [7914, 1484, 12, -381, 533, 576], [-1196, 2038, -271, -395, -202, 595], [1657, 681, -634, 989, -261, -417], [-3506, 868, -786, -324, -180, 666], [-2843, -1135, 813, -23, 126, -433], [-7320, -2542, 321, -529, 127, -24], [6834, -1074, 672, -103, 137, -336], [4948, -1399, -601, 620, -179, 431], [-722, -1858, 126, -292, 478, 920], [4476, 917, 666, -939, 1094, 761], [3648, 777, 176, 1274, -118, 99], [7161, -1167, -403, -691, -235, -135], [1477, 307, 1217, -458, -125, -345], [-8148, -1282, -888, 215, 699, 662], [10311, 790, 1184, -155, 159, -347], [1043, 2893, -469, 106, 576, 451], [3838, -1618, -408, 626, -1133, -449], [9952, -4478, -216, 1095, -658, 461], [775, 79, 120, -274, 1485, 912], [-5548, -1120, -1366, 264, -966, 168], [-3910, -776, 1376, 274, 103, -839], [3984, 2176, -844, -231, -1219, 266], [-2178, 100, 334, -1143, 780, -291], [-12108, 1301, 384, -361, 514, 1192], [1530, -1878, 1529, 904, 318, -902], [9395, 1550, -307, -339, -807, 999], [4758, 1994, 83, -879, 836, 271], [-5604, 1656, 796, -85, 19, 462], [1377, 2384, 231, 314, 616, 851], [-2010, -2186, -108, -1516, 1351, 1291], [6627, -1811, 53, -362, -992, -273], [7728, -3290, 1325, 93, 1295, 1238], [22598, -1722, 1049, 264, -44, -288], [-416, 1500, 275, -343, -1136, -2111], [6691, -1695, 987, -355, -1438, -81], [4574, 828, 1586, 978, 1250, -374], [18102, -739, 94, -883, 755, 1118], [9915, -1304, -784, 1350, 773, -832], [1379, -4914, -353, -242, -1489, -1604], [-4002, -1454, 26, 124, -757, -885], [17634, 2612, -1040, 1104, -209, 679], [1532, -2364, -77, -544, -379, -1], [541, -879, -1255, 88, -1299, -1724], [1511, -3283, -1179, -493, -692, -555], [6872, -1333, 81, -260, 711, 1529], [-7975, -3643, 637, 909, -1812, -1343], [4427, -2462, 766, -946, 61, 50], [-12171, 2685, 1369, -181, 616, -981], [1409, 1293, -1775, -745, -670, 1538], [12495, -673, -1117, -406, -1287, -93], [-8061, 1469, 397, -190, 1629, -413], [5896, 3060, -1074, 744, -1906, -772], [3739, 256, 3395, 227, 1014, -464], [15903, -445, -714, -630, 705, -313], [-15492, 344, -1584, -1024, 663, 2157], [-11372, -4590, 1901, 396, -381, 263], [-15114, -1138, -562, -826, 586, 1710], [-2757, -4745, -947, 320, -621, -1393], [9102, -447, 869, 677, -1424, -1008], [-3667, -772, 207, 601, -1768, -2364], [-736, -262, -1175, -1521, 1223, 816], [21756, -2700, 947, 2314, -761, -2123], [7610, 741, 1252, 209, -1689, -2611], [8479, 487, 2591, -784, 214, -1075], [7575, -2846, -866, -864, -785, 222], [-42295, 1961, 177, 951, -605, 292], [3664, -1601, -2485, -1522, -890, 442], [18882, 774, 240, 1284, 524, -146], [-3181, 8319, -25, -548, -85, 167], [7977, -825, -1047, 158, 1038, 2185], [1406, 2161, -424, 915, 575, 2054], [17905, -1564, 841, 1352, 523, -696], [-1968, 6481, -1953, 556, 220, -133], [-7627, 1347, -917, 1082, -633, -151], [12630, -4336, 1395, -943, 811, 600], [-8603, -822, 969, 275, -331, 109], [-4918, 2748, 2176, -618, 848, 1228], [8181, 1436, 107, 540, -162, 1249], [988, -2292, -902, 384, 1662, -604], [-20853, -3425, 573, -267, -1550, -686], [-8409, -2192, -2029, 131, 480, 2360], [13734, 2248, 658, 1046, 1056, 766], [-14438, -2700, 2018, 210, -1050, 440], [-31488, 5512, 451, 747, -554, -177], [5391, 3165, 821, -1625, 94, 1031], [-20620, 4263, -1336, -1663, 2047, 2012], [13727, -6165, 1608, -1186, 473, 1427], [5255, 6406, -1297, 2237, -192, 1194], [16480, -2344, -1912, 700, -510, -1110], [6962, -1586, 349, 333, -2393, -3044], [26314, -840, -862, 164, 1259, 225], [-17284, 2503, -745, -1699, 1567, 313], [-8343, 6901, -1700, -1324, -347, -120], [-11606, 5052, 131, 877, -185, -650], [1844, 1220, -3719, 2073, 271, -296], [-23132, 990, 623, -685, 924, -849], [7688, 7735, -1578, -1003, 2568, 2833], [-8170, -2218, 1412, -4202, 2166, 1022], [-10560, 2666, -1580, -2035, -2189, -1130], [8131, -3308, -859, -1433, 1374, -666], [15971, -3422, -3092, 1302, -1199, 1654], [-35603, 4162, -590, 1385, 1650, 1686], [-13365, -9707, 637, 413, -1677, -2261], [16777, 3536, 850, 18, -3384, -2451], [-367, -4172, 1684, 863, -398, -190], [9592, -3436, 2492, 2212, 785, -2927], [-2534, -825, 2293, -192, 1246, -1451], [12262, 5699, -900, 668, 1853, 2165], [-6372, -2854, -2019, 1891, 880, 1693], [10376, 1146, 1683, 280, 4233, 2857], [-15013, -2437, -465, -1612, 2715, 4040], [8317, -2027, -862, 1812, -782, -2415], [1119, 3715, -391, 2358, 1274, 493], [-34372, 5590, 272, 1239, -1441, -492], [-18643, 7801, -1109, 344, -926, -763], [-38941, -3221, -337, -517, 641, 1574], [-7990, 3184, 1368, -342, -1346, 938], [-55695, -4039, -211, 216, -1803, -1517], [-2986, -1900, 4546, 65, 2265, -2118], [3977, -3078, -2045, -3185, -2022, 876], [-7414, -1706, -338, -1124, 54, 2944], [10138, -7442, -1038, 10, 945, -269], [325, -2932, -668, 951, 17, -3181], [-28489, -1681, 4830, 1537, 2226, -2485], [-29542, -7672, -438, 2173, -3387, -278], [14319, 1586, -826, -2003, 2423, 167], [-22257, 10988, 1268, -3028, 2113, -1044], [-25358, 12896, -15, -1585, 2074, 2091], [-8978, 5266, 2416, 2834, 1658, 1202], [-23895, -299, -780, -633, -2797, -837], [111, 5538, 4524, -2138, 2437, -4204], [1791, 3439, -1851, -2296, -2702, -2497], [27777, -331, 4289, -2187, 576, 937], [-9327, -2607, 1189, 1192, -1123, 693], [15022, -5390, -1802, 400, 1402, 3394], [-41512, -5590, -4466, 1904, -3746, -1112], [23375, -3363, -3431, 853, -3373, 1499], [-3339, 4422, -177, 609, -4644, -3284], [7147, 8042, -1815, -2271, -589, 753], [6175, 1964, -1044, 2405, -611, 673], [14332, -4875, -722, 1892, 1118, -2935], [65758, -314, 816, 2060, 2906, 530], [-8807, -1079, -944, 4179, -1701, -1067], [4830, 1210, 937, -1431, 589, 322], [29289, -3403, -1245, 52, -1415, -839], [633, 1824, -2981, 2960, -4231, -840], [-26447, -2372, -853, -22, -1754, -1905], [-5370, -2108, -1608, -1991, 828, 4543], [-21685, -134, 1293, 2407, -2259, -2931], [52537, 1883, 2703, -319, -655, -1022], [-1784, 7363, -3146, 1524, -4124, -3247], [-49411, -12330, 1119, -205, 3016, -272], [-4391, -2106, -519, 2860, -5491, -1528], [34329, -3089, 1024, 723, 2657, 307], [-31226, 5394, -3849, 3034, -551, -2295], [18444, 1290, 1202, 4703, -3655, -6058], [8791, 2193, 2557, -435, -3326, -3202], [10958, 5332, 3352, 490, 4717, -177], [2281, -7060, -1412, 102, -880, -2479], [-18945, 8438, 1116, -2438, 905, 5382], [469, 507, 3635, -3973, -566, 1761], [14223, 1090, 89, 1204, 1160, -1203], [-60132, 5208, -1230, -2544, 40, 3098], [3023, 10003, 403, 1268, -352, -343], [-50177, 1920, 1518, 520, 113, 2650], [33302, -3104, -1844, -420, -3040, 4038], [-23284, 7739, -722, -368, -344, -2487], [-23136, -7156, 366, -580, 2286, -116], [39919, 6079, 3911, 1656, 142, -315], [8633, 3611, -2241, 5198, 51, 977], [1444, -7102, -2574, 225, 641, 5514], [-36386, -4786, -2750, -168, 2201, 7175], [33799, 7579, -5715, 69, 382, 5505], [58936, -2861, -3924, -1118, -3081, 1898], [-43884, 7988, 2762, 1130, 2354, -3178], [-10704, 556, -192, 2383, -1479, 1544], [-30732, -306, 906, -1418, 4030, 490], [23459, -1287, -2589, 330, -997, 2496], [35887, -867, 560, 1264, 3923, 3009], [-55223, -971, 777, 247, 1290, 3797], [13356, -7914, -2548, -3132, -3050, 458], [44312, -8429, -4753, 217, -1962, 1690], [-50152, 2640, 2793, -5314, -1540, 834], [-2431, 8035, 4902, -3824, -128, -1328], [7191, -6775, 981, 3123, 2236, -2994], [-36394, 4812, -4642, -947, -6326, -2043], [44550, -7878, 1030, -4030, 3944, 4626], [-65619, 3248, 4020, 1100, -633, 3226], [15543, -5467, 2127, 2898, -2898, -2759], [10781, -2078, 7114, 626, 4996, 341], [1731, 9287, -2319, -745, 5554, -1137], [-43179, 15627, 2061, -4074, 4226, -2003], [15678, -3166, 2296, 4786, 644, -6028], [-14129, -4605, 4587, -1913, 2532, 2389], [-13744, 9024, -3555, 2811, -3934, -5481], [-21166, -4173, 3658, 1385, 2440, -591], [-29540, 13646, 3416, -1524, 1306, -2688], [23748, 2549, -1183, 2445, 5929, 709], [73366, -1893, 5326, -1050, 1613, 619], [13925, -4492, -869, 2521, 1052, 552], [-29198, -7380, 1447, -298, -372, -4808], [9726, -14839, -2127, -2999, -1133, -1304], [1594, 7302, 354, 4933, -915, -2808], [-32419, -1899, 350, 1600, 796, 958], [30939, 3665, 5163, 2509, 3843, -2124], [-13153, 7599, -3797, 4512, -3520, 482], [-21465, 22116, -4226, -3110, -187, -2954], [16601, 10384, -5611, 4909, -3819, -1421], [-82153, 5125, 3911, -1626, 471, -2657], [6566, 11588, -1154, 682, -5242, -4366], [27471, -4629, 481, -4074, -1982, -2539], [19663, -11445, 7482, 1541, -2586, -408], [-11808, -11833, -1752, -221, -7270, -4815], [54320, 7080, -1492, 5725, -2557, -3186], [12480, 10618, 6409, -1440, 4435, -3791], [-5701, -755, -4370, -1448, -2045, 381], [6915, -6290, 4728, -6721, 2379, 1083], [-71712, -3911, -629, 2918, -5959, -6735], [65870, 14008, -7050, -638, 569, 223], [22004, 10933, -617, -640, -293, -2395], [-54327, -4559, -3411, -2695, 2374, 2791], [26998, -7116, 3480, 1156, -2629, -4103], [-49445, 2343, -7352, -1042, 2024, 848], [-26122, 3323, 3310, 4637, 4195, -2965], [87513, 5812, -5246, -1038, 448, -695], [-116801, -4605, -1645, 2335, -1425, -1928], [-47867, 13266, 2267, -2955, 2293, 3079], [-13356, 14954, 1066, 996, -338, -2686], [96484, -2650, -3498, 883, -541, -4434], [-32720, 5794, 2468, 991, -1353, -9492], [-504, 17220, -177, -2050, 1179, 3215], [2710, 9471, 1578, 613, 5869, 436], [8104, -8468, 1510, 2990, -3412, 1092], [-16692, 9716, -1834, -1809, 5317, 12426], [-52937, 6568, -2858, 3675, -5639, -471], [23285, 4720, 6808, 2406, 2250, -6589], [-35582, -364, -1084, 2315, -4397, 5124], [20749, 16917, 2701, 138, -1971, 2655], [-90838, 14952, 310, 84, 3138, 1622], [-13728, -3042, 3974, -2142, -7118, 2136], [26152, 830, -7788, 1746, -3454, 2938], [21583, 11267, -4579, 3336, 3188, 3417], [48678, 16242, -4135, -2403, 2039, 3464], [17275, 8778, 6099, 4027, 847, -3569], [51998, 11424, -1296, -1459, -1979, 2688], [44862, 6372, 3115, 2102, -4559, -3261], [1641, 12826, -3100, -1030, -7841, -5122], [-45519, -11275, -9719, 6475, -6020, 1879], [-74936, 6143, 3789, -3141, 3075, 5687], [92548, -8686, 7039, -3521, -5129, 784], [16541, 8279, 1104, -940, 8187, 6829], [-14911, -16960, 1085, 3338, -2269, 718], [18034, 4946, -1140, 5298, 7772, 5544], [-47583, 7442, -2894, 435, -3073, 4315], [27110, 6580, -362, -1525, -6191, -3214], [-47705, 7640, -3624, -7868, 2595, 12270], [11605, -3605, -4869, -139, -2308, -1349], [12388, -10776, -1124, -4920, -988, -2952], [-90005, -693, 3736, -9707, 3783, 513], [-16496, -6718, 4801, 0, 7134, -5936], [79834, 4834, -4046, 5916, 1481, -1801], [-329, 12591, -2029, -802, 8561, 7143], [130208, 386, -5140, 2474, -2650, -1916], [117952, -9782, -4103, -2305, -431, -3696], [-44595, 16043, -2383, -6563, 814, 3333], [54645, -11753, -3297, -569, -4083, -7396], [-42451, 10732, -7835, -2711, -5151, -951], [-25870, 19966, -6953, 6219, 1911, -114], [-28148, -1724, -7114, 5022, 4861, 1169], [-55811, 13168, 1184, -3990, -3747, -6986], [1553, -2575, 1214, 5352, -7708, 167], [-31381, 11067, 7401, 3634, 6790, -1003], [60230, 13758, -1800, 775, -511, 202], [15073, 10415, -5963, 5101, 7045, 5027], [39612, -4280, 5960, -6288, 8980, 7522], [90738, -11921, 1748, 2801, 5389, 1218], [44691, -1994, -5018, 3713, -899, 1375], [-93453, 13894, 75, 2819, 3799, -1351], [7578, 6004, 2424, -3292, 5623, 1977], [55341, 8687, 5587, -2167, -5483, -13095], [29520, 2760, 5906, -1450, 9585, 1043], [27381, 198, 2995, 1227, 10134, 2964], [113015, -2159, -5985, -3106, -4078, 8825], [-21767, -4000, 9779, -5310, 5164, -4161], [8327, -7672, -598, 3073, 6218, 8664], [80875, 18638, -4354, 3004, 6948, 7261], [12123, 7468, 3345, -6760, 305, 1724], [-41029, -13067, 4931, 1777, -4051, -7873], [-51271, -7362, 1728, -657, 9360, -208], [74951, 6943, 3756, -1409, 630, -1407], [-35610, 14260, -122, -3261, 7794, 5287], [12986, -4233, 1027, 3310, -6249, -3345], [-32427, -22300, 5327, 4269, -5006, 646], [-60064, -11668, 8156, 3092, -2012, -2432], [-41865, -20406, -2228, 3512, 4330, 8051], [-57756, 4793, 4647, -1751, -2456, 1466], [103385, -5310, -6503, -3607, -1202, 4166], [-89097, -15137, 107, -9123, 5200, 3493], [46043, 263, -1957, -5113, -6874, 7100], [-38309, 1868, -6552, 4840, -8563, -8140], [-51569, 6479, -1673, -7502, -2188, 3009], [-59815, -4028, -1939, 2359, 7729, 4165], [-71275, 19621, 2465, -4428, 1208, 2282], [-2366, -7721, -2548, 7143, 1022, -1857], [-32772, -17463, 732, 2124, -6724, -11173], [-52158, 10338, -1716, 412, -643, 849], [-26679, 17144, 149, 4009, 621, -3741], [9190, -24906, 18, -1140, 320, -5270], [-59293, 4946, -8862, 5684, -8058, -3995], [-55501, 30104, -792, 7318, -1442, -3871], [-57425, -23606, 4503, -5269, 2474, -4514], [17423, 8181, 10625, 393, 3319, 1215], [91657, 6334, 4720, -6768, 3416, 4503], [-7138, 18757, 4631, -4702, 5829, 3694]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1840_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1840_4_a_u();".
// 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_1840_4_a_u(:prec:=6)
    chi := MakeCharacter_1840_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_1840_4_a_u();".
// 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_1840_4_a_u( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1840_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-3496, -1831, 1158, 215, -75, -4, 1]>,<7,R![-3300776, -789580, 89664, 10329, -744, -14, 1]>],Snew);
    return Vf;
end function;