
// Make newform 847.4.a.k in Magma, downloaded from the LMFDB on 25 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_847_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_847_4_a_k();".
// 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_847_4_a_k();".
// 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 := [1488, 1820, -2076, -787, 584, 73, -45, -2, 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], [-12, 0, 1, 0, 0, 0, 0, 0], [30592, 15632, -22022, -3901, 2447, 232, -65, -3], [-17424, -52296, 15102, -991, -1611, 744, 53, -25], [240, 42390, -1065, -11696, -269, 961, 22, -23], [102432, 36188, -31288, -23725, 1909, 2154, -21, -49], [-10188, 21674, 9585, -8689, -924, 717, 25, -16]];
    Rf_basisdens := [1, 1, 1, 3568, 3568, 1784, 3568, 892];
    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_847_a();"
function MakeCharacter_847_a()
    N := 847;
    order := 1;
    char_gens := [122, 365];
    v := [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_847_a_Hecke( : Kf := Kf)
    return MakeCharacter_847_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, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, -1], [7, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [17, -4, 0, 0, 0, -2, -1, -1], [24, -4, 0, 6, 3, 2, -1, -1], [13, 1, 6, 4, 0, 0, -1, -2], [26, -7, 6, 1, -6, 0, 5, 3], [30, 22, -4, 6, -1, 4, 5, -3], [49, 5, 10, -17, -1, 4, 0, 2], [-33, -24, -14, -13, -5, 12, 2, -5], [154, -55, -2, -10, 6, 2, 6, -7], [28, 51, -12, 10, 3, 8, -5, -4], [-53, 10, -16, 23, 2, -6, -11, 0], [93, -33, -6, -15, -4, -34, -7, -7], [9, -18, 0, 30, -5, -6, -24, 18], [-280, -69, -10, 18, -17, -12, -3, -12], [-119, 64, -4, -5, 2, -20, 9, -20], [-266, -23, -20, -70, -13, 8, -3, 4], [181, 1, -36, 13, 1, 30, -16, 4], [65, 84, 10, 18, -15, 4, 1, 51], [105, -83, 76, -6, -8, -10, 9, 16], [-9, 113, 40, 75, 16, -20, -37, -1], [-120, 121, -102, 50, 28, 50, 14, -15], [285, 6, -66, 0, -31, 30, 2, -56], [66, -13, 44, 98, -23, 48, 19, 26], [77, -27, 6, -107, -15, -14, 16, -72], [205, 46, -14, -5, -49, -80, -6, -27], [519, -239, -32, -66, -55, 14, 9, 14], [-365, 75, -46, 76, -2, 16, 58, -51], [706, -22, -30, 23, -67, -46, 9, 28], [-223, -300, -22, -110, -13, -18, -39, -51], [199, -63, -90, 154, 48, -16, -41, -80], [-301, 57, -10, 61, 12, 30, -71, 79], [-162, 124, -48, -49, -137, -70, 0, -27], [-484, 274, -64, 105, 5, -88, -45, -114], [461, -555, 114, -51, -31, 2, 36, 96], [-530, 238, -10, 20, -22, 110, 54, -2], [127, -384, 130, -175, -58, -90, -87, 34], [221, -27, -230, -95, 17, 74, 32, -40], [-355, -266, 204, 72, -10, 18, -1, 41], [788, 76, 172, 199, 53, -150, -16, 5], [1106, -92, 106, 87, -46, -144, 41, -38], [1223, 66, -66, -251, 51, 12, 12, -43], [-107, 277, -114, 31, 123, -48, -32, -122], [-448, -167, 54, -48, 57, 110, 73, 156], [713, -326, 16, -207, -106, 30, 87, 32], [1029, 164, -24, 297, 80, -54, -103, 204], [563, 34, -36, 123, 91, -110, -76, 49], [2070, 187, 62, -159, 81, 138, -20, 172], [390, 263, 124, 423, -32, 2, 21, 121], [-458, -447, 126, 10, 7, -80, 3, -112], [-1141, -147, -74, -119, 91, 68, 76, 36], [-863, -517, 380, 155, -40, -44, -41, -43], [925, 119, 208, -340, -54, -114, 56, 141], [-315, -57, -234, -336, 55, 30, -150, 115], [689, 62, 30, 549, 4, 0, 129, -36], [-1365, 1381, 86, -79, -36, 38, -77, 85], [2036, -472, -200, 481, -15, 178, -16, 5], [-1949, 137, -114, 316, -178, -24, -87, 148], [3192, -295, 164, 141, 81, 100, 95, -53], [-159, -723, -34, -181, -209, 228, 62, 56], [-1321, -615, 120, 247, -209, 170, 142, -42], [952, -854, -80, 436, 207, 202, -21, 103], [-3405, -354, -18, 177, 24, 284, 57, -62], [2070, 468, 226, -208, -120, -94, -82, -140], [661, 266, 352, -668, 204, -96, -186, -16], [1595, 55, 290, -185, -25, 118, -166, 70], [-80, 118, -30, -437, 200, -172, -118, 55], [1417, -583, 208, -289, -10, 160, 123, 407], [2364, 835, 168, 72, -151, 0, -119, 152], [-5374, 1418, 330, 648, 250, -34, -28, 28], [-374, -239, 496, -734, 301, 162, 219, -40], [1652, -650, 46, 102, -82, -342, -288, -234], [-3197, 879, -148, -217, 69, 142, -176, 82], [1719, 330, -50, -351, -277, -212, 52, -7], [5782, 2241, -372, -242, 84, 64, -46, 75], [-491, 1222, -596, -175, -49, 190, -82, -171], [545, 592, -98, -645, -239, 176, -64, 29], [1682, -634, 172, -677, -377, 20, 49, -418], [1071, 286, -26, 293, -113, -60, 246, -133], [-2306, 1433, -46, 323, -100, 28, 169, 329], [167, -73, -292, 3, 78, 388, 13, -165], [-705, -178, 462, -67, 118, -316, -85, 466], [2477, -368, -110, -305, 152, -138, -21, -268], [-4937, -45, 248, 296, -171, -314, -107, -54], [995, -1477, 320, -732, -171, -190, -269, -8], [-1938, 2004, 2, -30, -73, 260, 5, -181], [3044, 1124, -1042, 27, 67, 380, -294, -31], [3503, -938, 326, 538, 319, 116, 100, 108], [3569, 221, 38, -287, -143, 372, 224, 12], [-176, -408, -420, 577, -301, -186, -206, 413], [-4727, 28, -82, 239, -72, 614, 243, 184], [-6682, 1109, 6, -420, -265, 426, 163, 66], [7222, 646, 168, 428, 24, -128, -348, 26], [1114, 283, -58, -361, -278, -116, 408, -4], [-3105, -1517, 184, -261, 639, 282, -320, 404], [228, -1033, 626, 137, -264, 58, 54, 202], [-3141, 1931, -1130, -619, 83, -326, -228, -648], [950, 925, -674, 852, 39, 2, -137, 470], [7195, -329, 546, -205, 49, -130, 154, -468], [3906, -1433, -1244, -729, -322, -28, -12, 344], [787, -99, -598, -358, -84, 592, 384, -197], [5793, -1721, -284, 1127, -381, 312, 222, 112], [-8104, -805, 1194, -384, -140, 190, 430, -211], [4049, -1893, 682, -68, 310, -224, 79, 280], [4513, -736, 274, -1, 405, -120, -290, 331], [8651, 951, -406, 628, -194, 72, -128, -733], [1695, -686, 110, 1037, 59, 460, -194, 219], [16, 279, 132, 1276, 345, -424, -335, 6], [998, 2167, -724, -1206, -514, 30, 102, -783], [-6609, -588, -756, 399, -123, 458, 582, 637], [4816, -186, 722, -737, -465, -442, 543, 738], [-3091, 3151, -602, 867, 265, 238, 62, -102], [6059, 154, 28, 1252, 210, -40, -616, 170], [-1227, 1967, -500, 779, 643, -26, 566, -444], [1850, -420, 40, -488, -282, -568, 184, 852], [-4165, 2035, 62, -95, 471, -366, -492, 900], [4027, 2497, -540, 437, 241, 712, -36, -374], [8161, -1921, 1054, -50, 305, 342, -4, 543], [-5625, -1195, 518, -1870, 320, 348, 114, -287], [2409, 37, -734, -324, -463, -330, -108, 235], [-5500, 395, 256, 1348, 633, 500, -157, 210], [-740, 1494, 396, -236, -446, -72, -524, -298], [4542, -2992, -808, -2298, -555, -48, 237, 327], [-7598, -1969, 820, -1022, 355, -806, -559, 552], [-6067, 463, -1012, -1289, -373, 110, 896, -14], [-322, 2771, 472, -948, 827, -476, -351, -254], [-1123, -138, 364, -2946, -164, -102, -143, 521], [901, 436, 1480, 2719, 286, -376, 1, 120], [-2095, 3060, -458, -65, 796, -230, -519, -182], [3325, 3845, 58, -410, 164, 592, 894, 245], [1233, 4532, -134, 2369, -49, 388, 692, -213], [8071, -1056, -1302, 1193, 69, -164, -454, 233], [7699, -997, -1376, -857, -194, 1104, -411, 211], [-10667, -299, 300, -1264, -284, -398, -311, -716], [2460, -2193, 974, 254, 733, -254, 233, 434], [7667, 63, 0, -752, 548, 670, -1091, 658], [8295, -2666, 518, -3033, -498, 360, 763, 762], [15950, 2002, 278, 1218, -148, 486, 580, 342], [16115, 521, -1162, -995, 565, 242, -62, -548], [1886, 1426, -86, -3342, -360, 58, 82, -244], [6300, -102, 46, 1560, 480, 818, 68, 1108], [-7209, 3745, 1182, 1760, 495, -274, -704, 507], [12333, -1347, -202, 1209, 417, 24, -210, -290], [20828, -1012, 974, 1155, 154, -372, 854, 725], [-3667, 116, 1246, -143, 212, -810, 725, 802], [-16653, -124, -1246, -781, -194, 648, -315, -840], [16147, 393, 894, -643, -417, 686, 250, 530], [-3432, -5643, 376, 2276, 220, -794, -316, -769], [1796, -4000, 1368, -1628, -891, 46, 357, 203], [-1545, 1036, 118, -3685, -326, -710, 193, 466], [-62, 1331, -2106, -634, -105, 1006, -583, -362], [3431, 1335, 1072, -351, -137, -632, 678, 1886], [64, -2288, -372, 1757, 383, 1378, 302, 37], [-27587, 1187, 112, 1819, -141, -344, -364, 266], [619, 6128, -334, -1867, 1293, -740, -720, -197], [-2964, 4585, 138, -778, 680, 374, -972, -301], [1528, 7527, 328, 1916, 614, -412, 178, -697], [-20602, 3476, 138, 646, -790, 130, 574, 846], [3147, -226, 12, 1386, 568, -68, 234, 830], [-7373, -1642, -338, 73, -718, 1222, 1029, -1414], [12396, 2132, 16, -2037, 759, -496, 87, -1354], [-12259, 4056, -304, 778, -432, -452, -1214, -416], [-16450, 1233, 2760, -86, -157, -1464, 667, 328], [21858, -881, -296, 1565, 462, 502, -601, 885], [-1501, 5885, -1518, 2064, 79, -234, -338, -1647], [-8776, 503, 298, 1440, 36, -620, -908, 1479], [7931, 1167, 1268, 2920, 700, -1510, 387, -852], [-6653, -3871, 172, -409, 443, 176, 806, -1610], [4517, 3492, 50, 2466, -239, 478, -702, 848], [-10776, 654, -1598, 2388, 120, 470, -256, -2100], [16159, 1720, -684, 2170, 326, 476, -1028, 1186], [-4794, -1485, -1060, 1514, -7, -252, -11, -1052], [9588, 2512, -1560, -1356, -1787, 314, 19, -375], [5397, 1551, -632, -643, 309, 64, 726, 230], [19441, -2673, -1226, 53, 120, -982, -305, -1337], [-18083, 748, 488, 535, 266, -166, -115, -1366], [-3404, 4290, 202, -1136, -679, 644, 1113, -969], [4822, -1686, -308, -1895, -957, 70, 226, 523], [9284, 482, -372, 652, -118, -1296, 528, 1182], [18093, 1018, 814, -877, -328, 1348, -47, 500], [19566, -2325, -262, -612, 214, 526, 54, 2049], [-9179, -2941, 2582, -2521, -299, -1574, -822, 502], [12879, -4135, 1928, 192, 262, -1122, 659, 598], [-4844, 4652, -2228, 1888, 1297, 540, -2133, -3189], [-5053, -1029, -1102, 36, 40, -1000, 1071, -1544], [11098, -1563, 1654, 3718, 1842, -820, -512, 503], [3249, 132, -634, 3711, 288, 2560, 621, 400], [4411, -9176, 706, -1673, 1684, 658, -357, 514], [22262, -955, -1568, 1654, -305, 1440, -321, -974], [2797, -10380, 566, 811, -628, 1258, -419, 1990], [-1972, -1077, -1816, -2117, -1295, 1216, 353, -51], [-9715, 3170, 1390, 619, -342, -26, 1313, -340], [3832, -764, 548, 2906, -1649, -330, 713, 125], [5682, -5745, 2094, -547, -1379, -294, 1326, 1374], [-40611, -1733, 1102, -4375, -163, -1274, -32, 956], [-2033, -6963, -172, -991, -394, 228, 943, 1701], [25989, 3479, 912, -765, 407, -1914, -734, -8], [-6515, 9707, -398, -1363, 1769, -502, -50, 106], [11010, -4755, 1498, -4492, -1425, -1954, 343, -2992], [-17306, -6417, -552, 1279, -177, 924, -135, 341], [-3171, 2089, 456, 539, -1558, 420, 1185, -291], [6941, 10099, 468, 2911, -17, 702, -226, 1780], [-3286, 2017, -358, -971, 1134, -444, -1408, -332], [8761, -2545, 110, -4811, -1049, -624, 782, -560], [-11765, -7181, 364, -2869, 113, -312, -1208, 562], [31563, 1769, 2736, -1422, 157, -246, -635, 818], [-16081, -7144, 352, -6081, 80, 1658, 2119, -524], [-24396, -522, -442, -394, 435, -1286, -79, -249], [-33370, -2636, -902, 643, 1196, 688, 274, 1753], [467, -2219, -784, -900, -2298, -502, -486, -435], [-19745, -6511, -486, 170, -840, -688, 1913, -2262], [-11786, 3025, 1100, -3364, 717, 904, 263, -1218], [-8350, -11366, 160, -900, 773, -2758, -745, 703], [-7007, -929, 3230, -4022, -402, -1000, -170, 1287], [-6098, 5348, -3008, 4082, 1690, 160, -2570, -780], [14828, 3971, 1718, 2755, -56, -3012, -325, -575], [-20112, -6119, -1540, -360, -1260, -1518, -1006, -1151], [8823, -12595, -2254, -6169, 18, -534, 503, -3077], [-9093, 1227, -898, -2533, 803, 1148, -2, -658], [2665, 10626, -104, 848, 1644, 1920, 72, 14], [-2323, -1402, 18, 4146, 1495, -516, -1683, 2277], [2256, 9106, -2970, -723, -2331, -178, 727, -2868], [10507, 835, -362, -3209, 1192, 1210, -569, 529], [-47642, 2038, -2820, -2626, 375, 930, -619, 2435], [2874, 8860, 3544, -4170, 1576, 1788, -766, 368], [-13282, -10686, -2222, -3828, -858, 138, -1054, -2022], [-11459, 5452, -2356, 1661, -788, -736, -53, 128], [5377, 2258, -1002, -3599, -1103, 1204, 2666, -1133], [-19106, -7496, -1600, -899, 283, 292, -585, -2480], [8272, -9741, -156, -2051, -624, -298, 1561, -297], [-1811, -6120, -200, 1334, 1124, -336, -3638, 1244], [-3148, 6240, -200, 3531, -3521, -1704, 2187, -930], [17963, 102, 802, -6515, -762, 2520, 487, 762], [27693, -1517, 92, -4699, -2393, -50, 418, -1940], [4592, -2635, 464, 5974, 1178, 1410, -918, 3743], [37771, 543, -1082, -847, -1763, -2434, 1274, -96], [-6069, 1809, -52, 5049, 633, -982, -2438, -1036], [15570, 3309, -592, 2028, -2767, 104, -649, -640], [-15661, 1653, -4090, -6399, 7, 1216, 704, 1280], [11489, -8927, 1944, -2697, 1145, 2274, 2292, 672], [-11662, -5181, -3388, -2544, 84, 886, 124, 2169], [35253, 2329, -312, -921, 851, -858, -1092, -2242], [-1854, -2074, -246, -5670, -2268, 1842, 20, -2], [21876, 4763, 1360, 2756, 953, -1404, -295, -2062], [268, 6361, -808, 2993, -248, 1348, -270, -862], [-62545, 5344, -810, 693, 0, 70, 491, -2034], [1245, -2254, 2366, -7230, -237, -2440, -125, 2567], [8694, 3904, -2320, -5776, -960, -676, 2616, -2016], [16720, -1865, -1934, -6718, -1034, 982, 2550, 1035], [-13364, 2210, -236, 203, 2583, -1686, -1262, 541], [15904, -6547, -1362, 4090, 1536, 1062, -2356, 847], [31721, -2388, 3732, -1151, -959, -1470, 428, -2019], [-28939, -4411, -4060, 3679, -1559, -936, -356, -2440], [8822, -12335, 3144, -3474, -1104, -1614, 1260, -855], [42094, -6815, -804, 364, 1493, -156, 251, -122], [17861, 14595, 342, -479, -292, 366, -477, 1865], [-18349, 3813, -3724, 3315, -667, 1318, -882, 2252], [-15861, -4527, 2478, -3739, -653, 182, -2042, 790], [26051, -10670, 70, 2605, 2842, -542, 1541, -1054], [2943, -12037, 6146, 1343, 1292, -3026, -43, 1989], [-14121, 4983, -7364, -4066, -1926, -438, 971, -1414], [-1005, 8196, 4838, 7365, 761, -780, -54, 4925], [-21474, 4386, 774, 5930, 2824, 2094, -396, 4318], [9278, 22052, -744, -2222, 794, 1588, -472, -114], [-8041, 387, 568, -293, -885, 1122, 2586, 2654], [-28404, 14414, -1846, -1426, 2442, -178, -3210, 1636], [12210, 3037, 5324, 6336, 1223, -466, -1557, 1158], [36119, -990, 5168, 2118, 2618, 562, 2101, 749], [34082, -11285, -3164, 612, -1869, -1108, -215, -540], [14009, 1454, -2814, 2169, -139, 1108, -2678, -1853], [5086, -2326, 1868, 2131, 681, 182, -3730, 277], [-6269, 8409, -3188, -4205, -711, 3286, -738, 1216], [-21427, -9183, -310, -1419, 521, -864, 1112, 1192], [31927, -5506, 1144, -7, -1748, -196, 841, -1828], [36732, 2776, -856, -100, -279, -156, 1607, 3671], [-17159, -9970, -926, 6202, -1619, 1042, 1229, 1315], [-81361, 10679, 760, 709, 575, -222, 912, -1252], [51634, 7263, -1190, -6970, -773, 374, 859, -4812], [-8316, -10830, -366, -5503, -3201, -64, 280, 6047], [8171, -9351, -2548, -7175, -623, 2586, 1606, -3800], [15192, 6409, 2968, 3656, -1852, -3136, 656, -1425], [30111, -16967, -858, 1406, 1740, -1360, -2855, 3090], [15942, -570, -6122, 3333, 989, 2760, 2732, -989], [-20294, -7077, -3612, -1847, -1084, 4108, 3659, -2919], [-9879, -5419, -1622, -1953, -671, -2618, -1592, -2456], [-47272, 16006, 480, 564, 2422, 540, -3572, -2102], [27885, 9392, 2646, -3525, 173, 1672, 1788, 5073], [37399, -14547, 1698, -7111, -3220, -2246, -567, -1105], [-25583, 5476, -4788, 4946, 1633, -942, -1930, -5478], [52453, -7004, 1160, -9016, -2342, -2196, 1028, -3004], [-34198, 3491, -3494, -419, -298, -1482, -40, -2844], [-18432, -287, -6056, -2122, -729, 2770, 2337, -3486], [-15125, 2979, -3328, 4172, 4516, -974, -315, -1862], [-10535, 3024, 1382, 9163, 2304, 2780, -1327, 3128], [-17874, -8973, -336, 9201, -1059, 172, -1229, 605], [16511, -5468, 1058, 6247, 2986, 240, 45, 1148], [-8131, -7310, -302, -5667, 804, -2860, -4067, 2284], [-19295, 1621, -3612, 10219, -413, -2730, -2372, -2798], [-6756, 18534, 5340, -4806, 1149, -884, -1609, 1127], [-53249, -277, -1076, -1319, 1487, -3532, -4658, 1794], [899, -4018, -4156, 2101, 632, 2572, -1081, -4230], [5673, 11657, -2424, 5687, 597, -52, 3346, 2338], [-9267, -6681, 2134, 9056, -618, -1504, 1874, -4339], [-7861, -18391, 5824, -13253, -561, 1808, 1402, 1290], [-85475, 10400, -3440, 5182, 1742, 242, -1469, -2899], [-1978, 17061, -1708, 2239, -2318, 2710, 3303, -2343], [26562, 132, 6400, 2330, -2819, -1948, 2261, 2211], [7153, -9055, -2790, -6781, -1569, 252, 1342, -1892], [3810, 1866, 4160, -5634, -1937, -364, 1295, -3685], [36625, -5189, -896, -769, -2152, -6348, 781, 561], [10067, -28073, 7362, -1575, -327, -550, 600, 3934], [28472, -5480, 1520, -5189, 3893, -574, -1996, -1291], [-31706, -7222, -9832, -5246, -421, 3258, 4705, -641], [-30955, -1093, 3600, 6724, -2944, -854, 1149, 2448], [-49068, -13064, -2974, 1887, -3881, -1196, 74, 4805], [-543, -7777, 1008, 1727, -1139, -2854, -3264, 5212], [17950, -7689, -8146, -2506, 1332, 2564, -134, -1901], [20657, -4079, -590, -6864, -876, 4712, 1861, 2512], [12209, -15623, 8424, -12261, -1126, -1968, 467, 3525], [-1627, 4668, -2856, 6082, 3234, -674, -2875, -4417], [23793, -14517, -3364, -28, 82, -1310, -1276, -1903], [23678, -7222, 670, -8189, -3292, -2872, -113, -1142], [-4329, -16211, 4300, 4085, 2615, 1178, -1246, -918], [-9789, -2258, 3740, 8285, -1580, 876, 3169, 48], [7188, -9866, 238, -6943, 2701, 926, -2913, -404], [-45469, 7600, 948, -9176, -1541, -450, 2011, -5911], [33420, -10593, -1748, 8094, 2200, 1866, 124, 2583], [32653, -30235, 422, -6479, -3270, -2410, -1065, -1647], [17657, 653, 4386, -4103, 479, -1254, 564, 1070], [1936, 19725, -778, 2602, 2679, 1138, 981, 6312], [52276, 22240, -2264, 4832, -988, 1684, 446, -838], [37041, 8770, -6524, -2143, 3566, 2532, -2685, 3702], [52450, -3219, 2486, 10541, 3376, -2406, -1946, 1000], [-16863, 3306, 1914, 185, -2187, 1160, -654, 599], [-30706, -2544, 5816, 4636, -1032, 1464, 1764, 6608], [37995, -20348, 6266, 2231, 4807, 344, -1916, 3181], [-33815, -22505, 166, -13589, 169, 236, 642, 4358], [-641, 4157, -6962, -8987, -4748, -1554, 2625, -517], [-37496, 18362, -2840, -6985, -95, -4382, 2072, -5483], [-30516, 15141, 388, 4203, 2211, -3460, -3577, -891], [-17252, 31073, -2644, 8119, 848, 2022, 2647, -5171], [20158, 22668, -3404, 9356, -3640, -1824, -2170, 730], [11447, -15719, -222, -3437, -2803, -2110, 4992, -3082], [-12871, 16234, -1632, -7644, -6, -3530, 1129, -5761], [-64721, 12186, -978, -497, -5912, -318, -893, 4810], [63704, 10577, 7128, -9062, 4541, -3608, -3449, 944], [2834, -1555, -2832, 1711, -687, 156, 659, -4071], [32969, 17237, 2192, 6147, 265, 898, 4008, -3560], [75873, -11922, 4258, -2692, 1255, -854, 2059, 1131], [-45238, 3229, 780, 11878, -1332, 3358, -2030, 2943], [-27204, 7866, 7554, 3818, 78, -706, 2902, 7544], [-45956, -2772, -460, 16, 1677, 4368, -4585, 1347], [73972, -2733, 3222, -5902, -2110, -298, 1752, 1309], [9732, 5954, -9018, -762, -510, -1234, -2052, -2686], [-65868, -9365, 3368, -315, 3746, 1628, -1148, 2182], [14293, 16096, 2348, 14192, 2358, -7832, -3386, -3202], [8202, -9736, 3056, 6594, -228, 148, -502, 800], [39960, -11456, 856, -4822, -3792, 396, -902, 3816], [5702, 13898, -3776, -3848, 2326, 400, -2580, -8566], [49200, 3400, -1950, -7965, -401, 4180, -648, -877], [20906, -15359, -592, 2836, -747, -1208, 3135, 1804], [14211, -15184, 92, -15496, -487, -2338, 864, -2358], [-38334, -2360, 150, -820, -3383, -1290, -3075, 2455], [-74112, 1259, -3320, 1995, 149, 2736, 89, -3931], [15695, -12200, -380, -5154, 1333, -6906, -389, -1797], [34866, 4202, 2774, -1192, -1137, 2058, -781, -4757], [19734, -11179, -1884, -3342, -3673, 2788, 4263, -3258], [-94396, 29817, 5036, -1467, -760, -2988, -1552, -1368], [4385, 15390, 1864, -1097, 3560, 8328, 4805, 3370], [-44980, -6449, 4740, -3410, 508, -5374, 2618, -3195], [38, -16927, 904, 5040, -2191, -3472, -2463, 372], [-30812, 7124, -392, -2312, -4531, 220, -599, -2567], [28435, 27809, -136, 1562, -2858, -1234, -381, -5674], [-9669, 20038, 1872, -2478, -869, -2670, -2043, -2373], [26194, -21139, -4406, -4772, -1384, -4202, -2202, -665], [1895, -30509, 4624, -8765, 4338, 1556, 4123, -3283], [-21955, -429, 7536, -4917, 2685, -2518, 342, -262], [-25307, 18620, 1598, -34, 8357, 3350, -1424, -1674], [-67534, 8795, 4842, 3142, 440, 272, 3842, 1547], [11379, 12195, -9578, -379, -3219, 3326, -3440, -138], [-9318, 11140, -1312, 8649, 4667, -1790, 4230, 995], [-4959, -7168, 206, -4132, 997, -1500, 4370, -7786], [412, 16838, -6556, -3292, 3502, 1320, -2232, 1042], [-27668, 8343, -1014, -1328, 5819, -1762, 815, -1620], [99673, 5240, -11068, -2315, -1827, -14, 0, 1521], [-7613, -14177, -9744, -8585, -2531, 736, 3204, -1782], [-97280, 2872, -1764, 2084, -832, 12456, 2924, 980], [-15862, -16907, -3032, 2118, 1417, -5146, 2387, -512], [40866, -1564, -11700, -6087, 3009, 7348, 4353, 1342], [-100359, 5431, -1560, -2169, -4769, -2040, -4382, 3160], [-7681, -10873, 2, -14310, -1734, 1048, -2275, -1800], [30022, 5620, -5668, 2513, -891, -8742, -4188, -2093], [22162, 34614, -2836, -3644, -5406, -1020, 2838, 708], [-72152, 2179, -7330, -15344, 379, -542, -671, 4080], [-67814, 8649, -9058, -1576, -2056, 3822, 5384, 1573], [4938, 12314, 5964, -1138, 2670, 3176, -6914, -554], [-113860, 3033, -4728, -11726, 598, 3014, -962, 4235], [32959, -21104, 3600, -1712, -870, -3358, -1931, -1191], [-31838, 12322, 2854, -2413, 2472, 2456, 417, -2836], [-27291, -20209, 1116, -424, -2078, 3458, 1760, 8629], [-73324, -8388, 524, 7462, 2804, 3776, -2514, -260], [-5226, 30615, -7634, 3012, 2847, 872, -3205, -612], [47584, 5827, -1350, 1552, -3113, -2446, 2731, 2002], [-70262, 20899, -9136, 802, -2654, -4466, -4282, -5335], [4447, -5296, 11364, 2282, 570, -5256, 3782, -652], [63200, 6914, -5720, -2448, 1166, 7076, 6896, -4594], [73429, -6425, -2114, -11626, -4652, 100, 2219, 1914], [74681, 1455, -392, 15573, 634, 2320, -555, -1695], [59706, 13835, -16464, -9228, 2040, 6466, -2890, -3421], [-883, 14635, 2152, 1891, 1315, 6528, 5382, -1108], [8481, 10979, 2358, 9701, -2545, -7778, -2668, 1834], [1748, 3239, 2190, 4191, -3091, -310, -5670, 5200], [104964, -7551, 3340, -1017, 1679, 768, 2519, -1227], [-11909, -8767, 10430, -14446, -1062, 2140, 1158, 3285], [50774, 9686, -308, 8112, 952, 6196, 3170, -92], [1388, 9920, -2516, 5068, 2198, 3832, 2788, -2892], [-86351, 27737, -9620, 5663, -483, 6038, -1516, 1540], [-54082, -11535, 8968, 1510, -1324, -1546, 3902, 1411], [8556, 13116, 996, 13814, 1304, 256, 2670, 4852], [8911, -18785, 858, -11518, -5280, 2288, 3384, -675], [-31113, 14239, 13730, 14970, -2410, 1288, 1557, 5168], [21138, -22527, -3414, -9748, 1736, 4090, -3936, 637], [52769, -14710, 928, 2662, 672, -8702, -2985, -3409], [-106975, -8599, 3052, -15653, -3079, 6432, 2498, -374], [-51995, -7248, 2270, -3091, -5740, 312, 1863, 2854], [43729, -29540, -6092, -13979, 1280, 578, 793, -4072], [-23361, 4143, 4690, 13377, -5143, -2720, -4246, 4628]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_847_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_847_4_a_k();".
// 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_847_4_a_k(:prec:=8)
    chi := MakeCharacter_847_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_847_4_a_k();".
// 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_847_4_a_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_847_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![1488, 1820, -2076, -787, 584, 73, -45, -2, 1]>],Snew);
    return Vf;
end function;