
# q-expansion of newform 1728.3.o.f, downloaded from the LMFDB on 16 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 = 1728
weight = 3
poly_data = [4, 0, 32, 0, 36, 0, 11, 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, 0, 0, 0, 0], 1], [[2, 10, 0, 7, 0, 1, 0, 0], 4], [[0, 14, 0, -1, 0, -1, 0, 0], 2], [[-6, -14, 24, 1, 6, 1, 0, 0], 4], [[0, 8, 14, -4, 8, -1, 1, 0], 2], [[0, -8, 14, 4, 8, 1, 1, 0], 2], [[42, 50, 70, 95, 22, 32, 2, 3], 4], [[42, -50, 70, -95, 22, -32, 2, -3], 4]]

hecke_ring_character_values = [[703, [-1, 0, 0, 0, 0, 0, 0, 0]], [325, [1, 0, 0, 0, 0, 0, 0, 0]], [1217, [-1, 1, 0, 0, 0, 0, 0, 0]]]
aps_data = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, -1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, -1, -1, 0, -1], [2, -1, 1, 1, -1, -1, 0, -1], [-2, 2, 2, 1, 0, 0, 0, 0], [-1, 0, 1, 2, 0, 0, 2, 2], [-2, 4, 0, 0, -3, 3, -2, 2], [7, 7, 0, -1, 0, -1, 1, 0], [0, 20, 3, -3, 0, 2, 0, 0], [5, 5, 0, -3, 2, 5, -1, 0], [1, 0, 1, 2, 1, 1, -4, -4], [-12, 12, -2, -1, -5, 4, -4, 8], [-4, 2, 6, 6, -5, -2, 0, 1], [-36, 18, -2, -2, -3, -5, 0, -7], [-27, 0, -3, -6, 9, 9, 0, 0], [-24, -24, 0, -4, 2, 9, -5, 0], [0, -4, 1, -1, -4, -4, -8, 4], [-1, -1, 0, 3, 3, 9, -3, 0], [33, -66, 5, 0, 1, -1, -4, 4], [7, 0, 1, 2, -4, -4, -2, -2], [2, -1, 9, 9, 5, 2, 0, -1], [88, -44, 2, 2, 1, -5, 0, -11], [25, 0, -3, -6, 7, 7, 0, 0], [0, -4, 3, -3, -8, 1, -16, 8], [0, 75, -6, 6, 0, 3, 0, 0], [-28, -28, 0, 12, -9, -9, -9, 0], [-44, 88, 6, 0, 13, -13, 6, -6], [23, 0, -1, -2, 7, 7, 8, 8], [-23, 23, 8, 4, 9, -10, 10, -20], [8, -16, 12, 0, -18, 18, -20, 20], [-36, -36, 0, -10, 11, 21, 1, 0], [0, 38, 7, -7, -8, -3, -16, 8], [-18, -18, 0, -6, -10, -1, -19, 0], [128, -128, 2, 1, -2, 8, -8, 16], [-122, 61, 15, 15, -15, 6, 0, 27], [-7, 7, -20, -10, 17, 8, -8, 16], [24, -48, 12, 0, -12, 12, 4, -4], [28, 28, 0, 0, -17, -7, -27, 0], [0, 53, -8, 8, 4, -21, 8, -4], [-62, 124, 10, 0, -18, 18, -8, 8], [-31, 0, -3, -6, 7, 7, 8, 8], [-40, 20, 0, 0, 5, -11, 0, -27], [-80, 80, 2, 1, -11, 16, -16, 32], [-110, 0, 0, 0, -2, -2, 0, 0], [1, -2, 9, 0, -9, 9, -8, 8], [53, 53, 0, 15, -2, 1, -5, 0], [80, -40, 12, 12, -5, -17, 0, -29], [-106, 53, 19, 19, -37, -19, 0, -1], [-29, 29, 32, 16, -23, 4, -4, 8], [-170, 0, 10, 20, -7, -7, 2, 2], [11, 11, 0, -33, -4, -5, -3, 0], [0, 29, -8, 8, 4, -14, 8, -4], [12, -24, 26, 0, -5, 5, 26, -26], [137, -137, 4, 2, -54, 4, -4, 8], [22, -11, -5, -5, -17, 12, 0, 41], [-13, 0, -5, -10, 27, 27, -28, -28], [-122, 244, 18, 0, -6, 6, 12, -12], [0, -59, 18, -18, -12, 15, -24, 12], [0, 250, -11, 11, -2, 26, -4, 2], [-10, -10, 0, -12, 35, 71, -1, 0], [127, -127, -12, -6, 37, 0, 0, 0], [24, -48, -30, 0, 9, -9, -18, 18], [-87, -87, 0, 29, -10, -9, -11, 0], [0, -119, -16, 16, 8, 26, 16, -8], [0, 46, 17, -17, 20, 36, 40, -20], [-166, 83, 15, 15, -31, -34, 0, -37], [11, -11, -12, -6, 14, -4, 4, -8], [167, 167, 0, -29, 27, 43, 11, 0], [0, -19, -6, 6, -28, 53, -56, 28], [0, 198, 7, -7, -8, -5, -16, 8], [-46, 92, -22, 0, 12, -12, 32, -32], [-346, 173, -9, -9, 45, 24, 0, 3], [-64, 64, -18, -9, 22, -32, 32, -64], [195, -390, -3, 0, 30, -30, 38, -38], [-148, -148, 0, 4, 15, -11, 41, 0], [0, 219, 14, -14, -4, 41, -8, 4], [-149, 0, -5, -10, -61, -61, -8, -8], [218, -218, 18, 9, 41, 12, -12, 24], [-139, 139, -8, -4, 58, -32, 32, -64], [5, 5, 0, 71, 16, -41, 73, 0], [0, 196, -19, 19, 8, -64, 16, -8], [-86, 172, -22, 0, 8, -8, -40, 40], [-157, 0, 17, 34, 46, 46, -22, -22], [270, -135, -9, -9, -63, -24, 0, 15], [8, -4, -64, -64, 29, -12, 0, -53], [-147, 0, -25, -50, -22, -22, -2, -2], [0, 188, 7, -7, -28, 53, -56, 28], [0, -132, -37, 37, -16, -70, -32, 16], [175, 175, 0, 27, -52, -67, -37, 0], [262, -524, -48, 0, 13, -13, 6, -6], [142, -71, -45, -45, 43, 8, 0, -27], [-146, 292, -66, 0, 48, -48, 88, -88], [100, 100, 0, -12, -20, -79, 39, 0], [-84, -84, 0, 12, 18, -69, 105, 0], [-101, 202, -9, 0, -101, 101, -108, 108], [12, -12, 42, 21, 0, 24, -24, 48], [-330, 0, -22, -44, 11, 11, -38, -38], [-103, 206, 57, 0, 21, -21, 48, -48], [422, 0, -16, -32, -34, -34, -8, -8], [-290, 145, -57, -57, -99, -69, 0, -39], [73, 0, -3, -6, -77, -77, -12, -12], [-83, -83, 0, 41, -3, -73, 67, 0], [0, 139, -28, 28, 8, -126, 16, -8], [-141, -141, 0, -33, 1, 61, -59, 0], [-115, 0, -1, -2, -26, -26, -22, -22], [-236, 118, -54, -54, -83, -46, 0, -9], [79, 0, 19, 38, 101, 101, -28, -28], [88, 88, 0, 68, -21, -55, 13, 0], [0, 118, 17, -17, -20, 25, -40, 20], [162, 162, 0, -66, 19, 19, 19, 0], [-17, 0, -57, -114, 123, 123, -24, -24], [524, -524, -10, -5, 13, -40, 40, -80], [-322, 161, -45, -45, -87, -57, 0, -27], [18, -36, -90, 0, -42, 42, -44, 44], [0, -85, -8, 8, -44, 90, -88, 44], [399, 399, 0, 15, -15, -39, 9, 0], [78, -156, -74, 0, 44, -44, 16, -16], [225, -225, -96, -48, 99, 0, 0, 0], [278, -139, 61, 61, -13, 62, 0, 137], [-55, 55, 4, 2, -79, 20, -20, 40], [0, 172, -7, 7, 18, 72, 36, -18], [0, 159, 30, -30, 48, -81, 96, -48], [-220, 440, 38, 0, 57, -57, 38, -38], [820, -410, 24, 24, -49, 11, 0, 71], [-49, 0, -21, -42, 41, 41, 0, 0], [0, -341, 32, -32, -60, 111, -120, 60], [192, -384, -16, 0, 64, -64, 128, -128], [426, -213, 21, 21, -87, -48, 0, -9], [64, -64, 6, 3, 54, -36, 36, -72], [1, -2, -93, 0, -24, 24, -82, 82], [88, 88, 0, 56, -15, -127, 97, 0], [-396, -396, 0, -12, -31, -13, -49, 0], [566, 0, 0, 0, 108, 108, 0, 0], [158, -158, 78, 39, -118, 30, -30, 60], [133, -133, -124, -62, 117, -90, 90, -180], [-509, 0, -1, -2, -63, -63, -8, -8], [-388, -388, 0, 18, 33, 3, 63, 0], [-292, 292, 26, 13, -104, -16, 16, -32], [1, 0, 67, 134, -22, -22, 62, 62], [278, -556, 36, 0, -69, 69, -62, 62], [0, 796, -1, 1, -4, 6, -8, 4], [-43, -43, 0, 81, 46, -71, 163, 0], [78, -156, 6, 0, 90, -90, 24, -24], [-421, 0, 87, 174, -19, -19, 4, 4], [-508, 254, -94, -94, 161, 69, 0, -23], [0, 812, 9, -9, 36, 18, 72, -36], [0, 248, 7, -7, 34, 60, 68, -34], [333, 333, 0, 21, -49, -91, -7, 0], [422, -844, -22, 0, 66, -66, 68, -68], [212, -212, 22, 11, 16, -56, 56, -112], [537, 0, -43, -86, -25, -25, -8, -8], [-370, 740, 12, 0, 27, -27, 2, -2], [-159, -159, 0, 41, 20, 63, -23, 0], [796, -398, 66, 66, 67, 16, 0, -35], [-390, 195, 73, 73, 147, 64, 0, -19], [-558, 1116, 18, 0, -60, 60, -120, 120], [0, -668, -41, 41, -2, -64, -4, 2], [737, 0, 5, 10, -13, -13, -92, -92], [-67, 67, -48, -24, 89, 84, -84, 168], [134, -67, -49, -49, 155, 111, 0, 67], [133, 0, -49, -98, 126, 126, -50, -50], [-557, -557, 0, -33, -78, -87, -69, 0], [-175, 350, 57, 0, 29, -29, -24, 24], [-723, 723, 116, 58, -136, 32, -32, 64], [-894, 447, 185, 185, -81, -52, 0, -23], [326, -652, -30, 0, -66, 66, -84, 84], [0, -271, -86, 86, 8, -127, 16, -8], [-191, 0, -59, -118, -25, -25, -44, -44], [498, -498, -114, -57, -90, 24, -24, 48], [740, -370, 22, 22, -19, -52, 0, -85], [128, -128, -146, -73, 56, -16, 16, -32], [129, 129, 0, 1, 28, 39, 17, 0], [0, -196, -53, 53, -32, 211, -64, 32], [94, 94, 0, 30, -19, 83, -121, 0], [189, -189, -168, -84, 201, -78, 78, -156], [-940, 470, 66, 66, -173, -110, 0, -47], [-211, 0, -55, -110, -77, -77, 52, 52], [32, -64, 96, 0, -96, 96, 32, -32], [0, 593, -2, 2, 68, 77, 136, -68], [792, -396, 48, 48, -29, -77, 0, -125], [20, -10, 22, 22, -127, -142, 0, -157], [547, -547, -208, -104, 133, -20, 20, -40], [-873, 0, 13, 26, -14, -14, -10, -10], [326, 326, 0, 54, -25, 85, -135, 0], [0, 730, -19, 19, -124, 90, -248, 124], [-106, 0, -76, -152, -50, -50, -124, -124], [1092, -546, -48, -48, -17, -29, 0, -41], [1115, -1115, -12, -6, 136, -116, 116, -232], [-244, 488, 140, 0, -132, 132, -112, 112], [67, 0, 85, 170, -288, -288, -18, -18], [-166, 83, -59, -59, -25, -73, 0, -121], [-288, 576, 126, 0, -141, 141, -134, 134], [0, -841, -6, 6, 60, 11, 120, -60], [290, -580, 100, 0, 73, -73, 46, -46], [-183, 183, -4, -2, 98, 32, -32, 64], [88, -88, -22, -11, -45, 108, -108, 216], [0, -59, 18, -18, 20, -79, 40, -20], [0, -239, 38, -38, 116, -90, 232, -116], [-140, 280, -120, 0, 106, -106, -84, 84], [-485, 485, -92, -46, 209, -92, 92, -184], [-1132, 566, 162, 162, -157, -31, 0, 95], [109, -109, 60, 30, 269, -28, 28, -56], [0, 239, 34, -34, 116, 206, 232, -116], [-126, 252, 28, 0, -127, 127, -26, 26], [975, 0, 59, 118, 89, 89, 64, 64], [-130, 260, 66, 0, 66, -66, 20, -20], [78, 78, 0, -162, 150, 237, 63, 0], [0, -9, -92, 92, 52, -260, 104, -52], [438, 438, 0, 66, 82, 55, 109, 0], [113, 0, 15, 30, 16, 16, 62, 62], [218, -218, 38, 19, 16, 44, -44, 88], [4, -2, 78, 78, -33, 81, 0, 195], [-1978, 989, -15, -15, -97, -86, 0, -75], [260, 260, 0, -144, -73, -191, 45, 0], [0, 115, -18, 18, 60, -12, 120, -60], [433, 433, 0, -39, 94, 61, 127, 0], [0, -854, -49, 49, -28, -111, -56, 28], [-498, 996, 62, 0, 88, -88, 8, -8], [-1058, 1058, 30, 15, -26, -84, 84, -168], [-290, 290, 74, 37, 216, -108, 108, -216], [-366, -366, 0, -6, 111, 351, -129, 0], [-686, 686, -174, -87, 49, -12, 12, -24], [526, -1052, -42, 0, 60, -60, -64, 64], [908, 908, 0, -28, -26, -35, -17, 0], [0, 17, 46, -46, -12, 339, -24, 12], [0, 111, -14, 14, -146, -77, -292, 146], [490, -980, -202, 0, 170, -170, 140, -140], [-570, 285, -249, -249, 161, -46, 0, -253], [34, -17, 163, 163, 175, 24, 0, -127], [-311, 311, 68, 34, 155, 20, -20, 40], [268, -536, -72, 0, 48, -48, -4, 4], [-151, -151, 0, -3, -112, -187, -37, 0], [251, -251, 128, 64, -140, 44, -44, 88], [438, -219, -39, -39, 169, 76, 0, -17], [1512, -756, -16, -16, 165, 113, 0, 61], [-1150, 1150, -134, -67, -126, 54, -54, 108], [75, 0, -81, -162, -63, -63, -96, -96], [-256, -256, 0, 140, -122, -311, 67, 0], [-460, 920, 40, 0, -14, 14, 220, -220], [20, -10, 22, 22, 89, -34, 0, -157], [-454, 908, -78, 0, -210, 210, -216, 216], [154, 154, 0, -174, -21, -9, -33, 0], [-1133, 0, 15, 30, 153, 153, 36, 36], [-1098, 1098, -30, -15, -177, -96, 96, -192], [472, -236, 16, 16, 73, 87, 0, 101], [-268, 536, -60, 0, 216, -216, 80, -80], [39, 39, 0, 71, 167, 207, 127, 0], [-353, -353, 0, 57, 160, 205, 115, 0], [-66, 132, -10, 0, 16, -16, -208, 208], [-650, 650, -46, -23, -92, 160, -160, 320], [-79, 0, 95, 190, -32, -32, 58, 58], [-481, -481, 0, -61, 118, -113, 349, 0], [0, 545, 94, -94, 98, -19, 196, -98], [0, -1591, -84, 84, -60, 95, -120, 60], [-23, 46, 19, 0, 264, -264, 262, -262], [479, 0, -73, -146, -65, -65, -136, -136], [290, -145, -165, -165, -47, -14, 0, 19], [998, 0, 60, 120, 146, 146, 96, 96], [-475, 0, 27, 54, -120, -120, -114, -114], [-422, 211, -195, -195, -155, -122, 0, -89], [-1216, 608, -172, -172, 209, 42, 0, -125], [649, -649, 116, 58, -347, -68, 68, -136], [337, 0, -27, -54, -13, -13, 16, 16], [-408, 408, -22, -11, 272, -82, 82, -164], [-362, 181, -81, -81, 221, 89, 0, -43], [919, 0, 79, 158, -13, -13, 44, 44], [0, 485, 54, -54, 24, -58, 48, -24], [535, 535, 0, -57, 55, 37, 73, 0], [-56, 56, -334, -167, 114, -88, 88, -176], [680, -680, -98, -49, 40, -32, 32, -64], [-474, 948, 102, 0, 66, -66, 64, -64], [0, 329, 132, -132, -12, -12, -24, 12], [256, 256, 0, -60, 15, -165, 195, 0], [704, -704, 106, 53, -61, 20, -20, 40], [116, -232, -36, 0, -120, 120, -168, 168], [314, 314, 0, -20, -123, -311, 65, 0], [0, -640, 1, -1, 80, -118, 160, -80], [-13, 0, 125, 250, -92, -92, -10, -10], [-1226, 613, -45, -45, -101, -19, 0, 63], [260, 260, 0, 192, 137, 133, 141, 0], [502, 502, 0, -198, 253, 271, 235, 0], [1034, -517, 105, 105, -145, -134, 0, -123], [0, -481, -152, 152, 32, -175, 64, -32], [286, 286, 0, -18, 12, -105, 129, 0], [497, -994, 129, 0, -145, 145, -240, 240], [-1301, 0, 103, 206, -15, -15, 24, 24], [-297, 297, 220, 110, -341, 124, -124, 248], [176, -88, 132, 132, -249, -63, 0, 123], [1886, 0, -62, -124, 33, 33, -142, -142], [0, -672, -45, 45, 204, -252, 408, -204], [365, -730, -269, 0, 94, -94, 154, -154], [-1157, 1157, 32, 16, -168, 92, -92, 184], [-33, -33, 0, 127, 37, 75, -1, 0], [0, 431, -56, 56, -64, -289, -128, 64], [131, -131, 4, 2, -27, 172, -172, 344], [-734, 367, -171, -171, -155, 112, 0, 379], [0, 914, 41, -41, -64, 352, -128, 64], [-340, 680, -32, 0, 88, -88, 148, -148], [1252, -626, -264, -264, 319, -17, 0, -353], [691, -691, 20, 10, -60, 84, -84, 168], [1035, 0, -89, -178, 37, 37, 56, 56], [232, -464, -312, 0, 228, -228, 224, -224]]
