
# q-expansion of newform 2352.4.a.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 = 2352
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], [-3], [8], [0], [-40], [4], [-84], [-148], [-84], [58], [136], [-222], [420], [164], [-488], [478], [-548], [692], [908], [524], [440], [-1216], [684], [604], [-832], [464], [632], [160], [-2198], [770], [184], [1452], [646], [3012], [-3170], [1880], [604], [-1116], [1784], [-344], [-1392], [4052], [3108], [50], [-162], [-1544], [1204], [-2000], [-388], [4180], [-1322], [-2412], [-4336], [-764], [4300], [3860], [-2800], [4880], [-6674], [-9402], [9100], [5952], [3004], [-688], [5592], [-2922], [7492], [10766], [3984], [-180], [-10428], [-8684], [-5648], [-2546], [-8268], [10872], [10434], [-3044], [8910], [5616], [8932], [-5538], [6700], [-5048], [1344], [4392], [3666], [26], [7656], [-12608], [3068], [-6456], [-11896], [264], [2628], [13568], [20656], [3628], [-4852], [-7130], [12788], [2406], [25412], [-9690], [-5604], [-21568], [-20300], [13812], [21996], [8368], [-21504], [-10270], [28358], [-16292], [-11256], [15518], [10452], [-72], [11962], [6016], [26068], [-20530], [-10056], [-6152], [14716], [28202], [22114], [9288], [-23848], [-34756], [-26044], [-36204], [11424], [-16622], [-38524], [-18440], [-13968], [-10916], [12360], [3402], [-292], [6910], [-568], [12144], [14828], [22824], [-41780], [-21420], [18132], [-24036], [-4374], [-46348], [20660], [1800], [41996], [41308], [-3936], [-7212], [-38976], [53544], [21392], [21162], [-8224], [8140], [32158], [41416], [-12296], [57652], [-8414], [-3336], [44880], [47532], [-54900], [-43338], [7864], [-7580], [-55820], [-8046], [-37312], [13220], [24696], [-50908], [31074], [46068], [43700], [64696], [66854], [21612], [7030], [-28456], [37288], [64528], [-30476], [-51480], [1336], [-59788], [11230], [-44774], [-9844], [-62160], [-22442], [24200], [64204], [-48152], [-70260], [46656], [24328], [-36864], [-24070], [-6028], [30414], [3768], [-52408], [-16116], [-19184], [-31448], [24536], [7980], [65316], [100858], [-74462], [-43344], [38706], [38464], [51708], [-10606], [30044], [-2012], [31488], [-42432], [-62550], [3268], [-48328], [8746], [62172], [-3008], [24752], [12014], [-47240], [-30368], [-69656], [33292], [-9808], [84854], [67356], [60024], [-67568], [-23700], [59708], [102988], [77478], [17636], [11724], [53240], [24000], [-66280], [-100174], [66292], [82176], [71608], [-11528], [83512], [-102308], [130212], [8172], [-52108], [113718], [-94572], [5380], [28562], [-74532], [58124], [-138008], [-9904], [50248], [-133984], [-66088], [-17018], [60010], [45708], [88880], [58360], [-74104], [49540], [51676], [7692], [-76078], [-62610], [-79688], [-12084], [33366], [-76484], [132438], [104380], [5526], [-13208], [47200], [98000], [142452], [28612], [74120], [35946], [-142912], [4032], [119052], [16766], [-135088], [32524], [129684], [35518], [149616], [-41502], [-59058], [96220], [-54284], [9592], [-2828], [68492], [-52168], [112046], [-58300], [-55546], [-27312], [53048], [-159254], [95232], [-167004], [81324], [-23892], [76018], [23510], [-90582], [33912], [-6172], [28852], [126716], [-99590], [844], [38872], [66168], [-15154], [-40986], [2320], [-93072], [106138], [-8304], [-124140], [102740], [183408], [118848], [-168204], [199082], [-215978], [-34072], [25166], [48356], [-57432], [37564], [106466], [-207052], [93278], [83868], [120156], [-170096], [-36596], [-179466], [177408], [-6944], [-25606], [-35328], [-118204], [31268], [68014], [150064], [-89786], [-144356], [-159500], [141328], [31004], [186992], [-129672], [-57846], [138000], [-183806], [-93820], [-239568], [123912], [-30084], [221572], [-88296], [-74962], [-118232], [146000], [-174332], [-144860], [-152522], [48600], [66780], [57124], [76434], [-55820], [-71374], [-259664], [125284], [-21168], [146792], [116854], [55026], [152564], [9540], [-84656], [85554], [-32272], [-22732], [219030], [-111696], [90972], [-15176], [-75476], [118848], [-308678], [-46492], [-123276], [94740], [73640], [-4400], [-180840], [-83994], [164932], [-239336]]
