
// Make newform 1840.4.a.ba in Magma, downloaded from the LMFDB on 25 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_ba();".
// 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_ba();".
// 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 := [57408, 864576, 2423016, 383603, -298243, -33828, 12246, 762, -192, -5, 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], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [-40, -1, 1, 0, 0, 0, 0, 0, 0, 0], [-13787240781840, 10772744588796, 9534676298151, -2615834670377, -675980973244, 137945915486, 14223759494, -2424760468, -90064369, 13492675], [46471969427424, 205167246593412, 86549522559441, -28864153120201, -6956017097892, 1380501328554, 148152752502, -23988456900, -932238831, 133928635], [7611310191408, -176960295677076, -40439695871631, 22121391694268, 2890995982752, -914845733946, -60353430060, 14353347492, 381349725, -74568380], [30379739386224, 159297910087380, 30440951108049, -20419450142675, -2581999841436, 869421171810, 57963763818, -13939762884, -380531223, 73632521], [44170193069544, 379569923446128, 81093834307938, -46055313237419, -6359378019096, 1903576710780, 136872598350, -30030328044, -873082230, 157136465], [-61611158517060, -216400233118308, -33907955846547, 27158690324471, 2953956686862, -1106918855226, -66106410600, 17149709286, 431383173, -88362863], [-98477372031504, -592582761122988, -98660434134705, 71994892186300, 8036919260232, -2890571942574, -177340372980, 44674875612, 1153582707, -230763412]];
    Rf_basisdens := [1, 1, 1, 189638109072, 1706742981648, 853371490824, 568914327216, 853371490824, 426685745412, 853371490824];
    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], [0, -1, 0, 0, 0, 0, 0, 0, 0, 0], [5, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, 0, 0, 0, 0, 1, 0, 0, 0], [6, -1, 0, 0, 0, 1, 0, 0, 0, 0], [5, 0, 0, 0, 0, 0, 0, 1, 0, 0], [24, -1, 0, 0, -1, 0, 0, 0, 0, 0], [-7, -4, 0, 0, 0, 1, 2, 1, 0, -1], [23, 0, 0, 0, 0, 0, 0, 0, 0, 0], [29, 7, 0, 0, 0, 0, -1, -1, -3, 0], [12, -5, 2, 2, 0, 1, -1, 0, 1, -1], [54, 8, 2, 0, 1, -1, 0, -2, -2, 4], [25, -4, 0, 3, -3, 2, 5, -1, 0, 1], [-24, -23, 1, 1, -3, 1, 2, -1, 0, 2], [-21, 0, -1, 1, 2, -4, 1, 0, -1, -2], [-13, -7, -6, 0, 0, -3, 9, 1, -1, 3], [-22, -13, 5, 2, 1, 7, -2, 3, 1, 2], [99, 12, -10, 0, 3, 7, -1, 7, 3, -4], [-31, 4, -11, 0, 2, 3, -9, 4, 0, -5], [-41, -36, -6, 3, 1, 8, -11, 3, 10, -2], [46, -27, -1, 4, -8, -7, 4, -3, -7, 7], [99, 9, 0, 0, -3, -12, 27, -9, -3, -9], [-65, -11, -4, -7, -1, 6, -15, 3, -6, 3], [198, -57, 7, 0, -6, 0, -20, -1, 3, 4], [286, -65, 12, 6, -6, 1, -22, 0, -6, 8], [290, -19, -7, -3, 6, 4, -8, 3, 6, 6], [-323, 25, -9, 6, 1, 1, 17, 2, 2, -4], [-309, 38, 7, 12, 2, -7, -17, 0, -6, 5], [214, -14, -12, 6, 4, -3, -26, -7, -3, 1], [406, -64, -6, -6, -7, -25, 34, -18, -14, 4], [-266, 14, 10, -11, -11, -16, -6, -4, -5, 27], [-100, -65, -1, -7, 3, 0, -48, 3, -6, 3], [252, -141, -14, 9, 14, -6, 1, 16, 2, -18], [263, 72, 33, -4, -10, 6, -3, -12, 0, 12], [390, -61, 1, 9, -7, -14, 20, 6, 5, 21], [493, 23, -29, -11, 8, 5, 5, -8, 11, -30], [554, -166, -8, -2, 5, -25, -28, -6, -4, -4], [-503, 23, 16, 3, -28, -1, -25, -18, -17, 35], [-109, 156, 13, 3, 14, 21, -5, 24, 23, -23], [985, 4, 24, -1, 20, 22, 33, 3, -2, 13], [-415, 45, -26, -12, -17, -31, 1, -13, 1, 22], [790, 114, -20, -16, -12, -13, -10, -15, 3, -9], [618, 76, 26, -4, -4, 16, 52, 10, -16, -14], [1257, 109, 32, 11, 16, 20, 47, 9, -16, 4], [494, -123, -30, -10, -16, -30, 72, -12, -12, -17], [291, 225, 4, 9, 8, 11, -31, 13, 28, -3], [797, -249, -22, -3, 19, -2, 1, -15, 14, -11], [-883, -108, -67, 12, -1, -8, 51, 22, 66, -43], [522, -143, -27, -9, -25, -55, 86, 1, 2, -40], [360, -13, 5, -26, -16, -26, 12, -21, -41, 48], [666, 61, -55, -11, 19, -26, 26, 11, 4, -41], [203, 434, -37, 4, -18, 8, -1, -28, -30, 42], [-8, 266, -52, 11, -35, -5, 20, 28, 43, -14], [1114, -349, 4, 10, -27, -43, -33, -32, 3, 42], [-1209, -241, -2, -34, -11, -27, 55, -7, -17, 50], [248, 31, -44, -28, 7, 2, 100, 18, 18, 17], [-257, 139, -42, 6, -10, 44, 65, 59, 3, 24], [993, 170, -48, 16, -3, -20, 38, 19, -46, 15], [-348, 247, -53, 19, 31, -22, -22, -61, -52, 7], [494, 503, -97, -5, 33, 59, -164, 31, -16, -32], [545, -61, 114, -25, 7, -16, 189, -27, -4, 9], [103, 183, -66, -20, 24, -19, 11, 7, 31, 51], [1554, -213, -64, -11, 39, 34, 126, -30, -7, 19], [2553, 301, -80, 22, 11, 11, -37, 37, 35, -50], [1943, -68, -50, -25, -64, -23, -88, 23, 17, 11], [-502, -661, 38, -22, -55, -19, -17, -80, -23, 50], [2857, 140, -99, 0, 20, 140, -103, 36, 62, -78], [-595, -42, -40, 11, 37, -2, -20, -19, -39, -17], [982, 87, 82, 14, 0, -33, -130, -30, -64, 45], [-967, 257, -62, -26, 72, 44, -11, 35, 77, -156], [2226, 189, 43, 23, -3, -40, -22, -67, 32, 1], [1521, 643, 22, 35, -12, 51, -31, -81, -26, 55], [1923, 387, 40, 37, -39, 80, -135, 5, 68, -11], [2682, -176, 36, 24, -40, 82, -36, -22, 10, 6], [1823, 46, 16, 5, -18, -26, -77, 57, 40, -21], [-1117, 124, 57, -28, 4, -97, -41, 40, 14, -7], [-1639, -447, 175, 4, 13, -27, 183, -42, -16, 34], [-1384, -461, 166, 3, 3, -81, -34, -88, -57, 155], [-1004, -282, 76, -48, -6, -110, -118, -176, -128, 70], [771, -300, -9, 62, -36, 33, -89, -73, 21, 57], [-137, 439, -108, -68, -23, -88, 129, -31, 41, -45], [-546, -128, 94, -33, 27, 2, -6, 29, 0, 41], [4797, 297, 16, -15, 12, -39, -9, -53, 86, 77], [4605, -20, -14, 3, 62, 19, 16, 117, -23, -45], [-477, 318, -102, -43, -25, -43, 16, 53, 107, -138], [708, 187, 117, 39, -37, 31, 38, 14, 1, 38], [-1268, -498, -20, -81, -68, -91, 316, -19, -40, 83], [153, -431, 156, -48, 28, -223, -181, -71, -53, 15], [-3301, -190, 13, -23, -50, -148, 97, -86, -61, 22], [-1573, 802, 81, -16, -33, -100, -141, 84, 10, -27], [735, -545, 88, -13, 59, 0, 259, 3, 42, 37], [270, 378, 164, 80, 96, 112, 224, 6, 56, -42], [2394, -366, -204, 13, -29, -32, 56, -88, 53, -141], [7203, -430, -97, 10, 50, 60, 279, 66, 38, -30], [-2958, 206, -216, 35, -2, -141, -158, -116, -111, 5], [317, 300, -65, 125, -79, -67, 113, -37, 68, 36], [-7134, -380, -176, 18, 24, -77, -78, 92, 20, -69], [-4242, -354, -232, 5, 41, 47, -162, 4, 141, 8], [-1814, -65, 125, -75, 49, 77, -546, -19, 56, 6], [-1896, -288, 112, 96, 42, 3, 114, 18, -58, -57], [-3369, -1471, 108, 15, 36, 7, 305, -6, -17, 175], [-6382, -1110, 42, -80, 91, -11, -10, 164, 86, -40], [-361, -291, 148, -27, -45, -176, -37, -161, -168, -41], [-594, 1096, -62, 54, 88, 50, -126, -20, -56, -136], [-1395, -438, -176, 17, -68, -252, 177, -193, -174, 85], [3052, 17, 97, -154, 82, -221, 402, -45, -51, -3], [1828, -931, -122, -45, 63, 269, -68, 240, 137, -204], [5375, -176, -111, -24, -13, -142, 183, -60, -56, 47], [-474, -420, -239, -7, 45, 102, 168, -73, -66, -54], [1240, -564, -90, 89, -62, -24, 144, 87, -208, 78], [-4973, 328, 95, 14, 129, -48, -107, -30, 124, 75], [-1038, 356, 20, -44, 100, 10, 144, 128, 36, -12], [-1397, 598, -36, 72, 44, 110, 213, 49, -15, 21], [-5766, 879, 140, 60, -159, -303, -161, -156, -99, 66], [-641, 567, -134, 41, -138, -83, -243, -143, -136, 149], [-184, -803, 171, 13, 113, 31, -142, -81, 26, -6], [-10761, 1111, 40, -45, 41, 76, -143, 91, 116, 13], [-2711, 350, -7, -32, -9, -205, -57, -114, 50, 112], [-3998, -526, -43, -90, -167, -124, 489, -171, -40, 97], [-698, 476, -82, 77, -5, 219, -530, 34, -119, 54], [2813, -205, 223, -66, -13, 207, 387, -86, -126, 78], [7926, -251, 91, 107, -121, -246, 24, 125, 22, 157], [-5343, 419, -110, -12, 36, 127, 67, -17, 241, -83], [-6302, -419, -55, 3, -67, 183, -560, 30, 69, -64], [-1150, -1010, -168, 4, 154, 118, -170, -88, 52, -178], [-4538, 1036, 162, 101, -37, 124, -102, 87, 84, -37], [-161, 818, -242, 14, -43, -475, 367, -233, -159, 72], [-541, -1162, -4, -108, -133, -152, 214, -243, -46, -31], [-5250, -710, 383, 33, -234, -7, -496, -47, -250, 261], [3907, 1007, -44, -24, 148, 143, -571, 91, 5, -115], [-12590, 1328, -180, 55, -126, 111, -28, 166, 177, -23], [-1962, -341, 201, -90, 186, 185, 4, 176, 68, -139], [-1821, 383, 0, -25, -12, 5, 7, 193, 232, -9], [-6538, -290, -78, 84, -19, -167, -538, 4, 2, 116], [6090, 1482, 66, -85, -48, 60, -138, -67, -84, 232], [4738, -950, -122, -250, -64, -112, -388, -6, -76, 86], [-3899, 1119, -220, -44, -63, -168, -29, 205, -1, -203], [-10901, 1443, -14, -177, -15, -102, 393, -173, 88, -15], [-15510, 1216, 46, 78, -161, -3, 166, 92, -208, -72], [-7355, 874, 544, -23, -163, -73, 557, 89, -136, 220], [787, -376, 321, -54, -216, -224, -81, -104, -200, 242], [-3785, 1134, -359, 65, -98, -41, -843, 46, -53, 85], [-17685, 6, -255, 106, -1, 15, 427, 30, 30, -48], [-1733, 2191, -212, 3, -207, -268, -61, 119, 70, -115], [2500, 793, 51, 37, -44, -152, 340, -103, -98, 58], [2947, -691, 322, -49, 122, -179, 761, 139, 40, 127], [3200, 1551, 10, 134, 55, 53, 207, 178, 301, -92], [7890, -899, 9, -153, -269, -260, -122, -63, 320, -1], [-2451, 288, -73, -182, -34, -296, -455, -40, 104, -30], [-6525, -484, -49, -73, -232, -122, 167, -456, -201, 274], [-6575, -1394, -264, 150, -177, -127, -27, -323, -131, 153], [5116, 288, -150, 203, -77, -269, 52, -14, 17, 66], [-11425, 1771, -130, 28, -321, 87, 801, 200, 4, -52], [-1804, -948, -222, -5, -115, 252, -1050, 136, 91, -85], [-15405, 204, -97, 24, -12, 505, 65, 270, 306, -231], [6769, -99, -194, 67, 68, -387, 345, -205, 82, -35], [-14061, 2149, 292, 147, -62, -387, 607, -51, -60, 291], [-10824, -303, -309, 261, 74, 247, 248, 71, -76, -141], [-4859, 856, -246, 115, -15, 304, -784, 127, 271, -11], [1117, -1727, 413, 43, 12, -264, -437, -262, -279, 0], [-400, 589, 131, 34, -124, -282, -306, -370, -210, 346], [5025, 1816, -178, 86, 385, 157, -157, 251, 137, -335], [-12962, -2164, 10, 36, 28, -285, 760, 16, 30, -57], [6629, 1916, -8, -78, 87, -135, -671, 321, -117, -245], [3420, 1425, -34, 67, -127, 229, 919, -54, 44, -154], [3850, -3362, -229, 159, 78, -7, 56, -79, -132, 17], [-12006, -77, 164, 17, -68, 385, -110, 124, -223, 96], [-9128, 2086, -162, 88, -298, 306, -196, 74, 180, 14], [-5184, -889, -113, -84, 192, -168, -134, 117, -59, -34], [-6415, 3633, 11, 73, 168, 239, 491, 244, -177, 76], [2511, 681, -430, 79, -220, 59, -455, 225, 322, -235], [-7490, 1631, 59, 59, 414, 375, -492, -73, -20, -49], [8496, -2586, 98, 102, -8, 62, -320, 96, 70, 288], [-344, -951, 140, 50, 1, -340, -332, -360, -362, 340], [-17218, -1655, 176, -84, -48, -200, 130, -38, -244, -19], [-8696, 1225, -123, 56, 30, 558, -112, 51, -399, -8], [4986, -2897, 585, 23, -225, 88, -94, 79, 84, 333], [11568, -117, 363, 19, -128, 137, -1196, 401, 128, 199], [-9260, -1881, 306, 100, 303, 176, 72, -4, 20, -93], [3002, -287, -441, -324, -12, 197, -824, 130, 202, -5], [-24312, -476, -598, 24, 278, 173, -236, -100, -264, 221], [298, -3775, -220, -37, 271, -286, -252, 546, 135, -166], [361, 1616, 312, -145, -91, -519, 228, -429, -321, 518], [5644, 3930, -132, 42, -34, 296, -128, 332, 264, 220], [6692, 2204, 59, -223, 172, 321, 394, -65, 124, -449], [5842, -677, 345, 8, -12, 137, 188, -216, -368, -365], [-4675, 1565, 261, -151, 97, 664, 234, 30, -122, -275], [-7923, -2838, 575, 78, -474, -525, 519, -142, -264, 481], [-1894, 62, -215, 36, 15, 391, -502, 405, 227, 144], [1494, -3395, 176, 75, -64, -781, 166, -172, -541, 580], [22074, 1873, 21, 11, 179, 694, -114, -245, -182, -373], [7267, 206, 255, 53, -190, -879, 503, -42, 23, 59], [2018, -2098, -264, 326, -106, 482, -758, 134, 128, -136], [-4, 5297, -141, 29, 266, 16, 706, 113, 432, -266], [15230, 1698, 292, 130, -234, 80, -1524, -54, 70, 62], [-4540, -981, 242, 251, -389, -71, 1197, -110, 106, 116], [8612, -1007, -767, 157, 259, -197, -608, -35, -50, -278], [-3082, -610, 576, -106, 280, 792, -470, 506, 170, -206], [1558, -2480, -386, 96, -42, 270, -1338, -268, 98, -2], [19067, -3816, -339, 181, 46, 56, -217, 368, -43, -396], [-7857, -4753, 25, 209, -124, -70, -551, -416, -39, 578], [10167, -1169, 547, -236, -230, -757, -114, -658, -409, 219], [535, 249, 709, -169, 58, -67, 493, -596, -311, 764], [10124, -1151, 775, -140, 262, 364, 530, -223, -251, 68], [35122, -1096, -94, 23, 163, 35, -530, -294, -213, 34], [3338, 527, 445, 4, -48, -349, 8, 193, -63, -451], [-17649, -2075, -974, 202, 315, -82, -405, 243, 171, -313], [20753, 1887, 189, -188, -223, -698, -567, -508, 30, 103], [3876, 892, -446, -203, 244, -342, -204, -63, 462, -646], [-20672, 295, -555, 57, -253, -72, -864, -595, -488, 179], [-14226, -3321, 537, -110, -132, -247, -418, -93, -1, 81], [1549, 2074, -163, 195, 140, 870, -823, 376, 753, 78], [12930, -864, 246, 29, 345, 580, -1098, 335, 514, -55], [18772, -1490, 456, -86, -216, 418, 682, -80, -436, 68], [35565, -1669, 166, -65, -589, 52, -1369, 361, 278, 95], [15364, 851, -627, 71, -219, -527, 462, 47, -4, -314], [-10072, 136, -592, -118, -238, -323, -350, 148, 544, 239], [12891, 1299, -246, -226, 480, -546, 435, 517, -137, -368], [5237, 550, 641, -179, -3, -477, -415, 271, 328, -426], [8183, 1703, 200, -147, -26, 540, 609, 153, 382, -444], [11787, 2821, 82, 146, -40, -578, 807, -371, -137, 278], [5459, -123, -138, -227, 662, 371, -1489, 193, 214, -11], [6510, -5334, 751, 116, 289, 1039, -586, 39, -27, 550], [6695, -2761, 520, -212, -10, -424, -2455, -258, -118, 434], [13249, 792, 615, 412, -107, 23, -579, -176, 34, -18], [9458, -1011, 113, 81, 350, -559, -492, -95, -12, 61], [-3047, 3112, -304, -261, 171, -202, 1698, 197, 51, 141], [4201, 97, -825, 279, -166, -518, 1248, -182, -596, 138], [5952, 1201, 513, 392, -94, 187, -226, -176, -202, 71], [3361, -1313, -546, -443, 339, -56, 1115, -67, 64, 75], [-14264, -127, 848, 171, 122, 1258, 291, 422, 180, -392], [-31562, -2393, -344, -179, 295, 612, -96, 66, 433, -22], [-14004, 1032, -698, 64, -32, -84, -350, 284, 562, -760], [19274, -2938, 181, -214, -385, 352, -386, 343, 179, -229], [-7935, -601, -550, 293, 5, 784, 367, 99, -574, 605], [-486, 4075, -307, 259, 373, 199, 140, 361, -204, -622], [-15624, -1448, 74, 0, 42, -346, 468, -74, -404, -574], [-20443, -3607, 118, -102, 99, -294, -1961, -431, -159, 237], [-9738, 202, -196, 83, -216, 223, -514, 302, -273, 289], [26056, -2154, -339, 126, 21, -531, 1162, 207, 453, -823], [22367, 2647, -96, -213, -11, -498, -787, -409, -340, 527], [-6462, -7274, -588, 177, -76, 287, -484, -592, -147, -467], [-18004, 2232, 120, 156, -84, 913, -506, 94, -240, 105], [24611, -2600, -237, -399, -506, 298, 557, 212, -219, 398], [25730, 310, -606, 86, -526, -266, 54, -368, -496, 248], [10514, -3494, -351, 216, 315, 278, 77, 391, 438, -329], [-37114, 4052, 28, 272, -216, 561, 752, 732, 270, -147], [30142, -2339, 684, -360, -295, -985, 225, -596, -369, 264], [5287, 2954, 924, -121, -482, 424, 27, -971, -302, 557], [26930, -7528, 151, -5, 46, 667, 572, 161, -212, -337], [22246, -2964, 398, -178, -272, -822, 2570, -614, -278, 116], [21970, 1206, -154, 227, -287, 137, 684, 898, 551, -94], [14439, 3418, -73, -211, -413, 519, 219, 71, 292, 360], [-3820, -419, -69, 508, -346, 310, -394, 633, 533, 216], [18461, 40, 123, 272, 387, 74, -2743, -90, -98, -17], [26246, 1924, -458, -137, -70, 269, 2224, -224, 63, 177], [28225, -972, -1138, 81, -380, -190, -47, -577, -138, 64], [10412, -5704, 82, -290, -358, -458, 2596, 526, 452, -176], [-2704, 6666, 339, 96, -219, -116, -1265, -459, -302, 237], [3368, 3069, -451, -490, -280, -603, 290, 427, 21, 635], [-2062, -1152, -717, -1, 440, 551, -552, 557, 248, 245], [-8743, 1458, -617, -260, 46, -13, -1027, -114, -364, 127], [13088, -2201, -289, 21, -470, -158, -2120, -49, 380, 78], [-25812, 4906, 110, 300, -567, -795, -334, -542, 162, 76], [52533, -1886, 215, 205, -70, -3, -1009, 482, 583, -413], [-3518, 493, -1010, -159, 281, -928, -908, 188, -41, -132], [8617, -1958, -1086, 195, 386, -834, 1589, -213, 492, -958], [57268, -897, -83, 25, 435, 807, -820, 745, 506, -866], [-11709, -1162, -507, -114, -422, -87, 199, -316, -36, -315], [-19796, 4710, 301, 291, 106, -673, 1685, -99, -139, 521], [27628, -645, -329, -101, 570, 807, -796, 411, -74, 295], [-17387, -1925, 254, -247, -283, -876, -1673, 285, 536, -513], [11398, 5323, 1110, -611, 247, -117, 13, -172, -324, 778], [-28729, 1001, -338, 138, -801, -358, -951, -417, -287, -19], [6283, -2301, -368, 262, 451, 1033, 17, -421, -17, 44], [-20472, -4678, -498, 236, -332, -133, -2694, -570, -228, 137], [-23889, 3201, 425, 262, 215, 635, -3217, -452, 200, -380], [27234, -1589, 1275, 269, 48, -1450, 1992, -511, -872, 808], [21132, -234, -1654, 111, -33, 69, -180, -228, -653, 30], [40356, -5219, -1490, -197, 246, 66, 419, -342, -10, -176], [1664, -7038, 1296, 52, 100, 539, -1742, -416, -26, -19], [-786, 1276, -1344, -144, 356, 966, -316, 604, 794, -144], [-5381, -2090, -190, 513, -94, -618, 2325, -495, 464, 92], [14622, 1554, 110, 85, 669, -917, -2372, -132, 207, -528], [-30496, -5137, 1225, -87, -5, -408, 134, -152, -1091, 893], [21190, 1869, -484, 47, 336, 395, 1214, 964, 743, -1012], [13933, -1383, -272, 518, -152, 511, -2449, 993, 485, 205], [2275, 1945, -12, -368, -375, 132, 1475, -99, -335, -323], [1121, 3064, 438, -418, 289, 201, -177, 1067, -65, -563], [21824, 719, -270, -185, -217, -558, 2926, 102, -713, 697], [-24828, 14, -1204, 453, -127, 241, 1886, -116, -385, 102], [-27191, -4953, -966, 7, 739, 764, -179, 799, 358, 217], [-8254, 2346, -376, -269, -287, 1139, 746, -38, 21, -128], [-16319, 678, 668, 176, -372, -547, -1104, -939, -662, 1667], [-11747, -557, -1549, -466, 183, -44, -333, -210, 512, -834], [-7149, -11575, 79, 209, 592, 1636, -639, 774, 1163, 300], [-31956, 504, -1474, -344, 1324, 504, -666, 1106, 384, -498], [27080, -2377, 1568, -163, -129, 1165, 406, 898, 499, -257], [20593, -2052, 371, -664, 216, -376, -1889, -82, -882, -38], [34584, 761, -810, -277, 751, 211, -1408, 284, 653, -1210], [-36534, -1091, 12, -121, 259, 215, -2071, 74, 424, -170], [11422, -2246, 1280, -332, 185, -1411, -2076, -834, -218, 274], [3462, -910, 1056, -721, 117, 1101, -1700, 42, 797, -248], [5106, 11766, -588, -194, 364, 343, -630, 448, 194, -115], [-81574, 767, -1272, -207, 240, 38, 2115, -246, -666, -838], [37897, 2547, 1136, 422, -317, 661, 2625, -323, -617, 292], [-37291, 2057, 2243, -185, -162, 1106, 1113, -334, 121, -202], [53608, -703, 221, -213, 647, -416, -134, 388, 361, -543], [38624, 138, 1106, -106, -762, 446, 92, 536, 262, 1528], [-20695, -6134, 422, -48, -89, 1527, -2063, 811, 169, 57], [14883, -16, 351, 396, -45, 675, 1405, 798, 426, 38], [938, 4580, -1730, -577, 571, -288, -162, -635, 592, -801], [59422, -10094, -1486, -419, 81, -321, -780, -74, -147, 84], [-5323, 5263, -957, 105, -362, -751, 2129, -76, -471, 55], [52327, -2021, 1580, -8, -26, -798, 3697, -838, -878, 756], [2130, -6133, 35, 269, 925, 1587, -552, 1195, 1242, -1248], [16769, -1032, -377, 158, 340, -284, 831, -786, 788, -456], [-2992, -2809, -1080, 116, -956, -575, -1175, -1122, 195, 347], [-42219, 5183, -1222, -12, -806, 767, -3185, 539, 665, -217], [-17382, -4793, -166, 129, 39, 215, -1332, 1538, 681, -1160], [35328, -5603, 1142, -156, 176, -149, 126, -744, 352, -104], [-28571, -4048, -290, 60, 1042, 434, 455, 929, -267, 325], [34474, 3294, 12, -66, 896, 483, 2782, -316, 116, -809], [4357, -2984, 163, -676, -339, 198, 689, -748, -654, 623], [-24468, -4437, 44, 162, 1029, 816, 524, 532, -766, -126], [27496, 7670, 292, -19, -223, 1589, -1952, 380, 869, -672], [38076, 3355, 756, 261, 48, -378, -3161, -196, -550, 294], [20089, 6629, 1282, 64, -717, -332, -1737, -934, -350, -65], [-31688, -3950, 1662, 153, 463, -134, 1132, 341, -32, 949], [-12075, 11157, -30, -212, -236, 1255, 91, -365, 421, 119], [-11256, -6395, -247, -57, -258, 1121, -1842, 429, -1210, 39], [16095, -10953, -175, -282, 831, 172, 2645, 46, 68, 50], [32650, 7568, -1266, -327, -96, 111, -1290, -398, 601, 271], [22500, 355, -511, -510, 306, 1008, -1034, 246, 770, -750], [-28241, 6879, 2308, 212, -221, -572, 305, -51, -659, 877], [18560, -7961, 1273, -47, 673, 153, -2530, 764, 1577, -470], [24373, -4391, 1849, 461, -904, -578, -1997, 278, -461, 786], [1655, 2615, 1260, 394, -83, -1074, -111, -835, -1667, 279], [-69792, -6511, 1460, 347, -1005, -2353, 1290, -746, -929, 1084], [-17478, -7701, 3658, -102, 129, -96, 386, -802, 152, -23], [11919, 3547, 32, -183, 34, 852, 985, 545, -310, 60], [-12922, 557, -528, -736, -108, 937, -574, 448, 1372, -208], [-28091, 2340, -141, -245, -870, 1077, -457, -160, 1763, 51], [-36546, 8340, -412, -1246, -182, -1474, 472, -1262, -622, 998], [-19215, 369, -1284, -100, 256, -1029, 2043, -1759, -745, -277], [23225, 7179, -694, 261, 499, 1832, 895, 125, 212, -853], [39690, -2129, -551, 63, 38, -377, -1048, -195, 1214, -465], [-25669, -7165, 2410, 117, -1468, -1960, 2345, -1256, -469, 882], [33762, 3402, 2868, -525, -249, -613, 904, 716, 871, -270], [28077, -14667, -1758, -80, 28, -99, 927, -145, -195, -845], [-34598, -2990, -440, 101, 460, -449, -1778, 74, 817, 455], [-33069, -4083, -692, -1035, -218, 224, -2853, 391, 222, 276], [-8845, -1839, 0, 346, 178, -989, 5071, 155, -283, 963], [23626, -9788, -1609, 449, -450, -533, 2204, -1491, -710, 227], [-13792, -3224, 2022, 147, 553, 339, -526, 26, 1079, 200], [-3432, 4530, 2136, 739, 725, 2293, 968, 330, -319, 122], [1152, 1188, -1838, 29, 289, 1569, -1504, 852, 1091, -1766], [-4016, -1053, -440, -1120, 1255, -1485, -253, 546, -383, -1750], [34912, 3779, -1245, 697, 261, 1872, -6114, 495, 1354, -571], [9047, 2324, -181, -41, -312, -533, 1155, 1568, -337, 937], [-3921, -33, -160, 402, -486, 329, 2885, -467, -687, 1289], [62126, -1657, 1675, -353, -140, 361, 874, 633, 252, 299], [37710, -4972, 2248, -119, -2089, -906, -22, -866, -519, 1199], [4929, -4744, 2484, 170, -49, 617, 2221, -227, -593, 1567], [-39563, -7547, -937, 489, 68, 1781, -2583, -284, 137, 141], [-20780, 6511, 123, 51, 1227, 738, 2662, -213, 452, -1477], [24927, -7991, 677, 223, -212, -2223, 3621, -1100, -1191, 1290], [22941, 3212, 659, -234, 406, 517, -4043, -232, 396, -1403], [-32392, 4298, -682, -836, 408, -396, -2402, -540, 8, -1430], [-10956, 866, 180, 179, -1436, 1157, -1976, 120, 341, 497], [7929, -3473, -138, 275, -119, -1634, 2581, -2285, -710, 295], [27380, 8280, 686, 85, 441, -106, 2268, -188, 727, 331], [31569, 4535, 1693, -303, -254, 648, -6181, 314, -1193, 886], [-4008, -14274, 918, 815, 53, -813, -3048, -1628, -599, 996], [-49818, -96, -1247, -1068, 625, -216, -5277, -195, 536, -563], [-49959, -2526, 193, -460, -888, -2376, 3045, -338, -712, 1494], [39923, -5309, -338, 101, 984, 29, -4363, 1125, 216, -323], [-36686, 1391, 1472, -850, 571, 794, 650, 58, 324, -12], [-40188, -2758, -1426, -359, -125, -377, -4662, -1278, 577, 50], [-24768, -1453, -1193, -422, -710, 367, -5252, 465, 401, -113], [-8739, 9747, 785, -208, -947, -313, -681, 980, 38, 220], [40410, 7169, -1224, -1160, -496, 967, 2194, 668, 1244, 274], [-19875, -1728, 621, 35, 452, 1643, -683, 1610, 805, -1227], [68660, -5673, 1427, 452, 158, -151, -2098, 629, 137, -599], [49855, -3337, 600, -2121, -512, -519, 3677, -741, -536, 1383], [29616, 434, -2170, 464, 498, 211, -1644, 1284, 708, -883], [-35125, -10749, 3, -701, -496, -1010, -2022, 1084, 1014, 348], [-85372, -5485, 564, -57, 182, -338, 2769, -594, -230, 764], [46455, 14591, -1998, -215, 1259, 1676, 1205, 497, 1152, -149], [-78851, -3538, 2205, 729, -1681, -1027, 1617, 161, -1050, 2206], [-55182, 8090, -248, 591, -841, 2133, 5442, 812, 95, -302], [-339, 2513, -1401, -260, -904, 1325, 452, -378, -159, 417], [27510, 9388, -1788, 931, -756, 3, -124, 202, -223, -607], [16553, 1490, -927, -255, -1170, -721, 117, -274, -841, 581], [863, 2325, -1772, 548, 37, 1120, -1763, 107, -1925, 155], [10583, 7606, 102, 861, 262, 2217, -4782, -401, 589, -207], [-1509, -7357, 70, 414, -1585, 82, 4253, -731, 195, 469], [-41268, 4887, 1331, -1135, -227, 853, -1356, 821, -894, 748], [-8474, 5051, -468, 17, -672, 874, 1203, 786, 1482, -1970], [-32568, -6143, -1797, 109, 776, -256, -4172, -407, 2170, -2822], [6837, 7261, -3386, -74, 660, 408, 2545, 565, 299, 142], [39993, -2139, 1460, -191, 1500, -1004, 3763, 333, -306, 794], [66235, -2016, -655, -614, -1242, -175, 2783, -624, -1656, 1477], [-5999, -4028, 308, -1001, 422, -675, -3598, 159, 461, 225], [-21067, -11183, -208, -80, -1094, -2200, 3185, -773, -977, 88], [39846, -8078, 2091, -142, 399, -2337, 936, -737, 501, 97], [-35392, 3000, -88, 1020, -263, -261, 4314, -40, 1076, -306], [31226, 12331, -1189, -320, -660, -850, 340, 290, -394, 54], [6192, -5461, 2509, 417, 539, 1467, -196, 1831, 1062, 1348], [5064, -48, -582, 204, -490, -1940, 5110, -452, -406, 550], [-133845, 6663, 238, 268, -481, 2051, 1631, 1965, 825, -1014], [8964, -509, -294, 1675, 65, 61, -3942, -764, 659, -341], [46406, 2569, 2045, -131, -335, 1063, 2358, -93, -622, 348], [-43817, -6566, -1478, -655, 290, -230, -2497, 207, -638, 49], [2696, -6469, -1114, 481, -2007, -231, 81, 1094, 1176, -1666], [-52500, 6484, 1640, -924, 728, 923, 972, -622, -488, -215], [12960, 8319, 548, -559, -1058, -3780, -3847, -2080, -80, 1144], [-7933, -9536, 1525, 873, -436, 1761, 2287, 262, -165, 1423], [27141, 11244, 872, -1300, 60, -2970, -2641, 243, -645, 5], [46074, -10304, 1830, 1319, 343, 858, -5454, -201, -1860, 1333], [61161, -2106, -1028, 919, -96, -1348, -691, 1769, 542, -998], [-32513, -6451, -2778, 42, 779, -1264, -2965, -195, -845, -1277], [-144115, -2184, -1907, 126, -971, -1876, -3737, -1888, -1494, 493], [54196, 7416, 980, -1464, 248, 294, 1036, -210, -474, 592], [-75623, 14213, 1340, -597, -50, -1856, 1557, -911, 558, 882], [61455, -8051, 1730, 102, 699, 2083, -3955, 1565, 1777, 252], [62712, 5473, -595, 547, 667, 777, 4498, -329, 1130, -1530], [-5653, -1202, -887, 744, 992, -3202, -953, -989, -649, -520], [45249, -6355, -2094, -740, -43, 695, -3321, 1427, 447, -630], [43709, 8388, 1370, 393, 1813, 1348, -3453, 893, -202, -440]];
    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_ba();".
// 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_ba(:prec:=10)
    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_ba();".
// 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_ba( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1840_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![57408, -864576, 2423016, -383603, -298243, 33828, 12246, -762, -192, 5, 1]>,<7,R![-2101566628800, 344614205160, 48504293896, -4276110998, -395834563, 16807960, 1329984, -26286, -1932, 14, 1]>],Snew);
    return Vf;
end function;