
# q-expansion of newform 6048.2.a.f, downloaded from the LMFDB on 25 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 = 6048
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], [-1], [-2], [0], [-1], [4], [4], [8], [-4], [-7], [5], [-1], [9], [-2], [-3], [-2], [4], [-12], [-16], [15], [3], [-6], [-4], [-2], [-8], [0], [7], [-10], [-7], [-4], [-12], [2], [18], [-7], [-16], [-11], [-3], [6], [-10], [-10], [-6], [-17], [0], [-2], [-16], [4], [28], [-18], [-4], [6], [12], [-5], [-18], [24], [-1], [22], [-15], [0], [6], [-15], [28], [13], [-14], [8], [-5], [-17], [-8], [-24], [-33], [-18], [-6], [11], [-11], [-19], [22], [4], [-22], [-4], [3], [-10], [-24], [-6], [26], [32], [-12], [6], [17], [-35], [-12], [27], [16], [0], [29], [-39], [27], [-17], [-14], [-11], [-41], [24], [-28], [0], [31], [26], [12], [-9], [-6], [4], [14], [-22], [-24], [-20], [-27], [-2], [46], [16], [10], [-14], [6], [26], [-18], [8], [18], [18], [-1], [-11], [-4], [22], [-28], [-44], [-8], [-17], [33], [26], [45], [-40], [18], [-10], [38], [-32], [-43], [-22], [28], [49], [54], [33], [30], [-22], [5], [-42], [-47], [25], [-51], [30], [29], [-55], [-44], [39], [40], [24], [-16], [-61], [-50], [-3], [-1], [-32], [5], [9], [24], [12], [-46], [43], [-40], [-25], [-44], [-30], [26], [6], [59], [15], [26], [11], [62], [-51], [38], [-16], [30], [-13], [56], [54], [-27], [21], [-34], [43], [58], [19], [50], [11], [18], [54], [-14], [-20], [-15], [-51], [-14], [-24], [12], [54], [13], [-10], [-29], [-57], [-5], [-4], [-13], [-58], [-38], [4], [63], [2], [42], [23], [23], [37], [21], [12], [34], [60], [-46], [-20], [-57], [6], [34], [24], [-38], [-34], [60], [5], [34], [66], [-66], [-50], [-54], [9], [0], [-13], [-19], [12], [49], [34], [2], [64], [-27], [48], [55], [-68], [-42], [10], [20], [6], [22], [2], [54], [-4], [64], [54], [-71], [-2], [28], [24], [28], [-37], [14], [68], [-18], [-41], [75], [-53], [27], [-29], [-11], [-28], [44], [-52], [25], [-72], [10], [17], [-6], [-69], [74], [63], [-65], [77], [72], [-41], [-1], [30], [26], [24], [-40], [-54], [25], [-2], [-72], [-42], [-38], [-62], [36], [-60], [-54], [-7], [-58], [-42], [81], [4], [-42], [-16], [-6], [-7], [17], [12], [6], [-2], [43], [-34], [-54], [-50], [62], [-74], [88], [-69], [-55], [61], [-34], [21], [54], [-50], [-33], [66], [-33], [-88], [6], [-84], [-8], [35], [-65], [30], [-60], [-83], [-76], [66], [7], [95], [0], [61], [36], [-34], [-13], [-55], [68], [-18], [-72], [-27], [-37], [-65], [23], [-12], [64], [-60], [92], [-10], [-34], [-28], [66], [-32], [-62], [-48], [-7], [-20], [-12], [42], [98], [-24], [40], [-58], [73], [12], [-21], [-86], [36], [82], [-72], [14], [12], [51], [52], [-72], [-40], [-102], [-47], [93], [-46], [90], [-19], [38], [-64], [-52], [-8], [-92], [74], [-11], [-53], [-54], [-78], [-4], [-41], [12], [38], [-84], [-18], [-63], [-38], [77], [32], [66], [-54], [88]]
