
# q-expansion of newform 8624.2.a.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
    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 = 8624
weight = 2
poly_data = [0, 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], [-1], [1], [0], [-1], [0], [2], [-2], [7], [-10], [7], [-9], [2], [4], [8], [2], [-15], [14], [-3], [-3], [-10], [-10], [0], [11], [-7], [-12], [12], [18], [16], [-3], [10], [2], [5], [6], [-2], [-10], [9], [-4], [18], [4], [1], [-5], [17], [-6], [18], [-16], [10], [15], [-4], [7], [2], [16], [-4], [1], [30], [6], [18], [20], [28], [-24], [-16], [-18], [16], [-24], [19], [-3], [7], [2], [30], [-26], [-21], [12], [35], [-4], [3], [15], [-11], [14], [18], [18], [-40], [-26], [12], [29], [-6], [-23], [31], [40], [18], [-23], [9], [16], [-25], [-18], [20], [4], [15], [45], [20], [4], [-16], [10], [4], [-6], [-20], [21], [28], [-18], [-16], [32], [34], [16], [18], [-21], [7], [-17], [1], [21], [-13], [-50], [13], [-8], [-42], [36], [29], [16], [-5], [27], [-37], [44], [38], [16], [13], [-50], [-36], [44], [38], [10], [9], [-18], [-18], [-30], [19], [24], [37], [3], [26], [36], [-35], [28], [-22], [-31], [20], [-6], [-8], [32], [-4], [-34], [48], [-42], [-19], [-44], [18], [55], [-15], [3], [48], [-28], [48], [11], [20], [30], [30], [-44], [-39], [13], [22], [-45], [-26], [-10], [-52], [8], [49], [-28], [21], [-54], [-52], [20], [24], [-30], [49], [-42], [-11], [-18], [14], [-33], [16], [-61], [-22], [-14], [-22], [12], [-38], [-34], [63], [-15], [-55], [6], [20], [28], [-60], [-45], [-13], [-12], [-64], [-45], [0], [70], [-36], [-5], [60], [58], [29], [-39], [52], [26], [-6], [-32], [52], [-36], [-23], [2], [56], [-68], [-71], [-66], [25], [6], [-25], [-3], [-41], [-46], [-52], [-71], [30], [-14], [-56], [20], [-6], [-26], [-16], [-56], [-43], [-54], [-52], [-6], [38], [26], [-39], [36], [-44], [48], [30], [-16], [18], [-52], [-5], [65], [6], [0], [41], [71], [-14], [12], [54], [11], [43], [58], [50], [0], [36], [-47], [66], [-18], [-34], [-27], [42], [-26], [-27], [24], [-51], [-68], [-4], [28], [62], [8], [-27], [-29], [6], [8], [-32], [-36], [-78], [-60], [15], [23], [-81], [-19], [80], [-52], [62], [26], [-86], [-19], [-50], [50], [7], [14], [26], [78], [68], [5], [-18], [29], [-22], [7], [71], [-29], [-54], [-48], [72], [54], [22], [70], [82], [-7], [49], [-70], [-77], [-44], [-51], [-57], [-84], [-17], [-85], [24], [-85], [35], [40], [31], [-40], [55], [-30], [18], [-36], [-36], [-3], [74], [-72], [-51], [-10], [18], [51], [48], [-81], [53], [24], [36], [76], [-35], [20], [-36], [64], [-80], [21], [-92], [78], [58], [64], [32], [-10], [47], [-58], [-78], [68], [-9], [40], [61], [34], [67], [89], [-37], [45], [3], [59], [86], [88], [-82], [-28], [0], [-66], [-43], [24], [-42], [-56], [-22], [-46], [40], [84], [3], [-72], [-24], [-20], [-88], [-90], [21], [-64], [31], [54], [34], [39], [-8], [36], [18], [-54], [3], [-13], [-48], [11], [-38]]
