
# q-expansion of newform 1080.4.a.f, downloaded from the LMFDB on 25 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 = [16, -11, -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], [[22, 3, -3], 1], [[48, -6, -6], 1]]

hecke_ring_character_values = None
aps_data = [[0, 0, 0], [0, 0, 0], [-5, 0, 0], [0, -1, 0], [9, 1, -2], [-1, 2, -1], [5, -3, 5], [-26, 3, 3], [35, -1, 6], [39, 1, -5], [-69, 1, 8], [-40, 19, -19], [100, -16, -3], [-161, -3, -10], [101, 17, -19], [-164, 8, -11], [80, 30, -3], [-148, -37, 20], [-174, -1, -36], [-56, -52, 17], [-292, -11, 27], [-701, -10, -3], [-14, -26, 53], [-756, 30, 13], [-464, -3, 29], [-515, -1, 12], [-404, -21, 66], [122, 40, -16], [-1032, 2, -2], [-39, -15, -50], [-538, -14, -20], [403, 41, -30], [-34, 68, 44], [-372, 51, 39], [-697, 9, 20], [-1893, 62, 15], [-1117, 11, 104], [-667, -10, -6], [1528, -22, 85], [-882, 98, -82], [1228, 16, 39], [-2498, -113, 64], [990, -124, 117], [196, -45, -59], [-504, -14, -77], [-367, 6, -103], [1980, -61, -167], [-2308, 48, -106], [3196, 92, -127], [764, -166, 24], [-1850, 98, 220], [-998, 98, -161], [-1827, 68, 8], [3433, 11, -75], [797, 19, -270], [-100, 16, -40], [-5367, -235, 67], [-418, 19, 183], [-2438, 100, -154], [-2018, 234, -328], [3648, 200, -82], [-4402, -184, -6], [3, -47, -132], [-576, 362, -73], [-1666, -87, 279], [-520, -308, 280], [-1476, -417, 85], [7134, 127, 91], [1820, -300, 339], [24, -309, -4], [-1497, -559, 180], [1980, 30, -344], [-2676, 395, -380], [6165, -74, -113], [-3282, -257, 371], [151, -475, -52], [-6049, 403, -231], [3081, 265, 104], [1916, 316, 299], [9715, 90, 118], [-4265, -469, 317], [-1994, 551, -690], [5676, -262, 146], [1926, 92, -420], [-1536, -428, 286], [3856, -412, 60], [-6722, 80, -249], [-2600, -786, 204], [-5446, -8, 269], [9456, -417, 298], [9028, -290, -19], [-7696, 68, 511], [5390, -379, 174], [1512, -54, -622], [10756, -320, 198], [3195, 375, 316], [-6961, 23, -380], [-3532, 302, -266], [1567, 702, -762], [1452, -419, -328], [6725, 486, -210], [-5156, -446, 111], [-14070, 166, -214], [3156, -106, -581], [10828, -255, 663], [-4158, -115, 659], [12374, -380, 584], [-10831, -329, 655], [-11818, -158, 617], [-9837, 331, 842], [2688, 927, -430], [1307, -296, 653], [21291, 195, 92], [-9992, 937, -1511], [8302, 759, -323], [-1138, -914, -146], [20239, -199, -64], [7436, 928, -135], [2416, -572, 516], [-7880, -52, -338], [1540, -349, 752], [-14320, 775, -1461], [13112, 1298, -431], [-152, -724, -137], [1322, -1086, 168], [-7685, -593, -376], [7690, -161, -724], [-5246, 1002, -1541], [-4340, 4, 1640], [-7098, 504, -230], [-14344, -1172, 408], [-11407, 373, 7], [-3617, -214, 463], [-2643, -724, -125], [24754, -316, 76], [5927, 572, -452], [-11946, 78, -1293], [-4411, 564, -818], [20080, -928, 160], [-12192, 1020, 634], [-10438, 114, -1212], [-11642, 1104, 817], [2706, -377, -1548], [22970, -8, 981], [9658, 1383, -282], [-11566, -1206, 736], [-6325, 84, -479], [41650, -22, 245], [-15784, -549, 75], [1673, -1499, 93], [4733, -1174, 1495], [27158, 460, 228], [-42, 701, 1240], [-2627, -981, -770], [-9031, 520, -908], [-41424, 232, -624], [-20735, 1159, -718], [11320, -24, 1003], [-8832, 1315, -287], [-3585, 907, -2170], [18350, 512, 677], [3631, -397, -479], [-12168, 441, -200], [20021, 1545, -943], [36653, 147, 279], [-13733, -1333, 204], [4981, 1522, -231], [-6917, -757, 1054], [2521, -2216, 2542], [-13490, 1816, 373], [-13233, 1841, -2913], [-22962, 400, -1806], [3838, -1472, -507], [1042, -1517, 1097], [-39571, -462, 643], [14024, -224, -65], [-3864, -2444, 1484], [-8938, 1344, 1798], [26618, -589, -1182], [31542, -1412, 468], [21958, -185, -1976], [-23256, 660, 184], [-32453, 283, -976], [2161, 237, -139], [-26112, 392, 1018], [-11650, -2046, 755], [-1357, 1014, -3161], [17933, 1206, 302], [-12136, 1017, -1898], [19570, 1284, 13], [-5948, -1079, 1069], [7182, 2118, -514], [13574, -2583, 3341], [-35687, -1163, -959], [-4136, 438, -1879], [36006, 1412, -1766], [3036, -2013, 1362], [-10821, 138, 1267], [65498, -396, 140], [-7016, -680, 1473], [-14523, 2121, -803], [14314, 2235, 123], [-9964, 1785, -429], [44264, 913, -254], [14043, -2151, 3047], [-54872, 1060, 1585], [-7011, -620, 1819], [-8458, -640, -846], [32426, -128, 2130], [5562, 1367, -2873], [-17150, 1497, 2797], [12805, 2437, -3239], [69630, -517, 586], [54526, -1336, 200], [6766, -2190, 1485], [34351, 2012, -2484], [-41506, -130, -144], [-31730, 736, 1818], [7201, 3203, -1997], [-6590, -750, 2951], [-59950, -81, 1700], [2335, -435, 3218], [43088, 1976, -2602], [28288, 620, -1506], [-27462, 1968, -4344], [77068, -549, -1140], [23589, -2035, 1999], [-29214, 332, -2442], [39742, -1871, 1526], [-3183, -4399, 4127], [-23948, 621, 1933], [-20598, 2814, -2266], [20113, 583, -2806], [9290, -1696, 3384], [33422, 229, -1082], [-11808, 342, 4491], [-5721, -1518, 3578], [-18768, 2142, -2705], [-1592, 1044, 1465], [64988, -896, -224], [27132, -2252, 2189], [24994, -2397, 1537], [-3544, -1507, 2980], [32508, 3091, -78], [1950, 896, -2193], [18296, 1554, -566], [5616, -839, 3486], [-27597, -3631, 816], [-29170, 74, -274], [315, -619, 1347], [18775, -2989, 58], [50272, -2490, -1123], [26228, -3482, 3385], [77332, -1439, 1284], [-38258, 1348, 3626], [10841, 2101, 973], [-13350, 1883, 1282], [66857, -1181, 1800], [-85186, -1478, -377], [6574, -208, -3482], [48254, -2935, 1490], [43386, -40, -3564], [5800, -3535, -888], [25811, -3012, 2881], [-27901, 3261, -1110], [-55328, -456, -570], [-12014, 1188, 3624], [-38008, 3784, -5027], [36767, 1273, 516], [-46564, -5110, 329], [-15362, 3385, -4046], [24943, 2424, -498], [-40726, 1384, 1060], [-28075, 1752, -5773], [15962, 3192, -66], [-17838, 5105, 398], [-24012, 562, 2312], [68552, 3498, 28], [48499, -149, 3194], [-55553, -427, 145], [48101, 3877, -640], [23507, -4007, 4562], [48927, 1241, -1139], [-55982, 501, 2312], [-68967, 2890, -4018], [60602, -2440, -1005], [-36670, 843, 2793], [-75622, 514, -3186], [-64731, -5790, 3183], [29746, 2720, -506], [-101579, 1905, 2566], [-78032, 212, -937], [38383, -2671, 101], [36948, 4452, -1450], [-18838, 3188, -6080], [-26142, -3066, -2460], [19962, 3353, 945], [20374, 1964, -5065], [33553, -741, -7215], [43850, -785, -5944], [-62078, 185, -1707], [-95400, 936, 1547], [-88385, -2771, -94], [-30974, -5858, 2692], [-16112, -4285, 6549], [-23810, -1164, 254], [84766, 1496, 449], [-26376, -95, -3020], [128466, 2526, -1168], [-74851, -4230, 1353], [-34269, 835, 41], [-12046, -3890, 5458], [-74658, 990, 3329], [-11007, -7022, 1546], [-92725, -2349, -84], [-64103, 321, 4374], [115007, -1813, 3431], [35700, 3906, 176], [-47652, 1486, 274], [18818, 2936, -1330], [-80194, -93, 3543], [-59750, -6719, 3095], [51687, 5565, -3409], [-2636, 660, -912], [42637, 2883, -4295], [-34815, 7728, -9314], [-35044, -496, -598], [-62076, 3080, -7656], [-32341, -7197, -764], [37884, 4626, -2870], [-61124, -959, 58], [-67442, -5286, -1501], [-89641, 566, -1319], [49794, -4334, -6123], [-7744, 1448, 858], [-81878, -8506, 1827], [-5194, 2889, 3860], [-32902, 1264, 5602], [23829, 2101, -3606], [-18446, -2482, 5780], [-21563, 946, 3363], [-8407, 4261, -806], [-11698, 3314, 781], [-37095, -748, -2789], [18316, -2292, 248], [-69309, 2035, -1767], [-37946, 1308, -5480], [-80308, 3968, 960], [-91668, -1056, -3540], [-36838, -3512, 3578], [13582, 6291, 129], [-97134, -3021, -95], [29963, 2489, 5854], [-51850, 3222, 4546], [26130, -6967, 1524], [-44893, -4813, 7862], [118068, -4152, 5059], [53311, -3003, 2549], [-76169, -4443, 4269], [23259, -2959, 8349], [24664, 5767, 361], [-74220, -6332, 1600], [-202084, 828, 851], [93859, -2401, 5771], [-40955, 1118, 7052], [-3994, -7459, 701], [92708, -1550, 1905], [-11464, 4887, 3000], [20547, 2192, 5242], [-39509, 4763, -7707], [-63940, -1917, 3589], [75033, -3397, 110], [70518, 5238, -4859], [27098, 2077, -2091], [39601, -20, 3649], [-35825, 7883, -11088], [-46368, -976, 3730], [-81778, 297, 1379], [67394, 4510, -7775], [-118412, -4931, 343], [13499, -1041, -2121], [32775, 1333, -9355], [-3434, 1091, -6206], [-62201, -3151, -3469], [122312, 1441, 3207], [-25987, 5915, -8324], [-110408, -3276, -3682], [66936, 6453, -7261], [7609, 9086, -9480], [24117, -9131, -3343], [9307, -7293, 3136], [71354, -6842, -2020], [64664, 2806, 2818], [85529, -5812, 4038], [-101132, 2458, -9042], [49930, 439, 2703], [70302, 10223, -2065], [75556, -3046, -1673], [42042, 5138, -7520], [-10583, 3239, -4885], [80680, -7714, 14406], [76459, -6511, 9841], [-30140, -828, -940], [-42857, 2285, 8397], [105982, -2050, 5116], [-17456, -3760, 106], [21185, -3208, -6275], [-112402, -3758, 6421], [90278, -5155, -5414], [46641, -2955, 11758], [-60426, -3968, 372], [70550, 10918, -1076], [-16726, -10968, -1743], [-42576, 6679, 821], [137132, -5551, 6137], [148610, -932, 2334], [-114682, -9472, 6025], [-75118, 2759, -4150], [12390, 6282, 4291], [171779, -2279, 5939], [224131, 467, -236], [35670, 14284, -2936], [-101257, 1415, 3371], [-116223, 3331, 3336], [13234, 11372, 294], [-124690, 1714, 726], [-36968, 11390, -9992], [-24172, 10204, 1975], [-17986, 5790, 1914], [-5566, -8010, -2435]]
