
# q-expansion of newform 9450.2.a.m, 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 = 9450
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], [-1], [0], [-5], [3], [-1], [6], [-9], [-4], [10], [-6], [10], [9], [3], [-6], [5], [-8], [-12], [-2], [11], [-6], [9], [16], [-6], [4], [-12], [2], [-18], [-5], [18], [-6], [20], [-21], [5], [13], [-14], [0], [-12], [-9], [-7], [-12], [-5], [15], [2], [-22], [-20], [24], [-7], [-24], [6], [-16], [-6], [3], [6], [-18], [-16], [-14], [30], [25], [-18], [-20], [-12], [-8], [3], [-4], [-23], [-27], [-1], [18], [6], [10], [-2], [26], [0], [-15], [25], [12], [20], [-36], [38], [0], [16], [14], [-21], [0], [13], [-6], [-29], [36], [3], [16], [-9], [-10], [-36], [-18], [-15], [-29], [2], [-8], [33], [-36], [0], [-22], [16], [-24], [21], [-18], [8], [-8], [-20], [6], [44], [23], [12], [-23], [33], [-45], [-27], [-22], [-14], [-42], [-36], [-4], [-30], [20], [-15], [-2], [37], [-22], [-54], [8], [-8], [27], [-40], [36], [-20], [-12], [-30], [-4], [-15], [4], [33], [35], [39], [-26], [-3], [-40], [24], [40], [-45], [-8], [24], [-20], [-36], [-16], [-33], [52], [12], [12], [36], [-23], [-36], [-30], [45], [11], [-62], [2], [36], [-24], [-34], [-18], [-35], [-4], [15], [-10], [30], [-38], [17], [19], [-30], [58], [-3], [-12], [-60], [-26], [19], [5], [33], [-26], [-27], [-52], [-60], [-15], [45], [-43], [28], [-33], [63], [-33], [-16], [49], [8], [0], [48], [-40], [-24], [12], [-19], [1], [18], [13], [-60], [-48], [8], [-68], [57], [36], [-6], [-4], [8], [72], [61], [12], [44], [3], [24], [-26], [3], [58], [-61], [41], [-30], [-41], [-48], [-16], [-39], [36], [-27], [39], [-25], [-26], [-46], [-69], [9], [70], [6], [-64], [48], [-32], [-33], [-24], [56], [-24], [51], [-16], [52], [30], [52], [13], [-9], [59], [-29], [-42], [-61], [51], [15], [-32], [51], [23], [34], [70], [35], [82], [-26], [-39], [8], [-82], [24], [72], [53], [-21], [29], [-20], [-24], [61], [42], [26], [-63], [51], [42], [12], [-6], [34], [18], [-64], [54], [42], [-20], [58], [-21], [-16], [-12], [-16], [70], [-39], [-82], [24], [-62], [63], [6], [-66], [-26], [-48], [-34], [42], [-12], [40], [30], [71], [-59], [30], [19], [54], [62], [-52], [-20], [-78], [-69], [-88], [-30], [44], [48], [-34], [78], [62], [3], [14], [34], [64], [-12], [18], [35], [54], [57], [77], [-62], [51], [12], [-13], [97], [45], [-14], [26], [69], [81], [-54], [-96], [-90], [70], [81], [66], [75], [-95], [-17], [-90], [40], [65], [63], [56], [-96], [-87], [38], [52], [-96], [6], [-38], [21], [34], [42], [72], [-20], [-72], [23], [-9], [29], [58], [64], [-75], [-49], [66], [-15], [13], [0], [-74], [-76], [45], [86], [30], [-103], [-84], [64], [54], [-90], [-64], [52], [-30], [-80], [-48], [34], [27], [-9], [50], [13], [66], [42], [-86], [-42], [15], [78], [-38], [36], [90], [70], [-12], [-96], [108], [-37], [-87], [-40], [60], [62], [-48], [-2], [-33], [71], [8], [-92], [26], [66], [-90], [50], [54], [-52], [36], [4], [0], [-70], [50], [16], [69], [3], [42], [-5], [-57], [32], [-78], [49], [0], [-40], [5], [-12], [50], [37], [-2], [-64], [72], [24], [-28], [-23], [15], [9], [-7], [-12], [-86], [-114], [50], [9], [42], [112], [-93], [58], [30], [-44], [60], [-94], [54], [-31], [-88], [31], [-33], [-85], [-24], [-60], [83], [-20], [-93], [-58], [62], [-30], [46], [-60], [-44], [40], [-18], [84], [44], [-20], [-65], [-60], [105], [34], [-9], [92], [79], [-48], [38], [-60], [-80], [64], [-94], [-18], [-36], [80], [0], [-62], [24], [-105], [-12], [28], [-42], [28], [75], [-71], [-24], [37], [27], [-106], [-32], [-123], [99], [44], [-42], [-30], [-82], [-11], [42], [-2], [90], [-24], [-116], [-93], [9], [57], [-79], [-44], [-9], [65], [-53], [-9], [-45], [48], [73], [26], [-1], [108], [-10], [-84], [27], [31], [0], [-16], [-104], [-34], [75], [102], [83], [-21], [2], [-75], [-68], [-54], [12], [74], [18], [-74], [-96], [-105], [40]]
