
# q-expansion of newform 7872.2.a.d, downloaded from the LMFDB on 08 May 2026.

# 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 = 7872
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], [-2], [2], [-4], [0], [6], [0], [4], [0], [-8], [-2], [-1], [-4], [2], [-4], [12], [6], [8], [-6], [14], [-14], [4], [-6], [6], [12], [8], [-4], [-8], [6], [-8], [4], [14], [-4], [-4], [-10], [-8], [-20], [-14], [2], [4], [-12], [-18], [-10], [2], [-2], [8], [-4], [0], [-20], [18], [-30], [-2], [-20], [18], [2], [-26], [0], [22], [18], [-12], [24], [-4], [-10], [6], [12], [0], [34], [-8], [-14], [18], [-24], [4], [-22], [-20], [-34], [-22], [4], [14], [-30], [-36], [-4], [-32], [-34], [14], [20], [18], [-18], [10], [26], [12], [-2], [8], [12], [-16], [6], [-8], [-34], [-36], [-30], [-4], [-24], [-24], [-10], [16], [-30], [-20], [-6], [-12], [26], [-36], [10], [-22], [-20], [20], [-42], [-16], [-20], [-16], [0], [-22], [-2], [14], [28], [28], [26], [44], [30], [30], [22], [-36], [-12], [-26], [44], [6], [-14], [-24], [-20], [22], [-18], [20], [50], [46], [48], [-38], [-30], [30], [-6], [44], [-32], [-22], [-42], [-44], [-6], [12], [32], [10], [-34], [-14], [-38], [36], [26], [6], [60], [-58], [36], [14], [8], [46], [0], [32], [-26], [30], [-26], [-38], [34], [-36], [18], [22], [-16], [-24], [-36], [8], [54], [16], [-6], [58], [20], [46], [2], [14], [0], [-4], [46], [-20], [14], [-14], [8], [10], [-14], [-6], [-20], [40], [-38], [16], [4], [-8], [-12], [26], [28], [22], [-60], [-8], [-4], [22], [-14], [46], [-6], [-42], [54], [-4], [-28], [-18], [6], [-60], [44], [58], [-24], [22], [-68], [-58], [16], [-16], [-6], [36], [54], [-34], [-60], [60], [-54], [-4], [-8], [26], [-10], [-46], [12], [12], [-24], [76], [16], [-10], [66], [44], [54], [-28], [20], [-48], [-56], [8], [-58], [28], [-36], [-80], [0], [-54], [36], [12], [70], [-52], [-68], [64], [-28], [-6], [-48], [2], [36], [-24], [-20], [26], [36], [-58], [14], [-16], [-10], [32], [66], [46], [6], [-42], [-14], [64], [-36], [18], [-68], [-68], [32], [-6], [-6], [-12], [-16], [-10], [-36], [84], [-72], [68], [78], [28], [-30], [-34], [-64], [70], [24], [14], [4], [-12], [46], [60], [12], [74], [-14], [-20], [54], [-54], [-34], [26], [86], [56], [20], [-6], [-38], [4], [66], [-64], [0], [52], [-24], [-68], [-62], [58], [64], [-56], [-42], [-80], [50], [-42], [44], [-42], [-28], [-46], [86], [-92], [-74], [-16], [-32], [-64], [66], [-20], [-44], [78], [56], [34], [58], [82], [28], [-28], [-22], [-36], [76], [-90], [12], [36], [-24], [-56], [44], [-76], [-28], [-76], [6], [46], [-90], [36], [-74], [76], [30], [4], [84], [-14], [4], [-84], [-102], [-94], [-24], [68], [92], [44], [-74], [102], [-22], [76], [-12], [-22], [70], [-48], [6], [102], [34], [-14], [-18], [52], [-20], [66], [62], [-12], [-12], [-38], [82], [-16], [-62], [-66], [-44], [18], [36], [-72], [60], [-30], [-30], [-24], [10], [-8], [-6]]
