
# q-expansion of newform 2664.2.a.f, downloaded from the LMFDB on 28 January 2025.

# 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 = 2664
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], [1], [-1], [-6], [4], [-8], [-6], [-2], [-4], [-1], [-7], [2], [-9], [3], [12], [4], [0], [-7], [7], [0], [-3], [12], [-8], [17], [2], [4], [16], [-2], [-17], [0], [14], [-4], [9], [0], [19], [-22], [-12], [3], [22], [-23], [0], [-10], [-7], [-14], [9], [25], [-24], [-5], [2], [-10], [-30], [-26], [-12], [-13], [6], [-9], [12], [20], [8], [-6], [29], [-24], [18], [10], [-22], [-9], [-22], [-26], [36], [25], [-16], [1], [37], [36], [12], [-1], [10], [0], [-5], [8], [-10], [-39], [-32], [13], [-20], [18], [6], [-22], [-18], [18], [-20], [12], [4], [8], [-45], [17], [6], [-36], [-8], [-14], [22], [-28], [21], [32], [24], [-3], [-15], [10], [32], [35], [-9], [5], [20], [-31], [14], [36], [8], [21], [-36], [11], [15], [-42], [52], [-24], [12], [-1], [-44], [19], [21], [-43], [-33], [10], [27], [-10], [-19], [-39], [-48], [-26], [45], [-29], [-24], [54], [-40], [-36], [26], [52], [-32], [0], [-22], [30], [20], [-47], [-32], [54], [-14], [-18], [-19], [-14], [52], [19], [34], [32], [-4], [9], [-22], [-6], [17], [-48], [-42], [-22], [-52], [11], [35], [-36], [32], [-18], [-7], [18], [52], [-10], [-48], [28], [24], [31], [-43], [-14], [62], [7], [-10], [36], [-30], [-37], [43], [-29], [-32], [-52], [-15], [-42], [20], [35], [-10], [27], [-16], [24], [-56], [36], [-36], [-15], [22], [-50], [56], [-28], [-60], [-13], [-10], [6], [-38], [42], [-29], [65], [41], [6], [-3], [4], [-34], [67], [-7], [6], [19], [-55], [-47], [-13], [35], [5], [-14], [-22], [6], [-6], [12], [-56], [17], [54], [34], [6], [-10], [-56], [21], [-56], [-52], [-42], [-40], [-76], [6], [-5], [-59], [-60], [55], [-46], [-12], [48], [-26], [2], [-48], [11], [15], [-32], [25], [-24], [-48], [-48], [-38], [-34], [-22], [76], [12], [-52], [27], [-26], [-9], [-18], [28], [-35], [22], [47], [-46], [42], [74], [62], [-32], [-10], [51], [29], [37], [49], [-5], [-26], [-54], [45], [66], [23], [-15], [40], [32], [-58], [26], [46], [75], [42], [33], [-5], [15], [-35], [60], [36], [45], [-12], [53], [46], [72], [71], [70], [-52], [91], [4], [-4], [-80], [-14], [-10], [-15], [24], [2], [68], [44], [44], [-11], [-71], [-44], [-24], [13], [-19], [-78], [-64], [-6], [-66], [-15], [-17], [-48], [61], [-16], [-53], [4], [74], [10], [74], [-48], [68], [81], [30], [74], [47], [42], [38], [-23], [-26], [18], [50], [-34], [38], [-10], [56], [54], [-2], [-23], [-60], [-65], [94], [22], [33], [-52], [-96], [20], [-94], [40], [-59], [-23], [-58], [-70], [-10], [-5], [-14], [-2], [58], [-59], [26], [-8], [71], [37], [-54], [-27], [-86], [-20], [94], [54], [37], [54], [-14], [4], [-73], [-53], [57], [38], [80], [-20], [2], [24], [35], [54], [0], [-4], [42], [8], [57], [-54], [-23], [-36], [55], [-76], [-18]]
