
# q-expansion of newform 2160.3.c.m, downloaded from the LMFDB on 02 January 2025.

# 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 = 2160
weight = 3
poly_data = [31, 0, 14, 0, 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], 1], [[0, 7, 0, 1], 3], [[7, 0, 1, 0], 3], [[0, 13, 0, 1], 3]]

hecke_ring_character_values = [[271, [1, 0, 0, 0]], [1621, [1, 0, 0, 0]], [2081, [-1, 0, 0, 0]], [1297, [-1, 0, 0, 0]]]
aps_data = [[0, 0, 0, 0], [0, 0, 0, 0], [3, 1, 1, 0], [0, 1, 0, 2], [0, -2, 0, 3], [0, 0, 0, 3], [-3, 0, 7, 0], [3, 0, 3, 0], [-15, 0, -14, 0], [0, 9, 0, 0], [17, 0, 15, 0], [0, 14, 0, -2], [0, -1, 0, -6], [0, -7, 0, 4], [60, 0, -14, 0], [51, 0, -9, 0], [0, 4, 0, -9], [-49, 0, 24, 0], [0, 8, 0, -26], [0, 6, 0, -21], [0, 16, 0, -7], [-45, 0, 63, 0], [-27, 0, 58, 0], [0, -29, 0, 0], [0, 10, 0, -22], [0, -8, 0, 6], [0, 28, 0, 2], [36, 0, 30, 0], [-19, 0, -90, 0], [12, 0, 30, 0], [0, 34, 0, 14], [0, -18, 0, -12], [27, 0, 135, 0], [-38, 0, 102, 0], [0, 35, 0, -12], [20, 0, -66, 0], [0, 16, 0, -19], [0, 28, 0, -10], [-21, 0, 60, 0], [69, 0, -29, 0], [0, -20, 0, 12], [113, 0, -42, 0], [0, -66, 0, -12], [0, 34, 0, 17], [279, 0, -1, 0], [-114, 0, 30, 0], [-171, 0, -105, 0], [0, 74, 0, -2], [87, 0, -232, 0], [-59, 0, 114, 0], [126, 0, 82, 0], [0, 44, 0, 48], [-191, 0, -90, 0], [0, 36, 0, -30], [87, 0, -213, 0], [-60, 0, 118, 0], [0, -18, 0, 72], [-115, 0, 147, 0], [0, -22, 0, 49], [0, -27, 0, 0], [0, -53, 0, 86], [-45, 0, -129, 0], [0, 0, 0, 60], [0, 114, 0, 21], [0, 112, 0, 20], [57, 0, 211, 0], [266, 0, 126, 0], [0, 56, 0, -95], [150, 0, 240, 0], [-37, 0, 84, 0], [6, 0, -182, 0], [0, 18, 0, 84], [0, -107, 0, -16], [0, 18, 0, 12], [-91, 0, -165, 0], [-465, 0, -76, 0], [0, -119, 0, -78], [0, -106, 0, -23], [0, 106, 0, 18], [-491, 0, -30, 0], [0, 50, 0, -63], [391, 0, 24, 0], [0, -152, 0, -33], [0, -8, 0, -103], [-135, 0, -189, 0], [-447, 0, 6, 0], [0, 33, 0, -132], [0, 98, 0, 82], [0, -78, 0, 30], [0, 132, 0, -96], [675, 0, 48, 0], [0, -34, 0, 93], [0, -51, 0, 30], [0, 18, 0, 132], [681, 0, -57, 0], [357, 0, 54, 0], [0, 54, 0, -192], [0, -17, 0, 6], [0, -137, 0, 86], [-80, 0, 210, 0], [0, 67, 0, -10], [210, 0, -66, 0], [-384, 0, -106, 0], [0, 19, 0, 12], [-127, 0, 699, 0], [0, 170, 0, -77], [309, 0, 162, 0], [-549, 0, -237, 0], [0, 162, 0, -75], [437, 0, -30, 0], [0, 53, 0, 16], [0, -176, 0, 14], [315, 0, -269, 0], [266, 0, -174, 0], [427, 0, -153, 0], [0, 38, 0, 192], [0, -45, 0, 12], [339, 0, 252, 0], [-855, 0, -49, 0], [0, 94, 0, -27], [668, 0, 258, 0], [0, -84, 0, 33], [444, 0, 94, 0], [147, 0, 268, 0], [65, 0, -345, 0], [0, -100, 0, -114], [636, 0, -378, 0], [0, -28, 0, 18], [0, 36, 0, -108], [0, -334, 0, -92], [-827, 0, 51, 0], [-498, 0, -576, 0], [-473, 0, -537, 0], [0, -166, 0, -2], [0, 153, 0, -156], [-687, 0, 102, 0], [-459, 0, -45, 0], [0, -155, 0, -82], [1011, 0, -281, 0], [0, -15, 0, -90], [692, 0, -282, 0], [0, 100, 0, -192], [0, -189, 0, 114], [615, 0, -424, 0], [180, 0, -930, 0], [0, -68, 0, 72], [0, -88, 0, 40], [945, 0, -537, 0], [653, 0, 315, 0], [-75, 0, 30, 0], [0, 226, 0, 83], [0, -117, 0, 342], [0, 123, 0, -90], [-531, 0, -798, 0], [0, -318, 0, 102], [0, -348, 0, -111], [762, 0, 366, 0], [0, -129, 0, -120], [0, -14, 0, 176], [0, -4, 0, -180], [-399, 0, 150, 0], [-294, 0, 814, 0], [0, -136, 0, 274], [0, -342, 0, -90], [-678, 0, 402, 0], [-243, 0, -70, 0], [-433, 0, 207, 0], [0, -120, 0, 159], [433, 0, -738, 0], [177, 0, 111, 0], [0, 6, 0, -60], [183, 0, 120, 0], [0, -146, 0, -69], [0, 212, 0, -62], [595, 0, -117, 0], [0, -201, 0, 216], [391, 0, -225, 0], [0, -213, 0, 0], [0, 23, 0, 178], [652, 0, 774, 0], [0, 223, 0, 38], [0, 266, 0, -276], [0, -88, 0, -242], [1068, 0, 534, 0], [-117, 0, 1124, 0], [0, -84, 0, 264], [0, -64, 0, -185], [0, 166, 0, -130], [-323, 0, -522, 0], [0, 176, 0, -123], [0, 66, 0, 264], [-1425, 0, 52, 0], [-961, 0, 243, 0], [0, 66, 0, -174], [1077, 0, 330, 0], [-843, 0, -825, 0], [-1287, 0, -342, 0], [0, -42, 0, -246], [-186, 0, -1290, 0], [-144, 0, -706, 0], [0, -105, 0, 216], [654, 0, 30, 0], [0, -54, 0, 432], [-97, 0, 144, 0], [0, 314, 0, -237], [-786, 0, -150, 0], [-1146, 0, -462, 0], [-573, 0, -356, 0], [0, 284, 0, -378], [-610, 0, -162, 0], [0, 364, 0, 83], [0, 165, 0, 186], [0, -122, 0, -52], [12, 0, 378, 0], [0, 118, 0, -486], [1003, 0, -804, 0], [0, 335, 0, -254], [0, 202, 0, 258], [-369, 0, -1280, 0], [1461, 0, -589, 0], [-1818, 0, -504, 0], [-701, 0, -261, 0], [0, 21, 0, -246], [0, 133, 0, 242], [1257, 0, -678, 0], [-843, 0, -174, 0], [-165, 0, 779, 0], [0, 100, 0, -225], [0, 56, 0, -248], [0, -110, 0, 270], [0, -22, 0, 439], [-701, 0, -537, 0], [-1070, 0, 882, 0], [0, -270, 0, 6], [0, 65, 0, -314], [63, 0, 80, 0], [1197, 0, 606, 0], [1401, 0, 919, 0], [0, -300, 0, 174], [0, 168, 0, 237], [-1284, 0, -102, 0], [-1997, 0, 627, 0], [0, -10, 0, -32], [233, 0, 558, 0], [-1074, 0, 386, 0], [0, -372, 0, -288], [0, 312, 0, 162], [0, -366, 0, -237], [1586, 0, 138, 0], [-2373, 0, 124, 0], [0, 396, 0, -12], [0, 284, 0, 126], [-159, 0, 670, 0], [-409, 0, -732, 0], [1581, 0, 535, 0], [0, -222, 0, 474], [-869, 0, -1272, 0], [0, 65, 0, 304], [-501, 0, -1165, 0], [0, -122, 0, 539], [0, 9, 0, 252], [-1149, 0, 392, 0], [-535, 0, 1026, 0], [0, 518, 0, 64], [2499, 0, 327, 0], [542, 0, -1386, 0], [0, -102, 0, 138], [0, -322, 0, 96], [0, 92, 0, 256], [2202, 0, 294, 0], [-949, 0, -384, 0], [0, -208, 0, -212], [0, 56, 0, -167], [-815, 0, 219, 0], [0, 440, 0, -395], [0, 133, 0, 146], [1185, 0, 634, 0], [-1253, 0, 1500, 0], [-475, 0, 1086, 0], [0, 648, 0, 111], [-132, 0, -1074, 0], [871, 0, 1671, 0], [-825, 0, 700, 0], [2119, 0, -588, 0], [0, -388, 0, -194], [0, 538, 0, -471], [0, -408, 0, 534], [-1098, 0, 302, 0], [-31, 0, 1803, 0], [0, -260, 0, -306], [0, -676, 0, -162], [381, 0, 774, 0], [270, 0, -162, 0], [0, -222, 0, 66], [0, -62, 0, 671], [0, -6, 0, -150], [-321, 0, -1485, 0], [-30, 0, -762, 0], [0, -280, 0, 420], [0, 507, 0, -558], [0, -664, 0, -305], [-555, 0, 1215, 0], [2018, 0, 222, 0]]
