
# q-expansion of newform 1080.4.a.m, 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, 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 = 1080
weight = 4
poly_data = [1, -6, -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], [[-4, 12, 0], 1], [[-24, -6, 6], 1]]

hecke_ring_character_values = None
aps_data = [[0, 0, 0], [0, 0, 0], [5, 0, 0], [2, 0, -1], [4, -1, -1], [6, -1, -1], [-7, -2, -3], [19, -3, 3], [29, 3, -2], [46, 8, -1], [39, 8, -5], [50, 8, 4], [0, -12, -5], [60, -4, 21], [228, 1, 16], [29, -1, 19], [238, -3, 15], [-171, -10, -22], [-58, -12, 14], [256, 19, -11], [-84, 15, 7], [69, 21, 17], [563, -17, -10], [104, 14, 33], [-360, -4, 60], [996, 6, 40], [-308, 0, -60], [556, -47, -22], [-435, -53, 14], [566, 41, -12], [1102, -14, -2], [894, 36, 4], [1179, -23, -71], [-396, 24, 72], [1160, -74, -15], [920, -87, -94], [-504, 29, 47], [1834, -30, 32], [713, 50, 100], [2087, -14, -23], [1324, 18, -94], [189, 43, 22], [-50, -72, 88], [-1654, -83, 51], [1759, 29, -37], [2080, 62, -30], [-291, -14, 53], [1534, 2, -72], [-593, 82, 238], [-3917, 27, 8], [326, -22, 244], [1682, -28, -50], [-2213, -19, -184], [1944, -18, -14], [-465, -3, -13], [-1544, 37, -244], [270, 104, 70], [3375, 132, 91], [-1844, 53, -101], [-990, 100, 21], [-2120, 20, 47], [755, -129, -11], [8182, -24, -92], [98, -137, -317], [-3352, 84, 258], [1385, 20, 143], [916, 94, 366], [-1138, 13, -533], [-956, -102, -24], [-7435, -124, -48], [-86, 84, -410], [1490, -238, 114], [6066, 40, -13], [-8584, 118, -146], [4785, -298, -311], [-2351, 328, 382], [-2724, -120, 215], [7698, 5, 199], [-1214, -26, 464], [-8911, -119, 42], [-2396, 499, -5], [-4077, 18, 416], [-946, 271, -113], [5090, 261, -199], [-961, 388, 13], [-8253, -99, -308], [-11130, 6, -77], [8548, 54, 558], [-326, -74, 662], [-4562, 334, 342], [-1177, -332, 242], [-788, -1, 307], [12664, 126, -223], [-3206, -188, 366], [-8353, 60, 157], [-9163, -367, 462], [-8708, -4, -416], [-6008, 356, -317], [5962, 192, 33], [2022, 431, -854], [5204, -522, -579], [-10466, 282, 338], [-8004, -173, -634], [4134, 524, -83], [-6389, 210, -543], [20752, 125, 83], [-1595, 715, 182], [-1045, 11, -349], [-1430, -329, 461], [5229, 425, -884], [3044, 308, 1197], [-3424, -790, 556], [-1571, 235, 843], [-18072, -38, -542], [797, -665, -159], [6992, -646, -436], [-9826, -442, -187], [3429, 738, -46], [373, 126, -787], [-5014, -805, 55], [-10522, -451, 698], [5094, 363, -29], [10918, -205, 448], [8963, 392, -512], [-13579, 522, 9], [-3226, -776, 776], [-10214, -373, 742], [16294, 176, -132], [12592, 98, -110], [-15848, 406, -408], [-7503, 816, 175], [-2536, 302, 920], [-2243, 229, -979], [15162, 448, 242], [12626, -34, -371], [6893, -443, -22], [2877, 36, 525], [4584, -1142, 63], [-8641, -217, 637], [-7144, -58, -249], [-460, -819, -102], [8854, 1040, -840], [-13796, -408, -299], [21693, 120, -682], [-10610, 309, -396], [9744, 1262, -330], [-5292, 1240, 882], [33841, -224, 103], [-17503, -216, -465], [10749, -663, -316], [19568, -371, -151], [1362, 1050, 1145], [-9798, 154, -97], [7309, 197, 108], [9892, 580, -296], [-12178, -345, -499], [-21488, 374, -992], [7504, -742, -237], [39392, -380, -194], [32442, -404, -100], [831, -227, -1814], [11702, -364, -1088], [22186, 1426, -984], [25118, 490, 1176], [-9182, 78, -1758], [-22431, 153, 1420], [-22591, 789, 13], [-920, 499, 569], [-4197, -509, 640], [17403, 854, 473], [18532, -678, -320], [-1049, -462, -302], [27646, -357, 911], [12508, -994, 484], [-31143, -17, -1371], [-18370, 860, -67], [-18129, -823, 1051], [-6, 812, 345], [-14432, 360, 521], [-20270, 849, 1390], [23220, 580, -1013], [-48856, 500, -474], [14098, 836, -608], [-2022, -1871, 576], [3819, -1066, 1048], [7556, -422, 2952], [-10434, -251, -2007], [-19016, -592, 1122], [40833, -101, 864], [-18830, -805, -1125], [5526, -536, -2000], [-25115, 1828, 1284], [-15995, 803, 873], [14976, -388, 152], [15675, 163, 3366], [10839, -1072, -89], [40317, -135, 288], [-11792, -1520, -1434], [36686, 1648, -1278], [-25592, 1431, 1742], [-45304, 872, 411], [2668, -120, -486], [8774, -1560, 588], [17659, 1882, -1376], [31486, -1079, -627], [-7686, 866, -2092], [-20236, -800, -710], [-45853, -156, -2894], [-6036, -966, -2128], [26820, 172, 1472], [27590, 307, 2655], [43572, 776, 1913], [27864, 1672, 260], [-452, -1283, 2746], [16916, -1548, -2832], [17445, -1704, 998], [6712, -2586, -259], [-21968, 414, 356], [-31027, 320, -1082], [-2163, -1868, 2019], [-5366, 752, -1188], [42951, -307, 2349], [-56934, 772, -11], [-5232, -1410, 35], [-75825, -681, 1182], [-27185, -2103, 2934], [17103, 191, 2281], [12496, 1203, 1297], [-866, -784, 1822], [-54724, 412, 820], [-4540, -659, 2577], [-22573, -553, 285], [17152, -160, -80], [6362, 2934, -800], [4306, 370, -1679], [26535, 1632, -186], [18641, 1379, 2148], [-6913, 110, 1809], [-18986, -322, -744], [-45340, -37, 2729], [-44772, -497, -1522], [-1849, -1403, -3879], [23222, 778, -2074], [-55979, -387, 1090], [-6494, 1458, -410], [30078, 128, -570], [-51968, 2280, 1894], [6610, -2727, 1717], [28284, -3106, -1972], [-51557, 1080, -428], [-78638, 400, 734], [-45642, 298, -414], [-48493, -1597, 1820], [33449, -1248, -2126], [32849, 1582, -1123], [44600, -586, -2692], [-77559, -1004, 776], [34398, 198, 3973], [-3031, -1915, 659], [-39950, -1631, -2251], [-11208, 374, 2615], [9529, 1398, 586], [12027, 2001, -1582], [-15468, -806, -1932], [-31793, -2019, -2973], [-7868, 612, 1680], [-49552, -1932, -1752], [-75574, -1804, 776], [55398, -2682, 184], [3726, 2188, 1726], [-8769, 1918, -1100], [-64658, 2862, 2310], [10672, 2653, 4291], [21751, 3710, -1461], [-53980, -1683, 3171], [25342, 638, 737], [-53487, 1957, -2452], [15213, 874, 4548], [34753, 1451, -2162], [-51040, 251, 2107], [-13784, 1231, -598], [73211, 1673, 2137], [35865, 524, -1514], [-32469, 824, 216], [35508, 2450, -824], [-38446, 1521, -4193], [-4366, 240, -402], [-35790, 1266, -892], [34785, -138, 903], [11696, 1772, -1280], [-26768, 1742, 2652], [72409, 2245, -2984], [20626, -1418, -5456], [5266, -1634, -2550], [272, 739, -2167], [-35868, 2208, -990], [17423, -3879, 1157], [20926, -974, -1412], [87272, 1518, -480], [-29638, 1844, -5831], [27888, 3801, -5233], [31237, -1304, 6879], [59200, -70, 3292], [-60669, -3907, 3218], [39585, -105, 1625], [47760, 1235, -1491], [66220, -3473, -1982], [-5653, 2095, 6376], [62284, 1039, 6597], [-47176, 1413, 897], [46539, 2116, -2914], [6836, -304, 3566], [-73784, -2252, 1566], [-47782, -488, -2513], [-34025, -4593, -294], [-31589, -3348, 2634], [65664, 1420, 1924], [106312, 1291, 1173], [27086, 313, 6205], [-14670, 3202, -764], [-45223, 567, -3189], [-117944, -580, -3038], [69268, -2168, -3450], [35584, 534, -4002], [20113, 3377, -1959], [-14258, 709, 2466], [90033, 1241, -1819], [47888, 546, -2434], [103512, 116, 5256], [32195, -3193, -165], [4938, -2336, 5764], [-123558, 3346, 2472], [-41728, 1285, 758], [81452, 3609, -832], [69784, 2106, 590], [22452, 1371, -2474], [27127, 1943, -2484], [100145, 488, 5669], [31102, 1179, 3640], [-55300, -772, -6883], [-22840, -3786, -5354], [95957, 1112, 1811], [-26894, -3022, -6809], [8313, 5224, -2335], [51438, -6965, -5892], [36680, -2985, 4517], [34079, -3134, -3324], [-41468, -4128, 3782], [-5340, 2466, 4674], [-19661, 1180, -8905], [-53420, 2595, 4602], [-8762, 4906, -2814], [134662, 2, 139], [5928, 82, -2826], [130970, -3243, -1300], [113337, 4300, -4319], [10646, -2287, -4605], [41130, -5831, -3363], [14054, -1128, 6702], [50521, 957, -5804], [-9522, 1147, -4319], [-68906, 2132, -4150], [-49336, 2329, -1020], [140710, -368, 3574], [-110572, -2872, 4202], [8766, 4319, 3119], [-35235, 1011, 6857], [161114, -96, -1068], [11682, 1840, -5500], [-30582, 1590, -8306], [121899, -2204, 3969], [69263, -7127, -4304], [-47908, 332, 4455], [-29913, -1350, -7493], [186360, -1148, 190], [-45858, 948, -7748], [-185034, -790, 916], [48412, -3661, -1755], [51782, 2000, 98], [-122010, 3706, 958], [-29540, 5346, 3390], [9303, -1841, 2021], [-92510, 2398, -31], [46693, -2336, -7787], [-12684, 6306, 4366], [-67196, -1525, 5128], [-83667, -19, -1101], [-149170, -1, 2031], [55428, -3390, 149], [-123072, -1832, -352], [37082, -5519, 4326], [-61775, 226, 7541], [1670, 1490, -1240], [-38066, 5550, 3860], [-21110, -4866, 4598], [37112, 3405, 3937], [148945, 860, 4541], [-20506, 1478, 9067], [-72555, -701, -2827], [107452, -4970, -4238], [106746, -1944, -4708], [37214, -3808, 1198], [-102666, 1118, -231], [-68538, 4860, 5368], [9230, 2120, -1631], [82315, 2542, 3419], [-25546, -1322, 8636], [-241138, 824, -1402], [-129724, 622, -7006], [59390, -2065, -8175], [-73130, -4530, 2908], [-93217, -1972, -11311], [-21515, 5637, -3840], [-93405, -2608, 4579], [-75534, -4054, 26], [60234, 684, -5365], [-192170, 1844, 742], [-48576, -2980, 2360], [97343, -1483, -2535], [7255, 7186, -4744], [-133924, 170, -1370], [82826, -7766, -3146], [14943, 2794, -884], [-213238, -3042, -202], [-40074, 360, -10522], [-73485, 1779, 4193], [10313, -5266, -5738], [29486, 1202, -5980], [42185, 8265, -993], [82368, 2873, 975]]
