
# q-expansion of newform 912.3.be.f, downloaded from the LMFDB on 19 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 = 912
weight = 3
poly_data = [43, -77, 94, -35, 20, -3, 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], 1], [[5, 0, 1, 0, 0, 0], 1], [[-6, 2, -1, 0, 0, 0], 1], [[34, -56, 34, -26, 5, -2], 23], [[63, 41, 109, -13, 14, -1], 23], [[-98, 271, -121, 33, -9, -1], 23]]

hecke_ring_character_values = [[799, [1, 0, 0, 0, 0, 0]], [229, [1, 0, 0, 0, 0, 0]], [305, [1, 0, 0, 0, 0, 0]], [97, [0, 0, 0, 1, 0, 0]]]
aps_data = [[0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], [2, -1, -1, -2, 0, 1], [4, -1, 0, 0, -1, 1], [5, -1, 2, 0, 1, -1], [0, -3, -1, 0, -3, 1], [11, 4, 4, -11, 3, -1], [-2, 0, 5, 5, 2, 0], [0, -3, 0, -20, 3, 0], [-22, 3, -1, 11, 3, 1], [15, -2, -3, -30, -1, -1], [9, -8, -4, -18, 4, 4], [10, -2, 2, 10, 2, 0], [-37, 3, 3, 37, 2, -1], [0, -2, 2, 16, 2, 2], [-26, 0, 9, 13, 0, -9], [-2, -1, 1, -2, 6, -5], [0, -5, -5, 4, 5, -5], [16, -2, -11, -8, -2, 11], [-5, -4, 4, -5, -13, 17], [-17, -20, -20, 17, -14, 6], [-3, -11, 11, -3, 6, 5], [47, 15, 9, 0, 24, -24], [-14, 12, -3, 7, 12, 3], [-23, 0, 0, -23, -7, 7], [0, 3, 11, -109, -3, 11], [8, 25, 22, -16, -3, -3], [33, 13, 11, -66, -2, -2], [41, 6, -6, 41, -11, 5], [21, 9, 16, -42, 7, 7], [148, 4, -10, -74, 4, 10], [25, -16, -16, -25, -25, -9], [0, 9, -9, 155, -9, -9], [0, -5, -2, 137, 5, -2], [-52, -11, -11, 52, -20, -9], [54, -46, -24, -108, 22, 22], [1, 18, 18, -1, 16, -2], [-68, -3, 8, 0, 5, -5], [-180, 9, 2, 90, 9, -2], [-33, -6, 6, -33, 53, -47], [50, 0, -35, -100, -35, -35], [26, 15, -3, -13, 15, 3], [125, 17, -14, 0, 3, -3], [-68, -6, 6, -68, -17, 23], [-41, -17, -12, 0, -29, 29], [0, -19, 48, 11, 19, 48], [-23, 5, -5, -23, 6, -11], [77, -7, 7, 77, 18, -11], [-7, 9, -22, 14, -31, -31], [32, 7, -17, 0, -10, 10], [-67, 36, 36, 67, -17, -53], [-157, 43, -26, 0, 17, -17], [-14, 0, 16, 7, 0, -16], [0, 26, -20, -170, -26, -20], [-90, -14, -27, 45, -14, 27], [-65, 36, 36, 65, 13, -23], [-115, 7, -7, -115, 49, -56], [-148, 12, 12, 148, 10, -2], [263, -9, 23, 0, 14, -14], [16, 71, 32, -8, 71, -32], [14, 6, 6, -14, 20, 14], [186, 16, 18, -372, 2, 2], [5, 22, -22, 5, 49, -71], [-40, 30, 51, 0, 81, -81], [0, 1, 31, -59, -1, 31], [64, 99, 64, -32, 99, -64], [-47, 82, 69, 94, -13, -13], [-16, -2, 2, -16, -39, 41], [-233, 69, 69, 233, 27, -42], [-346, 11, -19, 0, -8, 8], [244, -2, -25, 0, -27, 27], [232, 22, 22, -232, 40, 18], [0, 65, -16, 23, -65, -16], [93, 21, -37, -186, -58, -58], [237, 6, -3, -474, -9, -9], [139, 3, -3, 139, -35, 32], [0, -24, -33, 95, 24, -33], [-248, 32, 32, 248, 27, -5], [73, 19, -19, 73, -67, 48], [98, -73, -67, -49, -73, 67], [431, 37, -42, 0, -5, 5], [-167, -16, 16, -167, 61, -45], [32, -38, -46, -16, -38, 46], [-112, 23, -65, 56, 23, 65], [-28, 61, -61, -28, -25, -36], [0, -43, 39, 289, 43, 39], [35, -27, 49, -70, 76, 76], [380, -49, 25, 0, -24, 24], [-235, 93, 93, 235, 41, -52], [-182, -89, 2, 0, -87, 87], [-274, -50, 78, 0, 28, -28], [0, 45, 63, 79, -45, 63], [174, 38, -2, -348, -40, -40], [115, -32, -32, -115, -75, -43], [-442, 101, 101, 442, 49, -52], [0, -71, -9, -119, 71, -9], [16, -76, -18, -8, -76, 18], [80, -90, -101, -160, -11, -11], [-116, -36, -51, 58, -36, 51], [0, 116, 52, 91, -116, 52], [-118, 57, -16, 59, 57, 16], [0, 9, 87, 167, -9, 87], [37, -23, 39, -74, 62, 62], [222, -66, -40, -444, 26, 26], [256, -1, 44, 0, 43, -43], [-637, 23, 93, 0, 116, -116], [-422, 113, 113, 422, 40, -73], [0, 22, 29, -13, -22, 29], [314, -110, -45, -157, -110, 45], [236, -151, -81, -472, 70, 70], [-141, 6, 67, 282, 61, 61], [487, -116, -116, -487, -65, 51], [0, -69, -16, -712, 69, -16], [34, 35, 20, 0, 55, -55], [0, -6, 169, 98, 6, 169], [14, 64, -64, 14, -88, 24], [170, -91, -91, -170, -89, 2], [203, -117, 73, 0, -44, 44], [259, -39, 75, 0, 36, -36], [710, -16, -3, -355, -16, 3], [-1020, -70, -30, 510, -70, 30], [-300, 1, 21, 600, 20, 20], [66, -88, -132, -132, -44, -44], [63, -9, 48, -126, 57, 57], [-428, 38, 14, 0, 52, -52], [260, -27, -27, -260, -38, -11], [0, -23, 179, 106, 23, 179], [166, -43, -43, -166, 102, 145], [689, -55, -55, -689, -74, -19], [-253, 91, -9, 0, 82, -82], [-460, -69, -69, 460, 3, 72], [23, 35, -35, 23, -47, 12], [0, 200, 215, 0, 200, -215], [-26, -12, -12, 26, -1, 11], [631, -121, 110, 0, -11, 11], [0, 80, -60, 787, -80, -60], [152, -148, -70, -76, -148, 70], [32, -51, -196, -64, -145, -145], [47, 127, 157, -94, 30, 30], [-38, -36, -165, 0, -201, 201], [112, -158, -172, -56, -158, 172], [0, -233, -41, -451, 233, -41], [0, 118, -84, -622, -118, -84], [38, 119, 37, -19, 119, -37], [168, 65, 139, -336, 74, 74], [85, -107, 107, 85, -75, 182], [-29, 118, 118, 29, 48, -70], [270, 30, -30, 270, -88, 58], [0, -78, -37, -622, 78, -37], [210, 24, -90, -420, -114, -114], [-391, -34, 34, -391, 130, -96], [394, 100, -129, 0, -29, 29], [0, 117, 64, -469, -117, 64], [368, 215, 116, -184, 215, -116], [-532, -86, 86, -532, 68, 18], [50, 242, 198, -100, -44, -44], [-374, 117, 26, 0, 143, -143], [-814, -5, -5, 814, 64, 69], [0, 133, -15, -446, -133, -15], [-440, -116, -164, 220, -116, 164], [-557, 60, 60, 557, 97, 37], [164, 9, -9, 164, -114, 105], [431, -97, -97, -431, -30, 67], [232, 110, -110, 232, -58, -52], [-100, 38, 186, 200, 148, 148], [-341, -59, 59, -341, 45, 14], [-565, 145, -145, -565, -56, -89], [0, 92, -30, 199, -92, -30]]
