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