
# q-expansion of newform 1200.4.f.m, downloaded from the LMFDB on 23 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 = 4
poly_data = [1, 0, 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, 3], [0, 0], [0, 20], [24, 0], [0, 74], [0, -54], [-124, 0], [0, 120], [78, 0], [-200, 0], [0, 70], [330, 0], [0, -92], [0, -24], [0, 450], [24, 0], [-322, 0], [0, -196], [288, 0], [0, -430], [-520, 0], [0, -156], [-1026, 0], [0, 286], [-1734, 0], [0, -452], [0, -1404], [1474, 0], [0, 1086], [0, 1244], [-2328, 0], [0, -2118], [2324, 0], [-258, 0], [808, 0], [0, -2378], [0, 52], [0, -3720], [0, 426], [-1440, 0], [-3130, 0], [-3576, 0], [0, 2666], [0, 2718], [-3832, 0], [-1100, 0], [0, -1964], [0, 660], [1906, 0], [0, -1458], [1176, 0], [866, 0], [-432, 0], [0, -2526], [0, -5448], [2574, 0], [3184, 0], [0, -3962], [-8286, 0], [0, 2716], [0, 6018], [0, 9236], [-1536, 0], [0, -7342], [0, 3894], [-3692, 0], [0, 8998], [0, 5244], [-6302, 0], [0, 3414], [4824, 0], [0, -3508], [0, 10802], [1460, 0], [0, 4872], [14046, 0], [0, 2734], [-15942, 0], [-8714, 0], [11976, 0], [11054, 0], [-720, 0], [0, -15622], [-9880, 0], [0, 16116], [-9018, 0], [0, 3670], [17562, 0], [0, -1172], [0, 6876], [2280, 0], [0, -3076], [18912, 0], [9956, 0], [0, 10656], [2766, 0], [10530, 0], [0, -12692], [18110, 0], [0, 3620], [0, 14166], [0, 13404], [18654, 0], [7684, 0], [0, 1726], [0, 10596], [0, 2862], [-23592, 0], [-9574, 0], [0, 17444], [0, -2374], [0, 12162], [8804, 0], [12688, 0], [-9150, 0], [0, -25292], [0, -2736], [0, 22218], [14520, 0], [-10618, 0], [0, 1370], [0, 13758], [0, -11988], [-32996, 0], [-25902, 0], [27394, 0], [34848, 0], [0, 28028], [0, 18002], [15284, 0], [0, 18768], [-8696, 0], [0, 38662], [23874, 0], [-23618, 0], [0, 11538], [0, -14884], [0, 11334], [-44730, 0], [42748, 0], [-31686, 0], [0, -11036], [0, 25884], [-15950, 0], [13800, 0], [0, -27862], [0, 7314], [-28780, 0], [0, 32688], [0, -36650], [-2646, 0], [0, -10892], [0, -43464], [0, -14884], [1248, 0], [-6640, 0], [-29946, 0], [0, -45002], [6090, 0], [0, 56388], [0, 10854], [0, -42316], [-24480, 0], [0, 6906], [0, -6960], [-47792, 0], [0, -9938], [2590, 0], [0, -7374], [-23064, 0], [-22282, 0], [7176, 0], [0, 40898], [-47608, 0], [41214, 0], [-38900, 0], [-5454, 0], [0, -9452], [-30710, 0], [0, 44660], [5784, 0], [0, -18934], [0, 32634], [0, -29112], [33630, 0], [0, 15766], [0, 46276], [-63722, 0], [47016, 0], [0, -29878], [0, -62796], [-4988, 0], [5466, 0], [0, 17244], [0, 31686], [-77614, 0], [0, 26426], [0, -37326], [0, -35568], [-16458, 0], [13912, 0], [0, -44642], [14254, 0], [-1512, 0], [0, -18810], [-9304, 0], [0, 75612], [-498, 0], [71476, 0], [0, 40822], [59442, 0], [0, -18740], [0, -29076], [-84576, 0], [32618, 0], [0, 75548], [80058, 0], [0, -52848], [0, 7962], [-29266, 0], [36632, 0], [-83490, 0], [0, 31804], [0, 87756], [-6590, 0], [0, -85722], [-58464, 0], [0, 57836], [36456, 0], [0, 84170], [34076, 0], [67984, 0], [-22782, 0], [0, 26044], [0, -16656], [-55442, 0], [0, 41778], [52296, 0], [26352, 0], [0, 99564], [-18524, 0], [0, 40372], [-88238, 0], [0, 63798], [28704, 0], [0, 15212], [93360, 0], [115004, 0], [0, -57888], [0, 83950], [85122, 0], [0, -41880], [102166, 0], [0, -61062], [-12168, 0], [-32938, 0], [0, 28244], [0, 56718], [0, -110162], [0, -2252], [0, -67020], [31138, 0], [0, -125854], [0, 36066], [-126412, 0], [85734, 0], [-38022, 0], [0, -125300], [0, -106014], [72614, 0], [0, -23884], [0, 46658], [21512, 0], [0, 61414], [0, 40012], [0, 144492], [-102350, 0], [506, 0], [31560, 0], [0, 23520], [-28424, 0], [0, 12720], [-108754, 0], [0, 17516], [109080, 0], [0, 79058], [0, 99822], [-63448, 0], [18270, 0], [-42054, 0], [0, 6876], [0, 25278], [-56904, 0], [0, -31102], [57270, 0], [141928, 0], [0, 39954], [-49320, 0], [0, -117052], [0, 49826], [0, -29898], [-26368, 0]]
