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