
# q-expansion of newform 3100.2.a.m, downloaded from the LMFDB on 03 June 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, ZZ
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K([c/ZZ(den) for c in num]) for num, den in basis_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 = 3100
weight = 2
poly_data = [-3, 18, 9, -8, -2, 1]

# The entries in the following list give a basis for the
# coefficient ring in terms of a root of the defining polynomial above.
# Each line consists of the coefficients of the numerator, and a denominator.
basis_data  = [[[1, 0, 0, 0, 0], 1], [[0, 1, 0, 0, 0], 1], [[-4, -1, 1, 0, 0], 1], [[4, -4, -2, 1, 0], 1], [[0, 9, -3, -3, 1], 1]]

hecke_ring_character_values = None
aps_data = [[0, 0, 0, 0, 0], [1, -1, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 1, 0, -1], [0, 0, 1, 0, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 0, 1, 0], [3, -1, 0, 1, 0], [2, -1, -1, -1, -1], [-1, 0, 0, 0, 0], [2, 2, -1, -1, 1], [0, -1, 0, -3, 1], [0, -1, -3, -2, 1], [3, 2, 0, 0, 1], [1, 0, -1, -1, -1], [5, -1, 3, 3, 0], [-2, -2, 2, 1, 0], [2, 1, -1, -1, 0], [-3, 3, -2, 1, 2], [-1, 2, 2, 3, -1], [0, -2, -3, -1, 1], [8, -1, 0, 1, -1], [3, -1, 2, -1, -1], [-1, -1, -2, 1, -3], [-4, -1, 0, 3, -1], [2, -2, 0, -4, 1], [4, 3, -2, -1, 2], [2, 4, -2, -1, 3], [-2, 2, -2, -2, -1], [7, 2, -2, -1, 2], [3, 2, 3, -4, 0], [1, -1, 0, -4, 3], [-6, 4, -3, -1, 0], [-2, 2, 0, 0, -3], [-5, 0, -1, -1, -4], [5, -3, 6, 1, -1], [2, 4, -1, 3, 1], [2, 4, -1, 0, 2], [6, -2, 1, 0, -1], [-5, 6, -3, -2, -1], [1, -1, 2, -2, 1], [2, 3, -1, 1, 3], [-11, 2, -4, 5, 2], [13, -4, 2, 2, 0], [1, 4, -1, 2, 0], [-3, 3, 3, -1, -4], [9, -3, -1, 1, 3], [6, -6, -3, -2, -2], [4, 3, -2, 1, -1], [4, 0, 4, -1, 2], [-5, 4, 2, 1, -1], [-7, 1, -4, -2, 2], [-6, 3, 5, 1, -2], [-2, -3, 3, 4, -4], [11, -3, 7, 2, -2], [-1, 2, -2, 2, -4], [-4, 5, 4, 0, 2], [3, -4, -1, 5, 0], [11, 2, 0, 2, 1], [-6, 2, -4, -1, 0], [-2, 1, -7, 1, -2], [-2, 5, -8, 1, -1], [3, -4, -7, -2, -1], [-8, 3, -3, -6, 2], [3, -1, 0, -2, -7], [9, 1, 6, 0, -3], [-4, 5, 9, 2, 0], [11, 4, 3, -1, -1], [10, 0, 2, 5, 4], [-7, 9, -2, 5, 2], [3, -7, -5, -1, 2], [-16, 2, 2, -1, 0], [-8, -3, -3, -5, 3], [8, -3, 7, 0, -4], [18, -1, 6, -4, 0], [-3, -6, -3, 6, -4], [-10, 0, -2, -8, -1], [-8, 4, -11, -1, 3], [11, -9, -3, -5, -3], [-16, 7, 6, 4, -1], [-8, 2, -5, 2, 7], [2, 1, -6, 1, 7], [2, -10, 3, 2, -3], [-14, 2, 1, 4, 1], [15, -1, 0, -2, 3], [-15, -1, -7, -1, 1], [-7, -1, -4, -5, -3], [6, 3, 2, -3, -4], [0, 1, -7, -1, -4], [-18, 8, 4, 5, 1], [3, -13, -2, 1, 3], [-1, 4, 1, 9, 1], [6, 9, -6, 2, -1], [3, 1, -5, -1, 1], [17, -2, -7, -5, 5], [-19, -2, -1, -6, 1], [10, 7, 0, 3, -4], [-13, 3, -7, 4, 0], [-7, -2, -5, 4, 3], [1, 3, 2, -3, -1], [5, 1, 8, 3, -9], [0, 10, 5, -4, 5], [-13, 16, -5, 5, 3], [10, 4, 2, -7, -1], [-4, -5, -5, -4, 5], [-1, 0, -7, -4, 2], [-13, -3, -10, -2, 7], [-3, -5, -9, -4, 8], [-1, 8, 1, -6, -1], [4, 9, -4, -5, 7], [-1, 5, 4, -2, -1], [-9, 10, 5, 1, 2], [3, -8, 7, 3, -3], [-10, 7, -7, 2, 2], [12, 2, 5, -10, 2], [9, -4, -7, 1, 5], [-1, -4, 2, -3, -11], [7, -5, -1, -2, 5], [-11, -11, 3, 2, -4], [-1, 1, 1, 4, -6], [-7, 5, 4, 7, 4], [-19, 1, -4, 3, -4], [11, -5, 2, 0, 1], [14, -4, -3, -1, -2], [-10, 13, 5, 4, 2], [8, -2, 15, 9, -2], [2, -13, -6, 7, 1], [-16, 0, 0, 0, -1], [-12, 0, -5, 8, -4], [-20, 5, 2, 0, 6], [21, -5, 0, 6, 2], [5, 2, 6, 1, -7], [8, -14, 7, 2, 1], [10, 2, 2, 2, 11], [-22, 11, -2, -6, -2], [-8, 10, 3, -3, 2], [-7, -9, -1, -4, -7], [14, 0, -1, -6, 2], [-2, -1, 6, 4, -8], [-5, 5, -6, 5, 8], [20, -8, -6, -12, 0], [3, -11, 9, 5, -4], [26, -9, -2, 1, 1], [20, 10, -5, -2, 7], [-19, -4, -3, -1, 9], [-16, 5, 3, 3, -4], [1, -7, 1, -3, 1], [-4, 17, -3, 1, -1], [5, 4, -8, -1, -1], [8, 4, 3, -3, 11], [25, 5, -3, 2, 0], [-1, -4, 6, 0, -10], [24, -12, 8, 5, -2], [-19, -1, 8, 8, -3], [10, 3, 0, -7, 4], [18, -12, -5, -1, -1], [-1, -5, -12, 1, 2], [-5, 11, 1, 8, 2], [-17, 3, 2, 1, 5], [2, 4, 5, 14, -1], [16, -5, 3, 2, -5], [10, 3, 8, -3, -5], [6, -2, -4, 5, 11], [-2, -12, 7, 5, -8], [4, 2, -4, -1, -6], [-6, -5, 0, -13, 2], [8, -15, -4, 1, 3], [-17, -8, -10, -2, 6], [5, 14, 1, -1, 1], [2, 3, -9, -6, 0], [-11, 7, 8, 5, -1], [23, -12, -2, 2, -1], [8, -15, 2, -11, 0], [-4, -8, 0, -6, -13], [-22, 5, 7, 3, -7], [-17, -1, -4, -6, 1], [-14, 3, -9, -1, -1], [-7, 4, 1, 1, 2], [-7, 12, -1, 11, 4], [-36, 7, -8, -12, -6], [17, -3, 3, 7, 8], [-1, -6, 0, 11, -7], [7, -12, 8, 1, -5], [20, -5, 6, 0, 7], [-1, 12, 7, 3, 5], [-20, 20, -9, 7, 4], [-12, 3, 1, -2, 1], [1, 0, 16, 10, -11], [21, -9, 15, 1, 1], [5, -7, 12, 5, -6], [14, 11, -2, 10, -5], [13, -14, -1, -7, 3], [-5, 1, -2, 0, -7], [0, 10, -12, -8, 4], [-3, -5, 6, 10, -4], [-19, -11, 0, 3, -9], [-13, 7, 6, 10, -6], [-2, -6, 8, -8, 0], [14, -16, -1, -3, -1], [27, 1, -9, -10, 8], [-4, 4, 4, 3, -6], [21, 14, -5, 3, -7], [15, -12, -4, -16, 2], [-7, 11, -8, -3, 4], [24, 8, 4, 0, -2], [-1, -6, -9, -10, 7], [9, 3, 3, -3, 1], [6, -6, 4, 1, -2], [-18, -9, 4, 8, -12], [-16, -4, 7, 6, 3], [-1, -9, -8, 3, -1], [-5, -10, -12, 4, 3], [6, -5, 7, -2, 8], [18, -19, 15, 6, -2], [1, 10, 4, -9, 6], [-2, -10, 4, -1, -5], [4, -20, 8, 0, 2], [33, 9, -6, -3, 3], [19, -7, 2, 3, -3], [10, -12, -11, 2, -6], [11, 4, 1, 8, -3], [-5, -16, 4, -3, 5], [36, -2, -3, -1, -3], [-4, 3, -10, -12, 4], [38, -5, 3, -10, -4], [11, 1, 4, 11, 9], [-15, 6, -10, 3, 4], [-23, 5, -8, -4, -5], [5, -12, -7, -6, 0], [-4, -12, -7, 1, 0], [14, -9, -1, -7, 3], [17, -6, 7, -5, -7], [-5, 14, 6, -1, 0], [-5, -14, 12, 1, 5], [8, 1, -7, 11, -6], [22, -22, 1, 6, 3], [11, 4, -1, 0, -5], [27, 9, -3, -5, 1], [-35, 14, -7, -3, 0], [17, -2, -4, 0, -10], [-12, -12, 2, -12, 10], [-24, 9, 3, -7, -2], [16, -16, -8, -2, 0], [28, 3, 12, -5, 4], [-8, -5, -15, -4, -12], [-12, 15, 10, 11, -1], [10, -1, 2, -8, 9], [14, 0, 11, -7, 3], [6, -13, -8, 7, -4], [21, -1, -3, 4, -5], [-2, -17, 10, 0, 2], [-13, -4, 4, -5, 5], [-12, -3, -21, 3, -4], [23, 2, 17, 1, -1], [-7, -16, -2, -5, -8], [-17, 4, 5, 11, 6], [0, -14, 14, 0, 3], [-8, -3, -16, -5, 0], [22, -8, -9, -9, 3], [17, -12, 11, 5, 2], [18, -6, -11, 0, -2], [0, -9, -18, -6, 5], [36, 5, 5, -3, 0], [5, -7, -11, 7, 1], [-2, 2, -5, -6, 4], [-31, 5, 12, 2, 7], [8, -7, -6, -10, 3], [14, -9, 5, 6, 7], [14, -10, -17, -6, 2], [-6, 1, 3, -1, -1], [52, -5, -5, -4, 1], [-13, 5, 0, -7, 7], [13, 1, -9, -13, 4], [-17, 1, -1, -4, 1], [-19, 10, 3, -12, -3], [48, 6, -11, -8, 8], [-2, 11, -4, 12, 6], [-14, -13, -7, 4, 3], [-13, 6, -5, 8, -4], [7, 1, 7, -7, -2], [9, 20, 4, 3, -3], [30, 13, 5, -1, -9], [1, -5, 2, 0, 6], [-7, 0, 7, 6, 6], [-10, 5, 1, -13, -4], [-2, 23, -4, 7, -4], [-13, -2, 3, -11, -2], [20, 3, 2, 0, 1], [-19, 7, 1, 9, 4], [-1, 17, 11, 0, -5], [6, -2, -20, -8, 15], [21, 9, 9, 2, -15], [-8, 1, -13, -12, -2], [-20, 7, -18, 3, 2], [-21, 12, -12, -6, 0], [6, 4, 8, 4, 2], [16, 7, 8, 1, -14], [1, -6, 3, -11, -15], [32, 3, 12, 4, -5], [-16, -7, 3, -7, -1], [3, -8, 2, 16, -7], [16, 0, 11, -5, 8], [-17, 23, -10, 7, 3], [8, -28, 3, -4, -3], [-25, -8, -12, 6, -7], [-12, -10, -3, -5, 5], [0, -7, -18, -4, -1], [8, 5, 4, -6, -4], [18, 5, 2, -9, -2], [-23, -3, 3, 3, 3], [-11, 1, 7, -4, -21], [37, 8, -12, -7, 13], [-3, -1, -16, -6, 0], [-3, 1, 23, 11, -8], [-15, -8, 9, -11, 2], [8, 7, 9, 1, -14], [-40, -4, 5, 6, -11], [-24, 18, -22, -1, 7], [23, -1, 10, 14, -10], [-24, 10, -8, 3, 4], [10, -9, 8, 9, -1], [24, -2, -10, -13, 3], [4, -1, 18, -3, 2], [2, -3, -5, 2, 2], [-23, -3, -11, -5, -5], [-17, 4, -4, 18, -2], [-57, 3, -13, -5, 3], [49, 11, -4, -11, 11], [38, 3, 18, 2, -9], [21, -18, 15, 4, -9], [-13, 4, -1, 3, 9], [-19, 4, 24, 12, -7], [-3, 13, -3, 9, 16], [-38, -2, 2, 8, -8], [11, -24, 20, 2, -8], [39, 4, -2, 9, -4], [-15, 9, -7, -3, -4], [5, 8, 13, -10, -10], [10, -1, -3, 4, 11], [14, 4, 5, 11, -13], [-3, 0, -17, 1, 12], [-40, 2, -1, -16, 2], [11, 16, 6, -13, -1], [23, -9, 19, 6, 3], [-10, 7, -19, -21, 8], [-4, -24, 5, 2, -6], [-24, -6, -11, -8, -13], [-1, 15, -11, 0, -7], [-34, -8, -16, 3, 7], [27, -9, -13, -4, -7], [1, -14, -7, -19, 1], [61, 4, -4, 1, 1], [-22, 7, 14, 5, -7], [-22, -19, 15, -1, -3], [1, 10, -16, -2, -6], [-3, 19, -4, 9, 1], [-17, -19, 11, -2, -7], [-6, 4, -12, -3, -5], [-16, 1, 3, -16, -1], [3, 2, 12, 0, 3], [-2, 2, 6, 20, -1], [-6, 10, 7, 9, -14], [6, -10, 0, 6, 13], [25, -1, 4, -12, -1], [27, -7, -5, 7, -2], [37, 9, 10, -3, -5], [-14, -22, 2, 2, -8], [24, 17, -15, 3, -3], [-12, -12, 17, 1, -8], [20, 5, 10, 2, 3], [20, -6, -16, -7, -8], [-45, 2, -24, 9, 8], [16, 3, 13, -3, 11], [17, -19, 3, -8, -10], [38, -25, 5, 11, 6], [-35, -4, 0, -6, -15], [4, 7, 9, -12, -5], [2, -10, 14, 9, -11], [-44, -12, 0, 1, 8], [42, -8, 8, 5, 1], [-15, -13, 9, -11, 7], [-43, 20, -9, 17, 9], [24, -12, 1, 10, 8], [10, -17, 9, -17, -6], [-18, -9, 11, 1, -1], [33, 9, -9, 5, -6], [19, 2, -6, -6, -5], [14, -12, -10, 4, 9], [-18, 9, -3, 10, 19], [-17, -10, 9, 1, 3], [37, -10, 4, -18, -5], [-10, -7, -11, -2, 3], [-46, -15, 4, 13, -14], [-5, -11, 21, 2, 7], [-27, 11, 3, -16, 5], [-5, 8, -8, -17, -1], [-1, -8, 8, -9, -21], [-2, 5, 4, 12, 13], [30, -13, -13, -15, 9], [23, -18, -16, -11, 8], [14, 0, 6, 2, -9], [0, -1, -10, -23, 9], [18, 8, 10, 1, -18], [-17, -21, -16, 5, 12], [5, -6, -20, -9, 7], [-33, -4, -15, 2, 12], [-23, 3, 5, 11, 0], [-57, 9, -23, -1, -1], [-6, 0, -7, -9, 14], [-2, 1, 0, 7, -12], [12, -8, 17, 6, -2], [-13, -8, -5, 14, -9], [20, -15, 12, 11, -6], [-21, 12, -3, -1, -13], [-9, 14, -15, -6, -11], [11, -25, 16, -3, 1], [-67, -1, -9, 1, 4], [-3, 1, 23, -3, 13], [-3, -8, -7, 16, 0], [-34, -10, 16, 11, -12], [75, -18, -7, -6, -3], [-2, -2, 5, -8, -8], [-17, -14, -15, 10, -7], [28, -11, -10, -13, 6], [-12, 0, -7, -2, 16], [-9, -2, -24, -24, 9], [-15, -1, -8, 1, 0], [19, -6, 17, 12, -6], [59, 13, -1, -2, 12]]
