
# q-expansion of newform 1350.4.c.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 = 1350
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 = [[1001, [1, 0]], [1027, [-1, 0]]]
aps_data = [[0, -2], [0, 0], [0, 0], [0, 19], [12, 0], [0, 50], [0, 126], [-29, 0], [0, 18], [-102, 0], [-265, 0], [0, -65], [240, 0], [0, -367], [0, 72], [0, -636], [-102, 0], [-103, 0], [0, 52], [-582, 0], [0, 65], [-173, 0], [0, 498], [822, 0], [0, -821], [-1200, 0], [0, -2041], [0, 1278], [205, 0], [0, -1500], [0, -416], [-1902, 0], [0, 2712], [367, 0], [-3006, 0], [2651, 0], [0, -2801], [0, 1412], [0, 2154], [0, 234], [-2472, 0], [-190, 0], [1524, 0], [0, 3335], [0, 4440], [-2192, 0], [-1732, 0], [0, -5989], [0, 3300], [-4379, 0], [0, 2958], [2676, 0], [3626, 0], [-2046, 0], [0, -5700], [0, -7674], [-4326, 0], [6473, 0], [0, 7825], [2760, 0], [0, -4801], [0, -8166], [0, 577], [-7656, 0], [0, 2726], [0, 9450], [3089, 0], [0, 7894], [0, 3450], [-2261, 0], [0, 11544], [198, 0], [0, -10388], [0, -4867], [-656, 0], [0, 3078], [-1644, 0], [0, -5729], [-1776, 0], [-12842, 0], [11298, 0], [3431, 0], [10530, 0], [0, 3179], [-6047, 0], [0, 16554], [4446, 0], [0, -146], [9822, 0], [0, 7931], [0, -18714], [-12786, 0], [0, -10400], [-19548, 0], [-14939, 0], [0, 4098], [12216, 0], [18492, 0], [0, -5467], [6983, 0], [0, -9281], [0, 1986], [0, -12672], [8370, 0], [-19675, 0], [0, -26951], [0, 10986], [0, -11226], [11400, 0], [-6469, 0], [0, -6383], [0, -10843], [0, -25236], [-24809, 0], [-11476, 0], [25350, 0], [0, -14164], [0, 7536], [0, -432], [10782, 0], [26057, 0], [0, 19091], [0, -1044], [0, 26046], [-28060, 0], [16794, 0], [-2495, 0], [-1950, 0], [0, -16127], [0, -12634], [10420, 0], [0, -21936], [-21715, 0], [0, 19849], [-29952, 0], [-17582, 0], [0, 19194], [0, 9823], [0, -22188], [-9654, 0], [-32377, 0], [23952, 0], [0, 5072], [0, 3024], [3049, 0], [40374, 0], [0, 40322], [0, 19932], [-34553, 0], [0, 6918], [0, -6497], [-44082, 0], [0, 10127], [0, 12936], [0, 45853], [-34530, 0], [31015, 0], [-36186, 0], [0, 1441], [-33168, 0], [0, 42054], [0, 26460], [0, 29239], [-54288, 0], [0, 38634], [0, -19548], [28445, 0], [0, 48706], [32719, 0], [0, 4830], [-37350, 0], [-37135, 0], [672, 0], [0, 50525], [51880, 0], [-18450, 0], [-16213, 0], [11478, 0], [0, -8608], [-20981, 0], [0, -67544], [18240, 0], [0, -6121], [0, 66810], [0, 23574], [4872, 0], [0, -17894], [0, 16136], [16675, 0], [26058, 0], [0, 34013], [0, 67482], [-4969, 0], [-31608, 0], [0, 44004], [0, -19938], [34751, 0], [0, 81047], [0, 40812], [0, -12264], [36900, 0], [8993, 0], [0, 54061], [-32321, 0], [3804, 0], [0, 16830], [62989, 0], [0, 3318], [-4962, 0], [-85672, 0], [0, 64558], [70590, 0], [0, -89116], [0, -8796], [18114, 0], [-7297, 0], [0, -42311], [-56538, 0], [0, 16296], [0, -3912], [-36061, 0], [-28529, 0], [-81450, 0], [0, -53980], [0, 58236], [-13874, 0], [0, -57564], [-62838, 0], [0, 17776], [-46200, 0], [0, 7595], [97792, 0], [-86479, 0], [24720, 0], [0, -101743], [0, -51636], [22939, 0], [0, 23484], [53532, 0], [44214, 0], [0, -73572], [-37420, 0], [0, 72203], [-75134, 0], [0, 50394], [59598, 0], [0, -44219], [59040, 0], [-76217, 0], [0, 78714], [0, 40102], [50334, 0], [0, 73848], [40714, 0], [0, 66948], [22536, 0], [55571, 0], [0, 88180], [0, -48354], [0, -76214], [0, 28541], [0, -15192], [43045, 0], [0, 107945], [0, -37872], [78100, 0], [-77406, 0], [26406, 0], [0, -73564], [0, 61830], [30149, 0], [0, -125849], [0, 22322], [69316, 0], [0, 88555], [0, 42269], [0, -51378], [-115601, 0], [-31981, 0], [84642, 0], [0, 88680], [-97612, 0], [0, -129210], [147458, 0], [0, -148628], [-81402, 0], [0, -48478], [0, 41946], [124945, 0], [98718, 0], [-91578, 0], [0, -33738], [0, 38412], [27678, 0], [0, 74969], [-98736, 0], [42761, 0], [0, -18978], [-50478, 0], [0, -98003], [0, 102503], [0, -37500], [-32807, 0]]
