
# q-expansion of newform 8036.2.a.f, downloaded from the LMFDB on 23 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 = 8036
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], [3], [-2], [-1], [3], [-5], [-2], [-5], [7], [-1], [4], [3], [-3], [-5], [-3], [-13], [0], [1], [-11], [-4], [-5], [-2], [3], [-7], [-1], [-7], [-2], [0], [-7], [5], [12], [21], [3], [3], [-1], [8], [-11], [3], [22], [-7], [-7], [6], [-19], [4], [12], [-27], [-1], [-27], [-16], [-3], [8], [-1], [-25], [9], [-27], [-17], [-22], [-9], [26], [16], [13], [-1], [5], [21], [-18], [7], [30], [13], [-25], [27], [19], [-4], [-9], [-25], [15], [-13], [9], [24], [6], [-19], [-6], [35], [-9], [6], [-3], [-26], [32], [33], [-19], [-11], [36], [-7], [24], [11], [-13], [-11], [-1], [4], [-3], [21], [-45], [-5], [-17], [12], [-9], [17], [-42], [-23], [-29], [22], [-1], [40], [-35], [20], [-9], [-43], [-24], [45], [-34], [-27], [-5], [11], [-14], [5], [-45], [-32], [-7], [-23], [36], [-23], [-34], [13], [-2], [3], [11], [34], [41], [-36], [31], [-13], [40], [-7], [28], [46], [9], [25], [27], [-5], [-38], [-44], [15], [13], [48], [-11], [39], [58], [49], [35], [-26], [-8], [-57], [57], [-45], [-57], [-13], [-34], [3], [-25], [34], [33], [-9], [-47], [-6], [28], [-9], [-36], [-29], [47], [12], [-10], [9], [25], [37], [-29], [19], [45], [-43], [65], [4], [-9], [-55], [53], [-67], [-3], [-47], [-42], [3], [31], [8], [39], [7], [-28], [-5], [37], [57], [6], [23], [5], [54], [56], [37], [-3], [13], [35], [33], [61], [34], [49], [-8], [33], [-31], [48], [-58], [-19], [57], [39], [23], [-21], [-31], [-20], [-9], [-72], [-3], [-29], [57], [4], [48], [-41], [59], [-39], [-25], [-14], [-3], [28], [49], [21], [48], [30], [25], [37], [-58], [51], [-21], [17], [-31], [-42], [-5], [-43], [-12], [-5], [-54], [-15], [41], [30], [-70], [20], [17], [31], [57], [-31], [-1], [50], [69], [-3], [17], [-55], [55], [-11], [-33], [-48], [-38], [3], [-7], [-3], [66], [-11], [14], [-35], [-77], [-11], [36], [6], [31], [23], [-74], [67], [-12], [13], [57], [-7], [-36], [-53], [-74], [5], [-14], [-7], [-83], [-41], [9], [3], [49], [-80], [53], [76], [45], [-50], [18], [71], [-9], [-26], [8], [43], [-49], [-19], [-1], [73], [10], [13], [-61], [-52], [73], [-35], [-12], [-58], [-7], [-82], [-47], [21], [-38], [50], [68], [55], [24], [17], [3], [64], [-15], [-49], [-69], [-14], [-29], [-55], [86], [-15], [-85], [-73], [12], [-46], [-49], [51], [19], [-47], [-11], [42], [9], [94], [-25], [75], [-21], [22], [47], [-63], [-45], [-48], [-47], [-33], [62], [15], [78], [76], [-53], [24], [-17], [99], [-77], [15], [72], [-2], [-81], [87], [73], [-45], [-43], [49], [-54], [24], [69], [77], [-51], [-1], [87], [65], [-61], [-25], [-50], [-91], [-15], [-19], [19], [-60], [-35], [98], [-3], [71], [53], [62], [-31], [39], [75], [36], [-20], [-86], [-63], [-35], [-62], [25], [81]]
