
# q-expansion of newform 252.4.b.f, downloaded from the LMFDB on 19 April 2024.

# We generate the q-expansion using the Hecke eigenvalues a_p at the primes.
# Each a_p is given as a linear combination
# of the following basis for the coefficient ring.

def make_data():

    from sage.all import prod, floor, prime_powers, gcd, QQ, primes_first_n, next_prime, RR

    def discrete_log(elts, gens, mod):
        # algorithm 2.2, page 16 of https://arxiv.org/abs/0903.2785
        def table_gens(gens, mod):
            T = [1]
            n = len(gens)
            r = [None]*n
            s = [None]*n
            for i in range(n):
                beta = gens[i]
                r[i] = 1
                N = len(T)
                while beta not in T:
                    for Tj in T[:N]:
                        T.append((beta*Tj) % mod)
                    beta = (beta*gens[i]) % mod
                    r[i] += 1
                s[i] = T.index(beta)
            return T, r, s
        T, r, s = table_gens(gens, mod)
        n = len(gens)
        N = [ prod(r[:j]) for j in range(n) ]
        Z = lambda s: [ (floor(s/N[j]) % r[j]) for j in range(n)]
        return [Z(T.index(elt % mod)) for elt in elts]
    def extend_multiplicatively(an):
        for pp in prime_powers(len(an)-1):
            for k in range(1, (len(an) - 1)//pp + 1):
                if gcd(k, pp) == 1:
                    an[pp*k] = an[pp]*an[k]
    from sage.all import PolynomialRing, NumberField, ZZ
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K([c/ZZ(den) for c in num]) for num, den in basis_data]
    convert_elt_to_field = lambda elt: sum(c*beta for c, beta in zip(elt, betas))
    # convert aps to K elements
    primes = primes_first_n(len(aps_data))
    good_primes = [p for p in primes if not p.divides(level)]
    aps = map(convert_elt_to_field, aps_data)
    if not hecke_ring_character_values:
        # trivial character
        char_values = dict(zip(good_primes, [1]*len(good_primes)))
    else:
        gens = [elt[0] for elt in hecke_ring_character_values]
        gens_values = [convert_elt_to_field(elt[1]) for elt in hecke_ring_character_values]
        char_values = dict([(
            p,prod(g**k for g, k in zip(gens_values, elt)))
            for p, elt in zip(good_primes, discrete_log(good_primes, gens, level))
            ])
    an_list_bound = next_prime(primes[-1])
    an = [0]*an_list_bound
    an[1] = 1
    
    from sage.all import PowerSeriesRing
    PS = PowerSeriesRing(K, "q")
    for p, ap in zip(primes, aps):
        if p.divides(level):
            euler_factor = [1, -ap]
        else:
            euler_factor = [1, -ap, p**(weight - 1) * char_values[p]]
        k = RR(an_list_bound).log(p).floor() + 1
        foo = (1/PS(euler_factor)).padded_list(k)
        for i in range(1, k):
            an[p**i] = foo[i]
    extend_multiplicatively(an)
    return PS(an)
level = 252
weight = 4
poly_data = [262144, -32768, -8192, -3072, 0, 448, -448, 56, 0, -6, -2, -1, 1]

# The entries in the following list give a basis for the
# coefficient ring in terms of a root of the defining polynomial above.
# Each line consists of the coefficients of the numerator, and a denominator.
basis_data  = [[[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1], [[0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1], [[32768, 8192, 3072, 0, -448, 448, -56, 0, 6, 2, 1, -1], 32768], [[98304, 32768, 3072, -3584, 3136, 0, -56, 48, 22, 10, -7, -1], 32768], [[294912, 49152, -19456, 25088, -1344, 896, 216, 176, 98, -50, -5, -3], 32768], [[-1310720, -925696, 138240, -15360, 33600, 3136, 360, 1568, -610, 26, 69, 11], 98304], [[-3440640, -770048, -158720, -17920, -6464, -12928, 2264, -80, 34, 142, 91, 29], 98304], [[-3244032, -507904, -136192, 5632, 10304, -6272, 3784, -688, 182, 122, 41, 31], 98304], [[-4685824, -901120, -171008, -33280, -17216, -10496, 5336, 464, 98, 158, 91, 45], 98304], [[-5046272, -1712128, -224256, 52224, -19008, -12608, 1080, 1760, 26, 206, 111, 65], 98304], [[-3031040, -823296, -109568, -18688, -5696, -9312, 1304, 456, 186, 66, 79, 37], 49152], [[-5128192, -1130496, -375808, -23552, -6592, -10560, 4648, 384, 318, 138, 101, 59], 49152]]

hecke_ring_character_values = [[127, [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [29, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [73, [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]]
aps_data = [[0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0], [1, 0, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0], [0, 1, -2, 0, 0, 0, 0, 0, 0, 0, -1, -1], [-1, 1, -3, 1, 1, 0, 1, 0, -1, -1, 0, 0], [0, 1, -2, 2, -2, 0, 1, 1, 0, 2, -1, 1], [-7, 1, 3, -1, 1, -2, 0, 1, -1, 1, 0, 0], [-3, -3, 8, 7, -1, 0, 2, -1, 2, 1, -2, 2], [-21, 1, 1, 11, 5, 2, 3, 0, 3, 1, 2, -4], [-37, -3, -3, 13, -5, -2, -1, -2, 3, -1, 4, -2], [-25, 3, 19, 5, -5, -2, -4, 1, 1, -1, 2, 0], [10, 9, -26, -20, 0, 0, -3, 7, 4, 0, 5, -5], [-2, 4, 8, 0, 4, 0, 5, 3, -12, -4, -2, -4], [-18, -12, -36, 2, -10, -4, -6, 0, 0, -2, 2, 2], [-9, 7, 35, 11, -3, -6, -1, 0, 1, 1, 4, -2], [-90, -8, -48, -6, 14, -4, 16, -6, -4, 6, -2, -2], [-1, 21, -57, 5, -3, 0, 9, 8, -23, 3, 4, 8], [-2, -22, 72, -4, 8, 0, -1, -3, 16, -8, 0, -6], [-3, 17, -22, -1, 7, 0, 10, 7, -32, -7, 2, -2], [22, 4, -42, -42, -2, 0, -20, 2, 6, 2, 22, 2], [-26, 6, -66, 34, 18, 0, 9, -17, 8, -18, -4, 4], [42, 20, 96, 70, 2, -4, -10, 12, 16, 2, 18, -18], [10, -43, 232, -28, 8, 0, 5, 15, -30, -8, 9, -9], [-26, -36, 114, 58, -6, 0, 0, -26, -34, 6, -10, 22], [-28, -30, -23, 56, 0, 0, -6, -34, 27, 0, 10, 38], [113, 55, 243, -29, -27, -6, -3, -14, -7, -7, -4, 14], [-28, 1, -32, 32, 24, 0, 12, -16, -14, -24, 3, 7], [-178, -12, -20, 20, -20, -8, -34, 22, 4, -4, 8, 0], [150, 26, 98, -24, 0, 0, -36, 36, -6, 0, -6, 6], [18, 46, -222, -22, -14, 0, 1, 19, 64, 14, 8, 4], [540, -78, -330, -44, 4, 16, -24, 24, -6, -4, -14, 10], [-234, -40, -140, 120, 8, 8, -38, 42, 32, 0, 28, -32], [-280, -72, -300, 16, 16, -8, 8, 4, 0, 8, 4, -8], [-417, 39, 139, -121, -15, 18, 53, -66, -23, -11, -32, 34], [44, 20, -14, -96, 8, 0, -29, 15, -48, -8, 32, -20], [-5, 53, -153, 17, -7, 0, 41, 36, 49, 7, -24, -12], [-6, -50, 120, -4, 16, 0, -29, -35, -44, -16, 32, 22], [-198, 98, 378, -22, 6, 12, 20, -18, -2, -2, -8, 4], [6, -108, 451, 6, -18, 0, -36, -30, -7, 18, -42, -30], [70, -69, 500, -142, 2, 0, 2, 72, -86, -2, 39, -33], [19, -127, 537, -43, 5, 0, 29, 48, 67, -5, 12, -12], [-71, 27, -194, 155, -13, 0, -16, -87, -68, 13, -52, 32], [761, -47, -173, 165, 19, 34, 54, -47, 51, -5, 34, -46], [-75, 15, 55, 109, 35, -34, 83, -54, 13, 23, 30, -36], [-268, 54, 210, -78, -18, 36, 17, -35, -6, -18, -24, 24], [42, 148, -272, -40, -44, 0, -15, 27, -176, 44, -46, -44], [158, -60, -228, 104, 8, 32, -43, 43, 36, -8, 20, -28], [-150, 26, 90, 50, 30, -36, -118, 144, -2, 22, 16, -20], [15, 153, -411, 45, -75, 0, 93, 108, 51, 75, -48, 12], [828, -12, -64, -126, -10, -28, 16, -18, -40, 6, -26, 34], [83, 19, -86, -127, -39, 0, -144, -61, -152, 39, 42, -2], [-104, -46, 12, 200, 8, 0, -46, -150, -92, -8, -66, 30], [-240, 84, 264, -316, -4, -16, -6, 6, -84, 4, -76, 80], [-94, -133, 340, 144, 44, 0, 119, 25, 170, -44, 11, 61], [181, -13, -4, -321, -41, 0, -128, 53, 174, 41, 64, -76], [102, 94, -23, -238, 34, 0, -38, 64, -81, -34, -4, -140], [581, 95, 291, 159, 121, -14, 49, 34, 25, 45, 32, -70], [-949, -173, -681, 25, -9, 30, -122, 111, 17, -13, 2, -4], [-54, 150, 614, -4, -20, 40, -44, 24, 14, -20, -6, 6], [-619, 45, 255, -297, -135, -18, -94, 7, -69, -39, -60, 108], [-70, -54, 13, 182, -42, 0, -78, -148, 27, 42, -116, -4], [1655, 31, 189, 117, -37, 26, -114, 85, 41, -21, 28, -20], [906, 68, 300, -54, -50, 76, -52, 6, 16, -42, -22, 26], [-12, -152, 180, -28, 52, 0, -20, -32, 172, -52, 116, 76], [-963, 9, -19, -295, -17, -2, 7, -18, -73, -5, -72, 78], [-58, 236, -736, 120, -4, 0, 213, 155, -132, 4, 86, 148], [-460, 254, 1102, 250, -26, 28, 88, -110, 74, -18, 60, -56], [158, -67, 266, -302, -14, 0, -44, 114, 140, 14, 117, -27], [85, 11, -15, -217, 47, 0, -157, -72, -89, -47, 24, -108], [2, -139, 772, 12, -16, 0, 41, 43, -274, 16, 65, 79], [-161, 81, -278, 221, 101, 0, 50, -111, -104, -101, -112, -52], [2204, -90, -462, 142, 130, -20, 119, -29, 18, 50, 28, -68], [2306, 208, 632, 36, 204, -72, 8, 140, -32, 92, 4, -60], [-110, 488, -1604, 116, 104, 0, 169, 59, -248, -104, 6, 12], [-1872, 278, 822, -16, 264, 0, 224, -48, -26, 88, -26, -62], [3339, -19, -211, 87, 153, -54, 45, 66, -9, 69, 18, -60], [-11, -253, 1041, 35, -13, 0, -133, -144, -389, 13, 24, 48], [2694, 120, 124, -360, 232, 88, 74, 66, -80, 48, -124, 32], [206, 144, 750, -382, -30, 0, 72, 278, -614, 30, 10, -166], [-3024, -166, -534, 344, -48, 48, -286, 246, 106, -32, 82, -74], [-2377, 415, 1871, -143, -209, -122, -118, -1, -59, -29, 2, 88], [-21, -215, 376, -111, 153, 0, -174, -195, 282, -153, -28, -160], [-134, 298, -942, 318, -50, 0, 118, -16, -426, 50, -20, 164], [5060, -442, -1662, -230, -154, 20, 85, -191, -38, -58, -48, 96], [-6, 67, 74, -78, 90, 0, 114, 108, -240, -90, 99, 15], [-1416, 88, 488, 702, 58, -140, 38, 24, 124, 66, 194, -190], [-3112, 250, 754, 142, 242, 116, -204, 346, 54, 42, -4, -96], [272, -372, 1693, -496, -48, 0, 48, 320, 267, 48, 196, -28], [-274, 426, -1914, 422, 126, 0, 69, -205, -140, -126, -104, 44], [4608, 292, 1416, 236, -140, -224, -278, 222, -4, 28, 108, -24], [-5928, 18, 42, 4, 52, -152, 354, -294, -54, 68, 22, -14], [-300, -292, 518, 676, -76, 0, 147, -153, 464, 76, -248, 128], [-2, 157, -920, 190, -186, 0, 96, 94, 362, 186, -35, 153], [-110, -268, 1252, 308, -88, 0, 193, 83, -56, 88, -78, 120], [3426, -524, -1716, 654, -166, -220, 82, -156, 104, 18, 214, -122], [-16, 638, -1475, -84, 116, 0, 338, 322, -145, -116, -94, -194], [100, 339, -1610, -134, -66, 0, -369, -269, -332, 66, 41, 7], [-3646, -514, -1974, -418, -174, 12, -98, -20, -86, -62, -92, 148], [83, -49, -177, 37, 11, -130, 386, -357, -35, 47, 30, -12], [178, 690, -2568, -356, 0, 0, -105, 73, 380, 0, -124, -302], [4251, -465, -1973, 227, 165, -54, -163, 282, 25, 73, 52, -98], [450, 200, 252, -106, 450, 204, 14, 252, 4, 82, -98, -86], [4602, 430, 2162, 372, -332, 64, 50, -282, 142, -132, 110, -10], [170, -102, 1524, -388, 48, 0, -93, 77, -896, -48, 76, -142], [150, -330, 1386, -294, -6, 0, -198, -48, -282, 6, 132, -12], [-6054, -286, -1386, 194, 270, -12, -196, 378, 22, 94, 28, -116], [80, 499, -1724, -194, 34, 0, 55, 135, -362, -34, 237, 123], [-419, -543, 1390, 1007, -169, 0, -118, -537, -596, 169, -142, 446], [-330, 206, 318, 310, 350, 0, 446, 116, -610, -350, -140, -160], [6650, -236, -1260, -204, 236, 56, 201, -53, -52, 60, -80, -8], [-1240, -210, -714, -1158, -378, -36, -156, -90, -270, -114, -252, 384], [1260, 350, 1274, -886, -106, 116, 492, -582, -174, -74, -232, 248], [-7144, -160, -540, 952, 104, 152, 112, -68, 280, -16, 204, -264], [434, 610, -2454, -590, -278, 0, -263, 171, -136, 278, 324, 168], [-4332, -2, -826, -1102, 462, 252, 278, -12, -230, 70, -356, 160], [4259, 31, -219, 965, 523, 106, 252, 79, 233, 139, 180, -372], [-366, 82, -54, -170, 330, -108, 526, -288, -106, 146, -52, -40], [4305, -35, -167, -175, -25, 62, -555, 528, -21, -29, -52, 50], [280, 169, 1208, -500, -60, 0, 72, 352, -814, 60, -73, -293], [-429, -151, -297, 601, 257, 0, 185, -244, 857, -257, -308, -136], [353, 517, 1519, -683, 371, -142, 390, -119, -249, 171, -178, 78], [-30, -152, 553, -70, 130, 0, -176, -206, -141, -130, -58, -158], [-606, -53, -794, 978, 234, 0, 570, -36, 876, -234, -157, 215], [-12034, 222, 498, 274, 430, -44, -406, 700, 18, 158, 40, -176], [-4479, 801, 2989, -595, 75, -90, -493, 558, -185, 55, -140, 130], [5432, -62, 322, 678, -422, 340, -306, -32, 318, -254, 148, -64], [-12624, -230, -654, 316, -132, -264, 346, -390, 2, 44, 134, -46], [-4189, 449, 2205, -183, -449, 190, -557, 226, 55, -213, -40, 158], [-217, -459, 669, 149, 285, 0, -411, -628, -749, -285, 364, 296], [-406, -782, 2820, 1024, -212, 0, 367, -39, 68, 212, -228, 390], [149, 607, -3386, -193, -105, 0, -216, -67, 460, 105, 204, 160], [220, 320, -2890, -388, -52, 0, -453, -233, 664, 52, 324, 156], [-1804, 362, 1090, 794, 470, 284, -98, 364, 254, 62, 112, -316], [-476, -751, 910, 1190, -238, 0, -115, -591, 1008, 238, -405, 309], [596, -860, 1356, -800, -392, 0, -764, -168, 1376, 392, 288, 84], [408, -234, -233, -1140, 324, 0, -582, -174, 365, -324, 594, -138], [6878, 286, 534, -1330, 226, 196, -366, 484, -286, 10, -384, 276], [-874, -32, -131, 1534, 214, 0, 820, -54, 367, -214, -438, 222], [-5946, -38, -482, -608, 232, -440, 834, -606, -318, 224, -98, 94], [11642, -174, -378, 854, -118, 140, -502, 400, 270, -86, 200, -184], [-6261, -53, 631, 639, -663, 210, -81, -396, 285, -291, 180, 6], [-6, -334, -594, -170, 182, 0, -55, -61, 1880, -182, 52, -124], [-378, 363, -568, 562, 194, 0, 446, 68, -1138, -194, 103, 287], [-23, 427, -2841, 435, -389, 0, -209, -232, 1113, 389, -428, -16], [4020, 840, 3240, -1512, -216, -144, 78, -198, -408, -24, -336, 432], [569, -1, 3585, -885, -253, 0, 419, 988, -1065, 253, -112, -428], [-456, 421, -518, 362, 550, 0, 313, -143, -1140, -550, -109, -203], [-17167, 473, 1923, 711, 121, 94, 328, -263, 199, 9, 152, -208], [209, -825, 3038, -1077, 659, 0, -580, -371, -588, -659, 488, -380], [-9088, 522, 2234, -542, -274, 92, 28, -226, -82, -122, -128, 204], [160, 637, -1256, 66, -386, 0, 241, 401, -562, 386, -77, 149], [450, 400, -88, -1072, 172, 0, 437, 887, 712, -172, 86, -536], [-25218, -938, -3690, 1086, 146, 308, 136, -90, 362, -54, 208, -308], [-414, -88, 2216, 868, -40, 0, 201, -213, -1732, 40, -506, -52], [-367, 47, -2068, 1267, -533, 0, 208, -159, 1670, 533, -504, 396], [-28, -1044, 3986, 8, 48, 0, -173, -201, -656, -48, 232, 212], [122, -443, 2266, -68, -176, 0, 709, 831, 904, 176, 105, 159], [408, -408, 3276, -1164, 348, 0, 12, 420, -960, -348, 456, -300], [798, -532, 2797, -1250, -346, 0, -424, 374, 775, 346, -122, -574], [250, 247, -596, -818, 318, 0, -210, 40, 146, -318, 55, -513], [1194, 964, 3592, 36, 252, 0, -318, 486, -12, 84, -12, -72], [-674, 174, 642, 970, 378, 0, 717, 43, -1348, -378, -100, 196], [19314, -1602, -6162, -654, -402, 156, 690, -984, -78, -186, -156, 264], [-4728, -248, 296, -2, -1222, 212, -706, -144, 172, -478, 66, 306], [5010, -258, -690, -1134, -594, 108, -528, 114, -198, -234, -252, 432], [-320, 284, -1118, 308, 332, 0, -377, -697, -1664, -332, 132, 120], [717, 331, -1719, -1681, 247, 0, 151, 868, 1879, -247, 608, -356]]
