
# q-expansion of newform 5328.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 = 5328
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], [3], [5], [-3], [-3], [-5], [3], [0], [-4], [1], [-6], [-4], [-4], [3], [14], [-14], [-12], [12], [13], [-6], [-7], [1], [-12], [-10], [2], [-13], [-13], [-2], [17], [-10], [0], [16], [18], [9], [10], [-7], [13], [-19], [-18], [-10], [7], [-4], [21], [-4], [-24], [16], [-18], [-20], [-20], [-8], [-10], [2], [-7], [-12], [-23], [0], [-21], [9], [17], [-25], [-14], [12], [-8], [-22], [-16], [-15], [-18], [-26], [18], [16], [-29], [20], [32], [29], [-26], [-10], [21], [-6], [35], [38], [-11], [27], [26], [-12], [22], [-24], [10], [20], [6], [-31], [-4], [33], [-15], [-16], [3], [24], [0], [9], [-27], [46], [-38], [-41], [-12], [-8], [-12], [-46], [40], [19], [-4], [38], [-2], [-16], [-22], [50], [-5], [-41], [30], [-8], [45], [37], [13], [42], [-2], [44], [-3], [6], [28], [20], [-34], [-24], [4], [7], [22], [-40], [-11], [32], [-38], [-27], [-6], [7], [45], [32], [11], [34], [-19], [47], [-43], [6], [22], [-48], [5], [-26], [25], [32], [38], [-8], [2], [30], [-54], [-46], [4], [36], [45], [-6], [50], [-9], [-46], [6], [-44], [-2], [-12], [-7], [5], [-6], [-16], [-9], [-20], [10], [10], [30], [-27], [-38], [0], [21], [-32], [-17], [38], [12], [-14], [52], [43], [-7], [28], [-52], [-34], [46], [-10], [-3], [36], [49], [-2], [46], [-4], [-68], [25], [-13], [53], [6], [22], [10], [52], [-33], [-21], [41], [-34], [-6], [-73], [57], [-62], [-19], [46], [36], [12], [-35], [-58], [-30], [-56], [10], [-44], [52], [55], [18], [64], [24], [53], [-6], [0], [-12], [-2], [-13], [-43], [33], [36], [63], [58], [-72], [30], [21], [-59], [-46], [6], [-76], [-40], [-52], [-32], [0], [11], [14], [-30], [22], [-46], [16], [57], [-26], [-67], [46], [22], [4], [-27], [-7], [46], [-56], [-49], [41], [57], [-10], [27], [-48], [40], [42], [20], [62], [-32], [40], [64], [10], [2], [-67], [-54], [64], [48], [43], [16], [42], [-35], [39], [24], [-62], [-84], [-42], [0], [64], [-71], [-28], [0], [62], [-66], [61], [-8], [-45], [38], [22], [85], [72], [27], [81], [-58], [71], [-27], [37], [-74], [7], [22], [16], [40], [-20], [-27], [26], [10], [-66], [-82], [30], [-55], [-44], [-28], [-54], [40], [-56], [-40], [4], [24], [-14], [-12], [10], [0], [-52], [-48], [-2], [80], [-65], [-6], [-46], [-62], [24], [19], [24], [-96], [-12], [38], [-66], [-59], [-24], [2], [-6], [-18], [2], [2], [-84], [44], [-10], [53], [80], [34], [69], [-62], [-67], [-1], [57], [64], [-55], [-66], [-6], [92], [6], [-7], [-14], [48], [57], [-79], [14], [66], [-7], [12], [101], [34], [-48], [-68], [-33], [66], [25], [-80], [14], [-48], [-23], [87], [22], [12], [-8], [-57], [-85], [8], [105], [-88], [-77], [20], [-3], [42], [-4], [72], [81], [52], [65], [-15], [-18], [19], [10], [14], [0]]
