
// Make newform 476.4.a.c in Magma, downloaded from the LMFDB on 10 June 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_476_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_476_4_a_c();".
// 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_476_4_a_c();".
// 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 := [-7516, -4232, 2031, 184, -87, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [574, -47, -151, 45, 3, -1], [-30, 0, 1, 0, 0, 0], [4314, 1243, -538, -71, 10, 1], [-3077, -2811, 387, 155, -7, -2]];
    Rf_basisdens := [1, 1, 117, 1, 78, 39];
    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_476_a();"
function MakeCharacter_476_a()
    N := 476;
    order := 1;
    char_gens := [239, 409, 309];
    v := [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_476_a_Hecke(Kf)
    return MakeCharacter_476_a();
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..prec]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 4;
    raw_aps := [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [2, -1, 1, 0, 0, 0], [-7, 0, 0, 0, 0, 0], [-3, -2, -2, 0, 1, 1], [8, -3, -4, -2, -1, -2], [-17, 0, 0, 0, 0, 0], [-17, -1, -3, 1, 1, 1], [-37, -3, 2, 2, 2, 1], [-5, -6, 2, -2, -5, -7], [-95, 2, 11, 4, -2, 5], [-99, -3, 9, -11, 1, 7], [-89, -17, -5, -5, -6, 5], [-119, 30, -2, -10, -2, -7], [-65, 20, -21, 5, -10, -3], [-4, -24, -2, -11, -14, -12], [-104, 32, -9, -1, 15, 0], [-113, 21, -15, -5, 16, 3], [-19, -5, 24, 41, -6, 21], [-167, 97, -18, 14, -10, 7], [173, -19, 37, 45, -10, 15], [-329, 88, 19, 5, -2, -15], [-190, 51, -16, 14, 11, -26], [-293, 60, -23, 9, -28, 11], [68, -117, -5, -4, 12, 0], [-223, -13, -1, -35, 21, -27], [-246, 141, -71, 11, -18, -34], [-80, 87, 32, 14, 13, 14], [-340, -126, -21, -35, 19, -8], [-565, 102, -11, -15, 26, 35], [11, -5, -24, -29, 60, 27], [-368, -8, 10, -32, 22, 10], [180, -12, -99, 27, 8, 48], [345, -42, 81, -16, 16, 31], [654, 38, -17, 21, -66, -10], [-673, -66, 108, 56, -30, -37], [219, -80, 52, -124, 9, -37], [-204, 133, 62, -10, -9, 10], [536, -173, -42, -60, 4, -38], [963, 251, 71, 29, 40, -13], [-193, 72, -56, -132, 34, -69], [270, -34, -102, -16, -64, 42], [-121, -37, 132, 145, 60, -21], [-372, -129, -41, 81, 64, 38], [722, 219, 22, -148, -5, 42], [-610, -203, 276, 6, 6, 16], [-872, 326, -113, -31, -57, -102], [-199, -371, 180, 48, 96, 123], [837, -182, -41, -14, -90, 11], [279, 240, 102, -36, 25, 15], [631, 281, 112, -100, -48, -73], [903, 440, -10, 34, 2, -45], [2362, 461, -105, -60, -72, 18], [1723, -467, -49, -141, 29, -23], [1815, -81, 234, 238, 174, 127], [-576, -402, -26, 58, -148, -40], [1694, 610, 136, 162, -42, -58], [-1999, -519, 250, 106, 132, 7], [-2601, 23, -49, -69, -39, 21], [2990, -342, 322, -93, -86, -22], [-91, 28, 183, 68, 44, -189], [1785, -653, 241, -59, 23, 125], [-1050, 563, 144, 240, 49, 94], [-1485, -460, -367, -160, 184, 111], [-1204, -545, 39, -48, -36, -40], [-33, -13, 163, 73, 43, 73], [-3829, -541, -432, -345, 8, -61], [-1388, 140, -394, -120, 102, 86], [-3164, 260, 105, 161, -105, -74], [-1542, 367, 154, -96, 247, 128], [2111, -362, -427, -253, 50, -137], [-183, -309, -494, 45, -20, -131], [1294, -339, -66, 276, 56, -104], [-3166, -446, -553, -155, -48, -126], [-5195, 688, 220, 254, 153, 89], [2151, -938, -95, -19, -2, -95], [-1414, 118, 394, 377, 242, 66], [-1842, -353, 305, 40, -232, -80], [-2195, 139, 920, 424, -72, 85], [-3456, 1418, 188, -278, -232, -70], [2205, 1864, 23, -92, -56, 63], [380, -1264, -265, 169, 184, 152], [-2684, -1065, 243, 139, 146, -40], [3167, 136, 217, 539, 138, 167], [-7310, 717, 220, 214, -60, 80], [-4578, 188, 120, -64, -106, 202], [-2928, -901, -137, -429, 10, 122], [3426, -232, 240, 341, 318, 2], [-3113, 402, -32, -302, -49, -337], [-5677, -468, -182, -90, -234, -65], [-125, -334, 18, 478, 493, 125], [-2986, 1243, 200, -202, 10, 188], [-938, 75, 549, -39, -66, -202], [5111, 745, -50, 127, -280, -113], [-2818, -1219, 452, 102, 191, 8], [3249, 582, 295, 80, 38, 233], [-2518, 321, -542, 482, -103, 272], [13429, -387, -71, 209, 50, 323], [-2167, -439, 197, -267, -253, -457], [-3271, -331, -451, 21, -377, -617], [1363, 694, -448, 232, 155, 439], [1566, -1720, -314, -738, -110, -420], [409, -1226, 146, 398, 537, 319], [-484, -416, 297, -1, -4, 356], [-6759, -505, -851, -365, -97, 21], [1928, -485, 859, -109, 358, 626], [16469, -260, -304, -32, 7, 163], [4055, -1089, -1036, -682, -36, -65], [-2715, 1100, -122, 382, 186, -135], [4084, 50, -320, 56, 208, 646], [-2217, -556, -1011, 428, -8, 259], [-8962, -1732, 1056, 479, -194, -98], [5309, 152, -123, 167, -586, -483], [-2672, -1586, 768, -186, 438, 74], [4911, -665, 724, 21, -52, -501], [412, -537, 133, 435, -168, 122], [-718, -265, -494, -874, -388, -262], [10843, -814, -687, 129, -362, -699], [-13110, -628, -245, -1075, 487, 74], [5109, 1183, -568, -447, -130, -63], [4179, -75, -107, 357, 161, 107], [-4133, -1394, 327, 629, -154, 415], [-11028, 1790, -28, -130, -124, -44], [2278, -139, -32, -200, -145, 132], [-318, 41, -820, -528, -906, -42], [-3480, 514, 1364, 480, 212, 538], [-13268, 1757, -1288, 328, 395, 188], [-3526, 1277, -820, 402, 154, -340], [5380, -41, 1091, 191, 758, 284], [-3445, 1682, 746, 880, 393, -325], [-5265, -704, -718, -474, -440, 315], [1772, -74, 34, -932, 96, -56], [7097, -963, -606, -1198, 90, -729], [2242, 1290, -817, 165, 412, 502], [10462, 862, 1056, 956, 532, 748], [-10829, -152, -413, 259, -284, -221], [9055, 482, -1050, -150, 303, 715], [-10634, -2038, -1514, -348, 190, 500], [-36, -671, 804, -692, -325, 662], [-2086, -111, -387, 169, 844, -104], [4052, -1953, -1662, -154, 310, -112], [-21551, 1163, -1183, 273, -149, 147], [-9150, 2204, 780, 1238, 322, 86], [13166, 371, 378, -788, -133, -160], [-7148, 1801, 1000, -194, -713, -706], [-1574, 1246, -142, -326, -698, -114], [3702, -3096, -1034, -1152, -654, -562], [-3120, 327, -1261, 1122, 208, 192], [18415, -1062, -56, 718, 477, 389], [18881, 1061, -128, 959, -120, 133], [-25332, 495, 80, -450, -61, 668], [-20422, -1799, 483, -386, 148, 402], [2985, -1807, 1790, 233, -822, 45], [19435, -506, 695, 32, -812, -233], [-7626, -2816, 739, 1075, 671, 24], [7593, -1303, 1550, 916, 720, 99], [-17635, 3014, 1144, 124, -518, -167], [-4128, 707, -189, -110, -188, -888], [-2846, -2886, 122, -1096, 74, -340], [-8313, 4133, -879, 219, -360, -677], [2755, -2292, -600, -138, -65, -89], [-10738, -4556, 930, -195, 1244, 546], [-5419, 3372, -1128, 536, 650, -115], [-6619, -1308, 2302, 442, -109, 1131], [29596, -4100, -92, -351, 104, -192], [-21223, 496, 1119, 1144, 192, 713], [-12438, -5086, -548, 266, -586, -406], [4679, -2751, 1341, -1385, -20, -1013], [-21398, 3874, 320, -458, 200, 164], [-2291, -47, 23, -443, -706, -383], [-6018, -2896, 762, -1846, 348, -154], [-11560, -3260, -841, 413, -717, -966], [7246, 1150, -3294, -1314, 64, 118], [7542, 3496, -606, -1809, -376, 78], [-10440, -1723, -241, 819, -162, 596], [-11582, 3269, 1755, 1004, -428, 182], [-18924, 502, -517, 1053, -85, 206], [-4945, 2420, 1084, 592, -1227, -131], [9322, -1699, -1413, -905, 48, 722], [-4618, 985, 1384, 1426, 375, 312], [10454, 3338, -240, -132, -56, -334], [-8208, -5469, 1260, 8, 1562, 580], [-21853, 4850, -1360, 470, 465, -455], [24835, 2513, 818, -1374, -264, 175], [21663, -2629, 308, 399, -564, -1241], [-23909, -1177, 1909, -105, -457, 319], [-2018, 2937, -1720, -802, 503, -122], [-21512, 1168, 881, 283, -291, -472], [-1479, 2956, -1995, 967, -1202, 357], [-8708, -358, 1756, -28, -106, -1932], [14183, -1403, -1761, 611, -70, 525], [-24629, 3277, -1485, 13, 353, -693], [12706, -2650, -424, -896, -232, 1298], [8218, 6363, -2668, -1724, -183, -960], [-5512, -1537, -530, -416, -397, 1154], [16100, 935, -1505, 174, 312, 160], [37986, -2861, -741, -477, 466, -144], [-1795, 836, 426, -1466, -203, -241], [10955, -2127, 1533, 1737, 270, 93], [2603, 4075, 218, 2168, 204, -175], [-11492, -5665, 3838, 658, 871, 432], [-25717, 4772, 273, -690, -644, 23], [30746, 3849, -590, 866, -1261, -28], [23907, 628, 735, -405, 406, -1145], [-25785, 1746, -1574, -646, 581, 561], [-5419, -1551, 621, -499, -141, -667], [-15805, 3027, 1744, 1658, 802, 1049], [18779, 818, 348, -592, 524, 799], [-15705, -1117, -2228, 1290, -10, -69], [368, -886, 791, -1351, -661, -1964], [8880, -5373, 2217, -393, 884, 334], [11174, -2116, 3987, -2377, -273, -856], [4281, 1276, 2969, 2111, 996, 2279], [34808, -4498, 1131, 121, 897, 408], [1538, 743, -2270, 528, -218, 176], [37921, 4275, -1515, -799, 66, -493], [20790, 2150, -792, -556, 392, 642], [-299, -8933, -242, -304, -714, 477], [7372, 2626, 90, -988, 1636, -8], [3554, 976, -4642, -1577, 528, -1486], [2546, -606, 1266, 953, -202, -1046], [-33732, 2089, 694, -1204, -1854, -1322], [21216, -7166, -1007, -77, -680, -1272], [7957, -53, -2556, -1436, -480, -253], [-14244, 7058, -581, -949, -1601, -968], [-35260, -6950, -490, 1235, -780, -24], [8164, -2260, -2350, -1102, -940, -314], [21186, -3180, 200, -1298, -1354, -2], [15735, 11933, -2946, -118, -1496, -1227], [-28018, -4378, 1619, -701, 831, 1504], [40332, -4042, -131, 2227, 462, 1204], [-50490, 1132, -1596, -1154, 458, 72], [-13162, -230, -4988, -548, 612, 514], [14922, 8632, -2635, -449, -798, -1578], [-10556, -3145, 970, 782, 2763, 1296], [-5845, 6576, 2629, 2195, -436, 217], [14544, -7300, -494, -562, 784, 2110], [-39452, -3705, 2200, 898, -993, 48], [-4894, -4411, -3128, -716, -219, -904], [26988, 7195, 3427, 2781, -156, -1036], [-23015, -2892, -1646, -1068, -1385, -839], [-26082, 5550, -2365, -499, -531, -1362], [-2568, 8178, -1478, 428, 1268, -484], [-22214, -4226, 4967, 1409, 2350, 1594], [-18882, 9321, -1953, 582, -984, 846], [1089, -4356, 477, -242, -1098, 373], [26924, -3409, 4806, 1344, -566, 354], [-30886, -5505, 1498, 2126, -732, 550], [-4657, 647, -5464, -831, 760, 1547], [-12927, -1168, 1066, -1186, -1478, 413], [146, 1416, 3165, -2161, -838, 602], [36926, 3023, -651, 3096, -1388, -602], [25233, -27, 1800, -1517, -740, -299], [12996, 1243, 987, -2766, -520, -632], [-17038, 6642, 253, -579, -989, 404], [-16245, -3382, -4890, -4322, -48, -1745], [17128, -5432, 1769, -2457, -683, -212], [-17839, -2544, -431, -510, 142, 2127], [-14265, 5075, 267, 425, 1324, -1269], [38465, -3890, 755, -2077, -1360, 669], [-16144, 701, -2885, -1451, -3152, -1780], [-9213, 5167, 198, -1005, -1166, -2037], [-2516, -9399, -45, -3456, -166, -1338], [-7758, 6321, 1215, 342, 1828, -1128], [40817, -5599, -1711, -87, 210, -1841], [-18951, -2063, -3337, 1117, -7, -413], [-10264, 7674, -3300, -761, -1410, -360], [-15523, -764, -5189, -1461, -1618, -1519], [-12025, -5333, 237, 25, -2491, -469], [10290, -5288, 4221, -201, 920, 1438], [22204, 2573, 527, 568, 3206, 1394], [-15782, 5668, 4316, -592, -402, 1050], [-6458, -1221, 3931, -499, -920, 204], [20313, -4617, -1410, 1993, -304, -2347], [45381, 167, 3254, 4004, 742, 1393], [-16944, 7679, 1909, 183, 1372, -108], [38951, 388, 1324, 3772, 558, -113], [-4948, 14208, 1510, 1717, -1702, -508], [22986, -3162, -3853, 909, -832, -510], [-6865, -5849, 6503, -1691, 875, 1353], [-46144, -2116, -502, -3356, -584, -1296], [-25441, -9464, 3975, -469, 672, -51], [14798, -572, -2668, 228, -1122, -1870], [-4082, 4620, -3849, -13, 541, 3824], [34607, -2486, -2707, 838, -2174, -2475], [1627, 1552, -1904, 2076, 514, 1819], [56231, 5925, -1360, 820, -554, -761], [-33068, -1318, -921, 159, -917, 3048], [-52673, -5240, -3999, 873, -1898, 189], [-79099, -5355, -5126, -1936, -180, -123], [-3511, -4905, 675, -1901, 1213, -145], [-22135, 4238, -3627, -3784, -436, -2389], [-44636, 4138, -4272, -456, 1836, -702], [-22511, 6094, 3073, -4730, -2068, 463], [-15364, 7325, -292, -554, -1877, -1668], [35861, -13423, -989, 2473, 640, 2393], [-9648, -4004, -846, -1892, -960, 1784], [-78742, 334, 2721, 1531, -525, 276], [-28101, 280, 4889, 780, -820, -2771], [52403, 3772, 5256, 3134, 2789, 1885], [33860, 14118, 192, -2174, 502, 1190], [4120, -5048, 3300, 1572, 1522, -2386], [-52317, -13138, 663, -277, 560, 1189], [-1617, 4765, -3537, -3591, 677, -1773], [19540, -7725, 690, 4124, 3957, 850], [30541, -9444, 7179, -799, -806, 1477], [11521, 11981, -2046, 2431, -394, 1077], [26147, 2955, 5283, -2331, 92, -1105], [28095, 2317, 5346, 6637, 3024, 2487], [9034, -7230, -2585, -1743, 610, 826], [-15791, 2366, 2395, 3368, -706, -1263], [-50068, -4307, -6412, -1702, -3393, -4504], [-12113, -1143, 9918, 1500, -2426, -281], [-1035, 7408, -5186, -518, -2976, 25], [51057, -4722, 4, -2336, -1030, 2341], [-23107, 13503, -242, -372, -586, -2479], [44671, -3054, 4532, 1322, -137, -2115], [-9564, 14425, 819, 189, -3136, -856], [57541, -5577, 7639, 2139, 1334, 3183], [21196, -3748, -1536, 876, 4166, 2146], [-43024, 1975, 1912, -360, 794, -2028], [-2515, 5398, -3637, 2463, -2002, 1333], [12436, -1937, -6, -3672, -2741, -2786], [-15889, -5737, 6764, -1621, -1080, -1553], [-57214, -3, 251, -4425, 1620, 180], [53792, -4920, -1942, -1514, -2694, -1786], [-6045, 14348, 5142, 5054, 79, 2447], [89083, 4968, -487, 5620, -2228, -639], [-26782, 8866, -420, 766, 3002, 2866], [13764, 8486, 1751, 5401, -695, 152], [19161, -7648, -6046, -2202, -147, -3233], [68488, -16291, -1448, -2332, 897, -1440], [36790, 12125, -4640, -950, 218, -2944], [-5328, -6083, 11076, 3388, 1271, 4936], [9855, 10324, 4224, 4350, -403, 2439], [12806, 9330, 2696, -1410, 1364, 3824], [34852, 5660, 4727, 2953, -130, -2140], [-28979, -493, -4621, -2573, 862, 4359], [60227, 7325, 4907, -265, -2, -2319], [-7538, 3158, -9532, 1778, 3018, 2186], [-6118, -24490, -1029, -711, 124, 842], [-36006, -5622, -2806, -1009, 1090, 1314], [29704, -4448, 5646, 5036, -2336, 1872], [-25071, 4477, -1980, -345, 4068, -1571], [-4820, 9944, 2655, 1197, -1762, -1460], [40055, 7983, -3231, 605, 1099, -2201], [6682, -1963, -8761, -1818, 1776, -2460], [112761, 15529, -9160, -4505, 8, 357], [59015, -7820, -2967, 6510, 1392, 1479], [-58181, 6249, -4367, 5099, -1056, 2935], [-9489, -947, -7163, -1195, -1439, -1183], [60088, 711, -2667, 1155, -4558, -214], [21852, 10142, 3637, -69, 1090, 1632], [2201, 17504, -2383, 3496, -710, -3615], [-31330, -4080, -6034, -4433, -196, 122], [-23443, -19356, 4205, 5589, -1910, 2429], [-11645, 7247, -114, -4716, 510, -2739], [39540, -14871, -1904, -3708, 222, -2152], [-19307, 5122, 6845, 113, 4194, 4729], [64264, -18668, -612, -4684, 436, -4080], [517, 11310, 3324, 4038, 1519, 1735], [-15738, -5199, -9189, -5716, -3720, -5406], [-65641, -3205, -1632, -3325, -2584, -1441], [-7646, 3820, 3233, -1627, -4155, -32], [32414, -7099, -2882, 1740, 1369, 10], [-21236, 1198, 1030, 4827, 768, 2604], [-69891, -965, 365, -4437, -612, -1959], [-7279, 10708, 4700, 5484, 1466, -3903], [63394, -14497, -1473, -4281, -456, -728], [-17997, -1056, 6802, 3470, 5356, 1779], [-26932, -6617, -2872, -7800, -292, 312], [41915, -9598, -4815, 3579, 934, -995], [22840, -4922, 6697, 4279, 1104, 5380], [47846, -19053, -3191, -6297, -864, 1850], [35187, -2645, 687, 1243, 4709, 1353], [3220, -4721, -858, -3454, 1262, 1352], [10220, 8355, 2745, 6387, 620, -400], [-38181, 6538, -5173, -3155, -4774, -2793], [-29470, -10430, 3056, 4402, 1316, -3116], [64718, -13659, -5643, 1577, 1462, 628], [-3179, -11463, 8799, 605, 2140, 4705], [-98464, 14306, 1144, 1152, -600, 1326], [60656, 12929, -1081, -397, -4554, -1008], [-17450, -9974, 5282, 7352, -3176, 2992], [10500, -16131, 568, -3428, 1202, -1516], [-5382, 10094, -676, -7344, 1272, -2514], [-2048, 13500, 1468, -2944, -2124, -1288], [9440, 7194, -8565, -2859, -2789, -4286], [19357, 6039, -2409, -4209, 3103, -1619], [32355, 13451, 5702, -40, 1550, 3381], [-58382, 9054, -1926, -1592, 1682, -1960], [-74494, 3960, -10154, -848, 26, -930], [13655, 26975, -1048, -721, 656, -3045], [27814, 28225, -4504, -1592, -3237, -2370], [-53773, -3385, -688, -4551, -1048, -681], [-98350, -21575, 5179, 2981, -538, 964], [-93529, 13728, -3039, -4265, -1806, -6663], [-42077, -127, 420, 9194, 1008, 1491], [-105633, 1353, 635, -147, -1017, -1521], [4050, 19316, 4190, -2261, 4056, 4882], [51146, 18542, 532, 4890, -3678, 462], [-84164, -7576, 3058, -3907, -1734, -1784], [-54995, 3816, -7262, -1414, 2886, -967], [-14965, -13857, -6543, -59, 3090, 1085], [2166, -3246, 8139, -2815, 1289, -2948], [-18768, 10392, 7686, 10774, 2806, 2976], [-141310, 18904, -2366, -365, -728, -4842], [-25430, 5846, -6031, -3665, -3562, -5650], [8384, 17672, 4359, 1849, -1499, -1728], [-33668, -12607, 2780, 4164, -3052, 2340], [-43486, 3923, -4815, 746, -2864, -290], [-904, 238, -480, 3967, 1294, 2548], [96339, -6359, 2144, 4923, 1846, -1337], [-8394, -6348, 1659, 7797, 2121, 2508], [-75966, 7018, 4271, 3253, 1980, -2186], [33559, -4253, -5269, -3555, 2606, 4143], [6042, 3199, 2029, 1565, 1854, 2330], [3159, 10802, -803, 8140, 3866, 5171], [-77086, 299, 3429, -3378, 4568, 2074], [-14589, 7204, -2489, 581, -1604, 4381], [-109822, 14554, 9011, 7357, 930, 5622], [-3359, -8127, 4643, -6591, -2898, -1991], [27747, 4719, -11982, 992, -430, -2087], [104191, 11771, -1047, -83, 3459, 2517], [4744, 394, -5512, -6324, -104, 2310], [73049, 1794, 8970, -746, 651, -4443], [-61634, 4451, -6146, -3716, 4123, 1100], [-48459, -9454, -13923, -5557, -2280, 637], [-42342, -19204, 12445, 7633, -1775, 3194], [69407, 3076, -6821, 4548, 3294, 5311]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_476_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_476_4_a_c();".
// 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_476_4_a_c(:prec:=6)
    chi := MakeCharacter_476_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_476_4_a_c();".
// 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_476_4_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_476_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-7516, -4232, 2031, 184, -87, -2, 1]>],Snew);
    return Vf;
end function;