
# q-expansion of newform 2100.2.a.m, downloaded from the LMFDB on 24 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 = 2100
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], [-1], [1], [-4], [-2], [-4], [-7], [-9], [-2], [-1], [8], [9], [-4], [-6], [4], [4], [-9], [5], [-10], [-15], [6], [8], [-10], [6], [4], [-4], [1], [-13], [-9], [18], [2], [-10], [-3], [11], [-20], [-12], [16], [-8], [4], [-10], [20], [17], [15], [8], [-4], [6], [0], [22], [-19], [-16], [0], [-2], [-26], [15], [18], [-24], [-2], [19], [22], [-24], [22], [2], [-4], [31], [-23], [22], [27], [-28], [-18], [-35], [-4], [-11], [-23], [12], [27], [-10], [-33], [40], [30], [-17], [24], [0], [20], [-20], [13], [5], [-40], [4], [38], [36], [-3], [-3], [4], [14], [-28], [6], [40], [-25], [35], [-1], [30], [-45], [-23], [-8], [30], [12], [35], [-4], [0], [-29], [-31], [16], [-27], [-33], [-28], [-46], [-26], [4], [-16], [-2], [-18], [19], [28], [18], [-26], [24], [-30], [36], [-9], [24], [40], [7], [-4], [40], [26], [-26], [54], [-23], [-6], [10], [11], [-33], [-34], [-42], [-28], [4], [14], [-33], [34], [-54], [-1], [-52], [-24], [-9], [-59], [-26], [-36], [54], [-36], [-21], [-40], [-24], [33], [58], [37], [28], [-49], [-6], [19], [20], [-13], [-2], [-58], [-14], [-55], [-42], [-44], [18], [-19], [-44], [-25], [-38], [-19], [-46], [-7], [-14], [5], [-10], [-14], [13], [-41], [10], [-33], [36], [65], [47], [12], [-6], [30], [42], [-50], [60], [56], [20], [-6], [36], [-35], [0], [35], [-6], [-31], [-36], [6], [-26], [-47], [-28], [-23], [-67], [41], [-18], [-63], [-37], [28], [70], [46], [3], [14], [9], [35], [-10], [-48], [-63], [-20], [-14], [-20], [-5], [-35], [-28], [21], [52], [42], [59], [64], [-14], [22], [-78], [40], [24], [14], [0], [-24], [-46], [24], [60], [-19], [6], [12], [76], [-16], [11], [58], [2], [2], [48], [-51], [-78], [49], [21], [-44], [20], [24], [81], [-42], [-62], [-13], [-34], [-41], [-14], [-66], [-40], [52], [-62], [-2], [-27], [-71], [43], [-20], [6], [49], [62], [73], [-42], [69], [-26], [20], [-12], [4], [-10], [22], [-46], [-31], [67], [29], [70], [81], [24], [3], [46], [-6], [2], [-21], [-60], [-63], [-18], [78], [-44], [20], [63], [-38], [54], [12], [-1], [-29], [-50], [-23], [-54], [-63], [-39], [-6], [33], [50], [-58], [-88], [72], [-23], [-24], [68], [74], [86], [-79], [-16], [-35], [29], [-11], [-54], [65], [80], [-70], [-74], [-31], [62], [20], [75], [16], [6], [-58], [-66], [-64], [-3], [-10], [60], [77], [36], [74], [46], [-3], [-5], [-11], [-90], [-59], [38], [-22], [-47], [28], [37], [-86], [-92], [-78], [-2], [-21], [-77], [-17], [2], [-56], [71], [-34], [-31], [48], [85], [-26], [29], [14], [-11], [11], [-96], [56], [20], [99], [-8], [19], [-49], [84], [36], [52], [-51], [34], [48], [-26], [-96], [-43], [72], [73], [51], [76], [0], [50], [-84], [-106], [82], [-66], [-48], [24], [46], [42], [31], [-18], [-62], [66]]
