
// Make newform 1840.4.a.z in Magma, downloaded from the LMFDB on 16 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_z();".
// 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_z();".
// 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 := [53104, 286800, 42737, -87343, -4928, 6502, 278, -148, -3, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [-161016460, -98808921, -5808013, 18403540, 2205470, -544206, -40716, 4127, 163], [74795096684, 203410599449, 42594569976, -31446688712, -5143221570, 832440392, 100384680, -5815223, -514256], [-7764096076, 198407012009, 45096363696, -31446688712, -5143221570, 832440392, 100384680, -5815223, -514256], [-139395895828, -116428273513, 48012273123, 11088924784, -3337353690, -360717754, 79478880, 3148951, -569393], [-170844106264, -84342328444, 7066734219, 3213171712, 3965373360, 312182138, -147932640, -4616552, 1230451], [14256990172, -96502268313, -57548382767, 13127463324, 6448742270, -184830594, -153500780, 226071, 1015897], [35031968488, -54903099492, -68527830803, 6637407996, 7829453240, 90650274, -197866340, -2387616, 1382473]];
    Rf_basisdens := [1, 1, 2417192, 2501793720, 2501793720, 2501793720, 2501793720, 833931240, 833931240];
    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, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [-5, 0, 0, 0, 0, 0, 0, 0, 0], [-3, 0, 0, 1, 0, 0, 0, 0, 0], [-2, 0, 0, 1, -1, -1, 1, 1, 0], [4, -1, -1, -1, 0, 1, 1, -1, 1], [-14, -3, 1, 0, -1, 1, -1, 0, 0], [-13, 2, 1, 0, -1, 0, -2, -2, 0], [23, 0, 0, 0, 0, 0, 0, 0, 0], [28, -3, 1, 0, 3, 1, -6, 0, 1], [-21, 13, -4, 0, 0, 1, 0, 0, -3], [26, -17, 1, 1, -4, 0, 4, 1, -2], [-45, -29, -5, -5, -2, 0, -5, -3, 0], [-12, -9, 1, 0, 4, 1, -2, -4, -3], [10, 19, 7, -9, -1, -8, 4, 3, 2], [-19, -24, 7, 7, -10, 2, 3, 9, 2], [-88, -10, -4, -7, 2, 1, -6, 5, -3], [220, -7, 10, 1, 1, -5, 6, 5, -5], [-167, -23, -4, -9, 4, -5, 11, -3, -1], [-136, -17, -3, -5, -12, -20, 17, 17, -3], [77, -50, -21, -9, 1, 12, 7, -11, 12], [-299, 9, 16, 2, -10, -10, -1, 6, 0], [-261, -56, -3, 31, -2, 14, -3, 9, 6], [122, -47, 27, 2, 10, -21, 2, 6, -11], [252, -6, -16, 3, -5, 7, 27, 25, -8], [398, 0, 0, -19, 18, -7, 12, 1, 3], [-344, -12, -11, 9, 19, 4, -32, -37, 16], [-325, -17, -8, -17, 26, 9, -13, -35, 21], [220, 52, -1, -2, 20, 4, -33, -1, -6], [-350, 3, 15, 25, -18, 4, -14, 9, 2], [-755, 51, -10, -13, 11, 25, -7, 9, -27], [-139, -124, 19, -11, 39, -14, -29, 15, -32], [-442, 9, -13, -14, -13, 6, 13, -14, -30], [-296, 62, 14, -8, 49, 10, -22, 8, -26], [-28, -101, -4, 18, 14, 11, 1, 25, -33], [-900, -153, -15, 18, -6, 27, -15, 26, -2], [-92, -39, 31, 5, 2, 0, -12, 35, -30], [-290, -124, 11, 13, -7, -41, -3, -12, 15], [-351, 260, -9, -24, -2, 51, 9, 18, 17], [-303, -27, 8, 37, 11, -21, -6, 1, -4], [-544, 102, -72, -35, 29, 47, 2, -7, -17], [406, 120, -55, -94, -18, -2, 21, -33, 20], [-700, -24, 46, -32, -10, -2, -22, 18, -32], [-966, -124, -60, -7, 35, 79, 12, -75, 65], [207, 239, 0, -76, 66, -10, -80, -12, -25], [-27, 231, 44, -10, 54, 4, 37, 38, 14], [-1231, -230, -55, -51, 28, -4, 29, -51, 34], [-707, 100, -87, -66, 12, 47, -19, -46, 25], [-1402, 23, 87, 32, -46, -103, 42, 20, -51], [846, -21, 7, -84, -30, 7, 48, -56, 17], [-951, 404, -33, 27, 33, 72, 3, -41, 8], [-848, -6, 26, -74, -21, -12, -38, -24, 16], [730, 26, 10, -10, 8, -2, -100, 6, 12], [-518, -139, -61, -62, -39, -10, 49, 66, -20], [-1168, -226, 54, -101, -45, -97, 118, 77, 5], [197, -133, -33, -76, 87, 57, -9, -186, 57], [-376, -157, -43, 38, -61, -41, 80, -18, 145], [-1319, -37, 72, -13, -49, -56, 40, -61, -30], [633, -122, -39, -9, 9, 136, -67, -37, 40], [-1714, 549, 151, 56, -106, -125, 34, 182, -93], [1575, -238, -7, -21, 90, 58, -59, -101, 86], [-2525, -370, -43, 31, 70, 56, -71, -157, 8], [-1711, 524, 70, 101, 3, -21, -119, -5, 39], [660, -100, -4, -245, 169, 55, -222, -209, -27], [-2463, 135, 72, 147, 97, 78, -36, -13, 20], [-1448, 627, 51, -20, -103, -54, 103, 104, -56], [676, -596, 68, -30, -113, 22, 160, 108, -8], [-2117, 698, 97, 182, -67, -112, -20, 200, -34], [409, 346, 38, 41, -59, 27, -99, 39, -5], [1182, 49, -105, 94, 27, 233, -24, 24, 13], [-2305, 96, -3, -237, 25, -78, 167, -57, 160], [605, -357, -40, 196, -124, -30, 227, -66, 10], [227, 330, 65, -37, 32, -112, -23, 35, -110], [-2914, 404, -146, -164, 112, -12, -26, -42, 36], [-617, -155, 110, 3, -211, -121, 78, 277, -144], [2621, 381, 10, -161, 100, 13, -237, -89, -39], [-2166, 472, 109, 143, -95, -108, 68, -9, 14], [-1135, -397, -142, 248, -180, -88, 98, -20, 37], [-1110, -206, -234, -20, 16, 164, 100, -142, 46], [-1304, 526, -75, 22, 11, 44, 155, -5, 126], [103, -1105, -50, -46, 58, 64, -67, -152, 58], [1426, 148, 141, -62, -168, -78, -87, 51, -44], [1809, 405, 138, -20, 158, -40, -281, 8, -112], [-1679, 711, 200, -41, 57, -56, 206, 255, -22], [-1922, 277, -61, 87, -294, -245, 121, 47, -39], [3437, -862, -34, 69, -135, -56, 28, 124, -116], [-1860, -81, 56, -19, 14, -40, -169, -84, -42], [-291, 888, 23, 27, 116, -26, -125, -155, 90], [2526, -395, -139, 59, 49, 106, -154, 1, -116], [93, -780, 67, -16, -12, -243, 43, 84, 51], [-1791, 316, -81, 209, 146, 104, 45, -13, -28], [522, -492, 226, 362, -212, 130, -62, 118, 244], [-765, 315, -8, 39, 61, 67, 293, 139, 93], [-3490, 762, -142, 174, -119, 66, 78, -6, -6], [751, 592, -1, -436, 1, 71, 71, 72, -113], [6031, -377, 137, 221, 154, -187, 2, 268, -85], [1867, -87, 188, 89, -21, -415, 31, 353, -149], [-314, 590, 64, 282, -92, 14, 156, 80, 74], [6788, -777, -13, -46, -28, -29, 264, -50, -53], [9811, 45, 186, 117, 113, -43, -25, 25, -27], [-4152, 52, 203, -137, 257, 19, -379, 120, 15], [-1496, 63, 117, -213, -44, -202, 90, -191, -76], [-565, -1120, 81, -341, -130, -184, 89, -23, -6], [-2468, -648, -6, 116, 310, 242, -156, -58, 188], [-539, 195, -82, -371, 55, -59, -54, -117, -296], [-671, 92, -155, 281, -71, -254, 279, 185, 88], [-5350, 367, 72, -118, -8, -242, 86, -22, -270], [-3997, -920, -125, -598, 180, 75, -13, -184, -23], [-942, 59, -321, -487, 259, 36, -53, -175, -181], [9473, 400, 80, 160, -151, -55, -178, -29, 83], [-1405, -930, -151, -656, 144, 161, -97, -232, -21], [78, -286, -32, -142, 314, 78, -174, -10, 32], [-4833, -10, -205, -316, -25, 123, 50, -162, 40], [-1358, -1209, 217, -160, -179, -266, -191, 384, -216], [-7133, 257, 94, 30, 244, -260, -507, -20, -250], [5514, -901, 217, 188, -42, -77, 14, -4, -63], [7473, 698, -219, -417, 122, 266, -87, 17, 132], [-7282, -1489, 167, 87, 21, 68, -294, 139, -208], [-1989, 1959, -22, -373, 462, 212, -502, -367, -92], [-996, 1516, -144, -326, 180, 174, 232, -330, 242], [8926, -1826, -219, 287, -239, -72, 288, 3, -18], [2523, -1408, 71, -421, -185, -370, -39, -337, -40], [4067, 304, -123, -531, 126, 190, -235, -193, 122], [6357, 862, 16, 247, -69, -6, -22, 12, 318], [-1820, 3062, -162, -312, 132, 184, 136, -322, 22], [9402, -1958, -195, 400, -276, -122, -49, -141, 8], [7008, -337, -18, -403, -107, -321, -142, -199, -45], [-2009, -75, 76, 253, -367, -612, 356, 541, -98], [-4833, -390, -198, 18, 161, -46, -131, -444, 148], [4787, 2472, 297, 281, -176, 66, -63, 427, 58], [-8047, -1486, -99, -84, 417, 273, -71, -358, -35], [1002, -55, 118, -224, -16, 89, -681, -177, -303], [-369, -513, -106, 892, -518, -322, 605, 404, 20], [12336, 2843, -181, 743, -54, 164, 0, -43, 164], [2219, -628, 50, 694, -551, -187, -176, -115, -37], [5728, 32, -8, 434, -96, 374, 36, 534, -220], [-8969, 301, -22, 732, -620, -552, 451, 398, -72], [-4441, -406, -163, -193, 518, -284, 407, -345, 80], [1004, 467, -357, -3, 552, 382, -334, -389, 104], [2334, 952, -31, -442, -61, -291, 594, 58, 513], [-18, 760, 418, 502, -441, -470, -224, -110, 208], [14631, 350, 87, -64, 586, 459, -449, -406, -17], [-2188, -1543, -355, -179, -285, 444, 804, -93, 520], [-3623, 52, -323, 929, 100, 158, -309, -285, 264], [18516, -580, -48, -415, -34, -91, 400, 259, -87], [-7273, 2923, -130, 142, 10, 334, 113, 126, 486], [6786, 905, -217, 422, -569, 26, 503, 638, -316], [-4189, -1270, 323, 121, -579, -392, 13, 127, -222], [-1498, 3784, -84, -558, 559, 308, -766, -222, -68], [718, -247, -293, -519, 425, -44, -374, -403, -230], [15083, 1913, 646, 345, 81, -503, -266, 61, -40], [7258, 2604, 286, 818, 326, 154, -302, 186, -82], [3459, -781, -79, 94, -368, 672, 80, -247, 508], [-3849, -1081, 452, 5, 345, 237, -777, -119, 161], [-16927, 949, 472, 715, -176, -51, 443, 827, -37], [883, -1009, 40, -74, 14, 152, 349, 332, -632], [2939, -1195, 12, -232, -120, 396, 611, -220, 168], [-11219, 2031, 186, -496, 79, -434, -149, -60, 260], [-2123, 510, -181, 144, 527, -448, 746, 394, 130], [54, 910, 225, 1083, -821, -536, -60, 511, -258], [-3141, 2758, -620, -439, 241, 318, -34, -264, 302], [-3567, -849, -498, 141, 571, -597, -230, -423, -110], [-12255, 1491, 730, -153, -331, -263, -165, 411, -629], [3713, 2219, -150, -251, -433, 157, 240, 471, -106], [-12788, -1452, 8, 13, -155, 700, -299, 395, -88], [10215, -1040, -960, 544, 145, 842, -87, -930, 452], [204, -557, -299, 112, 329, 929, -59, -58, 566], [1118, -1356, -532, 422, -394, -450, 362, -180, 112], [-7812, -1719, -509, 178, 206, 387, 24, -134, 145], [2432, -4373, 761, 676, 298, -461, -17, 202, -216], [-7909, 2719, 602, 850, -964, -768, -211, 164, -74], [11215, 739, -476, -1422, -99, 38, -143, -724, 328], [9810, 516, 114, -1606, 612, 106, -594, -340, -148], [1350, 437, 665, -370, -279, -409, 289, -446, 132], [4411, 4267, -276, -164, 198, 76, -238, -182, -297], [-16138, 635, -177, 578, 812, 181, -70, -778, 121], [-4229, 3418, -47, 403, -467, -242, 111, -791, 422], [3159, 1759, -380, 86, -535, 404, -285, -708, 94], [-4365, 1829, -131, 830, -495, -39, 9, 1120, -103], [12736, -1921, -136, -678, 724, 1203, -843, -275, 263], [-2511, -703, -232, 697, 431, 57, 645, 759, -179], [-2126, -430, -18, -321, 911, 543, -449, -1225, 558], [13160, 971, -793, -175, -810, -45, 1113, 145, 735], [-18996, -2720, 216, -386, -616, -414, 48, 476, -292], [-171, -932, 362, -146, -719, -138, 799, -172, 204], [-13220, -251, 446, 1046, -920, -767, 517, 541, -223], [9799, -2601, -54, -34, 723, 615, -764, -592, 53], [175, -1595, 424, 369, -304, -247, 667, 687, 139], [-7438, 419, 58, -1559, -374, -715, 896, 165, -547], [14332, -535, -621, 396, -277, 375, -181, 242, 182], [4889, 710, -351, -1559, 381, 276, 595, 29, -176], [1259, 2368, -77, 834, -2, 697, -563, 48, 385], [3584, -2746, 146, -352, 786, 134, -836, -768, -122], [-2792, -1398, 258, -101, -126, -1253, -4, 129, -147], [-4438, 626, 526, 1872, 306, -308, -852, 180, -248], [-25590, 3056, 458, 667, 341, 282, -175, -655, 278], [12654, 2545, 305, -1066, 1090, -1, -106, -386, 147], [-4502, 432, -180, -1022, 996, -66, -518, 24, -1016], [-27986, -5754, -14, -1134, 276, -260, 114, 88, -306], [-6098, 2879, 1047, 1327, -917, -1008, -298, 297, -540], [2968, -2192, 857, 1435, -321, -584, -282, 219, -58], [1693, -3875, -618, 438, 269, 161, -144, -392, -123], [-624, -4429, -195, 196, 288, 75, -217, 478, 208], [-15814, -2389, 853, -406, 72, 93, -766, -458, -393], [3544, 3058, -278, 1476, 228, -90, -344, -340, 226], [-11147, -2344, -257, 1411, -495, 110, 1021, 507, -286], [4263, -1133, -328, -1168, -424, -382, -221, -350, 508], [-13819, -3349, -243, -184, 180, 93, 7, -306, -295], [-17269, -1060, -908, -92, -377, 631, -1086, 181, 37], [-2635, 780, -675, -555, -409, 1084, 1495, -177, 730], [-20261, 456, -457, -785, 679, -306, 933, -267, 4], [-4854, 1811, 687, 433, 917, -424, -1232, -181, -590], [-18072, 3312, -281, 356, -548, -878, 209, 23, 364], [13836, 2396, -194, -218, -424, -330, 1504, -90, -336], [-3641, 1852, 211, -13, -732, -946, 433, 691, -340], [12024, -225, 415, 618, 30, 105, -484, -864, 777], [-13963, 223, 38, 1559, 747, 353, -905, -909, 499], [-39694, -1147, 1053, 780, -661, -583, -566, -22, -533], [-14409, -6131, -555, -395, 266, -405, -452, -702, 517], [1232, 1274, 784, 509, -139, 577, 282, -117, -251], [17808, 2383, 125, 1048, -1173, 509, -30, 594, 749], [-15621, -41, 138, -606, -160, 418, 469, -64, 310], [-19884, -2337, 490, 1421, 56, -259, -1002, -431, 137], [24957, -2842, 124, -1005, 1140, -220, -86, -228, -1088], [-1696, 3247, -857, -427, 161, 456, 638, -23, 864], [39065, -2327, -336, 354, 819, -66, 127, -1000, 708], [-13915, 5582, -333, -124, 197, 90, -80, 286, -208], [15422, -735, 171, -686, 648, 254, 469, 520, -310], [-19882, -5567, -208, 1878, -982, 1195, -195, 1243, -253], [-2105, -494, -459, 93, 1120, 238, -435, -1027, 296], [4480, -2991, -1047, -1742, 791, 368, -539, -2226, 1070], [-14010, 3104, 660, -309, -587, -283, -163, 1659, -1054], [10706, 24, 808, -1472, 1264, 4, -2422, -574, 468], [-18403, 9066, 220, -660, -893, -802, 1179, 1090, -386], [-17031, -932, 851, -1271, 1136, 306, -2071, -1065, -48], [8632, -4315, 65, 1296, 96, 1757, -1368, -984, 355], [-27322, -4562, -8, -558, 362, -646, 386, -252, 204], [-6375, 2869, -454, -86, -246, -260, 543, 1026, 276], [10001, 6186, 1355, 530, -315, 147, -423, 1164, -1039], [-10289, -559, -366, 847, -1642, -355, 628, 1347, -576], [-17121, -2716, -1327, -1815, 1712, 740, 771, -905, 590], [11859, -596, 243, 1212, -1159, -55, 1467, 2492, -701], [-40383, 3483, -456, -93, -85, 1125, 385, -987, 823], [-10122, 2281, 1079, 157, -569, 6, 608, 1947, -514], [7664, -422, 228, 204, -1240, -1672, 1282, 982, -592], [-24137, -385, 402, -979, 2332, -542, -1018, -753, -688], [-21831, -2705, 982, 1443, -907, -1217, 1533, 873, -287], [-17884, 761, -1215, 88, -991, 196, 397, 304, 754], [5169, 961, -1464, -3065, 1007, 801, -84, -1899, -30], [-31347, -468, -104, 2314, -1313, 288, 963, 684, 1186], [17866, -974, 48, -2246, 808, 512, 340, -422, -78], [-32012, -724, -192, -24, 596, 1274, 196, -850, 686], [33093, 509, -429, -1635, -186, 133, 914, -214, 847], [2346, 10185, 1841, 1860, -682, -1729, 304, 1600, -645], [2781, -1214, -411, -2280, -84, 1369, -1893, -1992, 95], [-8875, -656, -1193, 2426, -1129, 309, 403, -80, 575], [-8066, -1395, -314, -97, 179, -423, 680, -1037, -427], [-7060, -2752, -1346, -1068, -1308, 290, 584, -964, 882], [-37997, -3175, 268, -207, 808, -844, 738, 999, 112], [4275, 2334, 199, 2319, 805, 1194, -1073, 395, -690], [-25289, 4248, 526, -2818, 2281, -610, -615, 200, -1168], [-41251, 1293, -878, 605, -334, 273, -403, -633, -595], [18714, 1690, -588, 225, 520, -429, 1120, -515, 255], [5580, -2899, 1065, 733, -338, -1294, 758, 1339, 546], [-37775, -3664, -413, 1642, -58, 53, 1, -1064, 1069], [25044, 2394, 908, -925, 711, -1007, -1001, -1173, 642], [4960, -2583, -1338, 1509, -103, -173, 730, -59, 1091], [14974, 203, -239, -1706, 342, 179, 1282, -378, 55], [-18479, -5101, 1638, -1277, 516, -1515, -1373, 231, -819], [-10815, 7473, 558, 1307, 1110, 638, -410, -111, 78], [11757, 443, 344, 886, -145, -1822, 1063, 2330, -1000], [-9899, 1614, 1141, 1115, 674, 868, -407, -1117, 1016], [40352, 3798, 650, 225, -825, -950, 577, 339, 774], [-8835, 2717, 8, -2614, 34, 46, 993, 428, -82], [9310, -4392, -858, 3197, -1477, -25, 534, 463, 397], [-30681, 4389, 732, -317, -697, -489, 1583, -173, 1623], [-15242, 4360, 567, -761, 625, 102, 316, 455, 386], [16716, 48, -1316, -1841, -86, -997, -380, -1581, 447], [-18760, 5414, -120, 70, -1878, -890, 572, 32, 1280], [8506, 7975, 385, 1236, 1027, -340, 683, -20, 298], [-13153, -1811, 870, -2449, 1915, 1389, -1169, 139, -87], [11130, -822, -1148, -2402, 36, 1190, 1388, -1664, 900], [-1718, 997, 648, -1325, 3145, 493, -10, -119, 135], [17332, 3666, 924, 398, 412, -2066, -386, 10, -846], [21216, 1881, 896, 1248, -1186, -995, 1799, 2173, -1411], [12772, -1883, -1793, 1012, -1913, 319, 1015, -1738, 1294], [41111, -3008, 177, 1323, -426, 396, -1747, -631, -100], [-22619, -665, 834, -3400, -170, -868, 1793, -840, 1268], [-22879, 8783, -314, -1543, 1345, 1359, -1836, -845, -1450], [4891, -3636, -46, 1335, -1305, -149, 1369, 1567, 553], [-14550, -3336, 24, 252, -448, -976, 2776, 724, 1060], [-379, -1532, -269, -1731, 96, 728, 125, 507, -708], [628, -6550, -852, 1102, -982, -1000, 2532, -482, 564], [-713, 4614, 1041, 946, -167, 544, -108, -716, -588], [24908, -1045, -1455, 1728, -2682, -765, 1437, -186, 502], [-18754, -1172, 1111, -3399, -995, 972, -144, 317, -414], [362, 3410, -410, 1094, 342, 1518, 122, 1366, -848], [15485, 415, -834, -596, 1370, 2824, -2156, -1552, 143], [-13076, -2814, 62, 132, 377, -1312, 2750, -346, -146], [19612, -291, -260, 600, -98, -1676, 924, -120, 744], [13680, -4534, -470, 495, 471, 1608, -595, -1471, -324], [-13878, -2751, -875, -1179, 1760, 322, 898, -857, 936], [5612, -2398, 1020, 2050, -972, -1294, -1218, 492, -920], [-69227, 7595, 392, 305, 2161, 1473, -599, -709, 725], [17400, 525, -1459, -1476, 517, -474, 931, 116, 1828], [10210, -3006, 308, -537, -2281, -1923, 652, 281, -537], [-44854, -4124, -597, 2125, -1047, 948, -2128, 857, -152], [23212, -9819, -1126, -2054, 972, 1921, 697, -1307, 1981], [6954, -1968, 936, -3190, 1070, 92, -872, -608, 276], [32975, -6171, 1402, -999, 111, -919, 2356, 1157, 74], [-1336, 1033, 1039, -1873, -1521, -896, 458, 963, 42], [22468, -2158, 745, 264, 902, -732, -1321, -2411, 898], [-10618, -7812, 630, -1320, 754, -984, -1798, 10, 416], [-25009, -8901, -695, 362, -1144, 1639, 973, 132, 1095], [-8561, 1480, 2920, 665, -1418, -1422, -924, 1346, -470], [20730, -1597, -919, 1318, 510, 2399, 354, 1668, 303], [-15878, 740, 2288, -686, 833, -72, -3010, -88, 592], [-28473, -16619, 1664, 1272, 646, -1489, -1714, 676, -137], [14961, -5972, -905, -2519, 864, 948, -1285, -309, -1112], [2466, -2793, 66, 1786, -218, -458, 1676, 88, 2372], [31990, -108, 548, 2743, -2053, 277, 755, 2547, 944], [12331, -6484, -1563, -2020, -177, 717, 2092, -1066, 2500], [17595, 17891, 1528, -1359, -377, -1871, -113, 161, -513], [34739, -4072, -883, 1226, -42, -2339, 2219, 2442, -51], [16588, -3405, -79, 1754, -2347, 2223, 1573, -710, 742], [-9596, -4022, 1040, 3958, 30, 548, -1818, -1126, 418], [40004, -10389, -1573, 762, 165, 1544, 1545, 530, -486], [-2320, -3332, 629, 2913, -931, 61, 451, 80, 109], [-5096, 1972, -965, 1066, -1118, 856, 1809, -643, 702], [-2015, 5394, 933, 1449, -1398, -2022, 1013, 2439, -1384], [-14967, 6117, -430, 906, -1713, -678, 487, 1226, -362], [-19828, -801, -1439, 1120, -1480, 2479, -1967, -162, 638], [63733, -900, 897, 1274, 151, 515, 453, 142, -1361], [-44231, -10824, 2402, 1849, -709, -1486, -494, 2614, -178], [91257, 639, 1440, 2810, -1368, -1026, -345, 180, -236], [55147, -11756, -460, 1199, -2201, -1470, 2088, -648, 106], [-43088, 10814, -45, 63, -491, 314, -1486, 799, -2032], [43791, -2917, -1012, -2006, -734, -774, 1181, 1774, -486], [27670, 6727, -952, -2448, 1932, 1826, 216, -338, 284], [26361, 2959, -245, 3012, 981, -859, -217, 94, -507], [-4140, 12038, 640, 4897, -1351, -2379, 610, 2335, -747], [-27184, -1074, -1436, 265, 1677, 1605, -135, 147, -228], [-22829, -2442, 147, 4866, 1004, -13, -2731, -430, 99], [-29006, 3334, -1254, -674, 940, -1066, 1554, -134, -1496], [34369, -1986, -665, -1031, -3178, 588, 1945, -769, 1130], [-91529, -4406, -3091, -4715, -528, 2894, 717, -1735, 952], [-22653, 2915, 1246, -2898, -235, 896, -835, -272, 1434], [17061, -9333, -2303, -3024, 1244, 1820, 1236, -887, 480], [-26340, 1230, -1008, 774, -3186, -76, 86, -2262, 320], [-50959, -548, 929, 71, -1712, -1436, 2691, 2133, -312], [33315, 6048, 2597, -696, -267, -2833, 1377, 2486, -1585], [-18954, 5132, 2386, 329, -1595, -1581, -116, 977, -549], [-19605, -10982, -1725, -1241, 296, -664, -557, -979, -848], [68185, -7430, 146, -2032, 307, -300, -861, -1254, 318], [-2800, -12942, 1232, -36, -1926, -1624, 3810, 1048, 1308], [30072, 3430, -2216, 2726, -1080, 38, 794, -612, 1186], [-14376, -2422, -612, -420, -2118, 676, 2800, 196, 1652], [12870, -7045, 257, 2640, 1365, -52, -249, -368, 714], [-18173, 15758, 137, 3087, -1539, -2056, -715, 999, -1062], [-36521, -4184, -967, 3272, -768, 419, -611, -1456, 1733], [-5495, 11026, -1169, -1945, -2354, 472, -187, -1065, 604], [66773, -4923, -404, -5836, -1715, 264, 475, 96, 1242], [80317, 8491, 154, 1281, -805, -409, 585, 883, 843], [17869, -621, -982, -331, 2291, 4449, -884, -1709, 1718], [6493, -12647, -1313, 1318, -1478, 205, -1861, -1620, 1], [62297, -7406, -127, -1101, 1077, -392, -539, 979, -936], [-29070, 2811, -2913, -1240, 1378, 3721, -1255, -4278, 1190], [-20815, -9763, -1426, 2415, 2790, 801, -761, -2809, 97], [10840, 7550, -1940, -2932, 1482, 1528, 1636, 4, -1918], [15989, -820, 857, 644, 3189, 2135, -1309, -714, 1255], [109809, 5298, 939, 3689, -2996, 900, -1005, 431, 758], [-1113, -7715, 2918, 4943, -2027, -709, 1351, 1611, -1483], [43180, -5698, 509, 1985, -1051, -766, 2350, 3381, -1988], [7938, -5704, -862, 144, -1556, 1906, -1090, 64, 2394], [-28445, -7407, -468, 2787, 2372, 468, -60, -2495, -88], [-66934, -2576, -194, 1796, 1593, 224, 132, -3708, 490], [70675, -13255, -3872, -466, -1446, -582, 2627, -908, 542], [-61178, 10125, 1045, 2872, -2565, -1831, 3081, 3408, 1010], [7198, -4002, 2696, 6050, -1600, 114, -2644, 1366, 222], [711, -4656, -3373, -49, 615, 2288, 2809, -2725, 1292], [13036, 5752, 2287, -1411, -2357, -640, 1962, 3773, -778], [38258, 14372, -904, 663, 1587, -1801, 1159, -1927, 786], [-1179, -6614, -409, 1698, -1500, -207, 5565, 2068, 227], [8553, 7838, 77, 3885, 3143, 1774, -3063, -2243, -198], [72165, 5823, 788, 256, -926, -1408, -1497, 2470, -3038], [-83399, 8941, -724, -1385, 3133, -617, -1353, -351, -1151], [-30788, 6867, 1887, -3598, -308, -482, 375, -932, -574], [4436, 11489, 4421, -1640, -55, -3236, 623, 4944, -1666], [54467, -1996, -513, 5617, 128, 1182, -1681, -625, 1056], [17733, -1687, -1487, 1077, 976, 1161, -2836, -2116, -253], [37628, -16546, -20, -450, 560, -542, 744, 1284, -640], [3445, -20615, -3230, 530, 2013, 929, -224, -2152, -365], [-38259, 4118, 1679, -1280, -1113, -1921, -269, 1418, 457], [-32287, 19758, -2465, -736, 1578, 3259, -2109, 38, 31], [57345, -213, 1408, 1804, 1424, -2106, -1639, 1816, -64], [-1197, -14391, -2204, 4903, -2731, -132, 3512, 719, 734], [41783, 489, -90, 4272, -2060, -420, 1597, -1768, 2804], [-61814, 2835, 847, -494, 1620, 487, -958, 4, 2505], [46512, -6471, -1895, -4772, 1469, 2686, -41, -1420, 156], [-16168, 16964, -3116, -4031, 2886, 1585, -2088, -1833, -527], [2142, 111, -787, -420, -3487, 1559, -3028, -2520, 77], [-16024, -3374, 1790, 1047, -1509, -1521, 2120, 1083, -1433], [12433, -5159, -1886, 643, -16, 2509, 275, -1649, 3393], [-130029, 5175, 2002, 2587, -395, -1532, -2662, 1411, -1306], [98136, -14579, 787, 1334, 567, -1205, 2494, 438, -3055], [19339, -10869, -604, -539, 2668, 2009, -808, -4323, 1740], [-19718, 4193, 1379, -3145, 1532, -1602, -2388, 1213, -70], [-15203, 6, -1138, 4249, 739, 564, -4022, -3678, 1972], [110922, -9551, 1307, 292, 2066, 1037, -2520, -1104, 1935], [-43476, -5044, 1154, 2600, -2074, 1530, -4676, 1914, -1302], [31336, 4490, 1270, 3083, -1609, -1741, 1046, 5425, -1747], [-52435, 15265, 1876, 2282, 200, -1492, 726, 2442, -1863], [-11148, -7191, 1161, 1522, -5104, -1733, 2514, 5172, -1157], [51201, 237, -1220, -3337, 1561, 1917, -362, -2751, -748], [62756, -16650, -4714, -1735, 1515, 4248, -2873, -4049, 2660], [-66239, -6541, -1168, -201, 2245, -717, 1951, -57, -561], [61890, -5887, -1409, 482, -843, -1236, 145, -1914, 1832], [-27203, 5752, -291, -7540, 4446, 1651, -1277, -1624, -847], [1635, 4748, 1045, -3368, 293, -787, 2754, -3218, 2130], [-68140, -320, 483, -120, -3736, -2966, 4733, 3023, -412], [39036, 21643, 686, -2637, 1449, -2475, 598, -1641, 925], [-38959, 6455, -338, 2000, -1374, -2154, -1245, 822, -1390], [39675, 2240, -1753, 1754, -1032, -1169, -1201, 884, -753], [-33542, 8592, 302, 3696, 456, 1340, 570, 1038, -1038], [-54740, 1202, -2158, 1263, 891, 2409, -212, -1933, -1445], [-33602, -3780, -2120, 1443, -1371, 791, 2540, -1151, 323], [-9380, 2177, 289, 1282, -1826, -4061, 3768, 2918, 1], [46475, 9387, 1629, -51, -2084, -509, 1130, 2248, 1105], [34052, -9326, -5130, 453, -1809, 1955, 224, -4687, 1199], [24702, 5085, 397, 3537, 690, -218, 805, 1955, -3583]];
    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_z();".
// 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_z(:prec:=9)
    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_z();".
// 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_z( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1840_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![53104, 286800, 42737, -87343, -4928, 6502, 278, -148, -3, 1]>,<7,R![26025813504, -13686546952, -2543169384, 51541174, 22839351, 521969, -47585, -1613, 25, 1]>],Snew);
    return Vf;
end function;