
# q-expansion of newform 3080.2.a.m, downloaded from the LMFDB on 20 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, 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 = 3080
weight = 2
poly_data = [-1, -5, -1, 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], 1], [[0, 1, 0], 1], [[-3, -1, 1], 1]]

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