
# q-expansion of newform 117.4.a.f, downloaded from the LMFDB on 04 September 2025.

# 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 = [-8, -16, -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], 1], [[0, 1, 0], 1], [[-10, -2, 1], 1]]

hecke_ring_character_values = None
aps_data = [[-1, 1, 0], [0, 0, 0], [-2, 0, 2], [8, 6, 0], [8, -2, -6], [13, 0, 0], [46, 8, 0], [28, -6, 16], [24, -32, 8], [10, -20, -8], [120, -54, -4], [150, -48, -28], [-150, 4, -34], [-68, -60, 4], [12, -54, 42], [186, 108, 12], [624, -82, -2], [78, 24, -28], [36, 42, -76], [276, 134, -14], [2, -240, 12], [-16, 48, -24], [272, -30, 10], [-430, -116, -30], [1098, -48, -4], [-414, 340, 128], [-752, 84, 76], [636, 304, -40], [54, 288, -64], [-330, -232, -68], [-448, 108, 72], [-364, 192, -152], [-918, -268, -146], [-308, 552, -116], [-810, 176, 94], [1392, -234, 20], [478, -480, 172], [332, 222, -288], [356, -230, 234], [1818, -4, -248], [-148, -452, -300], [-1594, -456, 348], [-1256, 92, 12], [-1742, -72, 280], [3534, -176, 26], [584, -108, 480], [252, 264, 272], [840, 282, -316], [776, 506, -490], [-2818, -216, 192], [638, 552, -380], [-468, 1086, 138], [4890, 96, -196], [2532, 20, 580], [1222, -1256, 124], [-1296, 28, 188], [-2902, -436, 512], [160, 918, -272], [-2050, 24, -552], [-2822, 612, 14], [1156, -636, 40], [-858, -40, -290], [3620, 102, -420], [-792, -720, 0], [3466, -48, 64], [-1754, 120, -166], [284, 2034, 420], [-3470, 1248, -272], [-132, 512, 232], [-2610, 2184, 716], [-1966, -788, 342], [-5196, 1074, 738], [-4248, -552, -148], [-3186, -312, -1456], [2212, -942, -728], [1684, -970, -210], [2426, 156, -44], [62, -1224, 588], [1082, 1396, 474], [-2190, 1704, 428], [5828, -2576, -624], [-3970, -72, -1248], [11364, 214, 446], [7722, -120, -148], [2432, -756, -1620], [9004, -624, 296], [-6406, -76, -718], [2, 1080, 1980], [-4858, -952, -238], [7248, 126, -760], [7788, 876, 444], [-6492, -1526, -1018], [-3392, 282, -1100], [324, -2948, -868], [-2636, 1362, 196], [-2656, 3452, 428], [566, -3560, 978], [-6210, -1392, -2316], [5612, 2232, -516], [5206, 528, 2104], [-8652, 1728, -628], [4398, 2944, -466], [-3108, 212, 844], [-14098, 1648, 1380], [2324, -4668, 912], [7874, -2832, 528], [56, 2314, 1986], [9578, -2316, -350], [-11744, 3396, -148], [7530, 4800, -544], [-1144, 504, -348], [13350, 2976, -340], [-18694, 1940, 950], [7372, -6954, -596], [-5200, 918, -2124], [-4754, -2920, -1704], [-13852, 1602, -636], [-9832, 376, -552], [7290, 3076, -1240], [-1804, -1648, 104], [-2762, -792, 364], [-20502, 2184, 500], [5978, -3804, -428], [216, 878, -1310], [-188, 2442, 700], [-542, -5532, -676], [19854, 120, -952], [-7296, 1952, 2464], [-2824, 6060, 2496], [-18938, 3624, -896], [-556, -1146, 492], [-13068, 886, -670], [-15016, -2268, -2460], [1302, -1344, 548], [-8678, -3964, 2670], [-3998, -4056, 2080], [-9274, 1376, -2722], [-8364, -5466, -460], [-12958, -772, -1876], [30414, -1424, -388], [-3196, -870, 3984], [-15578, 5104, -506], [-896, -996, -2228], [6536, -2970, 34], [11678, 720, 636], [-852, -2014, -554], [-13754, -2472, 1108], [-1634, -1824, 1532], [17364, -2352, 704], [-4012, -4290, -4658], [4334, -1800, 708], [-8938, -3080, 3036], [2364, -2556, 4016], [-18288, 6172, 524], [12052, 4476, -1208], [-18152, -1596, 308], [8536, -1080, -3392], [-14670, -724, 1030], [-21598, -2328, -1068], [-19810, 7464, 2518], [4248, 7342, 4070], [-5202, 6704, -1340], [12800, -10950, 804], [-15444, -2248, -2216], [13434, -12236, 26], [-36964, 6522, 1894], [840, -12216, 3044], [510, -3072, -4240]]
