
# q-expansion of newform 6018.2.a.m, downloaded from the LMFDB on 04 May 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 = 6018
weight = 2
poly_data = [1, -3, -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], [[-2, -1, 1], 1]]

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