
# q-expansion of newform 576.4.a.m, 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 = 576
weight = 4
poly_data = [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 = None
aps_data = [[0], [0], [0], [20], [0], [70], [0], [-56], [0], [0], [308], [-110], [0], [520], [0], [0], [0], [-182], [880], [0], [1190], [884], [0], [0], [-1330], [0], [1820], [0], [646], [0], [380], [0], [0], [-2576], [0], [1748], [3850], [3400], [0], [0], [0], [-3458], [0], [-1150], [0], [-5236], [-6032], [-3220], [0], [-4466], [0], [0], [-7378], [0], [0], [0], [0], [812], [4030], [0], [-5600], [0], [-10640], [0], [10010], [0], [-992], [-4930], [0], [11914], [0], [0], [4340], [-12350], [8584], [0], [0], [-1190], [0], [8246], [0], [-17138], [0], [-2590], [14924], [0], [0], [12710], [0], [-19780], [0], [0], [20900], [0], [15136], [0], [0], [0], [12040], [22678], [-1640], [0], [0], [0], [-23312], [-17710], [0], [0], [0], [-29302], [-28420], [-17390], [0], [26656], [1892], [0], [-13160], [0], [0], [0], [20482], [24050], [0], [0], [16072], [0], [-36146], [0], [-10780], [-15050], [-31376], [0], [-23452], [41470], [0], [-4606], [0], [-43400], [0], [0], [-39368], [0], [-12220], [0], [-17066], [0], [46690], [0], [-31304], [0], [-50150], [0], [20680], [0], [-44840], [0], [2756], [0], [-55510], [0], [0], [0], [-50020], [0], [0], [0], [-45628], [-28910], [50654], [0], [0], [40138], [0], [-15370], [21476], [0], [60352], [0], [67340], [-39494], [12980], [0], [-61490], [0], [0], [0], [-56810], [75040], [-73834], [0], [23870], [0], [37312], [0], [0], [0], [-7198], [56950], [0], [0], [0], [63308], [83230], [-49714], [0], [0], [85484], [0], [0], [41272], [81650], [0], [48620], [0], [0], [76538], [15860], [0], [0], [0], [-98642], [29036], [0], [-77380], [0], [-53534], [0], [0], [-109060], [0], [8710], [69496], [-103588], [0], [-113960], [0], [112574], [0], [0], [0], [0], [-31808], [100100], [49786], [0], [0], [-121660], [0], [118816], [0], [114550], [0], [0], [84854], [0], [0], [108862], [-121520], [0], [4970], [-24820], [0], [-34706], [134890], [0], [-64064], [0], [0], [-142760], [0], [-138278], [-92720], [51590], [133796], [-71890], [127820], [0], [111274], [5402], [0], [0], [-59092], [0], [-155918], [138040], [0], [-90610], [0], [22484], [0], [0], [0], [0], [0], [121210], [0], [5852], [0], [0], [-174440], [75530], [0], [171236], [0], [150568], [166430], [0], [12166], [0], [-60590], [0], [0], [0], [131560], [0], [-183274], [0], [0], [-31570], [0], [171808], [-69190], [0], [187220], [0], [-163618], [106216], [52360], [0], [0], [204262], [0], [-142324], [0], [-103952], [0], [-6806], [0], [47558], [-129220], [-203870], [0], [0], [87932], [0], [0], [114478], [-188480], [0], [0], [222712], [70310], [0], [178220], [217474], [0], [0], [0], [0], [0], [-7310], [0], [0], [0], [80080], [152570], [0], [-249100], [-179062], [0], [60424], [0], [0], [257348], [-255530], [0], [0], [178850], [0], [-39130], [0], [0], [-205900], [0], [271096], [0], [-267388], [-219170], [131920], [0], [-261826], [0], [0], [-280280], [0], [-254410], [206444], [0], [-272792], [0], [112714], [0], [191900], [0], [0], [8372], [41830], [0], [-58520], [0], [108290], [0], [0], [-235352], [-282490], [0], [0], [34580], [0], [0], [0], [263410], [0], [0], [277130], [0], [0], [0], [323512], [0]]
