
# q-expansion of newform 1350.4.c.f, downloaded from the LMFDB on 24 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, 13], [-30, 0], [0, -61], [0, -12], [49, 0], [0, 18], [186, 0], [-160, 0], [0, 91], [378, 0], [0, -268], [0, -144], [0, 570], [-204, 0], [-877, 0], [0, 187], [-606, 0], [0, 431], [-1151, 0], [0, 102], [-984, 0], [0, 265], [-1248, 0], [0, -1225], [0, 78], [-2198, 0], [0, 1986], [0, -2792], [-708, 0], [0, 1686], [307, 0], [1812, 0], [203, 0], [0, 214], [0, -673], [0, 3696], [0, 3132], [-510, 0], [-1087, 0], [-4056, 0], [0, 473], [0, -2556], [2923, 0], [-3175, 0], [0, -2176], [0, 3834], [3202, 0], [0, 4152], [5466, 0], [-943, 0], [-7290, 0], [0, -312], [0, -8004], [324, 0], [-7849, 0], [0, 5758], [-2688, 0], [0, 3260], [0, 5922], [0, -3728], [-732, 0], [0, 5357], [0, 4572], [845, 0], [0, -8723], [0, -9018], [-5759, 0], [0, -5772], [2046, 0], [0, 1069], [0, 7133], [8557, 0], [0, 14328], [-13500, 0], [0, -1334], [3474, 0], [-569, 0], [9132, 0], [-2971, 0], [12042, 0], [0, -8566], [-7400, 0], [0, -2580], [-13200, 0], [0, -18038], [5544, 0], [0, -17137], [0, 15888], [-3942, 0], [0, -1379], [14214, 0], [-9992, 0], [0, -21258], [16614, 0], [11838, 0], [0, 2201], [-10795, 0], [0, 14185], [0, 3576], [0, -9132], [-25020, 0], [-15997, 0], [0, 5971], [0, -19242], [0, 8118], [-1902, 0], [-14074, 0], [0, 13825], [0, 15569], [0, -11922], [-6899, 0], [11711, 0], [9240, 0], [0, -17908], [0, -7530], [0, -22788], [-16440, 0], [-12421, 0], [0, 6461], [0, 912], [0, -14442], [1892, 0], [-7914, 0], [1291, 0], [30210, 0], [0, -15680], [0, 13898], [-35300, 0], [0, 28188], [25163, 0], [0, -7979], [26622, 0], [35413, 0], [0, -33834], [0, -13469], [0, 21168], [-408, 0], [-36916, 0], [-24636, 0], [0, -18187], [0, -1464], [12295, 0], [-46884, 0], [0, 12197], [0, 28182], [-25433, 0], [0, -16968], [0, 22423], [8442, 0], [0, 41207], [0, -8472], [0, 21799], [23544, 0], [-11072, 0], [21654, 0], [0, 42835], [-48534, 0], [0, -14676], [0, 27372], [0, -3581], [-1824, 0], [0, 29778], [0, 9402], [-24907, 0], [0, -27830], [25771, 0], [0, 45948], [-35862, 0], [52778, 0], [31668, 0], [0, -44113], [45799, 0], [-22122, 0], [48692, 0], [-4374, 0], [0, -60019], [39382, 0], [0, 15343], [31356, 0], [0, -9646], [0, -23784], [0, 21012], [32814, 0], [0, 49237], [0, 23807], [-68441, 0], [-62772, 0], [0, 67847], [0, 60720], [-39703, 0], [-40560, 0], [0, 14460], [0, -34410], [65591, 0], [0, 8063], [0, -76854], [0, 55902], [38232, 0], [-53677, 0], [0, -69731], [14887, 0], [57126, 0], [0, 36582], [-44915, 0], [0, 23298], [-35766, 0], [11423, 0], [0, -2405], [-57636, 0], [0, -37591], [0, 4986], [-55854, 0], [72179, 0], [0, 14092], [26250, 0], [0, -26586], [0, -55698], [7709, 0], [-24716, 0], [-41628, 0], [0, 56000], [0, 38454], [-19667, 0], [0, 6312], [-8082, 0], [0, -15887], [-24408, 0], [0, -23197], [-9236, 0], [27920, 0], [-23766, 0], [0, -92485], [0, 61656], [-15245, 0], [0, -70680], [-84426, 0], [44124, 0], [0, 3750], [17903, 0], [0, -89095], [3121, 0], [0, 2592], [68514, 0], [0, 40279], [-10968, 0], [26332, 0], [0, -58386], [0, 3166], [-4716, 0], [0, -56976], [35215, 0], [0, 12942], [89880, 0], [-74443, 0], [0, 105928], [0, -32946], [0, -30674], [0, -22513], [0, 55878], [106219, 0], [0, 14405], [0, -19296], [-23708, 0], [30378, 0], [97302, 0], [0, -98908], [0, -54948], [-57505, 0], [0, -86363], [0, 99578], [-12719, 0], [0, 48490], [0, -39469], [0, 127122], [146590, 0], [-15802, 0], [113430, 0], [0, -128802], [104204, 0], [0, 16206], [55091, 0], [0, -90767], [54540, 0], [0, 112727], [0, -118728], [-82457, 0], [-29622, 0], [21822, 0], [0, -24198], [0, -142134], [54204, 0], [0, 100622], [-83928, 0], [-61843, 0], [0, -22140], [-44742, 0], [0, 130699], [0, 80261], [0, -72810], [43540, 0]]
