
# q-expansion of newform 117.4.q.f, downloaded from the LMFDB on 23 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 = 117
weight = 4
poly_data = [54756, 0, -47034, 0, 32913, 0, -5964, 0, 823, 0, -32, 0, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1], [[0, 480684672, 0, -1732704885, 0, 276029262, 0, -43326835, 0, 1684640, 0, -55141], 1995420258], [[-2476104930, 0, 1732704885, 0, -276029262, 0, 43326835, 0, -1684640, 0, 55141, 0], 1995420258], [[0, 447354927, 0, 1505088, 0, -1053216, 0, 677329, 0, -26336, 0, 1024], 25582311], [[242696439, 0, 1505088, 0, -1053216, 0, 677329, 0, -26336, 0, 1024, 0], 25582311], [[0, 2003386986, 0, 34193718, 0, -23927751, 0, 14588621, 0, -598321, 0, 23264], 153493866], [[-28627945398, 0, 18916912152, 0, -3733955064, 0, 344382751, 0, -12986243, 0, 328789, 0], 1995420258], [[24217853634, 0, -16946936613, 0, 2954171034, 0, -423763523, 0, 16476832, 0, -526679, 0], 1995420258], [[0, 11642937462, 0, -8147382759, 0, 1596984255, 0, -203727889, 0, 7921376, 0, -238924], 665140086], [[0, 44026693074, 0, -30808575693, 0, 5162405130, 0, -770378203, 0, 29953952, 0, -967807], 1995420258], [[-6315279750, 0, 20015673426, 0, -4502835657, 0, 807675646, 0, -32212346, 0, 1076341, 0], 1995420258]]

hecke_ring_character_values = [[92, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [28, [0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0]]]
aps_data = [[0, 1, 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, -1, 0, 0, 1, 0, 0], [-2, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, -1], [0, 4, 4, 0, 0, 0, 0, 0, 0, -1, -1, 0], [-16, 0, 0, -4, 0, 1, 0, -1, -1, 0, 0, -4], [0, -3, -6, 0, -1, 0, -2, 0, 0, 4, 2, 0], [-6, 0, 0, -3, 0, -3, 0, 0, -1, 0, 0, -5], [0, 4, -4, 0, -6, 0, 2, 0, 0, -1, 3, 0], [0, 17, -17, 0, 0, 0, 18, 0, 0, -9, 0, 0], [-10, 0, 0, -20, 0, 9, 0, 4, -18, 0, 0, 4], [-24, 0, 0, 24, 0, 13, 0, -1, 12, 0, 0, 0], [0, -15, -15, 0, 0, 0, 0, 0, 0, 28, 3, 0], [0, 0, 0, 143, 0, -9, 0, 18, 24, 0, 0, 9], [0, 0, -24, 0, 1, 0, -19, 0, 0, 19, -1, 0], [0, 158, 79, 0, 2, 0, -11, 0, 0, -11, 2, 0], [0, -20, 0, 0, -8, 0, 8, 0, 0, 0, 0, 0], [0, 0, 0, -226, 0, -11, 0, 22, -31, 0, 0, 11], [139, 0, 0, -139, 0, 17, 0, 9, 26, 0, 0, 0], [0, -168, 0, 0, 7, 0, -9, 0, 0, 0, 0, 0], [39, 0, 0, 78, 0, -8, 0, -6, 16, 0, 0, -6], [-550, 0, 0, 0, 0, -17, 0, 36, 0, 0, 0, -36], [0, 0, 200, 0, -23, 0, 1, 0, 0, -1, 23, 0], [0, 126, 126, 0, 0, 0, 0, 0, 0, -4, 34, 0], [148, 0, 0, 74, 0, 54, 0, 0, -59, 0, 0, -64], [0, -199, 199, 0, 8, 0, 2, 0, 0, -1, -4, 0], [-457, 0, 0, 0, 0, -30, 0, 15, 0, 0, 0, -15], [0, 36, -36, 0, 26, 0, -126, 0, 0, 63, -13, 0], [146, 0, 0, 292, 0, 35, 0, -68, -70, 0, 0, -68], [0, -81, -162, 0, 9, 0, -10, 0, 0, 20, -18, 0], [-1046, 0, 0, -1046, 0, -131, 0, 20, 151, 0, 0, 40], [0, 728, 364, 0, 22, 0, 42, 0, 0, 42, 22, 0], [0, -119, 0, 0, -13, 0, -144, 0, 0, 0, 0, 0], [0, 0, 0, -352, 0, -6, 0, 12, 219, 0, 0, 6], [0, -249, 0, 0, -46, 0, 25, 0, 0, 0, 0, 0], [117, 0, 0, 234, 0, 1, 0, 87, -2, 0, 0, 87], [-634, 0, 0, 0, 0, -113, 0, -53, 0, 0, 0, 53], [-1392, 0, 0, -696, 0, 260, 0, 0, -17, 0, 0, 226], [0, 436, 436, 0, 0, 0, 0, 0, 0, -44, -56, 0], [0, -380, -760, 0, -16, 0, 56, 0, 0, -112, 32, 0], [0, 8, -8, 0, -98, 0, 142, 0, 0, -71, 49, 0], [-730, 0, 0, 0, 0, -10, 0, -85, 0, 0, 0, 85], [0, -172, -344, 0, 16, 0, 20, 0, 0, -40, -32, 0], [1111, 0, 0, -1111, 0, 130, 0, -210, -80, 0, 0, 0], [0, 422, 422, 0, 0, 0, 0, 0, 0, 172, -22, 0], [0, 0, 0, 1817, 0, -23, 0, 46, -34, 0, 0, 23], [2398, 0, 0, 2398, 0, -19, 0, 60, 79, 0, 0, 120], [1386, 0, 0, -1386, 0, 114, 0, 74, 188, 0, 0, 0], [0, 48, 0, 0, 1, 0, -303, 0, 0, 0, 0, 0], [-1172, 0, 0, -2344, 0, 200, 0, -376, -400, 0, 0, -376], [0, 112, 56, 0, -84, 0, 40, 0, 0, 40, -84, 0], [0, 0, -980, 0, 55, 0, 15, 0, 0, -15, -55, 0], [-990, 0, 0, -495, 0, -488, 0, 0, 201, 0, 0, -86], [0, -468, -936, 0, -28, 0, -116, 0, 0, 232, 56, 0], [0, -129, 129, 0, 218, 0, 216, 0, 0, -108, -109, 0], [0, -464, 464, 0, 70, 0, 534, 0, 0, -267, -35, 0], [0, -260, -520, 0, -100, 0, 56, 0, 0, -112, 200, 0], [-416, 0, 0, 416, 0, 259, 0, 90, 349, 0, 0, 0], [0, 0, 0, 236, 0, 175, 0, -350, -342, 0, 0, -175], [0, 0, 581, 0, -65, 0, 34, 0, 0, -34, 65, 0], [-3587, 0, 0, -3587, 0, 41, 0, 195, 154, 0, 0, 390], [0, 1925, 0, 0, 10, 0, 43, 0, 0, 0, 0, 0], [159, 0, 0, 318, 0, -226, 0, 483, 452, 0, 0, 483], [0, -1648, -824, 0, 3, 0, -109, 0, 0, -109, 3, 0], [-2764, 0, 0, 0, 0, 313, 0, -168, 0, 0, 0, 168], [0, 0, -1299, 0, 60, 0, -413, 0, 0, 413, -60, 0], [912, 0, 0, 456, 0, 724, 0, 0, -183, 0, 0, 358], [1937, 0, 0, 0, 0, -274, 0, -74, 0, 0, 0, 74], [0, 1228, 2456, 0, 5, 0, -223, 0, 0, 446, -10, 0], [1838, 0, 0, -1838, 0, -381, 0, 88, -293, 0, 0, 0], [0, 993, 993, 0, 0, 0, 0, 0, 0, -240, 155, 0], [0, 0, 1544, 0, 151, 0, -173, 0, 0, 173, -151, 0], [-23, 0, 0, -23, 0, 737, 0, 95, -642, 0, 0, 190], [0, 0, 0, 38, 0, 95, 0, -190, -151, 0, 0, -95], [-1692, 0, 0, 1692, 0, -271, 0, 638, 367, 0, 0, 0], [0, -552, 0, 0, -192, 0, -28, 0, 0, 0, 0, 0], [0, -1250, -625, 0, 106, 0, 125, 0, 0, 125, 106, 0], [1684, 0, 0, 842, 0, 306, 0, 0, -263, 0, 0, -220], [0, 205, 205, 0, 0, 0, 0, 0, 0, 528, -213, 0], [-1310, 0, 0, -655, 0, -214, 0, 0, -192, 0, 0, -598], [0, 540, -540, 0, -352, 0, -360, 0, 0, 180, 176, 0], [-604, 0, 0, -1208, 0, 55, 0, 19, -110, 0, 0, 19], [0, 640, 640, 0, 0, 0, 0, 0, 0, -747, 117, 0], [0, 0, 0, 3011, 0, -420, 0, 840, 110, 0, 0, 420], [-2231, 0, 0, -2231, 0, -369, 0, -561, -192, 0, 0, -1122], [0, 1104, 552, 0, -44, 0, 616, 0, 0, 616, -44, 0], [0, 2162, 0, 0, -154, 0, -280, 0, 0, 0, 0, 0], [-3049, 0, 0, 3049, 0, -320, 0, -224, -544, 0, 0, 0], [0, 641, 0, 0, 120, 0, 549, 0, 0, 0, 0, 0], [-4451, 0, 0, -8902, 0, 400, 0, 161, -800, 0, 0, 161], [0, -2216, -1108, 0, -17, 0, -361, 0, 0, -361, -17, 0], [0, 2072, 2072, 0, 0, 0, 0, 0, 0, 496, 224, 0], [-4694, 0, 0, -2347, 0, -131, 0, 0, -181, 0, 0, -493], [0, -472, 472, 0, 90, 0, -174, 0, 0, 87, -45, 0], [-1578, 0, 0, -3156, 0, 0, 0, -330, 0, 0, 0, -330], [0, -248, -496, 0, 63, 0, -609, 0, 0, 1218, -126, 0], [0, 251, 251, 0, 0, 0, 0, 0, 0, -41, -496, 0], [0, 2590, 1295, 0, -5, 0, -682, 0, 0, -682, -5, 0], [3787, 0, 0, 3787, 0, -1268, 0, 439, 1707, 0, 0, 878], [-6082, 0, 0, -12164, 0, -141, 0, 577, 282, 0, 0, 577], [-4429, 0, 0, 0, 0, 956, 0, -433, 0, 0, 0, 433], [0, 1599, 1599, 0, 0, 0, 0, 0, 0, 253, 330, 0], [0, -1068, -2136, 0, -142, 0, -398, 0, 0, 796, 284, 0], [0, -2216, 2216, 0, -20, 0, -588, 0, 0, 294, 10, 0], [14891, 0, 0, 0, 0, 699, 0, -463, 0, 0, 0, 463], [-3879, 0, 0, -7758, 0, -905, 0, 888, 1810, 0, 0, 888], [0, -376, -376, 0, 0, 0, 0, 0, 0, 0, 76, 0], [0, 0, -2497, 0, -301, 0, 308, 0, 0, -308, 301, 0], [0, 6088, 3044, 0, 260, 0, 36, 0, 0, 36, 260, 0], [895, 0, 0, 895, 0, -439, 0, 294, 733, 0, 0, 588], [0, 0, 0, 4250, 0, 694, 0, -1388, -978, 0, 0, -694], [-9584, 0, 0, 9584, 0, 440, 0, -507, -67, 0, 0, 0], [0, -4965, 0, 0, 25, 0, 684, 0, 0, 0, 0, 0], [-4104, 0, 0, -8208, 0, -519, 0, 342, 1038, 0, 0, 342], [9172, 0, 0, 4586, 0, 1366, 0, 0, -895, 0, 0, -424], [0, -2157, -4314, 0, 23, 0, -188, 0, 0, 376, -46, 0], [-5524, 0, 0, -2762, 0, -2138, 0, 0, 1255, 0, 0, 372], [0, -2564, 2564, 0, 68, 0, 1516, 0, 0, -758, -34, 0], [0, 1388, -1388, 0, 896, 0, 704, 0, 0, -352, -448, 0], [0, -2312, -4624, 0, 216, 0, -288, 0, 0, 576, -432, 0], [2824, 0, 0, -2824, 0, -224, 0, 297, 73, 0, 0, 0], [1531, 0, 0, 1531, 0, 1374, 0, 372, -1002, 0, 0, 744], [0, 1272, 636, 0, 64, 0, -440, 0, 0, -440, 64, 0], [0, 604, 0, 0, -162, 0, 142, 0, 0, 0, 0, 0], [-7627, 0, 0, 7627, 0, -783, 0, -629, -1412, 0, 0, 0], [0, 1448, 724, 0, 456, 0, 164, 0, 0, 164, 456, 0], [19872, 0, 0, 9936, 0, -1621, 0, 0, 499, 0, 0, -623], [0, 460, 920, 0, 262, 0, -326, 0, 0, 652, -524, 0], [14369, 0, 0, 0, 0, -1830, 0, 605, 0, 0, 0, -605], [1156, 0, 0, 2312, 0, 117, 0, 137, -234, 0, 0, 137], [-430, 0, 0, 430, 0, 662, 0, -1058, -396, 0, 0, 0], [0, -4992, -4992, 0, 0, 0, 0, 0, 0, -570, 158, 0], [-2873, 0, 0, -2873, 0, 4, 0, -1097, -1101, 0, 0, -2194], [-6734, 0, 0, -6734, 0, -548, 0, 620, 1168, 0, 0, 1240], [0, -2274, 0, 0, 562, 0, -516, 0, 0, 0, 0, 0], [-17430, 0, 0, 17430, 0, 164, 0, 2, 166, 0, 0, 0], [0, 3686, 0, 0, -864, 0, 1614, 0, 0, 0, 0, 0], [26660, 0, 0, 13330, 0, -198, 0, 0, 1179, 0, 0, 2160], [0, 100, 200, 0, -174, 0, 1194, 0, 0, -2388, 348, 0], [0, 831, -831, 0, -1122, 0, -1580, 0, 0, 790, 561, 0], [-10478, 0, 0, -20956, 0, -1031, 0, 1184, 2062, 0, 0, 1184], [0, 3786, 3786, 0, 0, 0, 0, 0, 0, 34, 120, 0], [0, 0, 0, -6814, 0, 1098, 0, -2196, -2706, 0, 0, -1098], [0, 0, -4260, 0, -306, 0, -302, 0, 0, 302, 306, 0], [-632, 0, 0, -632, 0, 1306, 0, 797, -509, 0, 0, 1594], [0, -696, 0, 0, -608, 0, -204, 0, 0, 0, 0, 0], [-10248, 0, 0, -20496, 0, -525, 0, 1203, 1050, 0, 0, 1203], [0, 3506, 1753, 0, -357, 0, 788, 0, 0, 788, -357, 0], [-10807, 0, 0, 0, 0, 662, 0, -1019, 0, 0, 0, 1019], [0, 0, -2804, 0, -243, 0, 173, 0, 0, -173, 243, 0], [-2444, 0, 0, -1222, 0, -987, 0, 0, 214, 0, 0, -559], [0, 1161, -1161, 0, 774, 0, 232, 0, 0, -116, -387, 0], [-4654, 0, 0, 0, 0, 385, 0, -156, 0, 0, 0, 156], [0, 1172, -1172, 0, 744, 0, -936, 0, 0, 468, -372, 0], [-2510, 0, 0, -2510, 0, -120, 0, -158, -38, 0, 0, -316], [0, -5272, -2636, 0, -512, 0, -48, 0, 0, -48, -512, 0], [0, 0, 0, 3176, 0, 736, 0, -1472, -916, 0, 0, -736], [0, 11491, 0, 0, 635, 0, 1422, 0, 0, 0, 0, 0], [-10327, 0, 0, 0, 0, 1989, 0, -136, 0, 0, 0, 136], [0, 0, -7538, 0, 340, 0, -282, 0, 0, 282, -340, 0], [0, -280, -280, 0, 0, 0, 0, 0, 0, -536, 80, 0], [0, 1632, 3264, 0, -86, 0, 426, 0, 0, -852, 172, 0], [1821, 0, 0, 3642, 0, 1993, 0, -1149, -3986, 0, 0, -1149], [0, 1344, 2688, 0, -156, 0, -424, 0, 0, 848, 312, 0], [0, -4061, -4061, 0, 0, 0, 0, 0, 0, 460, 145, 0], [0, 0, -2900, 0, -848, 0, -2700, 0, 0, 2700, 848, 0], [127, 0, 0, 127, 0, -1860, 0, -1977, -117, 0, 0, -3954], [0, 0, 0, 8756, 0, -597, 0, 1194, 1737, 0, 0, 597]]
