
# q-expansion of newform 588.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
    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 = 588
weight = 4
poly_data = [-48, -1, 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], [-3, 0], [-5, -1], [0, 0], [1, -7], [0, -5], [-52, 4], [-32, -3], [28, 20], [143, -11], [-171, -20], [20, -45], [72, 18], [362, -3], [126, -36], [243, 9], [-113, 53], [246, 40], [94, -77], [778, 44], [-634, 53], [699, 62], [755, -101], [966, 42], [-295, 29], [-2, -184], [568, -111], [279, -207], [46, 31], [872, -110], [1233, -106], [-341, 335], [278, -2], [182, -181], [-2346, 78], [451, 301], [-1052, 402], [1388, 96], [2374, -4], [178, -490], [876, -246], [-2664, -209], [-3384, -18], [-2203, -378], [-1334, -202], [628, -132], [-2062, 378], [-1457, 609], [5793, 57], [-1300, 107], [-3500, 434], [-588, -618], [553, -903], [543, -327], [4038, 336], [5778, -54], [6061, -379], [-1767, 55], [-5488, 393], [-3590, 722], [158, 971], [825, -177], [-76, 143], [8152, 194], [2951, -526], [-3513, -735], [236, -543], [-2871, 164], [2940, 372], [-1042, 200], [6312, 582], [-6670, -326], [967, -840], [-680, 883], [2584, 169], [-7054, 274], [-106, 1516], [540, 385], [4104, -540], [-5807, 450], [-1968, 726], [3774, -1225], [-444, 174], [-6686, 1359], [-1215, 1471], [4045, 791], [-2896, -626], [9559, 598], [4246, -346], [6736, 1081], [-1580, -406], [-7126, 490], [7829, -468], [6837, -249], [12370, 397], [4152, -354], [9789, -1671], [-4158, 2322], [3064, 3], [-2730, 491], [6252, -760], [-4747, -1007], [-12949, -221], [12144, 1446], [-30, 797], [3473, -1744], [5225, 2359], [9372, 1194], [3786, 426], [-3467, 156], [17043, -116], [7212, 1790], [-6902, 1856], [9206, -151], [-13555, -1845], [7714, 1550], [8626, 1527], [-9030, 264], [1749, -2091], [2056, -1324], [-5266, -1417], [7277, -582], [-8601, 1581], [-22197, -303], [6304, -2001], [-21841, 49], [-20866, 984], [-17994, 552], [19529, -166], [-17202, 397], [17274, -2503], [-9306, 4176], [-15627, 1814], [7770, 2744], [-2152, -1208], [-4573, 1166], [1150, -2020], [18114, -1178], [14607, 1305], [32504, 262], [-19186, 3698], [-14717, -553], [-19592, 3928], [-11355, -1263], [11960, 491], [-24364, 3328], [20338, 615], [23034, 2886], [8554, 2094], [-5206, -2852], [-17408, -686], [-24462, 1926], [-22960, 297], [-14196, -1518], [13644, 3245], [-28026, 3330], [-19088, -2183], [12630, -6132], [-17435, -5004], [-5729, 3221], [6320, -14], [-9470, 2426], [9683, -3606], [11373, -3129], [35394, -2868], [-28572, 1104], [-7129, -3408], [2218, 3039], [11063, -666], [-6297, 1833], [-17017, -3623], [38438, -700], [-4416, 3012], [37077, -3496], [-20757, -4502], [-2828, 5468], [1206, 8147], [-13943, -967], [-37304, 576], [-23102, -4221], [42027, 2192], [-7471, -3233], [52774, -2225], [6886, -826], [2990, 3928], [-2157, -5151], [20538, 92], [-18578, -411], [47451, -970], [-30912, -2838], [-31345, 4736], [47607, 2631], [-28472, 6688], [50906, 2794], [-747, 5319], [17498, -1922], [-18970, 5613], [-29942, 1516], [21354, -7692], [-40962, -546], [35469, 4041], [-6288, 4015], [-38606, -1632], [462, 8032], [54096, 2766], [22809, 4101], [-536, -4512], [10623, -237], [42060, 1392], [-19454, -894], [27122, -6699], [20095, -4279], [-6381, 137], [21073, -1693], [-2304, 6012], [4126, -6045], [-4559, -5225], [37940, -8576], [-37634, 5462], [9946, 5024], [14320, -7967], [38504, -6379], [-3846, 5160], [42247, 5785], [31749, 4917], [-7432, -3414], [5642, -866], [18692, 5434], [-11871, 8062], [-41916, 2154], [-44106, 4067], [8216, -1924], [-6461, -698], [-20238, 1068], [22522, -5973], [26520, -7062], [52277, 5678], [-63375, 5181], [37812, -7752], [9556, 8006], [-14060, -4954], [-35888, 6765], [62671, -786], [-73134, -1276], [15416, 3040], [-34188, -2712], [-78003, 6214], [59876, -2954], [-22192, -6984], [47280, 24], [-17126, 7447], [78846, 426], [65706, -1140], [1694, 13445], [6917, 13195], [-49775, -6265], [-23410, 5367], [21012, -593], [24253, -11047], [-113573, 2871], [-5480, 661], [50645, 1219], [-51526, 3701], [-90004, -1723], [108342, -1188], [-35650, 4775], [-55887, 1185], [-77912, 4574], [-1676, 1000], [-71727, -6483], [51840, 1249], [129998, 870], [25563, -3128], [45701, 5844], [33587, -9997], [-22752, -7868], [11791, 5519], [-11220, 10079], [-25562, -4835], [40032, 13176], [-50922, -7614], [-122265, 362], [-2496, -4542], [-71564, -8223], [-22986, -2162], [7300, -12346], [71127, -1390], [-21407, 7757], [50803, -6462], [-65988, 4194], [-107394, 2166], [23505, -19077], [-11772, -7758], [39748, -5464], [-19000, -18297], [23415, -3885], [40120, 1305], [70386, 10794], [57132, -3366], [-49902, 13825], [117530, -6232], [32073, 6825], [83701, -785], [28605, 6279], [-22234, -3207], [-24334, 20499], [119765, 6025], [137578, -3711], [25666, 5198], [-70378, 2769], [-1266, 6342], [-35686, -9848], [72800, 6010], [-7168, -20688], [-33820, -4460], [16474, -12747], [108663, -8709], [76700, -9500], [87307, 1596], [27096, 2802], [4648, -4575], [31114, -13019], [-26895, -4623], [70240, -2663], [-50704, 11830], [83821, 6402], [-44902, -1269], [-5674, 6371], [76318, -7978], [84805, -14431], [-8194, -6033], [8833, -4843], [143424, 5641], [-53752, -1646], [41062, 4771], [101668, 12878], [61920, -20014], [-20654, -24334], [10639, 11916], [-100921, 9782], [-72790, 4041], [93240, -5544], [-10359, -11097], [46905, -7870], [-17001, 13167], [-28101, 14439], [-65918, 20361], [65426, -3270], [-116478, -4500], [-26775, -4203], [150016, 9564], [130739, -5001], [-114510, -4776], [939, -12203], [94642, 14545], [-8218, -5096], [574, 25376], [-136857, 9165], [61996, 2276], [-37382, -8704], [89518, 7156], [20168, 178], [94934, -5828], [151564, -4150], [75068, 9929], [-107197, 6531], [-111570, 11850], [64872, 4919], [-130247, -8843], [-83273, 20069], [-93760, -8695], [80658, -10188], [40343, 27127], [82448, -13873], [-73340, -9119], [158808, 9024], [-167384, 4496], [103493, 18893], [-108622, 20554], [6178, -6915], [98634, -17130], [47006, -13250], [-40256, -4568], [108120, -16140], [155906, 11498], [-27578, -29794], [-122080, -16719], [159068, 5150], [27808, -5303], [-16432, 9094], [-28879, -23736], [-201750, 6648], [-124667, -12841], [-169394, 9741], [-56830, 18964], [-17265, 33899], [104579, 15089], [21986, -12548], [74148, 12785], [-84743, 20117], [126016, 8298], [-203628, -11256], [-34364, 23644], [-110318, 9476], [-17739, -639], [-113177, -9798], [117934, 808], [-160566, 10698], [23386, -3561], [-85933, -19127], [22409, 20693], [93445, 13991], [-13829, -18523], [-39810, 22622], [-57118, -26697], [163829, 7033], [-63116, 10298], [-6640, 23105], [-66276, -19944], [-165194, -15910], [108901, -7837], [-210326, -8805], [-89870, -9946], [-15645, 903], [93862, -300], [21598, 11768], [97079, -3113], [-28260, 29052], [-93846, -15590], [-48892, 10612]]
