
# q-expansion of newform 8030.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 = 8030
weight = 2
poly_data = [-3, -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 = [[1, 0], [-1, -1], [1, 0], [0, -2], [-1, 0], [-3, 1], [0, 0], [2, 1], [-2, 0], [-4, 2], [-8, 2], [2, -4], [-2, 4], [-6, 5], [-2, -1], [0, 0], [9, -3], [3, -1], [1, 1], [2, 1], [-1, 0], [-4, 6], [-5, 5], [-5, -1], [4, 0], [-4, 4], [4, -4], [-2, -5], [-6, 0], [2, 3], [3, -1], [-4, 4], [4, 2], [0, -10], [-6, 1], [-7, -3], [-4, 10], [16, -6], [10, -8], [2, 0], [8, 5], [-8, -2], [-12, 0], [2, 10], [-2, -1], [2, -8], [-10, -3], [2, 6], [-6, -6], [0, 1], [12, -8], [-13, -1], [-6, 4], [8, -4], [-20, -2], [-6, -4], [-8, -6], [-1, -5], [14, 5], [21, 3], [-8, -10], [0, -12], [14, 7], [1, -5], [-6, -1], [0, -3], [-17, -5], [10, -6], [4, 2], [2, -7], [-20, 0], [20, 4], [-22, 8], [2, 8], [16, -3], [-18, 8], [2, 0], [-12, 7], [-17, -5], [4, 3], [0, 8], [13, -5], [-3, -11], [14, -13], [-8, -2], [20, 0], [-6, 4], [8, -9], [-14, -9], [20, -2], [32, 0], [2, -2], [-16, -4], [-14, 0], [-6, -12], [-16, -1], [6, -8], [0, -6], [-38, 4], [-8, 6], [22, -2], [-24, 6], [-40, 4], [2, 12], [-16, 20], [-7, -3], [-12, -4], [4, -11], [2, 2], [-15, 7], [36, 1], [-3, 1], [11, 3], [-8, 22], [4, -8], [-18, 0], [20, -16], [-34, 1], [-3, 3], [-30, 9], [8, 8], [-17, -3], [-14, -13], [6, -18], [-15, 13], [16, -24], [-1, 21], [-2, 4], [6, -2], [-20, -2], [-8, 4], [-14, 18], [28, -12], [-28, -7], [12, -19], [4, -5], [-12, 4], [-46, 0], [-3, -9], [-8, -6], [-32, 12], [6, 3], [2, 5], [2, 4], [34, 0], [-5, 9], [2, -10], [36, 3], [-8, -13], [29, -5], [-36, -2], [34, -6], [34, 8], [-2, 12], [-10, 8], [-2, 21], [-8, 27], [30, -2], [28, 13], [7, -25], [7, -5], [39, 5], [31, 7], [0, 13], [-39, 9], [-26, 1], [-38, 4], [-34, -10], [37, -5], [16, -13], [-28, 8], [-10, 18], [42, -14], [10, 0], [26, -6], [34, 11], [-48, 6], [36, -9], [-8, -8], [-38, -8], [4, 2], [8, 12], [-33, 13], [14, 8], [10, 10], [-24, -11], [7, 11], [18, 4], [32, 11], [-12, -16], [19, 15], [-12, 8], [38, -10], [-4, 9], [-16, -4], [36, -16], [18, 8], [14, -14], [-3, 7], [-9, -5], [27, -17], [-1, 27], [27, -19], [22, -20], [-24, -14], [14, -8], [-42, 11], [9, 11], [30, -18], [-22, -18], [-36, 4], [-21, -7], [31, 13], [52, 0], [24, -1], [-30, -4], [24, -14], [11, -3], [36, -20], [-38, -12], [35, 3], [32, 2], [38, -14], [-28, 20], [18, -15], [2, -14], [14, 24], [28, -18], [26, 14], [-13, 21], [-22, 2], [6, 5], [-13, -1], [-48, 3], [-24, -11], [-72, -1], [66, -2], [22, 5], [-12, 3], [6, -4], [-18, 6], [35, 9], [-6, 13], [42, -2], [-10, 4], [45, 9], [-23, 11], [-48, 12], [17, -1], [-3, -27], [-40, 24], [25, 15], [36, -12], [-65, -1], [-18, -16], [40, -8], [-14, -16], [-11, -17], [22, 0], [-32, -2], [28, -33], [-38, 20], [50, -10], [-30, -5], [34, 2], [21, 13], [-51, -9], [-2, -6], [25, -5], [26, -26], [-48, -9], [28, 10], [-14, 4], [-4, 28], [-41, -3], [10, 23], [-12, 27], [9, 5], [28, -2], [22, 10], [-39, -7], [-34, 1], [-22, 10], [-29, -13], [-34, 27], [21, 3], [-38, -12], [-39, 5], [53, -17], [-62, -2], [-6, 24], [72, 1], [6, -10], [-12, -26], [-38, -6], [6, 0], [10, -14], [20, 23], [21, 7], [0, -16], [-54, -8], [-30, 11], [-5, -21], [4, -11], [52, -12], [-24, 30], [-34, -6], [-12, -23], [-24, -12], [-2, -32], [-45, -9], [42, -30], [36, -18], [36, -10], [-12, 36], [26, -28], [34, -4], [8, 6], [0, -22], [-30, 6], [-62, -12], [-7, 9], [66, 7], [57, 3], [-48, 13], [-24, 40], [-33, -1], [-42, 4], [-60, 14], [-30, 8], [16, -36], [20, 6], [0, -16], [-28, 32], [11, 13], [5, 25], [-8, -26], [-34, -2], [41, -31], [-59, 25], [-68, -2], [77, 5], [46, -16], [34, 11], [-4, 13], [-34, 33], [-4, 23], [-38, 26], [-69, -5], [14, 22], [-71, 3], [-36, 24], [-36, 5], [-2, -6], [14, 0], [-20, 15], [30, -26], [2, -1], [18, -28], [51, 9], [3, -41], [-6, -40], [-18, 36], [-9, 37], [-16, 6], [-16, -16], [-39, 33], [14, -38], [25, -17], [-28, -24], [-28, -14], [-7, -23], [22, 1], [-58, -12], [16, -15], [0, 20], [48, 0], [-32, -1], [56, 16], [-16, -8], [-43, -25], [-54, 24], [-7, 25], [28, 10], [16, -18], [-18, 6], [-26, 38], [-17, -15], [-8, 24], [54, 19], [14, -36], [21, -41], [-4, -28], [0, 32], [58, 6], [20, 11], [-54, -8], [16, -2], [56, -16], [-22, -24], [-1, 3], [2, 41], [-64, -10], [-12, 0], [28, 4], [12, 36], [19, 9], [-24, 22], [18, -34], [63, -1], [-6, 4], [27, 15], [-17, -5], [30, 9], [-30, 40], [-9, 21], [28, -40], [-28, -16], [58, -20], [-76, 18], [23, -3], [-76, 14], [-20, -12], [-23, 11], [-34, 15], [-45, 5], [-52, 16], [-86, 12], [40, -5], [12, 0]]
