
# q-expansion of newform 8008.2.a.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
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K.gens()[0]**i for i in range(len(poly_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 = 8008
weight = 2
poly_data = [-1, -1, 1]

# The basis for the coefficient ring is just the power basis
# in the root of the defining polynomial above.
hecke_ring_character_values = None
aps_data = [[0, 0], [0, 1], [1, -1], [-1, 0], [1, 0], [-1, 0], [-4, 3], [-1, 5], [-4, 4], [0, 0], [0, 0], [6, -2], [-2, -6], [-4, 5], [-4, 0], [6, 1], [6, 0], [6, 3], [10, 1], [5, 5], [4, -6], [3, 1], [11, -3], [-6, 3], [-2, -8], [15, -5], [-8, 4], [16, -7], [-7, -1], [7, -3], [9, -17], [-6, 12], [-6, 16], [8, -12], [15, -11], [-16, 12], [10, 4], [-7, 11], [-4, 5], [19, 3], [12, -12], [-8, 12], [-22, 8], [14, -11], [0, -5], [11, -3], [4, -1], [-18, 18], [-2, 5], [11, 1], [-10, 8], [2, 8], [16, -12], [1, -3], [-2, -6], [3, 17], [-4, -12], [-4, 21], [12, 2], [-26, -3], [-18, -2], [-4, 16], [14, 1], [-1, 13], [-2, -12], [8, -14], [7, 13], [24, 6], [-13, -9], [18, 2], [30, 0], [-6, -10], [14, -15], [18, -2], [-6, 23], [-6, -4], [-3, 9], [8, -21], [-16, -10], [-14, 22], [0, 7], [14, 6], [-12, 10], [-32, 2], [-26, 16], [8, -10], [16, -12], [23, -29], [36, 4], [8, -4], [-28, -9], [-13, -17], [-28, 4], [-16, 24], [15, 5], [-6, 4], [-14, -4], [6, -4], [26, -18], [-26, 8], [-20, 8], [23, -3], [20, -12], [-4, 0], [5, -31], [6, -7], [-26, 34], [-8, 32], [32, -14], [-20, 9], [36, -14], [22, 0], [24, 14], [-20, -10], [-40, 15], [0, -23], [-8, -6], [0, -24], [6, 25], [28, 7], [7, 5], [22, -16], [-10, 13], [30, -21], [8, -12], [14, -30], [0, -12], [10, -35], [13, -17], [-6, 18], [8, -16], [-4, 30], [-8, -24], [25, 13], [18, 0], [16, -26], [-12, -25], [-26, 11], [-20, 18], [28, 6], [25, -25], [-44, 13], [0, 8], [40, -20], [-18, 24], [18, -4], [-26, -2], [7, -3], [0, -24], [28, -36], [-4, 17], [-24, 0], [-26, 0], [-2, -6], [36, -6], [8, -8], [-2, -23], [10, 23], [9, -41], [36, -6], [10, -19], [-10, -2], [-18, 22], [-25, 23], [-40, 16], [22, -26], [22, -40], [37, -15], [7, 7], [26, -28], [36, -10], [22, -28], [1, 23], [14, 9], [-14, -15], [40, -22], [6, 0], [8, -44], [12, -36], [11, -21], [5, -3], [-12, 32], [21, 9], [-18, 18], [-28, 27], [-4, -2], [20, -26], [6, -4], [-1, 27], [12, -44], [-34, -10], [18, 10], [-26, 6], [-36, 9], [4, 0], [50, -8], [38, -7], [-18, -9], [-18, 26], [-34, 42], [-8, 9], [-32, 30], [5, 35], [-13, 17], [2, 8], [20, 4], [-16, -28], [-16, -20], [35, -25], [-57, 15], [-36, 4], [-32, 32], [28, 2], [-30, 4], [41, 9], [-23, 49], [14, -37], [-22, 44], [56, -7], [14, -14], [-22, -16], [-20, -4], [60, -20], [-1, -21], [2, -16], [22, 0], [-46, 8], [-44, 20], [-70, 0], [18, -28], [2, 37], [-24, -22], [-2, 24], [26, -52], [3, -21], [8, 5], [-22, 52], [39, -15], [24, -30], [34, 5], [-24, -12], [-28, -8], [-38, 9], [-30, 42], [-12, -20], [0, -22], [-2, 10], [32, 18], [-16, 36], [32, 0], [-23, 7], [6, -26], [-32, 49], [-32, -20], [-47, 45], [62, -6], [18, -45], [-13, 5], [-16, -14], [-16, 46], [22, 13], [32, -15], [10, 26], [21, -15], [-50, 17], [-32, 19], [32, -10], [30, -39], [-34, 18], [42, -20], [46, 2], [-9, -35], [-63, 1], [26, -13], [52, -13], [22, 12], [-17, 21], [-36, 37], [2, -12], [6, 4], [34, -36], [23, -61], [-12, 28], [-32, 4], [-46, 19], [-22, 56], [13, -33], [-40, 17], [16, -44], [-8, -15], [-6, 4], [-28, 20], [-17, 7], [-49, -7], [46, -34], [-46, 44], [-58, 3], [26, -2], [-26, 58], [64, -32], [-10, -40], [52, -29], [8, 32], [58, -18], [2, 12], [-82, 10], [-6, 4], [18, 28], [31, 3], [66, -18], [4, -18], [12, 8], [-2, 16], [70, -12], [60, -8], [43, -63], [8, 6], [-6, -44], [7, -53], [32, -48], [-6, 2], [14, -30], [70, -25], [-4, -15], [42, 29], [-28, -6], [-2, -23], [-46, 10], [33, 3], [6, -16], [-16, -19], [-37, 51], [-18, 22], [-17, -3], [36, -52], [2, 20], [36, 20], [-66, 0], [25, 9], [-6, 26], [-16, 18], [54, -24], [-30, -18], [80, -14], [-14, 58], [-59, 13], [-50, 34], [-16, 8], [-4, -12], [30, -64], [-22, 11], [36, -18], [-16, 34], [38, 2], [-30, 0], [-22, 52], [64, -22], [4, -36], [20, -22], [33, 17], [16, -41], [-5, -23], [18, 40], [2, -44], [36, -49], [-51, 31], [-58, -22], [-58, 14], [-34, 56], [62, 16], [-75, -7], [68, -26], [-40, 54], [-4, 12], [-58, 7], [40, -14], [75, -23], [-8, 34], [-16, -17], [-73, 37], [49, -29], [10, -40], [48, -40], [59, -53], [-20, 48], [28, 14], [44, -24], [0, -28], [-4, 50], [-3, -29], [-12, 0], [70, -32], [-38, 57], [-19, 9], [-4, 1], [-28, -8], [23, -5], [-26, -10], [-10, -16], [33, -61], [-6, 52], [56, 9], [24, 30], [-10, -33], [42, 36], [22, -56], [-8, -36], [65, -43], [-58, 14], [42, -20], [35, -55], [-30, -10], [70, -24], [-69, 19], [86, -12], [-26, 12], [68, -46], [41, -41], [-43, 77], [-70, 36], [-31, -7], [70, -38], [-25, 11], [62, 20], [-70, 23], [59, -39], [40, -32], [71, 11], [-20, -38], [-16, 24]]
