
# q-expansion of newform 1568.3.g.m, downloaded from the LMFDB on 24 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 = 1568
weight = 3
poly_data = [256, -64, -32, -8, 24, -2, -2, -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, 0, 0, 0, 0, 0], 1], [[16, 12, -10, 0, 1, 1, 0, 0], 8], [[-16, 8, 8, -2, -2, -1, 1, 0], 16], [[0, 0, -20, 2, 0, -1, -1, 0], 8], [[64, -48, 0, 8, 10, -6, -1, 1], 32], [[-64, -88, 0, 22, -4, -3, 0, 1], 16], [[192, 16, -8, -20, 18, 0, 1, -3], 32], [[-384, 128, 88, 80, -22, -2, 1, 3], 32]]

hecke_ring_character_values = [[1471, [-1, 0, 0, 0, 0, 0, 0, 0]], [197, [-1, 0, 0, 0, 0, 0, 0, 0]], [1473, [1, 0, 0, 0, 0, 0, 0, 0]]]
aps_data = [[0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, -1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [4, 0, 0, 0, 0, 1, 1, 0], [0, 1, 0, -1, 2, 0, 0, 0], [10, 0, -4, 0, 0, 0, 0, 0], [7, 0, -1, 0, 0, 0, 0, 0], [0, 2, 0, 0, -2, 0, 0, -1], [0, 3, 0, 1, 1, 0, 0, -1], [0, 0, 0, -3, 0, 0, 0, 0], [0, 1, 0, -1, -5, 0, 0, 1], [-16, 0, -2, 0, 0, 4, 2, 0], [0, 0, 4, 0, 0, 1, -3, 0], [0, -4, 0, -1, -4, 0, 0, -2], [0, 5, 0, -1, 1, 0, 0, -1], [13, 0, 13, 0, 0, 2, -6, 0], [0, 3, 0, 0, -8, 0, 0, 0], [-38, 0, 6, 0, 0, -1, 3, 0], [0, 6, 0, -7, 10, 0, 0, 0], [14, 0, 0, 0, 0, -4, -4, 0], [0, 12, 0, 3, 0, 0, 0, 2], [9, 0, 1, 0, 0, 6, -2, 0], [64, 0, 6, 0, 0, 4, 6, 0], [-8, 0, 6, 0, 0, 8, -2, 0], [0, 3, 0, 11, 4, 0, 0, 2], [0, 10, 0, -6, 6, 0, 0, 0], [-86, 0, -2, 0, 0, 3, 3, 0], [0, -9, 0, 9, -3, 0, 0, -1], [17, 0, -19, 0, 0, 8, 3, 0], [0, -16, 0, 8, -4, 0, 0, 1], [-59, 0, -3, 0, 0, -6, 2, 0], [16, 0, -6, 0, 0, 0, 6, 0], [-93, 0, -21, 0, 0, 4, -4, 0], [0, -3, 0, 7, 5, 0, 0, 7], [0, -30, 0, 2, -10, 0, 0, 1], [0, 1, 0, -7, 6, 0, 0, 8], [-24, 0, 20, 0, 0, 13, 5, 0], [0, -22, 0, -4, -2, 0, 0, 6], [0, 1, 0, -13, 6, 0, 0, -4], [-26, 0, -14, 0, 0, -5, 7, 0], [0, 13, 0, 0, 22, 0, 0, -2], [0, -8, 0, -3, 28, 0, 0, 2], [25, 0, 37, 0, 0, 0, -5, 0], [0, 17, 0, -13, 5, 0, 0, -5], [0, 10, 0, -6, 22, 0, 0, -12], [62, 0, 10, 0, 0, -5, -1, 0], [0, 32, 0, -4, 8, 0, 0, 6], [-29, 0, 11, 0, 0, -4, 4, 0], [0, -1, 0, 13, 2, 0, 0, 12], [56, 0, 50, 0, 0, -8, -2, 0], [0, 20, 0, -16, 16, 0, 0, -1], [-96, 0, -18, 0, 0, 8, -2, 0], [-131, 0, 37, 0, 0, 26, 18, 0], [98, 0, -4, 0, 0, 0, -20, 0], [0, -26, 0, 3, 18, 0, 0, -8], [0, -35, 0, 1, -18, 0, 0, 0], [0, -4, 0, 2, 20, 0, 0, -10], [0, 1, 0, 5, 5, 0, 0, 19], [130, 0, -32, 0, 0, 16, 16, 0], [43, 0, -53, 0, 0, -4, 12, 0], [0, 11, 0, 11, 12, 0, 0, -6], [85, 0, 29, 0, 0, -14, 2, 0], [0, -26, 0, 23, -22, 0, 0, 16], [88, 0, 22, 0, 0, -12, -38, 0], [0, 39, 0, 3, -25, 0, 0, -3], [-48, 0, 4, 0, 0, -23, -35, 0], [131, 0, 3, 0, 0, -24, -35, 0], [-76, 0, 8, 0, 0, -11, 9, 0], [0, -41, 0, -2, 30, 0, 0, 10], [-64, 0, -90, 0, 0, -16, -6, 0], [0, -34, 0, -8, -30, 0, 0, -9], [0, -4, 0, -4, 12, 0, 0, -22], [0, -55, 0, -3, -23, 0, 0, -9], [-80, 0, 36, 0, 0, 1, 29, 0], [0, 40, 0, -39, -8, 0, 0, -6], [0, -75, 0, 25, 19, 0, 0, 5], [0, 35, 0, -6, 22, 0, 0, -6], [-21, 0, -117, 0, 0, -16, 13, 0], [-110, 0, 84, 0, 0, -36, -20, 0], [195, 0, -13, 0, 0, 4, 44, 0], [0, 25, 0, -5, -3, 0, 0, -9], [0, 20, 0, 14, -16, 0, 0, 21], [-66, 0, 56, 0, 0, 0, 36, 0], [0, -2, 0, 25, -6, 0, 0, 34], [-142, 0, 78, 0, 0, -9, -13, 0], [-184, 0, -46, 0, 0, -32, 6, 0], [-15, 0, 93, 0, 0, 24, 35, 0], [0, 11, 0, 6, 18, 0, 0, -34], [0, -28, 0, -9, -40, 0, 0, -6], [55, 0, 47, 0, 0, -16, -32, 0], [0, -40, 0, -49, 8, 0, 0, 0], [0, 14, 0, -14, 50, 0, 0, 3], [-450, 0, -22, 0, 0, 3, 7, 0], [138, 0, -130, 0, 0, -13, 27, 0], [0, -34, 0, -41, 26, 0, 0, -2], [0, -45, 0, 20, 30, 0, 0, -10], [290, 0, 4, 0, 0, 20, 36, 0], [-159, 0, 17, 0, 0, 54, 22, 0], [0, 31, 0, -61, 75, 0, 0, -11], [332, 0, -136, 0, 0, -31, -15, 0], [0, 3, 0, -21, -65, 0, 0, 5], [89, 0, -55, 0, 0, 22, 6, 0], [19, 0, 83, 0, 0, -16, 13, 0], [208, 0, -124, 0, 0, 49, 29, 0], [-16, 0, -42, 0, 0, 8, 66, 0], [-565, 0, 35, 0, 0, -36, -44, 0], [-562, 0, -48, 0, 0, -32, 32, 0], [0, 106, 0, -29, 38, 0, 0, -4], [224, 0, 70, 0, 0, 20, 6, 0], [0, 16, 0, 30, -64, 0, 0, 12], [0, 9, 0, 35, 15, 0, 0, 17], [547, 0, -45, 0, 0, -24, -27, 0], [-89, 0, 71, 0, 0, 8, 32, 0], [0, 66, 0, -53, 70, 0, 0, -12], [-113, 0, 55, 0, 0, -16, -47, 0], [297, 0, -103, 0, 0, -10, 22, 0], [0, -22, 0, 4, -18, 0, 0, 12], [0, 39, 0, -11, 5, 0, 0, -29], [172, 0, 232, 0, 0, 9, 17, 0], [0, -37, 0, -7, 16, 0, 0, -14], [162, 0, 0, 0, 0, 40, 80, 0], [0, 73, 0, -48, -78, 0, 0, 2], [402, 0, 86, 0, 0, 11, 27, 0], [-35, 0, 53, 0, 0, 74, 42, 0], [0, 55, 0, 35, -47, 0, 0, 11], [0, 141, 0, 13, 39, 0, 0, 41], [0, 44, 0, 13, 84, 0, 0, -18], [0, 134, 0, 22, 42, 0, 0, -10], [0, 151, 0, 10, 40, 0, 0, 12], [-720, 0, -4, 0, 0, 5, -3, 0], [0, -82, 0, 42, 26, 0, 0, 27], [0, 36, 0, 8, -56, 0, 0, 17], [0, -27, 0, -81, -29, 0, 0, -51], [-68, 0, 66, 0, 0, 20, -2, 0], [-388, 0, -14, 0, 0, 0, -38, 0], [0, 129, 0, -76, 16, 0, 0, -16], [-473, 0, -33, 0, 0, -72, 16, 0], [0, 5, 0, 91, -26, 0, 0, 12], [149, 0, 201, 0, 0, 24, 55, 0], [-829, 0, -29, 0, 0, 4, -28, 0], [0, -115, 0, -5, -27, 0, 0, -49], [0, 90, 0, 27, 14, 0, 0, 24], [278, 0, 122, 0, 0, -1, -89, 0], [0, -41, 0, -22, -108, 0, 0, -8], [0, -38, 0, -18, 126, 0, 0, 24], [0, 79, 0, 47, 74, 0, 0, 0], [-254, 0, -44, 0, 0, 12, -12, 0], [361, 0, -15, 0, 0, 38, -10, 0], [0, -96, 0, -63, 4, 0, 0, 22], [0, -45, 0, 19, 13, 0, 0, 19], [-588, 0, -78, 0, 0, 0, 54, 0], [738, 0, 134, 0, 0, -21, 51, 0], [0, -82, 0, 60, -182, 0, 0, 6], [130, 0, -146, 0, 0, -57, -45, 0], [0, 108, 0, 38, -8, 0, 0, 55], [0, 114, 0, -47, -18, 0, 0, 4], [278, 0, 208, 0, 0, -48, -28, 0], [110, 0, 80, 0, 0, 108, 20, 0], [0, 21, 0, 17, -28, 0, 0, 30], [140, 0, -56, 0, 0, 9, -63, 0], [-874, 0, 44, 0, 0, 32, 4, 0], [0, 54, 0, -8, -142, 0, 0, -5], [589, 0, -67, 0, 0, -102, -54, 0], [-184, 0, -158, 0, 0, -48, 14, 0], [0, 158, 0, 16, 42, 0, 0, -36], [0, 8, 0, 7, 52, 0, 0, 42], [0, -51, 0, -18, 92, 0, 0, -32], [-395, 0, 89, 0, 0, 48, 87, 0], [0, -137, 0, 91, -58, 0, 0, 12], [694, 0, 18, 0, 0, -61, -17, 0], [0, -61, 0, 0, -58, 0, 0, 38], [0, 22, 0, -49, -62, 0, 0, -24], [810, 0, -40, 0, 0, 16, 8, 0], [0, -12, 0, 31, -164, 0, 0, -6], [416, 0, 230, 0, 0, 4, -74, 0], [-558, 0, 182, 0, 0, -13, -69, 0], [0, -87, 0, -77, 31, 0, 0, 17], [0, 146, 0, -3, -42, 0, 0, 24], [0, -47, 0, 11, -20, 0, 0, 2], [0, 0, 0, 132, 20, 0, 0, 45], [197, 0, -203, 0, 0, -22, -22, 0], [0, -39, 0, -41, -21, 0, 0, -7], [386, 0, -36, 0, 0, -108, -104, 0], [0, 12, 0, -52, -48, 0, 0, -33], [0, -1, 0, -61, 18, 0, 0, -16], [0, -153, 0, 47, -101, 0, 0, -31], [-33, 0, 151, 0, 0, -96, -56, 0], [-752, 0, -134, 0, 0, 16, -74, 0], [0, 32, 0, -89, 8, 0, 0, 0], [92, 0, -118, 0, 0, 88, 118, 0], [-1170, 0, 34, 0, 0, 7, -33, 0], [686, 0, -238, 0, 0, 63, 87, 0], [0, -11, 0, -65, 158, 0, 0, 36], [-290, 0, 50, 0, 0, -89, -89, 0], [316, 0, -38, 0, 0, 52, 50, 0], [251, 0, -53, 0, 0, 120, -11, 0], [0, -17, 0, 159, 21, 0, 0, 23], [64, 0, -234, 0, 0, 8, -70, 0], [0, -278, 0, -21, -26, 0, 0, -14], [0, 175, 0, -15, 7, 0, 0, -7], [0, 84, 0, -59, 132, 0, 0, -20], [0, -83, 0, -36, 168, 0, 0, 24], [1228, 0, -6, 0, 0, -32, -2, 0], [193, 0, -111, 0, 0, 70, -10, 0], [0, -47, 0, 129, -68, 0, 0, 22], [0, -128, 0, -27, 192, 0, 0, 36], [124, 0, 16, 0, 0, -51, 41, 0], [49, 0, -163, 0, 0, 32, 131, 0], [-1235, 0, 117, 0, 0, 18, -14, 0], [47, 0, 407, 0, 0, 128, -15, 0], [0, -39, 0, -10, -204, 0, 0, -8], [0, 210, 0, 34, -42, 0, 0, 49], [219, 0, 43, 0, 0, 4, 140, 0], [0, -134, 0, -3, -74, 0, 0, 18], [-536, 0, -314, 0, 0, 12, -78, 0], [0, -20, 0, 57, -168, 0, 0, 26], [-316, 0, -182, 0, 0, 8, -22, 0], [0, 122, 0, 51, 54, 0, 0, -24], [0, 63, 0, -133, 213, 0, 0, -17], [0, -175, 0, -33, -145, 0, 0, 65], [0, 62, 0, -15, -70, 0, 0, -34], [-310, 0, 264, 0, 0, 24, 48, 0], [0, 12, 0, -104, 120, 0, 0, -61], [1119, 0, 247, 0, 0, 8, 72, 0], [0, 65, 0, 29, 83, 0, 0, 17], [-804, 0, -310, 0, 0, -76, 74, 0], [0, 136, 0, -56, -140, 0, 0, -33], [0, 274, 0, -33, 54, 0, 0, 2], [96, 0, 140, 0, 0, -67, -43, 0], [0, 91, 0, 63, 133, 0, 0, 63], [831, 0, -225, 0, 0, -24, -80, 0], [0, -440, 0, 31, -100, 0, 0, 6], [1274, 0, 40, 0, 0, 8, -80, 0], [-541, 0, -29, 0, 0, 92, 36, 0], [0, -132, 0, -6, 36, 0, 0, 34], [158, 0, 296, 0, 0, 120, -12, 0], [0, -127, 0, 5, 5, 0, 0, 51], [-1182, 0, -50, 0, 0, -17, 99, 0], [0, -54, 0, 7, -82, 0, 0, -72], [-680, 0, 12, 0, 0, 89, -19, 0], [321, 0, -95, 0, 0, 110, 70, 0], [0, -118, 0, -75, -138, 0, 0, -86], [0, 91, 0, -13, -29, 0, 0, 9], [1272, 0, -18, 0, 0, 40, -22, 0], [0, 134, 0, -112, 114, 0, 0, -68], [0, -208, 0, 136, -88, 0, 0, 52], [345, 0, 353, 0, 0, 22, -146, 0], [-4, 0, 136, 0, 0, 9, -55, 0], [0, -12, 0, -41, 32, 0, 0, -94], [0, -97, 0, -17, -153, 0, 0, -79], [-608, 0, 182, 0, 0, 88, 186, 0], [0, -82, 0, -123, -22, 0, 0, 16], [-272, 0, 70, 0, 0, -20, 70, 0], [0, -117, 0, -86, -8, 0, 0, -28], [290, 0, -178, 0, 0, -49, 59, 0], [0, 89, 0, 65, -53, 0, 0, 57], [123, 0, 35, 0, 0, -180, -76, 0], [0, 117, 0, -126, -80, 0, 0, 4], [-18, 0, -312, 0, 0, 76, -40, 0], [0, 16, 0, -110, 68, 0, 0, 7], [896, 0, -380, 0, 0, -127, -43, 0], [0, 177, 0, -100, -4, 0, 0, -12], [0, 95, 0, 54, -192, 0, 0, -44], [336, 0, 126, 0, 0, -40, -18, 0], [-1939, 0, -19, 0, 0, -46, -62, 0], [0, -209, 0, -51, -169, 0, 0, 69], [216, 0, -98, 0, 0, 92, 318, 0], [-394, 0, 266, 0, 0, -57, 55, 0], [0, 9, 0, -41, 95, 0, 0, -51], [0, -147, 0, -83, 82, 0, 0, 76], [1652, 0, 168, 0, 0, 29, -111, 0], [-1156, 0, 234, 0, 0, -108, -198, 0], [0, 264, 0, -100, -236, 0, 0, -11], [-594, 0, -448, 0, 0, -72, 80, 0], [0, 238, 0, -43, -118, 0, 0, 76], [620, 0, -312, 0, 0, -79, -87, 0], [0, -133, 0, -119, 43, 0, 0, -19], [577, 0, -19, 0, 0, 64, 99, 0], [-339, 0, -123, 0, 0, -94, -118, 0], [0, 120, 0, 196, -120, 0, 0, -18], [0, 142, 0, 149, 10, 0, 0, -76], [0, 150, 0, -164, -150, 0, 0, -22], [0, -85, 0, 23, 12, 0, 0, -46], [-789, 0, -421, 0, 0, -68, 44, 0], [0, 108, 0, 92, 0, 0, 0, -101], [-494, 0, -416, 0, 0, -24, -72, 0], [0, -119, 0, 1, -59, 0, 0, -41], [0, -290, 0, 156, -126, 0, 0, 18], [-924, 0, -206, 0, 0, -72, -10, 0], [0, -165, 0, 7, -197, 0, 0, 65], [573, 0, -267, 0, 0, -158, -6, 0], [-101, 0, -37, 0, 0, -248, -35, 0], [799, 0, -177, 0, 0, -88, 8, 0], [0, -57, 0, -59, 23, 0, 0, 37], [0, -313, 0, 18, 178, 0, 0, -2], [0, -272, 0, 178, 56, 0, 0, 2], [0, -13, 0, -159, 14, 0, 0, -96], [2257, 0, 185, 0, 0, 6, -82, 0], [635, 0, -293, 0, 0, -92, -172, 0], [526, 0, 312, 0, 0, 124, 48, 0], [0, -85, 0, 51, -163, 0, 0, 107], [0, -28, 0, 175, 40, 0, 0, -6]]
