
# q-expansion of newform 1152.3.e.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 = 1152
weight = 3
poly_data = [4, 0, -2, 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, 0, 0, 1], 2], [[-2, 0, 2, 0], 1], [[0, 4, 0, -1], 1]]

hecke_ring_character_values = [[127, [1, 0, 0, 0]], [901, [1, 0, 0, 0]], [641, [-1, 0, 0, 0]]]
aps_data = [[0, 0, 0, 0], [0, 0, 0, 0], [0, -1, 1, 0], [2, 0, 0, -2], [0, -2, 2, 0], [-8, 0, 0, 3], [0, -1, 6, 0], [-8, 0, 0, 2], [0, -10, 0, 0], [0, -3, -7, 0], [-30, 0, 0, 2], [-22, 0, 0, -4], [0, 21, -10, 0], [-36, 0, 0, -8], [0, -10, 8, 0], [0, -27, 5, 0], [0, 20, -24, 0], [-50, 0, 0, -8], [-28, 0, 0, -2], [0, -54, -12, 0], [68, 0, 0, -4], [-122, 0, 0, 6], [0, -78, -14, 0], [0, 17, 28, 0], [40, 0, 0, 26], [0, -33, -13, 0], [-10, 0, 0, -10], [0, -8, 56, 0], [-48, 0, 0, -3], [0, 37, -12, 0], [-134, 0, 0, -18], [0, -108, 12, 0], [0, 59, -2, 0], [-116, 0, 0, -22], [0, -15, -29, 0], [34, 0, 0, 10], [-150, 0, 0, 24], [124, 0, 0, -28], [0, -124, 36, 0], [0, -93, -47, 0], [0, -96, -20, 0], [64, 0, 0, -35], [0, 28, 52, 0], [58, 0, 0, -48], [0, 43, 35, 0], [62, 0, 0, 42], [148, 0, 0, -22], [-102, 0, 0, 30], [0, -162, 14, 0], [32, 0, 0, -33], [0, -21, -52, 0], [0, 168, 28, 0], [-140, 0, 0, 18], [0, 186, 14, 0], [0, -153, 48, 0], [0, -60, -72, 0], [0, -113, 23, 0], [-46, 0, 0, 22], [144, 0, 0, 57], [0, 45, 0, 0], [216, 0, 0, -24], [0, 229, 13, 0], [204, 0, 0, 62], [0, 124, -40, 0], [-170, 0, 0, -24], [0, 135, 75, 0], [124, 0, 0, 2], [-164, 0, 0, 8], [0, 174, 94, 0], [-10, 0, 0, -100], [0, 45, -20, 0], [0, -26, 180, 0], [154, 0, 0, -26], [422, 0, 0, -40], [176, 0, 0, -106], [0, 120, 140, 0], [0, 85, -121, 0], [510, 0, 0, 4], [0, -321, 2, 0], [16, 0, 0, -106], [0, 194, -38, 0], [56, 0, 0, -3], [0, 38, 112, 0], [-186, 0, 0, -56], [-6, 0, 0, 46], [0, -246, 106, 0], [0, 1, -166, 0], [-120, 0, 0, 10], [0, -539, 3, 0], [550, 0, 0, 18], [0, 262, -42, 0], [0, -330, -84, 0], [214, 0, 0, -98], [0, 176, -76, 0], [-368, 0, 0, -48], [0, 190, 148, 0], [0, 469, 77, 0], [0, -137, -78, 0], [64, 0, 0, 74], [-424, 0, 0, 29], [-148, 0, 0, 72], [0, -367, -85, 0], [0, 486, -6, 0], [0, 331, -46, 0], [280, 0, 0, 52], [158, 0, 0, 0], [0, -652, 40, 0], [0, -381, 148, 0], [0, 174, 56, 0], [66, 0, 0, 0], [338, 0, 0, 26], [-130, 0, 0, -92], [0, -67, 40, 0], [-304, 0, 0, -20], [-26, 0, 0, -14], [0, 363, 102, 0], [-900, 0, 0, 20], [0, 234, -64, 0], [0, -213, -195, 0], [0, -276, -40, 0], [26, 0, 0, -64], [226, 0, 0, -168], [0, -121, -139, 0], [0, -366, 66, 0], [12, 0, 0, -156], [0, 569, 1, 0], [-968, 0, 0, 47], [0, -510, 140, 0], [-474, 0, 0, 6], [-408, 0, 0, -161], [-360, 0, 0, -220], [0, 532, 148, 0], [530, 0, 0, 10], [-128, 0, 0, 43], [0, -367, 2, 0], [758, 0, 0, 104], [0, 297, 5, 0], [-1112, 0, 0, 30], [0, 663, 17, 0], [0, 117, 394, 0], [-432, 0, 0, -82], [0, -449, -225, 0], [-982, 0, 0, -38], [0, -20, -172, 0], [-1360, 0, 0, -35], [0, -570, -60, 0], [298, 0, 0, -8], [0, 837, 78, 0], [-4, 0, 0, 152], [0, -76, -164, 0], [694, 0, 0, -76], [0, 415, 0, 0], [-28, 0, 0, 248], [0, 228, 104, 0], [-20, 0, 0, -160], [0, -252, -212, 0], [-78, 0, 0, -58], [0, 783, -198, 0], [166, 0, 0, -32], [0, -347, 91, 0], [0, 4, -344, 0], [0, -721, 26, 0], [-674, 0, 0, 82], [0, 170, 346, 0], [0, -471, -226, 0], [0, 28, 72, 0], [-350, 0, 0, 2], [-18, 0, 0, -336], [-256, 0, 0, 86], [0, 379, 49, 0], [0, -792, -28, 0], [-702, 0, 0, 4], [0, 56, 308, 0], [-184, 0, 0, 88], [238, 0, 0, 74], [0, 549, -104, 0], [-48, 0, 0, 52], [0, 569, 91, 0], [170, 0, 0, 314], [34, 0, 0, 96], [-98, 0, 0, 150], [0, -258, -362, 0], [1008, 0, 0, -125], [0, -427, -336, 0], [0, 288, 164, 0], [0, -765, -79, 0], [64, 0, 0, -201], [856, 0, 0, 28], [52, 0, 0, -274], [0, 596, 104, 0], [-1064, 0, 0, 36], [0, 144, -76, 0], [1928, 0, 0, 44], [0, 485, -185, 0], [0, -380, 340, 0], [0, -77, -320, 0], [-802, 0, 0, -184], [632, 0, 0, 299], [0, 301, -304, 0], [0, 696, 24, 0], [0, -313, 109, 0], [-286, 0, 0, -202], [440, 0, 0, 65], [-332, 0, 0, 296], [0, 306, -146, 0], [0, 771, 159, 0], [-698, 0, 0, -274], [0, 1138, -98, 0], [0, -53, 308, 0], [1004, 0, 0, 16], [38, 0, 0, -48], [0, 31, 85, 0], [2002, 0, 0, -70], [0, 568, 292, 0], [0, 6, -580, 0], [-1226, 0, 0, 8], [1086, 0, 0, -82], [0, -979, -86, 0], [0, -120, 212, 0], [0, 831, 389, 0], [1096, 0, 0, 265], [-1254, 0, 0, -126], [0, -21, -150, 0], [462, 0, 0, 106], [0, -338, -210, 0], [418, 0, 0, 148], [0, -17, 372, 0], [0, -14, 388, 0], [1474, 0, 0, 282], [0, 700, -40, 0], [1096, 0, 0, -79], [-68, 0, 0, 300], [158, 0, 0, 498], [0, -1045, 224, 0], [-380, 0, 0, 228], [0, 266, 484, 0], [1592, 0, 0, 14], [0, 1073, -365, 0], [0, 606, 350, 0], [0, -870, -144, 0], [0, 462, 18, 0], [-788, 0, 0, -254], [214, 0, 0, -366], [26, 0, 0, -280], [0, -685, -432, 0], [0, -1294, -52, 0], [-1858, 0, 0, 90], [0, -468, -412, 0], [-532, 0, 0, 78], [0, 252, 336, 0], [672, 0, 0, -263], [0, -733, -372, 0], [0, -382, 112, 0], [2368, 0, 0, -36], [0, -293, 523, 0], [0, -916, 116, 0], [-272, 0, 0, -191], [-1392, 0, 0, -72], [0, -483, -239, 0], [1038, 0, 0, -184], [590, 0, 0, -106], [0, -1024, 284, 0], [-536, 0, 0, -211], [-902, 0, 0, 432], [0, -243, 686, 0], [516, 0, 0, 62], [0, 247, -343, 0], [0, -141, -84, 0], [2120, 0, 0, -90], [0, -55, -173, 0], [-242, 0, 0, 544], [40, 0, 0, 340], [-704, 0, 0, -120], [482, 0, 0, -574], [-264, 0, 0, -24], [1706, 0, 0, -174], [0, 86, 146, 0], [-834, 0, 0, -236], [-354, 0, 0, 440], [0, -960, 240, 0], [0, -470, 92, 0], [-1390, 0, 0, 270], [0, -774, -416, 0], [-2098, 0, 0, 132], [-136, 0, 0, 114], [0, 992, 264, 0], [916, 0, 0, 326], [0, 801, -169, 0], [-1526, 0, 0, -282], [0, 1805, 36, 0], [0, 595, 261, 0], [0, -636, -464, 0], [0, -1503, 68, 0], [0, -432, 732, 0], [-46, 0, 0, -288], [0, -1947, -157, 0], [-1262, 0, 0, -186], [0, -257, 75, 0], [0, -138, -102, 0], [-376, 0, 0, -402], [218, 0, 0, 16], [0, -75, 455, 0], [-2754, 0, 0, -166]]
