
// Make newform 1840.4.a.r in Magma, downloaded from the LMFDB on 01 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_r();".
// 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_r();".
// 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 := [-12420, -2088, 2667, 181, -114, -3, 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], [-1482, 3127, -83, -132, 1, 1], [-23706, 4971, 1003, -660, -15, 7], [-16194, 5487, 1511, -308, -19, 3], [-27594, -26901, 1079, 1452, 9, -13]];
    Rf_basisdens := [1, 1, 264, 1584, 528, 1584];
    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], [-3, -1, 1, -1, 0, 0], [-10, 4, 1, -1, -1, 1], [-4, -3, -1, 0, 0, -1], [10, -5, 2, -1, -2, 1], [12, 7, -4, 4, 3, -4], [-23, 0, 0, 0, 0, 0], [37, 0, -2, 3, -6, -3], [-37, 9, -2, -1, 7, 9], [120, -27, 1, 2, 7, -6], [76, -19, -7, -5, -1, 4], [-161, -13, -2, -5, -6, -6], [-180, -18, -3, 0, -5, -13], [37, 40, 1, 1, -27, -10], [-25, -30, 21, -1, -15, -4], [90, -24, -13, -7, 19, 7], [30, -41, -7, 12, 21, 18], [-205, -62, 17, -12, -7, 10], [-93, -1, 13, -31, 3, 7], [215, -13, 0, 11, 8, 28], [-231, -44, 27, -7, -19, 32], [257, -1, 32, 17, -26, 18], [-120, -80, 41, -19, -27, -1], [63, -26, 31, -11, -53, -4], [-85, -133, -37, 24, 21, -47], [-668, 23, -43, -10, 27, 14], [-368, 37, -10, 26, 23, -16], [436, 123, -39, 12, 49, -2], [-388, -144, 45, -30, -31, -69], [-699, 27, -3, -13, 47, 11], [-225, -54, -88, 21, -29, -14], [746, -81, 20, -14, 64, 71], [-513, -144, 48, -23, 71, 96], [236, 82, -44, 19, 32, -36], [-118, 67, -31, 104, 1, -64], [-181, -166, -75, 9, -4, -45], [-424, 12, -84, -40, 144, 20], [-315, 213, 65, 12, -1, 9], [123, -167, 41, -21, -141, -13], [-688, 299, -38, 38, -81, 74], [-14, 6, -32, 112, -88, 0], [-737, -67, -13, -79, 73, -57], [-992, -58, 102, 33, 24, 50], [653, -187, -128, -17, -26, -62], [1695, -52, 37, 75, -45, 68], [-1006, 264, -18, 74, -10, -116], [-1457, 301, -74, 83, -108, -38], [-2211, 121, -10, 119, -98, 28], [729, 295, -175, 83, 59, -131], [976, 75, -50, -34, 74, 143], [616, -28, -62, 96, 28, -194], [-423, 166, -48, 197, 117, -20], [-1357, 357, -47, -51, 123, -175], [-3061, 266, 20, 8, -30, 97], [-589, -272, -144, 85, 8, 37], [778, -462, 37, 14, 126, 116], [-933, 365, 165, -111, 53, 159], [261, 311, 82, -107, 66, 198], [-2021, 372, 11, 23, 169, 134], [211, 148, 29, -5, 33, 132], [-1683, -315, 219, -220, -49, 123], [-799, -287, 51, 65, -173, 97], [1544, -744, 163, -196, -196, 24], [577, 368, 118, 49, 15, 38], [-1512, 151, -18, -52, 94, -281], [-330, 129, -242, -80, 141, -160], [-1149, 281, 19, 268, 19, 197], [-2605, -198, 108, -69, 196, 35], [1187, 437, -95, -129, -161, 49], [-1763, 115, -294, 83, 100, -34], [-231, 284, 383, 151, -45, 74], [2586, 214, 180, 248, 34, -76], [1407, 39, 197, -186, 239, 235], [-2026, -219, 293, 132, -115, 124], [835, 307, -245, 128, 279, 85], [-996, 556, 342, 109, -84, 268], [7558, 550, -180, 164, 194, 136], [-1874, 396, 118, -260, -147, 157], [1581, 159, -340, 65, 208, -202], [2480, -311, 254, -222, 291, 8], [-4081, -603, -262, -9, -48, 174], [336, 0, -281, -376, 10, -234], [2046, -1639, -199, 148, -106, -243], [-1669, 614, -163, 457, 314, -123], [-1758, 980, -103, -64, 162, 12], [873, -50, 345, -359, -283, -172], [-288, 896, 71, 110, -591, -279], [1044, -1060, 84, -10, -162, 314], [-5657, 132, 165, 123, 77, -366], [2112, -1310, -126, 530, 184, -258], [-358, 154, -59, 60, 269, -101], [-1896, -161, -298, 226, -568, -211], [-3018, 683, -384, -108, 180, 199], [-8990, -266, -409, -68, 106, 68], [-5432, -438, -107, 68, -59, -669], [3570, -1256, -410, 48, -174, -602], [4009, -713, -84, 175, -346, 36], [-5754, 1078, -27, -210, -373, 171], [-2911, 848, -193, -509, 168, -117], [-1418, -77, -313, 324, -163, 68], [-2001, 674, -281, -119, 187, -406], [540, 750, -440, 274, 60, -120], [2381, 89, 523, -254, 113, 105], [6109, -423, 211, 19, 207, 223], [739, 923, 298, -28, -402, 700], [5852, 258, 30, 186, 136, 180], [-5741, -411, 131, -656, -557, -211], [4688, -220, 136, 218, 327, 749], [1442, 1346, 172, -230, -340, -60], [-4072, -642, -618, 158, -166, -442], [2597, -624, 216, -378, 76, -87], [4861, 188, -662, 313, 371, 100], [5111, 1047, -68, -39, 752, -116], [8521, -1927, -330, -347, 220, -342], [4625, 1644, -129, -69, -75, 308], [-6162, 998, -63, -340, -405, -479], [-6374, 59, -649, -438, 452, -85], [-658, -604, -250, -246, -14, -424], [-9775, 801, -245, -556, 779, -195], [-5981, 1919, -171, 237, 273, -659], [2115, -1232, -93, 115, -265, -870], [-9331, -602, -737, 451, 394, -693], [16592, 1082, 56, 20, -670, -372], [1384, -615, -108, -226, 11, -764], [1748, 2230, -241, 161, 283, -697], [74, 2202, -429, 598, 234, 708], [5410, 2129, -40, -143, 642, 301], [-521, 2942, 247, -81, 743, 864], [-1004, -997, 748, -790, -212, 325], [1243, -1264, 990, -585, -331, 720], [6599, 477, 310, -899, -770, -536], [-11316, 1151, -41, -426, 329, -182], [18870, 936, 626, -36, 253, 913], [20174, -290, 378, -320, 46, 976], [-1829, 991, -658, 455, 784, 154], [9363, 1680, 383, -173, -361, 192], [-3260, -1241, 481, -340, 263, 1208], [18322, -315, 604, -865, -86, -177], [5400, -123, 710, -1514, -248, 55], [6602, -1588, 1132, -1484, -736, 152], [-2834, 2188, -429, -432, 753, -243], [-10275, -356, -1343, 517, 417, -756], [-15147, 2226, 211, -343, 135, -98], [-9061, -165, 928, -773, -42, 22], [3905, -1808, -280, 97, -217, -934], [-2993, -1187, 387, -363, 975, 437], [-5382, -2577, 1150, -104, -924, -557], [-7172, 818, -769, -306, -277, -889], [-7041, 2293, 473, 564, -1445, 147], [12700, 598, -1370, -360, 476, -344], [15921, 548, 1032, 3, 429, 262], [2766, 1756, -77, -374, 579, 843], [-19580, 1515, 57, 822, -161, -82], [14059, 1341, -336, 923, -778, -812], [-12397, 699, 254, 379, -966, 654], [13031, 2306, 10, -149, 746, 29], [9116, 35, -932, 286, -193, 298], [-9859, 1179, -245, -436, -637, -833], [-4449, -494, -75, 577, -450, 497], [16229, 2949, 17, 126, -323, -577], [-2046, 470, -1823, -124, 1965, -777], [7619, -4565, -1049, -190, 49, -55], [14281, -875, -317, 1297, 516, 1220], [-2502, -1157, 674, -859, -856, -467], [-4220, 1609, -218, 479, 262, -17], [6906, -862, 6, 1920, 594, 992], [29301, -89, 188, -37, 626, -282], [-19782, -466, 238, 815, 244, 400], [-23127, -1595, 1064, -275, -1296, 412], [-6399, -606, -316, 639, 696, 673], [-16896, 932, 806, -816, -100, -444], [1726, -1657, 188, -751, 328, 1611], [-11708, -1542, 1086, 359, 958, 1302], [61, 2357, 320, 545, -1432, -390], [7395, -3479, 291, 909, -707, 45], [18441, -1038, 136, 1079, 1458, -781], [22443, -1838, -306, -718, 164, -837], [3247, 5410, 580, -423, 1143, 254], [-1324, -850, 1331, 690, -1209, 31], [4180, 16, 503, 635, -239, 1477], [-18186, -2829, 17, 162, 90, 241], [14058, 864, -726, 1138, -1338, -1018], [7204, -4637, 888, 211, 2, -1243], [-29671, 1328, -244, -173, -277, 654], [-16271, 962, 668, -895, 1337, 482], [-20214, 977, 23, -1496, 1259, -306], [13984, 777, -2053, -329, 1089, -814], [8456, -433, -762, -1311, 1530, -1331], [-12075, 5393, 311, -285, -1579, 1397], [12244, -1166, 74, -1608, -770, -648], [17158, -2808, 908, -418, -1072, 1126], [-5705, -1590, 965, -127, 335, 1608], [14358, -3052, -312, 872, -1234, -364], [11839, -2903, -163, 919, -48, -402], [-1465, -1003, 548, -33, 984, 476], [-10150, 3620, 322, 1472, -70, -1014], [-18184, 1226, -1682, 1358, 1206, -2154], [-5774, 3198, 1049, 894, -1281, 133], [8767, 3445, -881, 1110, 983, -1301], [28921, 4924, -584, 471, 801, 94], [7026, -4028, -10, -185, 424, 110], [17839, 2431, -1868, 867, -254, -860], [-9926, 5094, -332, -1054, 1372, 96], [-45147, -2789, 825, -561, -2115, 363], [-10213, -2107, 1254, -1395, -1796, 298], [8031, 5071, -932, -446, 892, -1174], [-29396, -716, 1476, -366, 589, 535], [21633, -2133, -367, -1063, -1117, -721], [8199, -3115, -423, 771, 1649, 159], [-48044, 1786, -19, 734, 97, -929], [10924, 273, 1460, 788, -1053, 162], [-33568, -1294, 1002, 36, 332, 878], [4815, 4282, 639, -1215, 1903, 374], [31065, 2729, 1316, -279, 40, 138], [-38258, -832, -47, 692, -367, -1971], [-5049, -1820, -14, -989, -442, 1543], [-16548, 2082, -1421, 1450, -1312, -2360], [-12057, 5437, -1069, -643, 1615, 977], [-31857, -6152, 594, 97, -882, -365], [-19221, 3847, 584, 41, -2494, -310], [-44844, 6183, 747, -1263, 1989, 1992], [-19155, -1965, 375, 1931, 1764, 1292], [14068, 3546, 399, 876, -2697, -1885], [-18677, -1158, -2296, 61, 1728, 443], [14560, 1609, 448, 1854, -1659, -1482], [11099, 1997, 736, -1781, -67, 287], [-19367, 4944, -1876, 1029, 1637, 1074], [1323, -2756, -599, 325, 2717, 862], [14417, 2116, -976, 1881, -425, -2714], [-2108, 1566, 455, 2745, 1805, 1263], [-8640, 1570, -1728, -940, -1068, 314], [13964, -3961, 470, 519, -2100, -1791], [3617, 2544, 885, 279, -2917, 210], [-293, 2343, -330, -393, 1358, 2766], [9028, 128, 146, 600, -678, 1116], [-27107, 8187, 1840, -2019, 220, 3392], [-38216, -3791, 286, -1970, -3268, -513], [213, -2816, -783, 1384, 2465, 2034], [21629, 140, -883, 1283, 1743, -1298], [32548, -3851, -736, 1340, 650, -611], [-13950, -7798, 1333, -1152, -3429, -343], [-8752, -6000, 89, 214, -653, -633], [-6672, -836, -1724, 1720, 2052, -966], [6236, 513, 1499, -1218, -326, 3587], [-3854, 604, 873, -82, 2843, 1667], [395, -3102, -2466, 1727, 157, -2186], [-10385, -151, -1479, 762, 3135, -735], [-36188, 5501, -1296, 281, 2962, 1127], [4376, 3968, -578, 294, -1024, -1654], [-6570, 9018, -396, -1628, 434, 1644], [-37836, 5126, 2571, 1318, -1700, 2176], [-955, 3045, 434, -255, 444, 2210], [-17352, -4338, 3076, -1694, -832, -572], [-530, -9771, -210, -678, -614, 1867], [-3832, 6142, 1477, -2027, -503, 1205], [-31548, 4256, 496, -1402, 1272, -192], [-14490, -6129, -2067, 3034, 1882, -1955], [30887, -1563, 125, 1345, 201, -1637], [-55060, -4813, 1812, -859, -1238, -1039], [1248, -1319, 2923, -3092, -3263, 3230], [-62149, -2276, 1587, -1091, 101, -2724], [3480, 10325, -2539, 538, 1445, 904], [-28786, -4974, 1238, -500, 446, -108], [-39838, 8638, -965, 3691, 1205, 309], [-15910, 2708, 1867, -771, 563, 1491], [24465, -4217, 1044, -1497, 100, -196], [-50500, 3723, 389, 16, -1491, 912], [-9144, -6831, -825, -220, -1722, -4235], [18505, -2198, 2640, -2001, -192, 913], [-25993, -5880, 783, -487, 3379, 3188], [-21989, -1139, -2589, 799, 1332, -2106], [-6995, -8821, -1228, 65, -2308, -3602], [-20285, 6783, 1371, 2361, -665, -1593], [-7194, -7900, -475, -60, 4145, 1465], [-65523, -685, -1755, 616, 2073, 83], [28187, 7224, -2583, 49, 2321, 2184], [22460, -8748, 670, -1362, 2014, -2016], [-1371, -1370, -1806, -763, 709, 780], [-49942, -88, -3, -2750, -3871, -731], [20874, -986, 5414, -3994, -1094, 4506], [-6416, 3064, -3717, 2105, 3437, -3263], [15318, 5914, 4682, -1376, -1266, 2412], [-19585, 7320, 1726, 1857, -321, -2706], [-11996, -2125, -1922, 649, -890, -191], [36117, 6084, -647, -239, 361, -2018], [-50551, 2693, -1654, -1609, 628, -3126], [-143, -33, 4475, -1810, -1897, 1837], [-18915, -4957, 583, 80, -863, -491], [3786, -6040, -808, -1676, 972, -644], [31175, 4530, 121, 1159, 4041, -848], [3998, -11628, -1998, 1660, -1692, 1584], [3250, -2167, -1018, 710, -1029, -2884], [1508, -11304, 550, -785, -848, 1184], [-51603, -11549, 1225, -484, -2215, 201], [-44426, 5758, 1318, -1530, 3240, 3004], [29034, 2468, -3054, 2157, -1032, 522], [44212, -7725, -444, 2760, -558, -841], [4819, -9001, 1228, -1196, 380, -38], [28981, 2137, 2477, 377, -4722, 2506], [8378, 10233, -63, 468, 861, 1558], [-46338, 7918, -134, -132, -306, 158], [13550, -786, -177, 598, 1467, 501], [1367, -9266, 3086, 15, -1249, -208], [70139, -4635, 333, -595, 3867, -719], [33843, 4727, 967, 1122, -2465, 1359], [-40835, 5524, -2468, 4267, 3003, 382], [20494, -408, -950, -1350, 2476, -1810], [28529, -1555, 1337, 720, 351, 3533], [-5358, -7624, 1149, 1586, -2965, -673], [-60940, -1755, 3140, -266, -2607, 986], [24802, -972, -1044, 2952, -3030, -2674], [3481, 8531, -2506, 2454, -3446, -1682], [15585, -1233, -623, -3833, -1102, 598], [10141, -367, -1504, 1301, 3796, -1614], [40670, -625, 370, -1202, -1968, 3103], [1807, 1595, 4998, 627, -1855, -459], [1535, 842, 2355, -4277, 1983, 1028], [-63279, 5115, -3322, 4998, 2148, 230], [33526, -4154, 375, -1487, 49, 1105], [-7475, 6044, 3916, -872, 2240, 5333], [-10, -2928, -99, 96, 1729, -1005], [-35344, 244, -2914, 3504, -548, -2916], [9598, 447, 756, 3479, 2612, -2165], [-11864, -1438, 4954, -4380, 172, 6376], [22423, 5832, 1768, -1153, -5225, -2342], [-27745, 14266, -2707, 345, 5228, 1391], [-978, -11697, 1706, -626, -3995, 1644], [-33325, -2816, -4717, -291, 183, -5442], [-411, -2986, 1600, 1841, 678, -1853], [-35284, 5046, -226, 1807, 1836, 3278], [-38524, 821, -1442, -4778, 510, 1325], [-539, -2780, -5343, 879, -1416, -7081], [-14919, 629, -1508, 1257, -3676, 408], [17699, -4076, -3853, -935, 434, -4869], [21525, -15183, -273, 2220, -757, 2385], [8531, -19119, 208, 209, -392, -2512], [-47525, -9107, -5524, 2086, 2418, -2812], [-42009, 732, 1148, -5840, 1418, 2451], [110307, -2383, 3799, 5, -5901, -1739], [-74808, 5560, -365, -533, -901, 1837], [-35820, 4956, -1626, 5472, 1144, -334], [72194, 212, 246, -1258, -2116, 262], [31755, -2288, 967, -969, 1707, 4006], [-5581, 18936, -47, -703, 1845, 1458], [16673, -6974, -260, 1353, -4540, 185], [-42969, -2882, 4262, -4163, -2763, 5126], [-32168, 1820, 490, -1570, -3360, -6092], [21937, 2658, -2451, 3747, 3729, 4880], [51310, -12519, -1476, 3048, -2922, -6213], [-6539, 5129, 1391, -685, -5161, -3265], [25147, -1420, 4393, 919, 323, 1842], [7840, -19781, 3170, -2803, -6304, -4769], [18560, -12672, 4076, -2026, -4808, 2390], [-59214, -8404, -2010, 2574, -3802, 946], [17170, -18520, 1608, 120, -2556, -2974], [-15231, 6708, 3346, -23, -5815, 2590], [5721, 983, 893, -1273, -6123, -1641], [28004, -8312, -4352, 986, -2142, -3846], [59115, -18348, -211, -2305, 339, 4886], [26033, -11014, 546, -791, 150, -933], [-29886, 5840, -1973, 5604, 3531, -1361], [-50825, 7343, -369, -1966, 125, 1741], [-10721, -4657, 2610, 1006, -470, -3956], [55115, -6139, 1821, 3217, -1247, -3233], [28106, 12726, -5174, 163, 6324, 112], [-40342, 6987, -2355, 372, -859, -6726], [-66822, 2750, 200, -5026, 2888, 3270], [-10706, 12365, -7780, 4822, 4302, 3459], [68907, -5866, 1609, 5691, -6639, -820], [-8996, 8648, -1287, 354, 5299, 5029], [-83385, 9177, 17, -1580, 473, -655], [52956, -1524, -5820, -40, -2660, -4940], [10412, 787, 739, 1100, 1698, -3565], [-21110, 1955, -1004, 4700, -1702, -3751], [-5023, 8431, -4696, 1775, 7800, -410], [20860, 10757, 9106, -4321, 2050, 3785], [74778, -13710, 1634, -814, 2674, 368], [97817, 8933, -1411, 1081, 623, -2785], [19981, -14475, -1443, 3510, -5139, -2473], [30604, -6488, -6143, 1339, 3441, -2533], [-16232, -18408, -666, 3554, 4150, -4002], [909, 15439, -65, -181, 451, -2219], [25367, 2867, 2870, -3589, 4278, 854], [88812, 3154, 2569, 400, -3255, 3501], [3385, 139, 4036, 2033, -75, 719], [-11985, 3706, -6510, 1987, -1441, -7966], [14249, -13180, -2375, 2321, 1607, -2914], [-38568, 7186, -4421, 2182, -1158, 3030], [65776, -18690, -3514, -2166, 2278, 1130], [-20737, 3270, -5928, -3385, 5887, 5218], [-58802, -7589, 1012, 1040, -340, 2231], [-63280, -6424, -1156, -1052, 224, -1652], [-77021, -6661, -9966, 3801, 4768, -7400], [-10962, -4934, -6077, 3278, 5686, -2970], [13647, 219, -1618, -3487, 5240, 4748], [-39053, -2731, 6352, -5105, -938, -2546], [76019, -6326, -2474, -1669, 3971, -2356], [52617, 3362, 1651, -1307, -4377, -462], [55533, 10922, -4354, 3113, 2828, 1137], [-54307, 2317, 1989, -3697, 43, 6283], [-50782, 9573, -1415, -52, -6059, 4536], [900, -1272, 5075, -9728, 1672, -1632], [-28627, -6062, 1236, 163, 982, -5725], [55989, -1968, 4771, -4632, 1087, 1660], [68786, 17823, -1581, -1896, -5109, -990], [24159, -10486, -1761, -1873, 6658, 1851], [93387, -11155, -1414, 3599, 500, -3010], [-35388, 448, 5480, -5096, 3240, 2896], [10603, 7997, -2703, 4945, 2207, 2173], [-43044, 8826, 5848, -3463, 3702, 8060], [-25021, -7413, -8292, 2687, 3688, -8360], [1613, 6081, 2121, -3598, 2631, -165], [41155, 16193, 3051, -4157, -334, 4072], [53562, -2944, 9059, -5156, -4325, 4677], [-119849, 9640, 1964, 5701, -3821, 1298], [105268, 114, -4144, 3372, -1998, -4396], [8327, 6292, -4944, 6624, -4192, -7477], [-22996, -8419, -1624, -2808, -3409, -998], [139814, 5826, -107, -1757, -4175, -2529], [154813, 1639, 222, -2063, -2630, 1454], [29068, 1236, 22, 4960, 7292, 2448], [-17026, -4628, -1092, -1022, -5350, -4496], [-102525, -22109, 7741, -3013, -7187, 4065], [14527, -14221, 2509, -5919, 969, 105], [6413, 15605, -240, -2455, -6684, -4324], [-25268, -4548, 1193, -750, 1796, 176], [52287, -15113, -3147, 3785, -579, -1393], [-72395, -19840, 979, -588, -5081, 3668]];
    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_r();".
// 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_r(: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_r();".
// 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_r( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1840_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-11776, 3324, 2511, -285, -114, 3, 1]>,<7,R![-79504128, 1667940, 657362, -15251, -1392, 20, 1]>],Snew);
    return Vf;
end function;