
# q-expansion of newform 600.3.l.f, downloaded from the LMFDB on 25 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 = 600
weight = 3
poly_data = [864, -96, 168, -136, 49, 20, -2, -4, 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], 1], [[-26976, -20988, 12557, 3613, -280, -530, 53, 7], 9300], [[-3912, 1704, -16366, 6186, 2045, -375, -319, 69], 18600], [[2064, -52728, -998, -2562, 65, -115, 213, -83], 18600], [[10584, 2136, -5698, 950, 927, -71, -89, 21], 3720], [[5424, 1152, 672, 2488, 5, -295, -17, 27], 3720], [[27036, 16968, -5602, -6418, -20, 405, 192, -77], 9300], [[-804, 1788, -507, 232, 145, -30, -28, 8], 930]]

hecke_ring_character_values = [[151, [1, 0, 0, 0, 0, 0, 0, 0]], [301, [1, 0, 0, 0, 0, 0, 0, 0]], [401, [-1, 0, 0, 0, 0, 0, 0, 0]], [577, [1, 0, 0, 0, 0, 0, 0, 0]]]
aps_data = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 1, 1, 1, 0, 0], [0, 1, -2, -1, 2, -1, 0, 1], [3, -1, -1, 1, 1, 1, -1, 0], [1, 2, -1, -1, 0, 2, 0, -1], [-3, -1, 1, -2, -2, -3, -2, 0], [-1, -1, -2, 0, 3, -4, 0, 0], [3, 1, -3, 2, 0, 1, 0, -5], [15, -1, 5, 2, 2, -1, -4, 0], [1, 1, -7, -1, -1, 3, 5, 0], [-9, -5, 9, -4, 0, -5, 0, -4], [44, -1, -3, 1, 1, 2, 0, 0], [5, 1, -4, 4, -1, 2, 0, -2], [-4, -6, 0, 2, 4, -10, 0, 7], [2, -3, -2, 5, 0, -3, 0, 11], [1, -7, -9, -8, -8, -7, -6, 0], [-28, 3, 13, -1, -1, -6, -2, 0], [-2, -4, -4, 2, 6, -10, 0, 6], [0, -2, 2, 4, 4, 2, -4, 0], [13, -1, -7, -2, -2, 1, 2, 0], [10, 3, -13, 7, 3, 0, 0, -20], [18, 2, -26, 16, 8, -6, 0, 4], [-14, -8, -8, -4, -4, -4, -8, 0], [-15, 1, 15, -16, 0, 1, 0, -7], [7, -4, 16, -5, -5, -15, -14, 0], [14, 9, -23, 5, 9, 0, 0, -8], [-23, -7, -5, -2, -2, -3, -8, 0], [23, 10, -27, 13, 4, 6, 0, -3], [49, 12, 12, 7, 7, 7, 12, 0], [18, 19, -20, -1, 2, 17, 0, -1], [-11, 4, -1, -15, 12, -8, 0, 11], [5, -1, -23, 10, 10, 21, 10, 0], [10, -8, 6, 18, -16, 8, 0, -1], [17, 1, 15, 8, 8, 1, -6, 0], [29, -11, 1, -15, -15, -21, -17, 0], [66, 15, -7, 9, 9, 20, 26, 0], [11, 9, -22, 2, 11, -2, 0, 10], [18, 4, 6, 14, -24, 28, 0, -11], [26, 11, -26, 15, 0, 11, 0, -15], [-156, 14, 18, -16, -16, -18, 12, 0], [0, 10, 10, -10, -10, 20, 0, -24], [-188, 18, 34, -6, -6, -14, 10, 0], [2, 2, 2, 0, -4, 6, 0, -51], [3, 5, 23, -8, -8, -17, -4, 0], [71, 3, -19, -16, -16, -5, 14, 0], [41, 0, -16, 15, 15, 23, 8, 0], [-28, -29, 49, 1, -21, -8, 0, -12], [0, -6, -54, -10, -10, 14, 18, 0], [37, -6, -29, 43, -8, 2, 0, -7], [6, 0, -18, 6, 12, -12, 0, -12], [-193, -1, 17, -24, -24, -33, -10, 0], [-12, -23, 22, 11, -10, -13, 0, 5], [17, -14, -13, 31, -4, -10, 0, -9], [15, 27, -30, -12, 15, 12, 0, 12], [-34, -24, 58, -10, -24, 0, 0, 29], [73, -3, 11, -24, -24, -31, -10, 0], [139, 15, -13, -13, -13, 1, 29, 0], [-1, 25, 1, -26, 0, 25, 0, -40], [216, -3, 7, -33, -33, -38, -8, 0], [-34, -16, 42, -18, -8, -8, 0, -9], [-188, -15, -49, -11, -11, 6, 2, 0], [-26, -16, 24, -10, 2, -18, 0, -14], [-50, 12, 44, 44, 44, 28, -4, 0], [2, 26, -38, -24, 36, -10, 0, 59], [91, -9, -15, 28, 28, 31, -6, 0], [62, 20, 80, 30, 30, 0, -10, 0], [10, 15, -25, -5, 15, 0, 0, -20], [-162, -20, -72, -10, -10, 16, 6, 0], [5, 20, -57, -15, 52, -32, 0, 13], [-18, -10, 6, -8, 12, -22, 0, -38], [49, 6, -22, 29, 29, 43, 20, 0], [-141, -33, -1, -27, -27, -43, -49, 0], [-59, 27, 21, -30, -30, -27, 30, 0], [-45, -41, 60, -4, -15, -26, 0, -34], [-86, -34, 78, -52, 8, -42, 0, -9], [-121, -21, 31, 19, 19, -7, -47, 0], [18, 0, -74, 18, 56, -56, 0, -12], [191, 27, 13, 44, 44, 51, 34, 0], [-12, 47, -24, -59, 36, 11, 0, 13], [41, 33, 71, 4, 4, -15, 14, 0], [34, 14, -24, 20, -10, 24, 0, -92], [50, 24, 72, 28, 28, 4, 0, 0], [455, 5, -9, -4, -4, 3, 12, 0], [-80, -43, 79, -37, 1, -44, 0, -48], [-11, 1, 27, -12, -16, 17, 0, 64], [6, 16, 44, -46, -46, -60, 2, 0], [-31, -9, -1, -22, 32, -41, 0, -77], [221, 12, 24, 17, 17, 11, 6, 0], [0, -3, 27, 3, -27, 24, 0, -28], [22, 48, 6, -26, -28, 76, 0, -32], [311, -34, -86, -37, -37, -11, -8, 0], [46, -35, -36, 81, -10, -25, 0, 49], [-427, 11, 5, 42, 42, 45, 14, 0], [-7, 43, -38, -50, 45, -2, 0, 18], [-131, -27, 123, -104, 8, -35, 0, -41], [38, -30, 26, 68, -64, 34, 0, -18], [-32, -37, -3, -9, -9, -26, -54, 0], [-270, -16, 48, 24, 24, -8, -48, 0], [-228, 5, -45, 21, 21, 46, 30, 0], [-40, -62, 32, 22, 8, -70, 0, 53], [-40, 21, 9, -61, 31, -10, 0, 62], [33, 15, -41, 18, 8, 7, 0, -122], [-229, 43, 101, -4, -4, -33, 14, 0], [-168, -30, -38, -30, -30, -26, -26, 0], [-48, 45, 13, -93, 35, 10, 0, -42], [21, 32, 39, -11, -60, 92, 0, -167], [-70, -30, 86, -40, -16, -14, 0, 142], [205, -3, -61, -64, -64, -35, 26, 0], [201, -4, 56, 45, 45, 15, -34, 0], [-67, 5, -75, 27, 27, 67, 45, 0], [75, 38, -107, 37, 32, 6, 0, 43], [-303, -13, -3, -34, -34, -39, -18, 0], [-253, 39, 13, -34, -34, -21, 52, 0], [-121, -35, 153, -86, -32, -3, 0, 102], [-46, 9, -13, 61, 61, 72, 20, 0], [-19, -23, 6, 4, 13, -36, 0, 132], [-30, -32, 114, 2, -84, 52, 0, 73], [-46, -69, 46, 23, 0, -69, 0, 97], [-15, -31, 7, 20, 20, 1, -50, 0], [-42, 28, 12, 8, 8, 16, 36, 0], [-130, -36, 158, -94, -28, -8, 0, -73], [42, 39, 29, 3, -71, 110, 0, 30], [-217, 15, 1, 4, 4, 11, 22, 0], [48, 60, -104, -12, 56, 4, 0, 1], [226, 32, -52, -22, -22, 20, 74, 0], [-100, -28, 104, -72, -4, -24, 0, -68], [483, 14, 82, -5, -5, -39, -20, 0], [-267, 37, -3, 11, 11, 31, 57, 0], [145, -57, -39, 82, 82, 73, -66, 0], [13, -1, 10, 14, -23, 22, 0, -66], [19, 7, 173, 38, 38, -45, -76, 0], [-217, 19, -81, -21, -21, 29, 69, 0], [14, -42, -22, 56, 8, -50, 0, 22], [310, 24, 64, 76, 76, 56, 4, 0], [38, 78, -90, -40, 52, 26, 0, -155], [-744, -27, -81, -25, -25, 2, 0, 0], [-22, -42, 98, 20, -76, 34, 0, 19], [4, 50, -108, -46, 104, -54, 0, 0], [63, 67, 109, 88, 88, 67, 46, 0], [-188, -82, 292, -106, -104, 22, 0, 83], [-329, 0, -60, -37, -37, -7, 30, 0], [184, 31, -213, 153, 29, 2, 0, 94], [-667, 13, 31, 82, 82, 73, 4, 0], [62, 74, -190, -12, 128, -54, 0, 42], [453, -51, -11, -9, -9, -29, -71, 0], [-99, 16, 175, -115, -76, 92, 0, -97], [-575, -85, -75, -90, -90, -95, -90, 0], [-5, -17, 28, 12, -23, 6, 0, 34], [101, -75, -87, -51, -51, -45, -69, 0], [69, 5, 59, 64, -128, 133, 0, -2], [-110, -45, -19, -55, -55, -68, -58, 0], [13, -35, 82, 48, -95, 60, 0, -196], [-82, 13, 139, 35, 35, -28, -50, 0], [-138, -22, 44, -116, 94, -116, 0, 72], [877, -13, -91, -22, -22, 17, 26, 0], [71, -13, -55, 84, -16, 3, 0, 148], [-802, 68, 144, -14, -14, -52, 30, 0], [-25, -93, 33, 68, -8, -85, 0, 51], [-144, 55, 121, -199, 23, 32, 0, -48], [-63, -126, 155, 63, -92, -34, 0, -63], [179, -12, -248, 63, 63, 181, 106, 0], [152, 61, -242, 91, 90, -29, 0, -71], [-33, -84, 1, 51, 32, -116, 0, 71], [-83, -85, 46, 2, 37, -122, 0, 54], [317, 89, 119, 108, 108, 93, 74, 0], [-789, -33, -33, -15, -15, -15, -33, 0]]
