
# q-expansion of newform 245.4.e.m, downloaded from the LMFDB on 03 March 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 = 245
weight = 4
poly_data = [196, -238, 289, -28, 17, 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], 1], [[0, 1, 0, 0, 0, 0], 1], [[-14, 0, 0, 1, 0, 0], 17], [[0, 289, -14, 17, 0, 1], 238], [[173, -14, 17, 1, 1, 0], 17], [[2422, -2941, 392, -173, 0, -11], 238]]

hecke_ring_character_values = [[197, [1, 0, 0, 0, 0, 0]], [101, [-1, 0, 0, 1, 0, 0]]]
aps_data = [[1, -1, -1, -1, 0, 0], [0, 1, 0, -1, -1, 1], [-5, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 0], [0, 3, 0, 25, 1, -1], [13, 0, -13, 0, -5, 0], [0, 13, 0, 21, 11, -11], [-54, 10, 10, 54, 0, 6], [42, 14, 14, -42, 0, 2], [105, 0, 19, 0, -17, 0], [0, 24, 0, -108, -4, 4], [14, -16, -16, -14, 0, -12], [120, 0, 10, 0, -2, 0], [6, 0, 30, 0, 34, 0], [239, 51, 51, -239, 0, -13], [0, -130, 0, -44, -22, 22], [0, -176, 0, 76, 48, -48], [-416, 34, 34, 416, 0, -26], [0, -12, 0, -32, 108, -108], [-32, 0, 72, 0, 40, 0], [0, 124, 0, -78, 76, -76], [315, 83, 83, -315, 0, -89], [-556, 0, -160, 0, -8, 0], [-108, 98, 98, 108, 0, -82], [55, 0, -87, 0, 65, 0], [0, 316, 0, -510, -40, 40], [-389, -313, -313, 389, 0, -73], [1054, 138, 138, -1054, 0, 106], [0, 437, 0, -323, -17, 17], [326, 0, -24, 0, -4, 0], [-236, 0, -348, 0, -28, 0], [-834, 14, 14, 834, 0, 26], [0, -146, 0, -820, -122, 122], [626, 0, -2, 0, 22, 0], [598, -244, -244, -598, 0, -60], [0, -363, 0, -605, 183, -183], [0, 100, 0, -282, -356, 356], [206, -390, -390, -206, 0, 178], [-1515, 0, 505, 0, -71, 0], [121, 371, 371, -121, 0, 195], [0, -792, 0, -212, -8, 8], [1732, 0, 246, 0, 302, 0], [-651, 277, 277, 651, 0, -215], [0, 518, 0, 3292, -2, 2], [28, 0, -110, 0, -178, 0], [0, 540, 0, 772, 252, -252], [-2543, 0, 285, 0, -55, 0], [3037, 0, -383, 0, 9, 0], [0, 165, 0, -1165, -109, 109], [-1504, -62, -62, 1504, 0, 302], [2244, -34, -34, -2244, 0, -202], [-2879, 0, -847, 0, -363, 0], [0, -260, 0, 254, -504, 504], [1366, 0, 1186, 0, 26, 0], [5822, 120, 120, -5822, 0, -112], [0, -262, 0, -1298, 638, -638], [0, 508, 0, -1706, 588, -588], [812, -1760, -1760, -812, 0, 164], [0, 796, 0, -4194, -500, 500], [497, 0, 1127, 0, 739, 0], [0, -1181, 0, -1403, 101, -101], [-4837, 0, 681, 0, -7, 0], [3387, 0, 843, 0, -173, 0], [0, -918, 0, -1622, -14, 14], [-1805, 1545, 1545, 1805, 0, 57], [914, -2016, -2016, -914, 0, 8], [1524, -664, -664, -1524, 0, 328], [2178, 0, -384, 0, -656, 0], [0, 1930, 0, 3150, -334, 334], [666, 0, 1224, 0, 124, 0], [0, 201, 0, 5713, -1097, 1097], [-2768, -1800, -1800, 2768, 0, 232], [0, 5, 0, 7175, 11, -11], [-3380, 1310, 1310, 3380, 0, 602], [-10860, 0, 400, 0, 80, 0], [3444, 1148, 1148, -3444, 0, 1172], [0, -135, 0, -9119, -149, 149], [505, 1643, 1643, -505, 0, -13], [117, 863, 863, -117, 0, 755], [0, 1808, 0, 254, 728, -728], [1600, 0, -1516, 0, 468, 0], [2867, 0, 485, 0, -1495, 0], [0, 1239, 0, 6257, -619, 619], [742, 0, 548, 0, 196, 0], [6666, -222, -222, -6666, 0, -358], [-5166, -262, -262, 5166, 0, 422], [5109, 0, 1267, 0, 223, 0], [5436, 1082, 1082, -5436, 0, -314], [-6148, 0, 758, 0, 1726, 0], [-10716, 0, 120, 0, -68, 0], [-1607, 1481, 1481, 1607, 0, 81], [0, -2890, 0, -2650, -1290, 1290], [0, -34, 0, 8378, 1082, -1082], [4429, 0, -1287, 0, 253, 0], [-3, 1865, 1865, 3, 0, -83], [13755, 0, -49, 0, 455, 0], [-7426, 2452, 2452, 7426, 0, -972], [0, -1128, 0, -6742, 1196, -1196], [788, -1256, -1256, -788, 0, 968], [-7305, -2451, -2451, 7305, 0, -655], [-380, 0, -1756, 0, 1072, 0], [0, 1334, 0, -5228, -910, 910], [0, -1152, 0, -5708, -32, 32], [-778, -832, -832, 778, 0, 928], [0, -1680, 0, 3556, -2952, 2952], [0, -885, 0, 2679, -475, 475], [-1320, 0, 2636, 0, 2276, 0], [4807, -1483, -1483, -4807, 0, -987], [0, 895, 0, -655, -2195, 2195], [9594, 0, -2592, 0, 1168, 0], [-755, 5825, 5825, 755, 0, 281], [0, 2212, 0, 12974, -228, 228], [-3730, 0, 220, 0, -1356, 0], [0, 2274, 0, 5134, 306, -306], [1031, 0, -337, 0, -805, 0], [0, -1600, 0, 2334, 2656, -2656], [9369, 0, 2649, 0, 505, 0], [0, -5400, 0, -664, -208, 208], [22362, -756, -756, -22362, 0, 792], [4739, 0, -321, 0, 1187, 0], [0, -2970, 0, -9372, 170, -170], [9500, 0, -2354, 0, 730, 0], [4579, -2563, -2563, -4579, 0, -531], [0, 396, 0, 9524, -496, 496], [348, -6880, -6880, -348, 0, 280], [-12915, 0, 311, 0, 515, 0], [3231, 2341, 2341, -3231, 0, 2913], [-23610, -3470, -3470, 23610, 0, -650], [-5368, 0, 6376, 0, 208, 0], [-4457, 2945, 2945, 4457, 0, 1385], [0, 2907, 0, 6489, -2455, 2455], [-7080, 0, 152, 0, 4112, 0], [1451, 1171, 1171, -1451, 0, 215], [23812, 0, -4610, 0, 1086, 0], [-5194, 2492, 2492, 5194, 0, -1208], [-6046, 0, -7504, 0, -2944, 0], [0, -3933, 0, 523, 421, -421], [0, -651, 0, 3323, 1051, -1051], [-5353, 0, 4989, 0, 1949, 0], [0, -4039, 0, -331, 27, -27], [9302, 0, -6710, 0, 730, 0], [23009, 879, 879, -23009, 0, 779], [0, 4080, 0, 3660, 1292, -1292], [14326, 0, 3234, 0, 1018, 0], [0, 4574, 0, -19080, 462, -462], [3894, 0, 4618, 0, -1250, 0], [-1782, 0, 1692, 0, -20, 0], [0, 148, 0, 10194, -1876, 1876], [13100, 2832, 2832, -13100, 0, 1264], [-7640, -4988, -4988, 7640, 0, 176], [-3926, 8732, 8732, 3926, 0, -2296], [6772, 0, 4066, 0, -3478, 0], [4728, 0, 5872, 0, 2420, 0], [576, -1400, -1400, -576, 0, 5032], [0, -490, 0, 26906, 1742, -1742], [-28488, 0, -192, 0, -2184, 0], [-6873, -1, -1, 6873, 0, 3115], [-20036, 2166, 2166, 20036, 0, 2086], [6735, 0, 5505, 0, -5231, 0], [0, 5814, 0, 2520, -5106, 5106], [13016, -2096, -2096, -13016, 0, -900], [-9396, 0, 7798, 0, -3422, 0], [9478, 0, 2902, 0, -3594, 0], [4448, 6440, 6440, -4448, 0, -2180], [0, 2276, 0, -18258, -3704, 3704], [0, 6175, 0, 23253, 1385, -1385], [0, 8288, 0, 22848, -96, 96], [0, -759, 0, -34667, 87, -87]]
