
# q-expansion of newform 1200.3.l.m, 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 = 1200
weight = 3
poly_data = [9, -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 = [[751, [1, 0]], [901, [1, 0]], [401, [-1, 0]], [577, [1, 0]]]
aps_data = [[0, 0], [0, 1], [0, 0], [8, 0], [3, -6], [-2, 0], [-3, 6], [-11, 0], [-6, 12], [-6, 12], [46, 0], [16, 0], [-9, 18], [62, 0], [6, -12], [-6, 12], [-12, 24], [-16, 0], [113, 0], [-18, 36], [-101, 0], [-68, 0], [3, -6], [-9, 18], [22, 0], [24, -48], [26, 0], [3, -6], [176, 0], [-21, 42], [-106, 0], [-12, 24], [9, -18], [127, 0], [-18, 36], [-164, 0], [-38, 0], [47, 0], [30, -60], [12, -24], [-3, 6], [-106, 0], [42, -84], [193, 0], [-6, 12], [4, 0], [-209, 0], [-148, 0], [0, 0], [116, 0], [36, -72], [30, -60], [59, 0], [21, -42], [-84, 168], [42, -84], [60, -120], [178, 0], [202, 0], [-12, 24], [197, 0], [-72, 144], [-127, 0], [-48, 96], [58, 0], [48, -96], [-257, 0], [127, 0], [-63, 126], [-292, 0], [108, -216], [48, -96], [668, 0], [-242, 0], [-191, 0], [48, -96], [102, -204], [772, 0], [-45, 90], [701, 0], [51, -102], [-148, 0], [36, -72], [463, 0], [394, 0], [111, -222], [-21, 42], [-509, 0], [36, -72], [-64, 0], [108, -216], [42, -84], [-382, 0], [120, -240], [94, 0], [-132, 264], [54, -108], [-135, 270], [467, 0], [-976, 0], [779, 0], [-126, 252], [-12, 24], [-165, 330], [286, 0], [487, 0], [-99, 198], [-15, 30], [-108, 216], [-271, 0], [404, 0], [34, 0], [-72, 144], [-1046, 0], [106, 0], [-36, 72], [566, 0], [84, -168], [-84, 168], [-93, 186], [-298, 0], [274, 0], [168, -336], [21, -42], [373, 0], [114, -228], [-184, 0], [-108, 216], [758, 0], [-26, 0], [-1298, 0], [90, -180], [478, 0], [1072, 0], [93, -186], [-169, 0], [78, -156], [878, 0], [138, -276], [36, -72], [106, 0], [-102, 204], [-1348, 0], [-183, 366], [-1222, 0], [-72, 144], [-902, 0], [-141, 282], [577, 0], [246, -492], [-488, 0], [-180, 360], [-313, 0], [192, -384], [374, 0], [108, -216], [-1286, 0], [84, -168], [1597, 0], [-42, 84], [60, -120], [105, -210], [-1576, 0], [195, -390], [-81, 162], [-240, 480], [676, 0], [-1004, 0], [881, 0], [186, -372], [87, -174], [104, 0], [156, -312], [433, 0], [1294, 0], [-159, 318], [211, 0], [-60, 120], [-1408, 0], [26, 0], [-1192, 0], [87, -174], [-1112, 0], [-75, 150], [-114, 228], [156, -312], [-1088, 0], [437, 0], [-1549, 0], [-6, 12], [493, 0], [273, -546], [2011, 0], [-18, 36], [27, -54], [-132, 264], [17, 0], [1354, 0], [105, -210], [60, -120], [282, -564], [148, 0], [1396, 0], [-1147, 0], [396, -792], [-390, 780], [-866, 0], [276, -552], [144, -288], [-1214, 0], [682, 0], [-84, 168], [902, 0], [-153, 306], [-366, 732], [-1003, 0], [-1222, 0], [453, -906], [-96, 192], [252, -504], [1034, 0], [-86, 0], [-111, 222], [-304, 0], [-243, 486], [1196, 0], [189, -378], [306, -612], [698, 0], [159, -318], [-2612, 0], [-2423, 0], [736, 0], [75, -150], [2246, 0], [264, -528], [-667, 0], [-126, 252], [441, -882], [276, -552], [-3, 6], [1171, 0], [-2218, 0], [-604, 0], [-267, 534], [-396, 792], [2288, 0], [12, -24], [-521, 0], [294, -588], [316, 0], [249, -498], [348, -696], [2711, 0], [510, -1020], [159, -318], [-2566, 0], [-1831, 0], [-228, 456], [2131, 0], [932, 0], [45, -90], [458, 0], [-1742, 0], [-327, 654], [-1013, 0], [-294, 588], [324, -648], [-1909, 0], [180, -360], [-2446, 0], [1289, 0], [2209, 0], [94, 0], [-2078, 0], [1412, 0], [129, -258], [-4, 0], [2594, 0], [129, -258], [480, -960], [-2222, 0], [-408, 816], [3404, 0], [383, 0], [348, -696], [-2822, 0], [-546, 1092], [1012, 0], [-12, 24], [72, -144], [-168, 336], [-555, 1110], [-417, 834], [-632, 0], [138, -276], [-2084, 0], [-270, 540], [-180, 360], [419, 0], [3349, 0], [480, -960], [4, 0]]
