
# q-expansion of newform 6480.2.a.f, 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 = 6480
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], [5], [4], [4], [5], [6], [5], [9], [-10], [-7], [2], [2], [-8], [-1], [-2], [-6], [1], [-8], [-12], [6], [9], [14], [3], [-2], [-6], [-1], [16], [-16], [15], [-12], [19], [2], [5], [2], [-8], [12], [6], [23], [-25], [1], [26], [-12], [-16], [-11], [-8], [4], [6], [-6], [-16], [-11], [-12], [6], [10], [31], [8], [-18], [-6], [-6], [-18], [-10], [-9], [-4], [2], [21], [-8], [20], [13], [18], [-27], [-18], [16], [-4], [-36], [-6], [-38], [-30], [14], [16], [13], [3], [-26], [29], [6], [-17], [-38], [15], [6], [4], [-15], [-8], [43], [-7], [-20], [-2], [-10], [-16], [3], [-28], [24], [-18], [3], [-5], [-16], [18], [14], [-17], [-19], [-34], [4], [24], [28], [17], [-3], [-6], [-10], [8], [44], [25], [42], [-6], [48], [-4], [-19], [22], [27], [-44], [-46], [35], [-4], [32], [28], [27], [5], [-18], [-4], [-4], [-7], [21], [-3], [46], [44], [27], [13], [0], [-32], [-55], [-44], [-24], [25], [52], [6], [18], [-49], [11], [-1], [42], [-46], [18], [16], [40], [-27], [28], [48], [1], [48], [17], [20], [9], [31], [-15], [6], [56], [-51], [-36], [-9], [28], [-29], [-2], [16], [-44], [-34], [-30], [49], [-18], [56], [11], [-28], [58], [-10], [36], [37], [-66], [-16], [-23], [-54], [-60], [-44], [-15], [39], [-60], [-23], [12], [12], [37], [56], [-54], [-20], [-58], [5], [36], [-64], [-15], [-7], [-22], [-45], [10], [-42], [-35], [-5], [33], [8], [-20], [-1], [30], [-32], [-34], [60], [12], [35], [40], [34], [-44], [-42], [63], [32], [-36], [51], [36], [-24], [-34], [54], [-36], [47], [22], [44], [49], [-46], [22], [-29], [-78], [3], [74], [0], [43], [-14], [-60], [-40], [38], [-62], [-19], [12], [-30], [35], [-26], [71], [40], [-62], [-13], [-16], [-52], [39], [-18], [22], [30], [9], [-30], [60], [-26], [-64], [-62], [54], [-48], [-39], [-26], [-42], [-11], [-78], [-55], [16], [12], [-63], [-28], [27], [-59], [-48], [-9], [-62], [-18], [-20], [59], [66], [-67], [-28], [72], [5], [-81], [-48], [66], [33], [27], [-38], [-8], [73], [33], [57], [-30], [-81], [28], [-40], [13], [-16], [-72], [-71], [-23], [26], [0], [70], [-39], [-2], [-89], [-8], [7], [-14], [35], [-58], [5], [-48], [-2], [26], [-45], [12], [64], [-36], [-43], [38], [-33], [8], [63], [60], [-10], [-46], [-27], [30], [-29], [-93], [42], [-16], [-8], [67], [72], [-25], [70], [-44], [-72], [-66], [-31], [69], [12], [14], [63], [45], [-32], [41], [93], [2], [-9], [16], [-22], [-30], [-58], [14], [-21], [8], [88], [-10], [-24], [42], [30], [-20], [-4], [-86], [71], [14], [-35], [18], [68], [-15], [67], [-72], [-58], [68], [-37], [-40], [-52], [-82], [78], [27], [72], [42], [-16], [-45], [68], [34], [37], [14], [96], [-86], [2], [-14], [36], [-43], [38], [-2], [-62], [-6], [-53], [-16]]
