
# q-expansion of newform 1344.3.f.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 = 1344
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, 4, 0, 1], 2], [[1, 0, 1, 0], 1], [[0, 0, 0, -3], 2]]

hecke_ring_character_values = [[127, [1, 0, 0, 0]], [1093, [1, 0, 0, 0]], [449, [1, 0, 0, 0]], [577, [-1, 0, 0, 0]]]
aps_data = [[0, 0, 0, 0], [0, 0, 1, 0], [0, -1, 2, 0], [2, 2, 1, -1], [6, 0, 0, 1], [0, 2, -8, 0], [0, -11, -2, 0], [0, -8, 2, 0], [6, 0, 0, -3], [-30, 0, 0, 0], [0, -12, -12, 0], [20, 0, 0, -12], [0, -7, 14, 0], [32, 0, 0, 10], [0, 4, 28, 0], [54, 0, 0, 4], [0, -20, 28, 0], [0, 4, -4, 0], [-44, 0, 0, 4], [-30, 0, 0, 19], [0, 26, 4, 0], [32, 0, 0, 24], [0, -20, -32, 0], [0, -21, -54, 0], [0, 10, 44, 0], [0, -27, -42, 0], [0, -52, 28, 0], [42, 0, 0, -1], [2, 0, 0, -8], [-90, 0, 0, -4], [56, 0, 0, -8], [0, -12, -24, 0], [30, 0, 0, -32], [0, -8, 116, 0], [-126, 0, 0, 20], [4, 0, 0, 18], [0, 36, -84, 0], [124, 0, 0, 12], [0, -32, -68, 0], [0, -3, -18, 0], [102, 0, 0, 21], [0, 38, 16, 0], [6, 0, 0, 25], [28, 0, 0, -12], [150, 0, 0, -8], [0, -68, 2, 0], [-64, 0, 0, -10], [0, 36, -18, 0], [0, 24, 132, 0], [0, 6, 72, 0], [210, 0, 0, 36], [150, 0, 0, -31], [0, 2, 100, 0], [0, 32, -16, 0], [0, 21, -138, 0], [-246, 0, 0, -37], [0, -59, -194, 0], [0, 52, -52, 0], [-104, 0, 0, 44], [-66, 0, 0, -20], [0, -24, 198, 0], [0, -167, -74, 0], [0, 24, -54, 0], [0, 76, -56, 0], [0, -116, -136, 0], [18, 0, 0, -132], [-256, 0, 0, 18], [190, 0, 0, 24], [-66, 0, 0, -91], [0, -20, 164, 0], [0, 139, -182, 0], [-102, 0, 0, -1], [0, 124, -10, 0], [118, 0, 0, 72], [128, 0, 0, -54], [0, -172, 116, 0], [78, 0, 0, 72], [0, 48, -348, 0], [222, 0, 0, -112], [0, -22, 28, 0], [0, 140, -28, 0], [-32, 0, 0, 76], [318, 0, 0, -63], [0, 228, 96, 0], [0, 156, -6, 0], [522, 0, 0, -69], [-210, 0, 0, -92], [382, 0, 0, 24], [0, 139, -38, 0], [152, 0, 0, -72], [0, -144, 168, 0], [0, -148, -112, 0], [-164, 0, 0, -38], [-198, 0, 0, -105], [-136, 0, 0, -146], [0, 92, 164, 0], [0, -143, -242, 0], [0, -169, -70, 0], [0, 272, 100, 0], [376, 0, 0, -156], [436, 0, 0, 72], [-750, 0, 0, -20], [0, 84, -360, 0], [690, 0, 0, -4], [316, 0, 0, -12], [0, -16, -248, 0], [0, -168, 168, 0], [0, -307, 110, 0], [-6, 0, 0, 223], [0, -264, 48, 0], [0, 268, -202, 0], [-38, 0, 0, -56], [54, 0, 0, 96], [0, -88, -92, 0], [-160, 0, 0, -228], [66, 0, 0, -224], [0, -144, 30, 0], [0, 384, 0, 0], [-138, 0, 0, 140], [-654, 0, 0, 59], [0, -304, -236, 0], [292, 0, 0, -212], [0, 15, -678, 0], [1026, 0, 0, -49], [0, 24, 84, 0], [234, 0, 0, 20], [14, 0, 0, 48], [0, -244, -352, 0], [0, 60, -156, 0], [0, 186, -480, 0], [-1028, 0, 0, 72], [246, 0, 0, 241], [244, 0, 0, 46], [974, 0, 0, -72], [0, 89, -634, 0], [0, 260, 304, 0], [0, -37, 362, 0], [0, -88, 76, 0], [0, 279, 186, 0], [-198, 0, 0, -20], [0, 216, 228, 0], [-882, 0, 0, -92], [-280, 0, 0, 156], [-810, 0, 0, 37], [0, -286, 280, 0], [0, -152, 580, 0], [0, 152, 316, 0], [0, -95, -170, 0], [0, -88, -14, 0], [-66, 0, 0, 101], [658, 0, 0, 48], [0, 39, 138, 0], [1208, 0, 0, 66], [0, -32, 508, 0], [680, 0, 0, 30], [-150, 0, 0, -69], [484, 0, 0, -142], [0, 445, -266, 0], [0, -112, 280, 0], [0, -29, -62, 0], [-258, 0, 0, -39], [-954, 0, 0, 96], [872, 0, 0, 92], [0, -512, 100, 0], [222, 0, 0, 372], [0, -472, 92, 0], [916, 0, 0, -30], [0, 564, 324, 0], [-664, 0, 0, 276], [0, 197, -202, 0], [1506, 0, 0, 51], [0, -48, 108, 0], [-450, 0, 0, 21], [752, 0, 0, -84], [0, 100, 170, 0], [0, -53, 562, 0], [-716, 0, 0, 0], [78, 0, 0, 44], [0, 76, 284, 0], [0, -12, -780, 0], [-1408, 0, 0, 60], [0, 352, -344, 0], [-1160, 0, 0, -12], [0, 449, 278, 0], [798, 0, 0, 37], [0, 85, 70, 0], [-286, 0, 0, -208], [0, -464, 236, 0], [8, 0, 0, -100], [0, 316, 328, 0], [0, -74, -1060, 0], [-210, 0, 0, 1], [416, 0, 0, 102], [0, 185, 350, 0], [-294, 0, 0, 327], [0, 439, 298, 0], [100, 0, 0, 52], [472, 0, 0, 228], [0, 561, 150, 0], [0, 44, -160, 0], [1206, 0, 0, -120], [0, 620, -254, 0], [0, 418, 104, 0], [0, 274, 20, 0], [0, 200, -520, 0], [0, 13, -146, 0], [0, -268, 514, 0], [-750, 0, 0, 247], [-1506, 0, 0, -40], [0, 328, -958, 0], [1118, 0, 0, 0], [0, 477, 318, 0], [508, 0, 0, -258], [0, 616, -44, 0], [0, 212, -544, 0], [0, -64, -680, 0], [-1124, 0, 0, 14], [0, -207, 558, 0], [546, 0, 0, -97], [-2130, 0, 0, 112], [-514, 0, 0, -216], [0, -420, 420, 0], [-810, 0, 0, -12], [700, 0, 0, 218], [0, 4, 40, 0], [-508, 0, 0, -36], [0, 247, -902, 0], [438, 0, 0, -3], [0, 116, 1372, 0], [-1446, 0, 0, -185], [-226, 0, 0, -136], [0, 384, 666, 0], [820, 0, 0, -130], [-654, 0, 0, -220], [0, 344, 682, 0], [0, -840, 276, 0], [0, 170, -188, 0], [930, 0, 0, 240], [-1158, 0, 0, -109], [0, 692, 116, 0], [2034, 0, 0, 63], [0, 656, -92, 0], [0, -76, -1226, 0], [596, 0, 0, -340], [0, -393, 690, 0], [0, 736, 292, 0], [0, 124, -748, 0], [0, 728, 32, 0], [-548, 0, 0, 116], [-1590, 0, 0, 51], [-478, 0, 0, 448], [0, -561, -582, 0], [966, 0, 0, -243], [0, 470, -788, 0], [0, 173, 278, 0], [-906, 0, 0, 141], [304, 0, 0, -396], [0, 336, -234, 0], [0, 579, -174, 0], [0, -24, 168, 0], [-1264, 0, 0, 224], [-1638, 0, 0, -97], [0, 1034, 208, 0], [0, -232, 4, 0], [0, 291, -342, 0], [0, 96, 804, 0], [-6, 0, 0, 40], [0, -321, 1074, 0], [-188, 0, 0, 656], [-450, 0, 0, 340], [0, 16, 284, 0], [-664, 0, 0, -250], [0, -390, 492, 0], [1468, 0, 0, -42], [0, -582, 564, 0], [0, 236, 1228, 0], [714, 0, 0, -421], [1292, 0, 0, 364], [628, 0, 0, -364], [0, 224, -856, 0], [0, 208, 424, 0], [-2440, 0, 0, -140], [0, 944, 200, 0], [0, -556, -884, 0], [0, 808, -364, 0], [42, 0, 0, -181], [862, 0, 0, 552], [1470, 0, 0, -160], [0, 668, -1220, 0], [0, 337, -578, 0], [-2610, 0, 0, 128], [0, 148, 1456, 0], [-1914, 0, 0, 136], [0, -460, 1364, 0], [2038, 0, 0, 152], [0, 41, 134, 0], [0, -356, 362, 0], [0, 343, -854, 0], [0, -592, 644, 0], [0, -40, -1772, 0], [0, 460, -88, 0], [2562, 0, 0, -120], [-2536, 0, 0, -132]]
