
# q-expansion of newform 7920.2.a.f, downloaded from the LMFDB on 16 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 = 7920
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], [-1], [0], [-1], [-2], [-2], [-4], [8], [2], [-8], [6], [-2], [4], [0], [-6], [4], [-10], [12], [0], [2], [-8], [12], [6], [-14], [10], [-8], [4], [6], [-2], [8], [12], [6], [20], [10], [16], [-2], [-4], [8], [-6], [12], [-10], [24], [-6], [18], [0], [12], [-16], [-20], [6], [-10], [0], [-30], [-12], [-18], [24], [18], [24], [22], [30], [4], [2], [12], [16], [-6], [2], [12], [-22], [-12], [6], [-18], [-24], [32], [-10], [12], [32], [-6], [14], [30], [26], [-20], [22], [32], [34], [16], [-36], [-2], [34], [18], [-16], [-12], [-16], [-8], [-12], [4], [24], [34], [6], [20], [22], [12], [-6], [-4], [-18], [36], [18], [-4], [-34], [0], [10], [8], [22], [-26], [-20], [0], [-2], [-20], [24], [-30], [12], [-26], [-6], [50], [12], [-28], [2], [6], [-8], [-40], [-2], [-20], [24], [-40], [22], [-50], [2], [42], [-4], [2], [14], [-28], [10], [-24], [4], [46], [-48], [-26], [-10], [-36], [-48], [14], [30], [44], [-24], [52], [24], [16], [46], [34], [-46], [20], [-26], [-16], [36], [30], [-24], [56], [-26], [2], [-6], [-44], [14], [8], [-46], [8], [-42], [-28], [26], [16], [-26], [-16], [-20], [-58], [6], [48], [42], [46], [-20], [42], [0], [-46], [-60], [20], [-30], [12], [-26], [34], [-66], [-18], [-56], [-30], [-40], [-10], [34], [-28], [66], [8], [-4], [30], [-4], [-70], [42], [-56], [-4], [40], [42], [8], [-26], [-24], [-14], [-2], [-16], [-18], [48], [60], [-50], [54], [-40], [64], [36], [14], [-36], [8], [-66], [-28], [32], [-46], [-62], [36], [48], [-12], [68], [-24], [-2], [46], [-8], [-48], [12], [-60], [48], [62], [6], [-40], [10], [42], [44], [-26], [52], [-38], [2], [72], [28], [-50], [14], [-18], [-28], [18], [22], [20], [-14], [62], [12], [10], [40], [-70], [-56], [-68], [-42], [-38], [-20], [-16], [-32], [40], [62], [-76], [8], [-30], [-30], [-80], [-58], [-78], [-28], [-26], [84], [-2], [-30], [8], [-6], [52], [-36], [-46], [-38], [56], [20], [76], [-30], [44], [30], [-48], [-26], [-80], [42], [-42], [-36], [-8], [74], [12], [-16], [50], [70], [-4], [-22], [-62], [-64], [-90], [50], [4], [-28], [64], [66], [6], [-30], [40], [76], [20], [-36], [-82], [-66], [-22], [8], [-10], [86], [-86], [0], [18], [60], [-58], [36], [-32], [90], [28], [74], [50], [-56], [-18], [6], [40], [-60], [-18], [-56], [70], [62], [16], [-12], [-4], [-38], [42], [64], [90], [-100], [-20], [0], [26], [80], [94], [76], [0], [-38], [54], [18], [-30], [-26], [16], [-2], [-20], [24], [88], [86], [-44], [32], [-94], [42], [36], [92], [-96], [-14], [56], [22], [12], [-6], [-58], [46], [24], [-42], [10], [80], [-50], [-58], [28], [12], [-54], [66], [60], [-36], [-62], [18], [0], [56], [-2], [-8], [-94], [-90], [-48], [52], [74], [34], [-60], [78], [-4], [-8], [-70], [44], [-68], [80], [-34], [-18], [42], [6], [-76], [-16], [-100], [94], [-34], [-80], [98], [62], [-60], [64], [34], [54], [28], [-48], [-84], [-34], [-78], [74], [-10], [12], [6], [-42], [60], [-80], [60], [-90], [-92], [-86], [16], [76], [-90], [52], [-24], [-12], [72], [66], [-12], [46], [98], [-56], [80], [-22], [106], [-98]]
