
# q-expansion of newform 1200.3.bg.f, downloaded from the LMFDB on 24 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 = 1200
weight = 3
poly_data = [9, 0, 0, 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, 1, 0, 0], 1], [[0, 0, 1, 0], 3], [[0, 0, 0, 1], 3]]

hecke_ring_character_values = [[751, [1, 0, 0, 0]], [901, [1, 0, 0, 0]], [401, [1, 0, 0, 0]], [577, [0, 0, -1, 0]]]
aps_data = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0], [-2, 0, 2, 1], [2, 2, 0, -2], [12, 5, 12, 0], [2, 0, -2, 2], [0, 2, 5, 2], [-18, 6, -18, 0], [0, -14, -2, -14], [-11, -6, 0, 6], [28, 0, -28, 12], [-8, 2, 0, -2], [-26, 19, -26, 0], [-20, 0, 20, 14], [26, 32, 26, 0], [0, 32, 2, 32], [-45, 24, 0, -24], [-66, 0, 66, 15], [-64, -14, 0, 14], [28, 20, 28, 0], [0, -4, 78, -4], [4, 70, 4, 0], [0, -28, 28, -28], [80, 0, -80, -21], [-124, -30, 0, 30], [-36, -8, -36, 0], [66, 0, -66, -60], [0, 48, 23, 48], [8, 80, 8, 0], [-52, 0, 52, 12], [-80, 46, 0, -46], [-60, 0, 60, -86], [0, -104, 2, -104], [0, 24, -134, 24], [-143, -18, 0, 18], [-8, 0, 8, 91], [62, 35, 62, 0], [82, 0, -82, 12], [-114, 54, -114, 0], [0, 0, -134, 0], [-103, 28, 0, -28], [106, 54, 0, -54], [-68, 5, -68, 0], [-60, 0, 60, 10], [0, -90, 135, -90], [23, -50, 0, 50], [114, -95, 114, 0], [82, 0, -82, -100], [0, 16, -171, 16], [-218, 64, -218, 0], [0, -6, -104, -6], [199, 32, 0, -32], [80, -48, 0, 48], [-72, 0, 72, -124], [66, 128, 66, 0], [0, -18, -406, -18], [158, -24, 0, 24], [116, 0, -116, 73], [330, -2, 0, 2], [-42, -95, -42, 0], [232, 94, 232, 0], [14, 0, -14, 99], [298, 24, 0, -24], [84, -153, 84, 0], [-16, 0, 16, 156], [350, 88, 0, -88], [-36, 0, 36, -83], [-236, 0, 236, -106], [0, -40, -238, -40], [314, 86, 314, 0], [0, 158, -196, 158], [42, 0, -42, -135], [-4, -285, -4, 0], [0, 210, 93, 210], [-276, 56, -276, 0], [0, -22, -540, -22], [12, 0, -12, 245], [360, -94, 0, 94], [0, -204, 237, -204], [0, -138, -300, -138], [-302, 12, 0, -12], [554, -118, 0, 118], [180, 25, 180, 0], [0, 198, -61, 198], [-244, -236, -244, 0], [0, -64, 164, -64], [-208, 0, 208, -320], [128, 206, 0, -206], [-84, -244, -84, 0], [-314, 0, 314, -122], [0, 12, -386, 12], [66, 0, -66, -85], [28, 168, 0, -168], [0, 170, 335, 170], [186, 292, 186, 0], [0, -4, -462, -4], [54, 338, 0, -338], [390, -69, 390, 0], [-125, -260, 0, 260], [276, 0, -276, 80], [252, 0, -252, 138], [-118, -90, -118, 0], [0, 222, 70, 222], [331, 86, 0, -86], [-304, 0, 304, 31], [170, 0, -170, -232], [-258, 252, -258, 0], [0, -308, 248, -308], [-403, -156, 0, 156], [536, 0, -536, -188], [-168, -12, -168, 0], [-174, 0, 174, -84], [0, -290, -321, -290], [-101, 194, 0, -194], [-52, -340, 0, 340], [140, 444, 140, 0], [-108, 0, 108, 400], [216, 54, 216, 0], [0, -10, 528, -10], [-118, 64, 0, -64], [-492, 108, -492, 0], [18, 0, -18, -18], [708, -168, 708, 0], [-522, 312, 0, -312], [46, 234, 0, -234], [0, -168, -207, -168], [0, -218, -22, -218], [-54, 0, 54, -129], [-120, 476, -120, 0], [0, -28, 770, -28], [-164, 652, -164, 0], [170, 312, 0, -312], [-528, 0, 528, 105], [-392, -212, 0, 212], [0, 300, 35, 300], [-554, 60, -554, 0], [206, 0, -206, 129], [-72, 0, 72, 472], [0, -430, 112, -430], [425, -442, 0, 442], [-770, 80, 0, -80], [318, 187, 318, 0], [342, 0, -342, -504], [0, -40, 254, -40], [0, -130, 1090, -130], [-56, -87, -56, 0], [108, 0, -108, -260], [0, 288, -550, 288], [508, -408, 508, 0], [384, 0, -384, -83], [-176, 508, 0, -508], [-74, 895, -74, 0], [88, 0, -88, 546], [-360, 0, 360, -476], [946, -96, 0, 96], [0, -206, -31, -206], [0, -526, -194, -526], [492, 0, -492, 133], [-282, -428, 0, 428], [-318, 0, 318, -6], [-36, -4, -36, 0], [-104, 0, 104, -172], [-638, -364, 0, 364], [216, 0, -216, 298], [-592, 116, -592, 0], [407, 418, 0, -418], [64, 0, -64, -428], [0, -304, -553, -304], [572, -462, 572, 0], [0, -66, -334, -66], [131, 532, 0, -532], [-166, 440, 0, -440], [612, -175, 612, 0], [0, -58, 201, -58], [0, 272, -208, 272], [669, 62, 0, -62], [350, 434, 0, -434], [-1050, 69, -1050, 0], [0, 128, -925, 128], [-898, 0, 898, -423], [-1412, 192, 0, -192], [604, 431, 604, 0], [-84, 0, 84, 518], [-508, -570, -508, 0], [0, -268, 910, -268], [972, 0, -972, 23], [-454, 233, -454, 0], [0, -156, -695, -156], [1446, -318, 0, 318], [-132, 153, -132, 0], [-134, -1008, -134, 0], [585, -242, 0, 242], [334, -626, 0, 626], [-910, 0, 910, -42], [760, -26, 760, 0], [-242, -388, 0, 388], [160, -660, 160, 0], [-320, 0, 320, 986], [822, 158, 822, 0], [0, -126, 964, -126], [158, -488, 0, 488], [976, 0, -976, -256], [0, 644, -646, 644], [0, 668, -564, 668], [-198, 0, 198, -258], [0, -162, -1829, -162], [-114, -94, -114, 0], [0, 84, -192, 84], [1849, 54, 0, -54], [-144, 0, 144, 995], [1346, -232, 0, 232], [678, -57, 678, 0], [-264, 0, 264, -624], [0, -228, 1606, -228], [-158, 644, 0, -644], [-1230, 0, 1230, -355], [458, 706, 0, -706], [450, 0, -450, 1064], [1170, -390, 1170, 0], [1471, -276, 0, 276], [0, -758, -115, -758], [0, -428, -854, -428], [276, -668, 276, 0], [902, 0, -902, -160], [0, 100, 1267, 100], [-510, 250, -510, 0], [0, 24, -210, 24], [326, 0, -326, -521], [534, 374, 0, -374], [-1004, 61, -1004, 0], [0, 56, 1222, 56], [471, -766, 0, 766], [186, -948, 0, 948], [-828, -708, -828, 0], [1272, 0, -1272, -444], [0, 92, -2090, 92], [-1862, -96, -1862, 0], [0, -912, -606, -912], [692, -502, 0, 502], [-134, -510, -134, 0], [2013, 186, 0, -186], [370, 667, 370, 0], [0, 304, 459, 304], [48, -930, 48, 0], [0, -104, -914, -104], [718, 0, -718, 443], [-1986, 58, 0, -58], [0, 130, 59, 130], [740, 226, 740, 0], [-1000, 0, 1000, -628], [-470, 50, 0, -50], [-1816, 0, 1816, 248], [0, 196, -881, 196], [-14, -1074, -14, 0], [0, -312, 324, -312], [1169, -424, 0, 424], [276, 0, -276, -756], [-226, 0, 226, -620], [-208, 0, 208, 484], [326, -1357, 326, 0], [790, 0, -790, -386], [0, 240, 706, 240], [-420, 391, -420, 0], [-892, 0, 892, 454], [0, 184, -38, 184], [0, -216, 1510, -216], [-1168, 372, 0, -372], [360, -236, 360, 0], [336, 1562, 336, 0], [-463, -580, 0, 580], [372, 0, -372, 1296], [-24, -932, -24, 0], [0, 546, -1343, 546], [-696, 0, 696, 311], [94, 1841, 94, 0], [-240, 0, 240, -594], [0, -260, 857, -260], [631, 84, 0, -84], [-2508, -140, 0, 140], [-1066, 16, -1066, 0], [-1326, 772, 0, -772], [-678, 0, 678, 1114], [-1395, 608, 0, -608], [-806, 0, 806, 1077], [158, -1288, 0, 1288], [-1000, -57, -1000, 0], [-230, 0, 230, -944], [0, 880, 910, 880], [0, -506, -288, -506], [-934, -688, 0, 688], [24, 0, -24, -1316], [652, 608, 652, 0], [4, -136, 0, 136], [856, 781, 856, 0], [0, 290, 1312, 290], [-1769, 110, 0, -110], [1622, 580, 1622, 0], [0, 518, -1898, 518], [168, 0, -168, -372], [-1272, 932, -1272, 0], [1316, 0, -1316, 216], [0, 806, 1441, 806]]
