
# q-expansion of newform 1216.3.e.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
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K.gens()[0]**i for i in range(len(poly_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 = 1216
weight = 3
poly_data = [-14, -1, 1]

# The basis for the coefficient ring is just the power basis
# in the root of the defining polynomial above.
hecke_ring_character_values = [[191, [1, 0]], [837, [1, 0]], [705, [-1, 0]]]
aps_data = [[0, 0], [0, 0], [-4, -1], [4, -3], [4, -5], [0, 0], [-4, -7], [19, 0], [-30, 0], [0, 0], [0, 0], [0, 0], [0, 0], [-44, 3], [-44, 13], [0, 0], [0, 0], [44, 15], [0, 0], [0, 0], [-4, 33], [0, 0], [-90, 0], [0, 0], [0, 0], [102, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [-124, 35], [-116, -23], [-76, -45], [-116, 55], [0, 0], [-10, 0], [-250, 0], [0, 0], [0, 0], [0, 0], [0, 0], [4, 85], [0, 0], [-90, 0], [-76, -75], [0, 0], [0, 0], [0, 0], [44, -105], [236, -7], [244, -35], [0, 0], [-44, 115], [0, 0], [164, 77], [0, 0], [-142, 0], [284, -33], [0, 0], [244, -93], [0, 0], [0, 0], [-284, -35], [-590, 0], [0, 0], [0, 0], [0, 0], [356, -37], [316, -105], [-510, 0], [-44, -155], [50, 0], [0, 0], [0, 0], [0, 0], [-164, 175], [-404, 63], [0, 0], [0, 0], [-762, 0], [0, 0], [0, 0], [0, 0], [0, 0], [-124, 203], [0, 0], [236, 153], [316, -185], [-316, -123], [436, 43], [-942, 0], [0, 0], [918, 0], [164, 195], [930, 0], [0, 0], [0, 0], [0, 0], [-116, -225], [0, 0], [524, 47], [0, 0], [0, 0], [-458, 0], [556, 33], [-524, -77], [-30, 0], [0, 0], [0, 0], [0, 0], [284, -273], [604, -143], [662, 0], [436, 165], [0, 0], [484, 147], [596, -187], [44, 287], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [-236, 315], [-1098, 0], [1318, 0], [-604, 245], [-124, 333], [1270, 0], [116, 315], [0, 0], [0, 0], [-244, -297], [-724, -55], [-404, -255], [0, 0], [0, 0], [0, 0], [764, 65], [0, 0], [716, -265], [724, 117], [0, 0], [0, 0], [0, 0], [1030, 0], [0, 0], [-844, 195], [0, 0], [0, 0], [76, 385], [596, -357], [0, 0], [0, 0], [0, 0], [1762, 0], [642, 0], [44, -423], [0, 0], [1830, 0], [0, 0], [-1790, 0], [0, 0], [0, 0], [0, 0], [0, 0], [956, 63], [0, 0], [-404, -377], [0, 0], [0, 0], [-1662, 0], [850, 0], [0, 0], [-964, 305], [-202, 0], [1084, -65], [0, 0], [-1076, 15], [-556, 477], [0, 0], [0, 0], [0, 0], [-844, 413], [-724, 455], [0, 0], [0, 0], [0, 0], [402, 0], [0, 0], [484, 427], [0, 0], [0, 0], [1350, 0], [0, 0], [764, 345], [310, 0], [-2430, 0], [116, 533], [0, 0], [0, 0], [0, 0], [0, 0], [-618, 0], [-164, 583], [1076, -435], [0, 0], [-596, -455], [0, 0], [-2270, 0], [-2298, 0], [-1324, 213], [0, 0], [0, 0], [0, 0], [1970, 0], [0, 0], [0, 0], [-1364, -17], [0, 0], [0, 0], [0, 0], [-716, -483], [0, 0], [-1444, 255], [0, 0], [0, 0], [0, 0], [1396, -365], [-484, 663], [0, 0], [0, 0], [0, 0], [-1084, -357], [-1516, 77], [956, -615], [1276, -497], [-1098, 0], [0, 0], [0, 0], [-284, -645], [-3070, 0], [0, 0], [0, 0], [404, -715], [-764, 693], [0, 0], [0, 0], [916, 493], [-2890, 0], [-1556, 385], [-510, 0], [0, 0], [-1396, 527], [-3162, 0], [-164, -705], [0, 0], [0, 0], [-1550, 0], [0, 0], [0, 0], [-836, 735], [0, 0], [-916, 737], [0, 0], [0, 0], [1756, -95], [0, 0], [524, -793], [0, 0], [0, 0], [1324, -663], [-1724, 405], [0, 0], [3490, 0], [-1804, 323], [0, 0], [0, 0], [1844, -85], [0, 0], [-62, 0], [1364, 437], [0, 0], [1444, -693], [1796, -475], [-1124, -567], [0, 0], [484, 765], [0, 0], [3798, 0], [356, 803], [0, 0], [0, 0], [0, 0], [3702, 0], [0, 0], [-356, -833], [0, 0], [-1756, 627], [-836, 897], [0, 0], [596, -915]]
