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