
# q-expansion of newform 1380.2.a.f, downloaded from the LMFDB on 19 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 = 1380
weight = 2
poly_data = [-6, 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, 0], [-1, 0], [-1, 0], [1, 0], [-2, 1], [0, -1], [-1, 1], [0, -3], [1, 0], [-7, 1], [3, 2], [-5, 2], [-3, -1], [2, 4], [0, -3], [-3, -3], [-9, -1], [-2, -1], [-1, -4], [-5, -3], [0, 3], [-4, 4], [-13, 1], [-8, -2], [0, -2], [-9, 3], [-2, -2], [9, 3], [-16, 1], [-3, 5], [6, 5], [0, 0], [4, -6], [-1, 4], [-8, -1], [6, 4], [11, 0], [2, -8], [12, -1], [0, -4], [10, 0], [0, 2], [0, 7], [4, 2], [-6, 2], [10, -6], [25, 0], [14, 0], [12, 4], [-8, 6], [4, -8], [1, -9], [-8, -9], [-18, 0], [8, -5], [7, -3], [3, 5], [11, -2], [-10, 4], [-10, 3], [-1, 2], [5, 9], [-8, -5], [4, -8], [-19, 6], [20, 3], [11, 4], [14, 4], [4, 10], [-9, -10], [8, -1], [-12, 1], [25, 2], [20, -4], [4, 4], [9, 5], [10, -10], [-28, -4], [18, -2], [5, 6], [-26, 3], [0, -3], [-12, -10], [-15, 4], [-10, 6], [-20, -1], [-7, 13], [-3, -10], [2, -6], [0, -3], [-15, 7], [-4, 11], [-6, 13], [-9, -5], [17, 4], [1, -7], [16, 6], [2, 5], [-20, 4], [8, 10], [-12, -4], [29, -3], [-25, -3], [-6, -6], [-6, -1], [-4, -4], [-10, -12], [-12, 5], [0, 10], [-7, 12], [10, -9], [14, 0], [25, -7], [-36, -4], [14, -9], [-2, 1], [-1, -10], [18, 3], [-2, 3], [-6, -11], [30, -6], [-30, -1], [-1, 3], [24, 9], [10, -8], [-24, -3], [-26, 3], [3, -3], [-13, -2], [3, 12], [27, 8], [-44, -4], [28, -7], [-5, 6], [-25, -7], [-18, 7], [6, -2], [-13, 14], [35, -1], [39, 1], [-23, 4], [20, -10], [8, -4], [-1, -21], [-17, -6], [-2, 0], [-10, -2], [6, 8], [-3, 8], [6, 14], [10, -6], [-32, -5], [-30, 5], [18, -6], [-45, 0], [24, 8], [16, -4], [-3, -13], [-12, -10], [-28, 1], [-28, 6], [14, 8], [-14, -3], [-40, 2], [-15, 3], [-9, -7], [1, 8], [-32, 2], [-8, 12], [36, -1], [-32, -8], [41, -8], [-6, 4], [1, 2], [56, 0], [-12, 7], [14, -6], [5, -5], [-3, -8], [-12, 15], [-20, 7], [36, 9], [26, -10], [6, 9], [-1, 1], [18, 15], [-4, -5], [-35, 0], [-13, -14], [39, -7], [44, -5], [14, 4], [-36, -1], [17, 17], [-14, -8], [11, -5], [0, 3], [-8, -6], [6, -12], [18, -8], [40, -9], [26, -8], [-20, -7], [-16, 17], [40, 7], [-18, -10], [-34, 1], [6, -5], [29, 7], [50, 0], [18, -6], [10, 2], [10, 22], [26, 0], [-45, 9], [-18, 15], [30, 2], [-31, -1], [-21, -7], [10, 9], [55, 6], [6, 2], [9, -17], [-7, 0], [2, 11], [-1, -10], [6, -2], [33, -13], [-28, -4], [-17, -17], [28, -1], [0, -25], [26, 6], [17, -11], [-5, -18], [30, 4], [-14, 9], [30, 8], [23, 13], [-3, 19], [-9, 23], [15, 10], [-6, 26], [40, 6], [-52, 4], [-8, 6], [22, 9], [6, 7], [46, 10], [-17, -9], [-60, 2], [-54, -4], [-15, 5], [-6, -22], [18, 17], [-21, 19], [-2, -13], [-24, 4], [-14, -19], [-6, -12], [-43, -14], [-49, -1], [1, 22], [-61, -2], [-40, -2], [14, -13], [-12, -19], [-14, -4], [-13, 6], [36, -12], [11, 12], [-1, -6], [11, 6], [10, -24], [-42, -3], [-20, -1], [-12, -5], [-17, -8], [-18, 21], [16, -19], [22, -16], [14, 5], [-56, 10], [-52, 0], [20, -23], [-39, -3], [65, 6], [-30, -4], [14, -14], [38, -14], [-18, -2], [-31, -1], [-28, 14], [-20, -7], [-10, 9], [8, -8], [-56, -9], [18, 15], [-3, -13], [-34, 4], [31, -6], [23, -15], [-20, 26], [-68, 5], [-8, 32], [18, -1], [-30, -1], [-18, -12], [32, -3], [2, -15], [8, -16], [18, 19], [-68, -1], [4, -20], [9, 3], [-22, -5], [27, 9], [45, 11], [-47, -16], [-52, -10], [10, -3], [-3, -2], [-42, 4], [-26, 0], [-27, -3], [10, -19], [18, 9], [12, 11], [60, 8], [21, -11], [3, -10], [42, 11], [37, 2], [-6, 3], [-20, -20], [20, -8], [-42, -6], [-10, 14], [12, -6], [-77, -2], [22, 22], [-34, 12], [-54, 10], [-74, 3], [19, 21], [15, -7], [-9, -6], [4, 23], [42, -8], [17, 31], [-79, -2], [58, 7], [27, 25], [-19, 4], [-10, -1], [-58, 4], [-30, -11], [18, 24], [-10, -23], [-26, 10], [-5, 8], [-27, 7], [6, 6], [-16, -14], [74, -6], [46, 10], [16, 1], [-61, -2], [20, -12], [29, -9], [-1, -4], [54, 8], [-24, -18], [-16, -12], [-40, -3], [-13, 17], [-70, 10], [49, -12], [-16, -18], [-10, -2], [-2, -30], [-42, 2], [36, -8], [-62, -15], [72, -6], [-6, -28], [45, 22], [26, 3], [25, -14], [47, -1], [32, -13], [10, -14], [15, -15], [10, -7], [54, 9], [57, -8], [-46, 14], [24, 10], [-24, -20], [-39, 23], [-13, 12], [-34, 8], [87, 0], [33, -17], [23, -3], [-7, 10], [-3, -4], [-38, -6], [-18, 16], [4, 0], [-2, 23], [42, -15], [20, 8], [28, 6], [79, 0], [58, 8], [-8, 14], [34, -9], [-41, 11], [16, 14], [26, 11], [-20, 10], [54, 5], [40, 16], [-10, 35], [-4, -36], [76, 6], [-81, 7], [22, 2], [-47, -7]]
