
// Make newform 1840.4.a.x in Magma, downloaded from the LMFDB on 24 April 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_x();".
// 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_x();".
// 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 := [124632, 36684, -45582, -7035, 4492, 335, -123, -4, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [-32, -2, 1, 0, 0, 0, 0, 0], [-1138428, 612936, 227019, -129876, -9779, 3891, 108, -31], [1064268, 152664, -187299, -39724, 4699, 1189, -28, -9], [-3995244, -432, 1065687, -112158, -44497, 4983, 474, -53], [-1076868, -982584, 159159, 132804, -2159, -3729, -12, 29], [3741228, 1979064, -431589, -272424, 2489, 7539, 72, -59]];
    Rf_basisdens := [1, 1, 1, 49680, 16560, 49680, 24840, 24840];
    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, 0], [2, -1, 0, 0, 0, 0, 0, 0], [5, 0, 0, 0, 0, 0, 0, 0], [3, 1, 0, 1, 0, 0, 0, 0], [5, 0, 1, -1, 0, 1, -1, 0], [-6, -1, 0, 0, 1, 1, -1, 0], [-2, 0, 0, 1, -1, 1, -1, 1], [15, -1, 0, -1, 2, -1, 0, 1], [23, 0, 0, 0, 0, 0, 0, 0], [9, -8, 2, 3, 3, -1, 0, -1], [32, 7, -2, 0, 3, 2, 2, -2], [-15, -10, 1, 0, 3, 0, -2, 1], [49, -20, 2, -4, 0, 1, 5, -1], [59, 14, 1, 4, -7, -1, -6, 0], [125, 8, 4, -1, -1, 2, 4, 0], [20, -26, 0, -2, -6, -1, -7, -2], [159, 1, -6, -2, 4, -13, 4, 2], [62, -41, -17, 9, 2, -9, 14, -6], [220, -25, 11, -16, 11, 6, 9, 3], [83, 9, -13, 20, 3, -10, -5, 0], [25, -11, 5, 5, -26, -5, -13, 4], [187, -48, -3, -4, -15, -13, -5, -5], [245, 7, -18, 14, 6, 1, 19, 3], [48, 23, 1, 14, 1, -15, 0, 3], [-315, 56, -9, 15, 20, 3, 21, 6], [-150, 0, -8, -18, 14, 1, -14, 1], [330, 22, 6, 15, -31, 18, -10, 11], [446, -129, -27, -2, 17, -10, -3, 3], [91, 39, 26, -29, 2, 9, 1, 8], [-533, -8, -21, -6, 49, 4, 12, -9], [432, -127, 20, -61, 61, 30, 1, -8], [420, 64, 35, -41, -22, 23, -31, 7], [-237, 46, 59, -31, -33, 12, -13, -7], [677, -141, -41, -31, 2, -8, 12, -18], [-210, 163, 79, -61, 5, 28, -9, 12], [430, 102, 1, -36, 21, -15, 1, 14], [-479, 112, -31, 40, -3, -28, -42, 1], [914, -86, 7, 2, 8, 12, -51, 7], [664, -40, -24, 74, -58, -4, -9, 3], [-805, 125, 2, -43, 51, 6, 30, 18], [974, -192, -5, 49, 12, -17, 30, 2], [733, 33, 52, -71, -6, 29, -45, 10], [468, 270, 0, -52, 48, -44, 26, -10], [-737, 325, -41, 55, -22, -29, -10, 13], [-476, 42, -31, 12, 23, 31, -10, 7], [314, 219, 9, 28, -9, 37, -9, 14], [-59, 215, 66, -90, -62, 9, -35, 41], [709, 391, 50, -26, 44, 22, -59, 14], [339, -138, 45, -110, 41, 77, 10, 32], [326, 407, -9, 2, 33, 5, 78, -49], [-358, 214, -17, 99, -6, -31, -79, 17], [-83, 315, 53, 149, 60, 44, -48, -26], [1939, 35, -50, 24, 56, -14, 82, 15], [284, 23, -37, 29, 85, -94, 79, 8], [1810, 112, -119, 157, 26, -85, 130, -12], [172, 297, -33, -27, 28, 16, 43, -58], [531, 58, 22, -173, -49, -35, 22, 13], [-398, 253, 71, -109, -127, 39, -98, 26], [1762, 128, 123, -13, -104, 133, -53, 35], [1741, 340, -39, 84, -43, -37, 26, 4], [1391, -13, -42, -188, 28, 3, -41, -27], [426, 2, 56, 56, -44, -3, -65, -38], [-124, -446, -64, -109, 109, -4, 129, -12], [-1670, 488, 69, 45, -32, 131, -110, -2], [-1035, 112, -17, 5, 9, 123, -136, -31], [-594, 161, -135, 105, 41, 78, -3, 14], [615, -39, -97, 285, -2, 10, 150, -48], [1690, -322, -2, -57, -76, -51, -138, -44], [2175, -291, 172, 145, -17, 20, -21, 93], [2011, 194, 114, -331, 69, -57, 6, 5], [716, 250, -145, 147, 154, -11, 57, -9], [-22, 65, 67, -68, -103, 13, -139, -12], [1107, -547, 78, -130, 68, -63, 79, -51], [-3256, 670, 0, -10, 84, -18, 78, -48], [123, 355, 274, -183, 127, 8, 50, 10], [-716, 51, -111, 118, -81, 70, -67, -59], [114, 902, 18, -223, 93, -100, 62, 69], [333, -355, -179, 90, 33, -161, 58, -12], [3446, 188, -148, 186, -212, -94, -236, -64], [-502, 672, -143, 104, -72, -85, 55, 72], [-1747, -332, -243, 42, 135, -7, 1, 51], [3782, 8, 300, -101, 104, -119, -27, -31], [-1058, -237, 271, -152, 73, -19, 85, 64], [-1433, 30, 257, -235, -31, 133, -46, 95], [1119, 522, -44, 24, 45, 123, 167, -37], [3487, -403, -65, -32, 32, -42, 396, -65], [2007, 192, -225, 157, -9, -71, 135, -190], [1870, 516, -94, 152, 106, 83, 29, -42], [4803, -318, 34, 235, 181, 64, 118, -84], [-27, -661, -306, 290, -90, -80, -57, 2], [-507, -541, 88, -10, -74, 65, -85, 75], [-2368, 478, 34, 12, -24, 64, -42, 2], [-5966, -259, -174, 219, 207, -316, 113, -128], [-1967, -749, 67, -43, -80, -138, 176, -80], [-1385, 81, -175, 11, -146, -142, -49, 9], [-2204, -585, -423, 231, 179, -247, 18, 50], [-1973, 1060, 192, -219, -121, 244, -231, -33], [5913, 459, -62, 30, 220, 40, 78, 73], [943, 530, -255, 376, 115, 41, -240, -84], [-229, -226, 214, -485, 237, 96, -263, 1], [-848, 40, 19, 396, -116, 124, 197, -73], [-5503, 854, 19, -34, -289, 206, -156, 211], [-2455, 1361, -20, 266, 190, -153, -25, -79], [5486, -54, 162, -512, 142, 74, 256, -54], [5327, -289, 202, 103, 213, 244, -166, 76], [-2871, -1007, 153, 259, 94, 111, 167, 46], [-2679, -358, 16, 408, 140, -180, -172, -75], [-167, -271, -486, 296, -152, -152, 387, -58], [-162, 2070, 458, -67, -223, 140, -377, 98], [58, 1968, -455, -194, -6, -195, 72, 67], [-4113, 839, 192, 218, -22, 6, -193, 186], [-13956, 582, -210, 42, -100, -198, 114, 152], [4593, -1972, -135, 137, 172, -214, 166, 218], [3292, -1483, -27, 229, -397, -38, -261, -40], [2920, 103, 33, 168, 145, -187, -53, 180], [9451, 2414, -7, -6, -151, 241, -46, -42], [7119, 497, 160, -366, -164, 431, -373, 99], [-2736, 639, -432, -43, 285, 34, 268, 203], [-10347, -58, 168, -594, -49, 127, -176, 40], [-5113, 1097, 282, -516, -82, -158, 446, 101], [-1408, 514, 422, -635, -623, 172, -42, 199], [-2808, -2142, 109, 5, -244, -151, 47, -81], [-5912, -1338, 52, -722, 558, 9, 27, 50], [2829, 2411, -247, -284, -4, -222, 298, -45], [6104, 1656, 120, 194, -112, -42, -96, -24], [6128, -608, 162, 477, 154, -41, 135, 13], [-13188, -609, -389, 817, -262, -29, 242, -184], [-2130, -169, 181, 621, 131, -51, 102, -178], [-3969, 1441, -546, -33, 49, -295, 613, -134], [-12130, -104, -166, -368, 238, -203, 231, 42], [6961, -775, 233, -763, 84, -40, 401, -227], [8777, 658, 77, 395, -393, -510, 469, -125], [-1786, 955, 95, 104, -89, -63, 163, 22], [-11983, 52, 31, 880, -327, -252, 226, -83], [680, 818, -59, 126, 50, -189, -434, 45], [-5310, -286, 378, -192, 134, -88, 180, 296], [-9119, 530, 483, 32, -375, -173, 51, 35], [6477, -523, -112, 300, -548, -415, 269, 23], [-10567, -610, -447, -398, 717, -378, 116, -9], [5214, 142, 384, -683, 33, -75, 82, -134], [5885, -441, 77, -597, 516, 26, -38, 272], [2866, -176, -320, 306, 98, -548, -135, -67], [10008, -1419, -226, -115, 667, 306, -154, 61], [-2371, 609, -264, 348, 320, -141, -83, -31], [-13326, -1630, -510, -32, 182, -167, 358, -25], [68, 551, 673, 28, -225, 45, -553, -32], [-21466, 2071, 667, -649, 283, 296, -499, -186], [1888, 456, 271, -943, -122, -239, -5, 91], [-921, 2651, 347, -505, -342, 188, -392, 178], [245, -282, -256, 597, -365, 142, -122, 264], [-16556, 3150, 50, -301, -255, -274, 716, -119], [14315, 895, -104, 418, -700, 50, -36, 163], [-5374, 1983, -3, -397, 423, -52, 88, -199], [-9564, 2829, 214, 371, 171, 450, -817, 58], [-5152, -39, 77, 454, -223, 422, 29, -31], [-3056, 143, 515, -826, 535, -99, 287, -86], [9094, -1581, -317, 850, 65, 59, -91, 356], [3305, 1798, 550, 49, 153, 459, -749, 282], [-1580, 800, -716, 561, 804, -481, 460, 252], [-445, -1237, -802, 415, -113, -296, 408, -484], [-13236, 2468, 929, -640, -498, 146, 108, -114], [1822, -618, 20, -445, -199, -450, 312, 251], [75, 2428, 956, -313, -103, 140, 229, -209], [-7054, -318, -1020, 331, -489, 16, -142, -19], [1552, -1320, -192, -903, -222, 146, -63, 178], [-1645, -681, -176, 135, 415, 593, -331, -86], [2649, 2671, -268, 749, -805, -729, 31, -266], [-2528, 1724, 542, 704, -438, -352, 298, -320], [-2158, -1663, 107, -838, 351, -97, -162, -523], [-9800, -2896, -623, 1220, -333, 165, -117, -120], [-570, -749, 193, 216, 137, 545, -217, -402], [3105, 2542, 696, 545, 139, 239, -463, 508], [2438, -1968, -878, 1194, -14, -158, -366, -140], [-6070, 850, 338, 463, 59, -37, -1191, -45], [-12478, -212, 41, 1084, -615, -223, -576, 439], [7458, -2275, -499, -176, 205, -749, 556, -299], [-4854, 3482, -711, -343, -462, -319, -791, -199], [-8845, 3872, -590, -291, 55, -319, 787, -202], [6566, -3383, -759, -1, 956, 110, 517, -558], [4891, -4730, 751, 293, -153, -60, 325, -57], [769, -2946, 196, 227, -1267, -110, 15, 41], [2436, -1559, -891, -609, -32, -979, 99, -439], [-17335, 1588, 264, 730, 207, 547, 549, 323], [338, -1174, -574, -614, -460, 214, 340, -116], [11761, -3307, 384, 215, 299, 335, -493, 52], [-7393, 712, 69, -947, 1441, 654, 49, -187], [-6356, -3023, 91, -241, -15, -622, -252, -117], [7312, 3313, 897, -32, -1111, 406, -959, 371], [-14485, 428, -566, 1184, -92, -1219, 1320, -18], [7451, 2965, 844, -1741, 1201, 181, 657, -46], [-16430, -1564, -135, -625, 536, 401, 41, 121], [-19048, 1442, -846, -142, 4, -92, 479, -565], [9764, -3354, -192, -1206, 910, 462, 932, -132], [25840, -4344, -302, -960, 696, 343, -398, -61], [-14296, 682, 1176, 66, 520, 202, 276, -172], [23642, -1410, 354, -603, -1074, -426, -83, -36], [13573, -2440, -13, 42, 361, -1159, 1054, -400], [11132, -4564, -108, -146, -294, 652, -530, 134], [4778, 1120, -642, 886, 1124, 614, -418, -342], [-15749, 1264, -28, 1025, 185, 652, -650, 12], [-1665, -3883, 988, -497, -379, 1122, -1382, 380], [-1905, 4526, -1141, -237, -507, -696, 912, 316], [-16304, -444, -493, 1046, 631, 189, -581, -314], [-13790, 2043, -923, -140, 35, -325, -152, -95], [-14109, -2869, -912, 948, -856, -1230, 118, -291], [-11901, 25, -61, 539, -156, -701, -395, 466], [-13627, -852, -921, -1740, 73, -297, 703, -195], [15687, -290, 1074, 336, -190, 710, -637, 534], [8708, -2, -789, 350, 342, 547, -740, -173], [30716, -3200, 653, 631, 1980, 89, 1025, -231], [-29, 1535, -357, 143, 640, 447, 333, -582], [21761, -5122, -158, -997, -89, 78, 736, -90], [-11262, -4796, 904, 167, -630, 395, -1357, -149], [-7296, -1526, -936, -640, -182, -78, 116, 78], [17729, 305, 176, 1170, -1082, -127, 269, 185], [-7215, -7154, 719, -2280, 1391, 1439, -4, -86], [-1305, -60, 438, -271, 637, 464, -983, -447], [37127, -2684, -20, 65, -413, -489, 1428, 399], [33410, -1909, 451, 25, -1031, -715, 1132, 80], [18849, -6013, -115, -285, 686, -1311, 124, -149], [-3677, -3524, -2058, 1361, -967, -1727, 1248, -115], [10796, -7325, -1477, 908, -499, -773, 1131, -630], [10575, -2892, -1006, 22, 26, 215, 858, 20], [-2209, -1153, 1234, -985, 286, 1214, 374, 178], [18726, 2849, -84, -627, -277, -356, 680, 255], [-10973, 3558, 2164, -2133, -623, 609, -689, -368], [26400, 872, -1952, 1667, 1036, -127, 462, 214], [-14414, -3001, -2082, 300, -677, -542, 873, -387], [-4979, -1914, -65, -257, -581, 326, -473, -771], [5413, 3111, -222, -534, -104, 337, -1095, 97], [-4735, -3260, -23, -2341, 1669, 1336, -683, 23], [32958, -4333, -951, 481, -834, -845, 313, 397], [18374, 6166, 1166, -1810, 108, 528, -970, 86], [32076, 4504, 728, -287, -1251, 1085, -919, -119], [-5791, 8573, 60, -912, 918, -821, 623, -217], [2143, -1642, 797, -776, 209, -53, 336, -190], [6940, -2590, -598, -1288, -50, 472, -322, 424], [7187, 1836, 2017, -1792, 1177, 1859, -893, 329], [8175, -1767, 1321, -383, 998, -230, -339, -363], [22485, 5929, -1253, 854, 513, 670, -1020, -17], [10453, 3853, 12, 1060, -318, -1137, -355, -379], [18841, 97, -609, 1483, -1678, -856, 39, 17], [19879, -3504, -282, 131, 21, -882, 1123, -797], [-5675, 670, -1446, -695, -817, -1240, 676, 378], [15998, -2138, 398, -3098, -892, 80, -326, -88], [14949, -460, -502, 226, 2147, 375, 1626, 396], [197, 5094, -1906, -207, -97, 580, -697, -31], [31028, -461, -1239, 861, 1265, 130, -317, 172], [-2239, -287, -264, 1427, -1513, -1072, 1216, -348], [4157, -1279, 2000, -251, -675, -755, 667, 232], [-35562, -2756, 1174, 1720, -512, -300, 720, -28], [36857, -3787, -730, 1326, 858, -174, -26, -193], [10796, -1263, 735, -915, 653, -711, -474, 540], [-18236, 5545, 87, 550, -521, -271, -994, -315], [-15009, -935, -704, 2618, -630, -1278, 715, 168], [-6993, -1385, 277, -1725, -1930, 368, -1365, 679], [-34331, 3416, 249, -681, -974, 1003, -1830, 21], [-15198, -146, -1058, 140, 1314, -586, 1688, 420], [-12645, 2326, 448, -328, 125, -309, -404, 84], [-19945, -757, 805, 1719, -18, -611, 967, -70], [-26923, -3379, -1886, -569, -895, -899, 361, 288], [31714, 5629, -915, -302, 1257, 448, 107, 227], [-5792, 994, 184, -1884, 1302, -289, 854, 79], [9073, 678, 1103, -2108, -1413, 1938, -2844, 25], [-2118, -5354, 1550, -1338, -208, 2052, -185, -269], [-19630, 1537, 1125, 595, 580, 1789, -1201, -193], [15765, -3764, -1247, 181, 80, -2105, 1848, 405], [31281, -4814, -1677, 1698, -1131, 53, -1346, 212], [-28194, 1903, -1119, 206, 1875, -82, 1865, -521], [-8918, 9307, -138, -906, 711, 263, 350, 65], [-8299, -2830, 224, 1261, 1163, -49, 1671, 70], [17157, 8169, 158, 928, -918, 15, -253, -21], [7040, -2750, 68, -1453, 868, 500, 1105, 230], [18679, -2554, -1063, -2090, -493, -347, -63, -699], [-42388, -5272, -2191, 905, -1528, -719, 622, -172], [-4951, 10610, -1298, -1355, -11, 120, -451, 167], [46870, 1130, 2646, 597, -1135, 808, -1406, -193], [-9140, -4344, -30, -1186, 2620, 1325, -18, -421], [10225, 1565, 2038, -196, -166, 246, -490, -659], [39607, -4726, 1507, -97, -915, 872, 1683, -79], [-11303, -3478, -1360, 2061, -373, 782, -591, -311], [5242, 4670, -1318, 1458, -2712, -770, -112, 570], [24211, 8290, -151, -1079, -202, -33, 1696, -359], [-19929, -3243, -1976, -444, 752, -216, 1708, 443], [-48684, 3557, -547, -579, 265, -1374, 1289, 234], [34091, 2013, 20, 371, 53, -1155, -863, -86], [-35036, -6814, 140, -1890, 490, -1421, 331, -412], [-8755, -3808, -809, -1148, -427, -393, 2289, -667], [23824, -6406, 1016, -2765, 1053, -946, -338, -399], [-2226, 2504, 542, 2655, 369, -882, 485, -434], [38907, -3573, 2394, 1048, 790, 1156, 982, -223], [29239, -6303, 638, -3468, 378, 285, -565, 447], [37577, 5371, -84, 2054, 828, -642, 122, 147], [22769, 4053, 168, 245, -674, -1561, 1658, 199], [-15293, -12441, 611, 292, 553, -1095, 1379, 77], [56533, -2525, 274, -35, 1133, 620, 1184, -668], [-650, -4926, 292, 1246, 2048, 1072, -282, -530], [27595, 5961, 515, -1592, -1671, 51, 932, 1278], [-21619, 2761, -2991, 947, -932, -1500, 908, 868], [-20725, -2430, 1576, 1210, -2242, -1036, -622, -1025], [20024, 5650, 884, 2311, -1144, 930, -591, -448], [-173, -4578, -2329, 3706, 785, -1072, 2160, -281], [27671, -3127, 154, 522, 2068, -868, 1520, 571], [10345, 6720, 458, 577, -2399, 1726, -425, 567], [46579, -10280, -3383, 2205, 551, -476, 1595, -753], [-48264, -118, -2331, 2349, -366, -1705, -1760, 572], [45657, -1489, -168, -4659, -337, 346, -752, 160], [9214, 2377, 1111, 397, -1229, 1418, -1369, 724], [-20218, -6754, 1338, 2568, 208, 1172, -1344, -490], [-28938, -1294, 1088, -375, -211, -810, 158, 459], [14394, 1897, -1320, 1931, 1959, 112, -736, -563], [34232, 1592, 3200, 2685, -214, 1601, -1413, 587], [-5149, 17199, 368, -92, -1214, 678, 308, 37], [-4008, -3355, 1386, 920, 110, -1622, -881, 1101], [11729, -6605, -2106, -471, -876, 10, 16, -580], [-21419, -5966, 91, -1428, -117, 327, 602, -324], [31753, -12071, 441, -377, 668, -478, -2080, -298], [23226, 3301, -498, 478, -913, 1404, -3048, 58], [4364, 1742, -2858, 2424, -570, 197, -615, -418], [-11575, 4338, 480, 2094, -1132, 920, -110, -441], [-16303, -4954, -1963, -2845, 1204, -277, -231, -4], [-37869, -498, -597, -79, -1282, 2480, -1120, -748], [-44501, 6170, -380, 2897, -1441, 1184, -747, -281], [-76679, -639, -96, -1092, -2, -334, -1421, 710], [54318, 10022, -1652, 4507, -291, 273, -939, 333], [-44787, -2591, -1996, -862, 108, -986, 3608, -431], [-13929, -6674, -1443, 441, 2761, 1362, -999, -301], [13009, -11133, -615, 1366, 1894, -1472, 1301, 856], [-4314, 2072, -2638, 3137, -834, -251, 1035, -393], [27264, -3074, -850, 578, 1768, -1029, -545, -156], [25541, -6942, -1352, 2889, -1195, -913, -821, -18], [-43959, 4777, 781, -2418, -2683, 1013, -825, -307], [-7961, 2873, 4531, -1035, -858, 2100, -1451, 2239], [30326, 7100, 3913, -2304, 988, 3390, -1036, 28], [-34351, -7676, 539, -1608, -3069, 141, -1205, 1027], [8985, -6551, 595, -1080, 1350, 80, -2220, -317], [32645, -107, 2752, 153, -133, 592, -90, -1318], [53517, -14076, -307, 1568, 5, 375, -811, 57], [-6141, 4468, -668, 1424, 2046, -1024, 2726, 719], [45896, -5655, 1813, 411, 2556, 1244, 267, -184], [-27135, 11999, 201, 3687, -146, -827, -608, 1543], [289, -2306, 305, 3429, -1180, -523, -2281, 888], [55650, 12076, -1208, 1438, -1064, 422, -1381, 129], [56126, -6826, 974, 540, -1052, -1492, 958, 132], [4676, -3986, 1300, 1826, -58, 1117, 1519, 530], [27641, -113, 3430, -82, -2136, -1183, 733, 597], [2645, -7522, 2942, -3995, 1053, 3029, 1445, 246], [-16987, -12908, 2003, -3407, 1017, 912, -286, 450], [37505, -1943, -1978, 2994, -134, -2520, 3032, -1183], [-20002, 72, 756, -3632, 2428, 481, -2695, 356], [15127, 553, -1767, 313, 3446, -1248, 1001, 319], [37431, -1193, 2653, 1233, -2484, -317, 334, 983], [-55292, -10636, 1386, -4932, 292, 289, -841, 408], [-57519, -153, 2846, 13, -793, 2009, 1495, 128], [36001, 12123, 38, 4190, 1332, -466, -1736, 529], [209, 10639, -1584, 1058, -218, 2650, -2148, -599], [-16449, 2967, 420, -1950, -4446, -456, -2406, 841], [35042, -22921, -145, -1103, 899, 780, 1793, -982], [-34984, -6400, -2127, 1935, 54, 591, 183, -561], [42722, -2914, 896, 786, 756, -1128, 3279, -547], [8232, -18036, -714, -800, 1344, -1333, 3743, -454], [-3775, -2064, 1234, -241, -1277, 1897, -5, 662], [-40014, -2973, 4236, -933, -1119, 72, -791, -528], [-26690, 1890, 1860, 2519, -193, 912, -2542, 541], [-6128, -20565, -616, -1430, 1750, -366, 69, 289], [-14198, -3392, -1961, 1003, -848, -203, -2485, 7], [-21716, 2780, 1245, -4588, 811, 561, 261, -1490], [-18168, -10497, 131, -2652, 5147, 1626, 1133, -1097], [-15352, -6446, -2240, 1590, -1322, 1574, -1992, -126], [37919, 473, -1421, -287, 356, -434, 2835, 51], [-86743, 11443, 3798, -2976, -510, 47, 1519, 679], [-33616, -23475, -474, -469, 2153, 328, 1843, -136], [32011, 6187, 1302, -635, -3799, -800, 122, 12], [-46487, -2501, 410, 1624, -1470, 0, -1108, -1069], [38863, 8242, 4698, -5220, -139, 3595, -2078, -82], [41711, 5741, -1077, 121, 2540, 752, 854, -686], [-44500, 9229, 2737, 2318, 1243, -1585, 701, 478], [35494, -9454, -4348, 3029, -1957, -3167, 1385, 87], [-54119, -1725, -1050, 1372, 2102, 442, 1718, -347], [68459, -18479, -2087, -835, -530, -657, 713, -404], [-23848, -10416, 904, 2923, -2211, -222, -1016, -823], [39807, -1294, 1633, 383, 2482, 1897, -2603, -302], [3708, 3838, -266, -2296, -470, -2062, -1817, -301], [-22937, -925, 2667, 493, 1250, 2099, 789, 1220], [-34148, 5341, 475, -1138, -2483, 179, 1209, -1142], [17175, -14430, -6090, 2113, -1159, -1820, 753, 873], [-3224, 4599, 3728, -3416, -3827, 3168, -3817, 1647], [83427, -2246, 285, -4151, 769, 668, -181, 85], [-71673, -945, -730, 104, -2216, -199, 3333, -431], [12456, -9027, -119, -3819, 241, 1935, -1312, 1012], [-33517, -465, 2400, 1170, -1154, 3578, 826, 301], [-17879, 15998, 3859, 285, -1883, -778, -978, -66], [-81047, 7295, 761, -1497, 286, -538, 1223, 495], [-17984, -2052, -3400, 4522, 18, 148, 2093, -279], [-69699, -2688, 297, -1014, 917, -1289, 1633, -235], [-87325, 5796, 459, 1117, 1027, -757, 244, 467], [48067, -4494, -127, -6854, 2109, 203, 1245, -417], [20103, 1750, 1789, -4626, 2725, 959, -446, 924], [-52217, -1240, 2349, 4465, -1077, -548, -2789, 551], [12458, -5234, 1042, -4076, -1646, -1587, -234, -513], [-6461, 1558, -696, -4283, -1151, 1447, -3158, 1105], [2347, 10001, 3563, -1301, 1670, 3329, -1254, -593], [-8222, -10267, 1, -1134, 1911, -2386, 2561, -1137], [35623, -4202, -1233, 2129, 249, -981, 210, -231], [26783, 8764, 5430, -4165, -3191, 2433, -1508, -309], [-28879, 4451, 1783, -5064, -33, 2022, -608, -911], [79059, -2172, 2837, 162, -1385, -3084, -534, 1653], [35532, -22388, -245, -3170, -528, -2250, -422, 1024], [-98645, 13410, 3733, 850, 341, 121, -1732, -166], [-49522, 2358, -3188, -888, -1928, -52, 548, 950], [70508, 4778, 3337, 413, -5750, -1601, -3498, 1378], [68631, 10077, 991, -2774, 2979, 2763, 1378, 442], [-62607, 13570, -51, -3046, 2099, 2011, -2966, -804], [-32297, 15705, 262, -3279, 3535, -856, -910, 74], [-39934, 9020, -830, 351, 4528, 630, -325, -672], [38889, 2378, 208, -4965, 2461, 1864, 485, -1477], [-67613, -6148, -795, -5341, 2333, -604, 3831, 769], [16496, -9912, -6264, 6760, 1446, -1874, 1745, -1899], [-3069, -15328, -2467, 1027, -902, -3164, 2110, -156], [17160, 22710, 1672, -1785, 602, 1091, -21, 741], [49875, 15388, -2167, -2119, 2152, 453, 3884, 441], [17849, 6396, -3231, -470, -1345, -1793, 171, -1007], [75673, -2343, -872, -72, 690, -3358, 4111, 606], [52406, 3184, -1602, 5094, 4070, -1924, 1286, -46], [53325, -14995, -1687, -1465, -1558, -2269, 3206, -341], [-55466, 7160, -1215, 99, 4242, 2821, 388, -186], [40531, 3494, -4801, 118, -727, -319, -1752, -350], [-101457, -1506, 901, -323, 1103, -2599, 904, -163], [-121898, -10288, 213, 91, -1906, -949, 1104, 242], [-50103, -4597, -2497, 1406, -2799, 2746, -3209, 1144]];
    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_x();".
// 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_x(:prec:=8)
    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_x();".
// 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_x( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1840_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![33856, 83904, 16400, -22173, 462, 1029, -67, -12, 1]>,<7,R![-575432512, 511740376, -70422072, -8737786, 501889, 31419, -1184, -31, 1]>],Snew);
    return Vf;
end function;