
# q-expansion of newform 294.4.e.m, downloaded from the LMFDB on 18 January 2026.

# 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 = 294
weight = 4
poly_data = [4, 0, 2, 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], 1], [[0, 1, 0, 0], 1], [[0, 0, 1, 0], 2], [[0, 0, 0, 1], 2]]

hecke_ring_character_values = [[197, [1, 0, 0, 0]], [199, [0, 0, 1, 0]]]
aps_data = [[0, 0, 2, 0], [3, 0, 3, 0], [0, -1, -6, -1], [0, 0, 0, 0], [-2, -6, -2, 0], [-24, 0, 0, -15], [66, -11, 66, 0], [0, -46, -60, -46], [0, -102, -38, -102], [-56, 0, 0, -150], [216, -54, 216, 0], [0, -180, -140, -180], [-18, 0, 0, 127], [-64, 0, 0, -288], [0, 338, 132, 338], [-134, 192, -134, 0], [168, 298, 168, 0], [0, -353, 252, -353], [192, 144, 192, 0], [-198, 0, 0, -342], [-156, -595, -156, 0], [0, -300, -424, -300], [324, 0, 0, 80], [0, 175, 306, 175], [1092, 0, 0, 133], [-810, 351, -810, 0], [0, -350, 264, -350], [0, -402, 694, -402], [680, -1008, 680, 0], [246, 0, 0, 912], [-1028, 0, 0, 744], [0, 1008, -156, 1008], [-1164, -1350, -1164, 0], [180, 0, 0, 844], [0, 216, 926, 216], [2092, 108, 2092, 0], [-2100, -1193, -2100, 0], [0, 636, -3008, 636], [-108, 0, 0, 986], [0, -609, 390, -609], [-2478, 810, -2478, 0], [408, 0, 0, -417], [0, -90, 1354, -90], [1918, 1104, 1918, 0], [4042, 0, 0, 600], [2304, -876, 2304, 0], [-1116, 0, 0, -2244], [-3912, 0, 0, -1332], [3264, -594, 3264, 0], [0, 237, 1632, 237], [0, 2106, 1500, 2106], [1170, 0, 0, -3498], [1116, 3615, 1116, 0], [-5664, 0, 0, 170], [0, 2253, -2778, 2253], [-270, 3462, -270, 0], [1506, -1681, 1506, 0], [0, -334, -6000, -334], [-3490, -864, -3490, 0], [-3220, 0, 0, 2790], [5292, 746, 5292, 0], [-2430, 0, 0, 4811], [-5460, 0, 0, 938], [5100, 26, 5100, 0], [0, 3951, -1824, 3951], [0, 2016, -3886, 2016], [0, -840, 9988, -840], [1760, 0, 0, 5388], [-6810, -798, -6810, 0], [5316, 0, 0, -3261], [-7194, -2057, -7194, 0], [0, -3354, -82, -3354], [0, 4904, 0, 0], [0, 6072, 5506, 6072], [3148, 0, 0, -1560], [0, 2932, 4824, 2932], [7784, -2886, 7784, 0], [0, -1081, 3612, -1081], [0, 618, -11508, 618], [-11196, 3309, -11196, 0], [5016, 0, 0, 7846], [1530, 0, 0, 5064], [3966, -162, 3966, 0], [5592, 0, 0, -117], [0, 2136, 6792, 2136], [0, 4158, -50, 4158], [-4602, 0, 0, 2880], [0, -336, 9582, -336], [6870, 0, 0, -1315], [-4460, 0, 0, -1884], [0, 2606, -3816, 2606], [1836, 7078, 1836, 0], [8388, -2532, 8388, 0], [4074, 0, 0, -1410], [0, -10020, -1336, -10020], [-7656, 0, 0, -6472], [0, 277, 4662, 277], [12510, -1961, 12510, 0], [0, 2580, 8148, 2580], [0, -2928, -170, -2928], [7156, 0, 0, -6972], [-1266, -336, -1266, 0], [9432, 1354, 9432, 0], [0, -11442, -2236, -11442], [-3940, -4284, -3940, 0], [10728, -8577, 10728, 0], [-6552, 0, 0, -12306], [0, -11045, -4842, -11045], [-8794, -846, -8794, 0], [-18696, 0, 0, -891], [0, -5988, -8232, -5988], [144, 18780, 144, 0], [23132, 0, 0, -3294], [8892, -5060, 8892, 0], [-12028, 0, 0, -2148], [22484, -6162, 22484, 0], [-7236, 0, 0, 13954], [7236, 12138, 7236, 0], [0, 8526, 3912, 8526], [-14286, 0, 0, -1902], [16620, -2841, 16620, 0], [-12, 0, 0, -1512], [0, -10749, 12582, -10749], [5874, 17010, 5874, 0], [0, 6072, -15348, 6072], [-10080, 0, 0, -7458], [0, 5448, 1120, 5448], [0, 7520, 10464, 7520], [7872, 0, 0, 2302], [0, -4203, 16632, -4203], [19152, -2676, 19152, 0], [11738, 0, 0, 3702], [0, 468, -20536, 468], [-11560, 0, 0, 2544], [0, -2957, -31038, -2957], [7224, 0, 0, 3507], [-13494, 2801, -13494, 0], [-1116, -22696, -1116, 0], [-15774, 0, 0, 18591], [21278, -14496, 21278, 0], [-1812, 0, 0, 10428], [0, 5208, -7134, 5208], [8600, -2388, 8600, 0], [-9306, 0, 0, 26106], [-20136, -13759, -20136, 0], [1764, 0, 0, -31094], [5796, 0, 0, -2121], [26718, 2501, 26718, 0], [0, -20114, -16548, -20114], [0, 26334, 7426, 26334], [0, 5772, -2176, 5772], [-31026, 0, 0, 4869], [-1648, 0, 0, 10356], [0, 12874, -27060, 12874], [5552, -15708, 5552, 0], [-5270, 0, 0, 16830], [0, 9216, -5060, 9216], [0, -6901, -20382, -6901], [-8592, 0, 0, -5279], [22410, -23153, 22410, 0], [0, 2130, 21798, 2130], [-25774, 0, 0, -7584], [5220, 0, 0, 14736], [0, 16448, 1572, 16448], [-20388, -12918, -20388, 0], [-10920, 26576, -10920, 0], [-14636, -8904, -14636, 0], [-10788, 11279, -10788, 0]]
