
# q-expansion of newform 1350.2.a.m, downloaded from the LMFDB on 16 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 = 1350
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], [0], [0], [-4], [-3], [-1], [0], [2], [-9], [6], [-10], [-7], [-6], [-10], [9], [6], [-3], [-7], [-4], [15], [2], [8], [-12], [12], [-19], [12], [14], [-9], [2], [6], [2], [-15], [-6], [-4], [18], [2], [14], [-10], [21], [0], [21], [-1], [-12], [-10], [-24], [-22], [8], [2], [-3], [-1], [12], [-15], [5], [-15], [-12], [15], [12], [20], [2], [-6], [26], [-24], [26], [-21], [14], [18], [-10], [2], [12], [-10], [-6], [-27], [8], [-22], [-10], [9], [-6], [5], [12], [-7], [12], [-37], [-27], [11], [-4], [-3], [-18], [-19], [24], [-22], [-3], [-24], [-4], [-36], [-16], [-12], [30], [-24], [-4], [35], [-28], [-12], [27], [18], [-34], [-13], [-12], [12], [-12], [35], [-22], [29], [-18], [2], [-10], [12], [14], [-15], [36], [-36], [-31], [-1], [18], [-9], [-46], [-36], [-1], [21], [-4], [-13], [-16], [3], [-4], [23], [18], [-46], [-42], [8], [6], [-42], [32], [6], [26], [45], [47], [9], [-55], [-12], [50], [-24], [-43], [-36], [-52], [3], [-46], [-39], [-46], [-42], [-1], [12], [24], [36], [32], [-27], [-48], [9], [32], [53], [41], [-24], [0], [2], [-15], [-31], [44], [54], [56], [6], [-22], [-19], [50], [3], [11], [-6], [-12], [30], [2], [32], [-31], [-39], [-7], [27], [-28], [18], [21], [48], [23], [-37], [42], [24], [54], [-10], [23], [-19], [51], [18], [20], [39], [-30], [20], [62], [-12], [-10], [51], [51], [-10], [-22], [-18], [-3], [6], [59], [56], [-54], [-70], [33], [-7], [-54], [-9], [32], [48], [11], [56], [-40], [12], [-10], [15], [-31], [-48], [-36], [21], [60], [-34], [-46], [29], [-66], [63], [-52], [27], [44], [9], [-49], [12], [-15], [17], [30], [27], [-22], [62], [66], [-25], [26], [36], [-58], [-19], [18], [62], [12], [-54], [14], [-54], [-43], [-34], [17], [-76], [-19], [14], [-24], [38], [-13], [3], [-75], [-58], [-15], [-19], [32], [33], [41], [42], [26], [-30], [-78], [-60], [0], [-39], [50], [-24], [62], [-66], [12], [-46], [-13], [48], [20], [51], [68], [-7], [-75], [26], [21], [-34], [24], [24], [30], [32], [-48], [65], [-84], [-33], [-34], [-60], [-28], [-73], [-12], [-76], [36], [-43], [44], [14], [63], [12], [-1], [66], [32], [-39], [-46], [-24], [-58], [78], [41], [56], [-19], [18], [78], [-22], [-48], [-36], [-46], [-28], [-3], [-84], [-70], [29], [-24], [-4], [14], [-18], [-45], [-12], [-42], [3], [-91], [-6], [9], [15], [56], [-22], [-18], [56], [23], [84], [-100], [15], [18], [14], [2], [84], [-21], [14], [66], [2], [-66], [-60], [-52], [18], [-94], [-24], [32], [59], [-34], [48], [2], [60], [24], [14], [48], [26], [44], [-30], [68], [102], [41], [30], [-10], [-96], [-30], [2], [-1], [-72], [104], [69], [11], [-12], [-51], [44], [74], [-18], [-72], [62], [-96], [96], [24], [38], [-75], [72], [38], [-42], [84], [-36], [-64], [3]]
