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