
# q-expansion of newform 7056.2.a.m, downloaded from the LMFDB on 18 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 = 7056
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], [0], [-2], [0], [-2], [-1], [0], [1], [0], [-4], [9], [3], [-10], [-5], [6], [-12], [12], [-10], [5], [-6], [3], [1], [-6], [16], [6], [2], [-7], [-8], [9], [-10], [15], [14], [12], [-3], [12], [16], [14], [-4], [14], [8], [2], [-13], [10], [11], [-16], [0], [-4], [16], [-18], [19], [-6], [6], [-14], [8], [26], [4], [6], [16], [13], [4], [-11], [8], [-17], [6], [1], [-24], [25], [13], [32], [14], [34], [20], [-9], [23], [-3], [12], [6], [9], [36], [-5], [-30], [-7], [-18], [-31], [0], [12], [18], [-11], [20], [17], [-6], [28], [-31], [-28], [-37], [42], [2], [12], [31], [-19], [-28], [2], [26], [26], [19], [17], [-16], [-6], [12], [9], [23], [34], [6], [-29], [-8], [0], [-19], [-2], [-18], [36], [41], [-41], [12], [-12], [-37], [0], [30], [18], [-13], [15], [15], [42], [-13], [-22], [-48], [49], [-34], [40], [-8], [-30], [32], [-2], [0], [-30], [-41], [44], [-35], [-32], [-40], [-54], [-38], [24], [13], [34], [37], [-24], [-23], [14], [-15], [-4], [-10], [-44], [-19], [-36], [18], [-36], [-17], [-19], [61], [32], [48], [18], [60], [5], [-19], [-16], [53], [-10], [24], [-31], [19], [0], [41], [-28], [-54], [-52], [46], [-17], [-23], [38], [-49], [-6], [40], [-36], [52], [-24], [35], [-18], [-30], [-12], [-14], [23], [-54], [14], [-38], [-22], [24], [-42], [36], [52], [39], [-24], [-4], [-4], [-44], [-7], [40], [-20], [28], [30], [5], [61], [-50], [64], [-50], [26], [-8], [-46], [47], [-6], [-11], [4], [49], [-46], [-63], [30], [35], [10], [-60], [22], [-18], [-39], [45], [-50], [72], [20], [-5], [-50], [8], [24], [77], [-24], [10], [-37], [64], [56], [-7], [-57], [-78], [-14], [-59], [56], [43], [61], [14], [-55], [6], [58], [44], [26], [-19], [4], [-37], [-47], [-10], [-76], [-38], [-81], [43], [-8], [-56], [-63], [-2], [-55], [20], [6], [25], [-6], [53], [18], [-4], [20], [-54], [-60], [-29], [46], [25], [-28], [34], [-1], [18], [6], [-28], [28], [3], [-75], [-6], [63], [16], [19], [-36], [70], [-90], [48], [8], [7], [6], [48], [-73], [54], [-19], [-41], [-42], [1], [42], [47], [-7], [53], [-52], [-30], [-23], [66], [17], [-66], [5], [-58], [-70], [-36], [19], [-59], [-17], [16], [48], [-37], [-14], [-26], [-25], [-4], [66], [-70], [76], [-54], [62], [0], [-65], [2], [-30], [60], [-32], [6], [-6], [-26], [30], [2], [41], [70], [8], [-1], [78], [84], [21], [-6], [-54], [95], [49], [56], [-8], [34], [36], [-57], [-16], [-60], [56], [4], [60], [28], [73], [-46], [-11], [42], [25], [54], [36], [-73], [-22], [58], [-44], [-78], [-15], [-102], [-14], [52], [-16], [-6], [66], [49], [-18], [-20], [101], [36], [46], [-44], [-16], [44], [-15], [90], [66], [-79], [12], [96], [24], [41], [-88], [-2], [10], [18], [58], [72], [-12], [72]]
