
// Make newform 1840.4.a.s in Magma, downloaded from the LMFDB on 09 May 2024.
// 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_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_1840_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 := [588, -3915, 1520, 161, -81, -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], [-2172, 1527, 79, -82, -1, 1], [-708, -1005, 1139, -194, -29, 5], [516, 1245, -559, 10, 13, -1], [204, -3423, 2185, -214, -55, 7]];
    Rf_basisdens := [1, 1, 72, 72, 36, 72];
    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)
    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+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 := [[0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0], [-5, 0, 0, 0, 0, 0], [-5, 0, -1, 0, -1, 0], [1, 0, 0, 1, 1, 0], [-5, 0, -1, -1, 0, -1], [8, -9, -2, -1, 1, 5], [-2, 6, 6, -2, 1, -3], [23, 0, 0, 0, 0, 0], [18, -14, 8, -5, 6, -3], [62, 12, 6, 3, 5, 2], [21, -7, -2, 2, -10, -1], [-23, 15, 1, 4, 1, -19], [34, 11, -17, 0, 4, 16], [23, 2, 7, -19, 12, 18], [21, 12, -11, 10, -9, 21], [-19, 50, -17, 2, -20, -15], [-107, 40, -10, 21, -2, -6], [61, 63, -32, -4, -11, -45], [19, -2, 30, -14, 35, -29], [-293, -23, -10, -13, -5, 18], [244, 59, 9, 24, -41, 4], [175, 54, -15, 24, -37, 17], [-262, 83, 3, 20, -2, -52], [-555, 90, 4, 1, -55, -20], [-225, 58, 59, -6, 34, 37], [137, 53, -27, 23, 32, 2], [101, -107, 34, -48, -5, 129], [-318, 132, -18, 32, -62, 1], [-627, 165, -108, 26, 10, -31], [307, -58, 53, -1, 57, 8], [-153, -97, -64, 25, -17, -6], [-664, -133, 25, -24, -10, 69], [42, 121, 11, -55, -4, -33], [-432, 79, 129, 14, 60, -115], [574, -146, 135, -18, 1, -40], [-595, -43, -42, -16, 32, -153], [-483, 33, 38, -49, -72, 3], [-112, -32, -20, 6, 83, 44], [477, -69, 85, -13, 26, 220], [-401, 213, 108, 47, 0, 14], [-582, 258, 32, -2, -52, 87], [148, -306, -44, -16, 82, 60], [-735, -25, 70, -99, 134, -84], [-502, -352, -27, -70, 144, 258], [-248, -49, -53, 34, 99, -176], [821, -202, 95, -28, 143, 3], [-1058, -28, -138, 34, -109, -22], [-202, 131, 191, 148, 66, -98], [-684, 3, 7, 34, 6, -162], [191, 141, -66, 237, -201, -28], [-1616, 1, 19, -3, 132, -79], [-1552, -2, 150, 14, 102, 142], [98, -417, -115, 58, 10, 207], [-989, -469, 160, 91, -16, -24], [-1178, -52, 303, -51, 9, -77], [732, 82, -30, 95, -144, -97], [1003, -145, 314, 2, 129, -128], [91, -567, 98, -9, -109, -20], [-1276, 257, 215, -128, 128, 56], [-1373, -170, -11, -138, 251, 319], [3005, 108, 117, 168, 21, -25], [621, 97, -373, 247, -327, -146], [-211, -465, -148, -7, -246, 80], [-355, -245, 132, -242, -17, -174], [-742, -437, 205, -112, 342, -155], [888, -275, -83, -59, -438, -183], [-1526, -108, 254, 246, -99, -351], [-3147, -15, -315, 165, -147, -336], [-672, -144, -266, 53, 124, -47], [931, -85, -294, -171, -145, 12], [-4690, 9, 127, -82, -139, -490], [99, -1576, -255, -22, -67, 69], [3738, 508, -360, -68, -184, 394], [549, 575, 107, -141, -2, 378], [-5527, -691, -126, 146, -351, 93], [481, 457, 79, -323, 454, 312], [890, -574, -513, -96, -178, 664], [-2890, 360, 484, -208, 202, -130], [-1004, 1157, 553, -103, 6, 42], [-4228, 451, -3, 254, 57, -590], [-1146, 172, -470, -84, -92, 57], [-2578, -65, -545, -266, -279, -138], [4849, 333, -214, 292, 351, 74], [-1435, -320, -625, 7, -502, 433], [-4271, 487, 284, -53, 719, 175], [-3981, 337, 226, -324, 266, 86], [-2123, 738, -129, 312, -565, -373], [85, 820, 301, 453, -314, -898], [116, -1446, -132, -68, -101, 308], [-3751, -880, 525, -346, 609, 303], [-1418, 448, 520, 442, 276, 298], [2191, -636, -205, 271, 161, 648], [4212, -385, 325, -313, 370, 377], [-738, 749, -275, -13, -489, -265], [-2939, -361, 638, -218, 231, -598], [-1737, 1320, -303, 61, -697, -172], [-84, -1144, 454, -58, 200, 208], [-1528, 1365, 41, 350, -220, 202], [-1121, -478, -77, 41, 29, 602], [1659, -1387, 296, -201, -54, -345], [-5037, 1227, -614, 20, -164, -293], [-1105, 1010, -193, 478, -19, 133], [-4050, -214, -706, -48, 48, -32], [9643, 721, 89, 121, 474, -414], [-2923, -551, 864, -489, 541, -274], [2022, -2179, -880, -488, -578, 1038], [504, 872, 54, -14, 39, -524], [1835, 1427, -501, 147, -369, -184], [-8014, -71, -385, 447, -361, -424], [-484, 6, -446, 838, -447, -440], [7116, 182, -164, 882, 210, -24], [438, -558, 761, -105, 132, 979], [2172, 65, -323, -406, -482, -811], [11980, 1279, -985, -16, -267, 1196], [2000, -675, -869, -372, 34, 1274], [527, -1438, 911, -12, 999, 205], [2807, -326, 749, 335, 70, -1124], [9399, 1942, 753, -227, 359, -1021], [-1918, 840, -466, 940, -88, 958], [4825, -649, 431, 45, -866, -964], [2051, -97, 568, -131, 915, 218], [-5757, -696, -709, -106, -1119, 135], [-3165, 1645, -320, -303, -757, -851], [16236, 540, 884, -204, 222, -610], [-5012, -2522, -178, 344, 168, -483], [3737, -114, 50, 285, 198, -854], [3021, 1581, -310, -498, -213, -64], [6294, -937, -442, 51, 165, 1003], [8171, 390, 417, -796, 413, -319], [11006, -4367, 237, -187, 389, 617], [-6012, -1767, -359, -650, -180, 217], [10286, 177, 683, -84, -627, -590], [-5141, 151, -806, -162, 442, 273], [-5008, -1431, -1703, 603, -243, 734], [-8220, 230, 228, 484, -672, 450], [7260, -1201, -1599, -414, -611, 1990], [2063, -3404, -1417, -84, -185, -53], [3433, -1209, -338, 344, -76, 733], [-7724, -1271, 898, -103, 72, -433], [22388, -563, -741, 309, 252, 651], [1282, -3660, -624, 26, 797, -208], [10625, -152, 429, 671, -452, 762], [10981, -4844, -615, 144, 539, 565], [5555, -2834, -255, -960, 374, 2003], [4084, 1349, -369, 114, 183, -116], [188, -2747, 145, -760, -48, -467], [-5123, -339, -1304, 749, -309, -16], [16024, -689, -103, 749, 490, 859], [-35, -1504, -1147, 645, -920, -1254], [-16719, 2283, 1079, -1439, 446, 1266], [700, -2228, 1256, -1280, 1144, 892], [-1186, -3037, 467, -158, 889, -1429], [-271, 2142, 3125, -517, 1075, -1130], [12949, 281, -470, 540, -2081, -1039], [2680, 471, -947, -852, 243, 814], [3174, -1549, -601, 1026, -1973, -1396], [-6842, 388, 1956, -655, 169, -1499], [-8408, -2186, -1170, -200, 523, 197], [7609, 5973, 1353, -25, -50, -466], [-13179, -1937, -1004, 51, -167, 1179], [-18255, -655, -335, -747, 164, -760], [12031, 2732, -845, 455, 71, 800], [1023, -2109, 141, 409, -2520, -306], [-21471, -1134, -527, -494, -896, -398], [-9080, -1095, 554, 243, 21, 2193], [19150, -533, -900, -237, 175, -287], [11060, -798, 660, 1432, 222, -1566], [-7626, -89, -103, -400, -1260, -1604], [8102, -5168, 265, -730, 893, 272], [-4824, -1427, 715, 320, -1279, -1812], [18800, 144, -1580, 813, -97, 347], [2990, 750, -1192, -992, 732, 2608], [-12106, 1671, 754, -939, -577, -839], [-2412, 4206, 2197, -382, 48, -1240], [-1670, -2821, -833, 1188, -468, 1102], [23053, 677, 1028, -73, 395, -1862], [1132, 2126, -518, 991, -381, -2373], [-4436, -4176, -2053, -829, -305, 271], [5604, -7243, 1867, -524, 1792, 155], [6533, 5724, 233, -229, 1245, 846], [-4289, -788, -656, 397, 919, -2366], [-9543, -5058, -2445, -51, 768, 207], [-11520, -3132, 140, 574, -1688, -1056], [-914, -371, -608, 1291, -521, 755], [4516, -4645, -795, -848, -496, 2215], [-5804, 1949, -1355, 98, -1947, -1361], [2439, 3613, 312, -84, -1083, 861], [-19445, -6613, -2005, 744, -888, 421], [5446, 5305, 1512, 289, 205, -333], [-11151, -201, -430, 621, 619, 2922], [-17538, 1554, -864, -2210, -609, 2030], [12496, -2720, 2484, 702, 456, 566], [26061, -300, -345, -126, -160, 1925], [-24036, 2254, 88, 1280, 274, 798], [21303, 2004, -2179, 1108, -958, 1448], [-14898, 1491, -1189, -2486, -412, -136], [6680, 1500, -1390, -1406, 726, 784], [-5812, 5346, -1136, -974, 66, 1360], [-28237, 6118, -305, 1847, 302, -3076], [-5891, 1531, -201, -813, 2336, -938], [22878, 3197, 2225, 1258, 1663, -1287], [-1982, -198, 95, 1116, 941, 598], [-14326, -9, 3415, 50, 3462, -818], [-20448, 1194, 1966, 1236, 388, -568], [4467, 6031, 2056, 735, -277, -5124], [-19390, 4295, -379, 26, -3787, -42], [-20228, -559, 1724, -2412, 473, 1066], [-18306, -8593, 65, -291, 1073, 840], [20003, -7693, 286, -1623, 2015, 1002], [-8265, -359, -3720, 2011, -1841, 2480], [15911, -2500, 1379, -2797, 1430, 1572], [-8422, 3682, 610, -810, -1364, -1355], [-13770, 8620, 2626, 138, 94, -354], [-22617, -1402, -685, -2062, -499, 2489], [-5574, 2823, -713, 2848, -254, -194], [19923, 4366, 285, 145, 1187, 922], [13594, 886, -1478, -11, -1094, -2713], [-18995, 6597, 576, 1238, -297, 1116], [-16443, -5711, -128, -785, 126, 796], [20306, 3034, -80, 637, 346, -2577], [-1700, 2017, -1467, -22, -185, -48], [-9289, 5017, 3419, 1390, 86, -3805], [-7803, -4906, -1693, 2244, -1921, -1352], [-18763, 3020, 1727, -75, -1384, -4962], [-23648, -280, -500, -1097, -2835, -775], [-17968, 2386, 2514, -780, 251, -2713], [-26708, 2288, -4112, 1067, 520, -194], [-17718, 6775, -2511, 728, -3316, -1989], [11281, -8716, 1271, -694, 181, 235], [-504, 809, -55, 1040, -1006, -1091], [-2017, -4454, -2940, -825, -827, 2760], [5180, -6482, -1930, -1390, 1314, -1342], [22606, -9261, 3228, -2223, 2315, 2915], [4217, 346, -735, 1646, -589, -1287], [-37218, -3833, 2067, -1228, 3558, 416], [-5252, 516, -4968, 1940, -2686, 2166], [-20374, 8841, -1103, 1360, -2917, -2388], [-22164, 1813, 2875, 43, 1719, 3631], [463, -4780, 2222, -480, -432, 2987], [-5935, -330, 3589, 158, 1165, -1983], [11354, -8527, 1047, 189, 2413, 4599], [21291, -5366, -795, 53, 1931, 504], [15179, -572, 1011, -341, 1016, -1978], [-26734, 2832, -1626, 406, -3954, 2062], [-19353, 7070, -193, 2743, -1929, -3473], [9747, 4232, -619, 2471, -6269, -1334], [-10488, -3011, -3131, 3864, -3320, -1075], [-35843, 165, -2363, 1337, 32, -5224], [9018, -1989, 604, 157, 1203, -3531], [-30592, 3734, 68, 1766, -1126, -302], [25614, 2060, -3868, 1936, -3278, 2046], [-62043, 857, -424, -2094, -523, 1184], [-19964, -8359, 4095, -1684, 3252, 1062], [-27886, 6038, -534, 1782, 793, 1316], [-44104, -7509, 2111, -873, 1667, -3507], [13435, -5970, 1440, 1319, 340, 1642], [-33224, 6088, -362, 356, -3084, -912], [19301, -4546, -4209, 903, -3021, -1533], [-24849, -1719, 2786, -1269, 33, -3648], [31426, -9859, 514, -241, 1949, 4823], [-41917, 555, 6336, -2312, 4277, 839], [3187, -2534, 3027, -2638, 5336, 1615], [-13331, 1659, 5584, 996, 3954, -4405], [-24164, 10950, 820, 698, -249, 1270], [-28641, -2242, 1200, -2975, 4135, 2062], [-31231, -2044, 554, 2217, 178, 354], [-9450, 1297, -2453, 74, 572, -5676], [37925, 9015, 4350, -898, 649, -5179], [-39437, -6414, -1883, -1161, 3273, -1217], [-3236, -11136, -1768, -959, 529, 6543], [9943, -11800, 3641, -1776, 1653, -261], [-49979, 2870, 3441, 1104, 3540, -1136], [-13144, 7467, 1253, 1698, -3663, -5442], [-22407, -2037, 106, -2523, -1494, -2038], [18715, -5518, -491, -207, 4215, 1366], [-24521, -1277, -3489, -367, 1038, 208], [-23711, 5280, 467, -38, -5722, -3925], [340, -5876, -90, 2376, -1484, 1698], [-45932, 2393, -227, -3990, 3574, 4191], [43107, -2950, -2373, -1007, -3653, -862], [-12130, 6382, -1764, 1334, -2188, -3992], [-40291, -1458, -4176, 2489, 216, -4690], [11316, -6550, 252, 1120, 126, 2386], [-17908, -5609, -4307, -4120, -1710, 5133], [-23066, 2153, -1668, 1757, 2317, 899], [-40463, 14920, -5979, 1622, -1895, -3035], [-17096, -7167, -3611, -762, -2197, 1918], [37363, 7265, 3957, 2341, 3798, -4660], [-72055, -5541, -737, -1441, 783, 1502], [5158, 2696, -2120, -2940, 1684, -1284], [-23007, 3822, -6801, 4976, -2787, 3537], [2448, -3838, 1048, -236, 3418, 7852], [10604, -6110, 3672, -2710, 1357, 2609], [-43114, 14042, 2961, 2542, 2427, 1376], [-14945, 573, 2739, -2111, -2490, -2018], [26814, 11616, -3058, 1484, -6988, -2160], [-67354, -3882, 73, -282, 2176, 1774], [54346, 1879, -855, 381, 690, 2337], [-5300, 3265, 5750, 3966, 2776, -2062], [16451, -14250, -1697, 80, 236, 3522], [-4047, 12071, 1424, -1982, 1338, 2229], [20822, 5254, -878, -1806, -458, -780], [54125, 10372, 4587, 233, -767, -4192], [22292, 7431, 2747, -2426, 1368, -959], [-43185, -97, -752, -537, 1446, -4272], [26405, -11469, 3225, -5103, 7410, 1214], [-8240, 4815, 289, 1064, -3284, -7557], [-17006, -9410, -1136, 858, -1258, 6778], [-25951, 12675, -2983, 1355, -7072, 1628], [29579, -12148, -5539, -4503, -3670, 5722], [-17356, -988, -3612, 2338, -3574, -2975], [-9478, 1794, -2218, 158, -7752, 5724], [18914, 10061, -3324, 1468, -2729, -6888], [-62421, -82, -2131, 1950, -2523, 1624], [-13082, 5295, 2003, -1172, 340, 7690], [24292, 14415, -2397, 1301, -3778, -4937], [-4062, 8144, 8986, 455, 2321, -7420], [74299, 8590, 3933, -2828, 1679, 1529], [-15644, 9677, 1656, -98, 6630, 3402], [-13381, -9790, 1818, 189, 311, -294], [30406, 11342, -1101, -1017, 2342, 3515], [-19465, 1626, 4477, -2835, -2061, -7568], [36774, -7982, -2944, 2210, -2489, 2756], [-2702, 3419, -1972, 1541, -2557, -3219], [55612, -2432, -2344, 1636, -9448, -5268], [-87642, 6419, -2887, 2068, 1564, -2689], [25065, 10641, -1210, -4265, 3690, 2827], [9564, 660, 3054, 2368, 2080, -6127], [-71249, 8100, -1791, -894, -1235, 1779], [1784, 12442, -10372, 2615, -2893, 723], [21386, 9268, 8943, 1612, 4215, -4978], [26020, -3421, 4197, 961, 5353, 1331], [49849, -1617, -2224, -1579, 2519, 11987], [-15200, 9597, -201, 3920, 359, 472], [-30809, -4785, 4194, 1225, 2717, -9531], [80505, 5679, -2013, 2165, 3864, 804], [-18574, 20279, -775, 1036, -1015, -3400], [103722, 811, 2754, 1060, 5478, -2114], [41146, 2994, 1981, -701, 9733, -3395], [-32327, 12269, 1924, -245, 390, 1332], [87675, -1926, 2576, -1901, 1023, 2280], [47800, -8270, 34, -2628, 177, 9406], [-33310, 110, -4292, 2, -3244, 5238], [-62901, 7648, 8299, -1370, 3221, 3535], [-2735, 2256, -3953, -2162, -1339, 6647], [14688, 11376, -2826, -903, 3763, 2167], [30468, -6445, -3599, 2666, -2457, -5793], [18418, 16646, -510, 2192, 1684, 484], [-15131, -1678, 4601, -3896, 6583, -4873], [21982, -5363, -1547, 4407, -1489, -8211], [44357, 6213, 1384, -1687, 1632, -4934], [-37503, -11194, 4003, -2106, 6165, 6251], [50004, -2371, 4060, 213, 2719, -5045], [80150, 7016, -6376, 1878, -1166, -3722], [-284, 12816, -8108, 1906, -5286, -3240], [-33176, 1680, 1246, -4170, 2856, 114], [3780, 4015, 5579, -4808, 7250, -503], [-38969, 2167, -5900, 659, 1515, -3092], [-15028, -5426, 5628, 2088, 5313, -8292], [-17995, -19590, -7589, -1306, 835, -1953], [-19174, -20724, 6192, -1501, 4669, -669], [-61727, -8358, 83, -1273, -6543, 2622], [-5065, 12411, -3431, 1029, -5512, 2734], [33626, -16435, -2642, -910, 6721, 8014], [4163, -1439, -4342, -2069, -741, 2456], [12674, 6948, -8739, 1018, -2393, 7576], [-31115, -9017, 4084, -2028, 5481, 11355], [31610, 4702, -3824, -3042, -1428, -7782], [25086, -2867, 6703, -1881, -2743, 4389], [-70843, 15070, -7841, -204, -6617, -551], [-7277, 5448, 1959, -2615, -1063, 1140], [-40161, 715, -629, -2403, -3040, 2158], [-36112, 1464, 3268, -7712, 306, -2036], [53911, -11100, -6297, -3655, -3097, 4073], [23838, 11235, -601, 647, 484, -4745], [-42008, -10393, 287, 954, 2755, -1842], [73380, 16757, 1654, 1743, -365, -3287], [-74044, 4582, -10226, -460, -1832, 3002], [8043, 519, -4190, -2921, -2703, 2914], [-32029, 1263, 5155, -3625, -1580, 9344], [-56639, 25606, -2606, 4173, -11251, -2180], [20678, -19504, -5676, -1992, -3725, 4108], [59465, -12365, 6890, 4021, 4143, 900], [-62846, 479, 7711, -4306, 4071, 7260], [-46365, 22648, -3675, -367, -1657, -1106], [74248, 9754, -9134, 4683, 38, 2150], [45322, -22547, 2399, -4744, 2134, -1867], [-32523, 8630, 6231, -982, -3191, 5585], [-47707, 19639, -1306, 2796, -135, -5844], [10568, 8854, 5644, -310, -6036, -11408], [-70712, -17873, -2229, -1054, -885, -3943], [8446, -17511, 9969, 1671, 3331, 3939], [5248, 2184, -140, 886, 3177, -900], [-58286, 11193, 5747, 3968, 7295, -4828], [87933, -26697, 4228, -1316, 3177, 270], [-23430, 9765, -6737, -4464, -153, 4680], [73230, -22091, 6049, -5668, 4598, -1584], [-92060, -2553, 9611, 1082, 8264, 7921], [14779, 11958, -4463, 2844, -10634, 1215], [65658, -9762, -54, 1511, -1090, 5267], [14219, 11755, 2944, 681, 6222, -3146], [5637, 197, 1290, 1534, -2811, -3751], [46813, -13829, 2108, -3838, 4621, 7894], [15416, 14842, 2570, 705, 7392, -273], [-143315, -14668, -1416, -1122, 3836, 1291], [46195, 12157, -3932, 2342, -3540, -309], [-103485, 18199, -5972, 3395, -7887, -2413], [-31058, -3433, 8711, -952, 5784, 802], [-40180, -8260, 3668, -7040, 4304, 2348], [131283, 4751, -10824, 3079, -4140, 1968], [26464, 1660, -2385, 11584, -4550, -1386], [-1076, -157, -6203, 4914, 2008, 3312], [-17003, -8875, -7589, 6791, -5286, 3282], [10085, -13656, -4061, 5322, 2444, 364], [39545, -530, -12037, 9435, -2669, -14964], [-770, 551, 2435, -868, 720, 7131], [52248, 9560, 10136, -138, -2245, -6210], [5938, -27886, -10631, 2813, -2984, -1403], [4462, 6378, -5430, 2598, -4176, 7353], [-12089, -6098, 13288, 1073, 9102, -3552], [10536, -16675, 5043, -6106, 2295, 20], [47238, -298, -6704, -4866, 903, 7844], [24304, -502, -12174, 856, -4756, 4770], [191599, 935, -3078, 375, -3060, 3186], [36567, 13315, -3476, 4435, -14212, -562], [14372, 9993, -6293, 7634, -9542, -4060], [-44081, -4985, 996, -1062, -7331, 7472], [34335, -22443, 3726, -6017, 6572, -4928], [-55523, 7780, 7060, -4884, -4209, 7819]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1840_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1840_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_1840_4_a_s(: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_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_1840_4_a_s( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1840_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![588, 3915, 1520, -161, -81, 2, 1]>,<7,R![-223000, 77400, 18730, -3513, -348, 28, 1]>],Snew);
    return Vf;
end function;