
# q-expansion of newform 2058.2.a.m, downloaded from the LMFDB on 05 October 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 = 2058
weight = 2
poly_data = [-377, -107, 187, 21, -25, -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, 0, 0, 0], 1], [[0, 1, 0, 0, 0, 0], 1], [[-484, 46, 120, -91, -7, 8], 293], [[1239, 1162, -421, -235, 27, 11], 293], [[-3392, -1208, 594, 326, -20, -19], 293], [[6408, 1580, -2044, -374, 129, 20], 293]]

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