
# q-expansion of newform 384.4.a.f, 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 = 384
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], [-4], [-10], [4], [-26], [14], [-8], [-148], [-72], [-18], [-262], [-378], [432], [-148], [-360], [428], [442], [692], [-540], [-1018], [-386], [-108], [-382], [298], [-1800], [818], [-716], [1134], [1858], [1402], [-1188], [734], [-404], [684], [3502], [3258], [856], [-1552], [1548], [-3420], [3502], [4792], [-98], [-1184], [1466], [2692], [4554], [-5580], [902], [1962], [-2016], [-1826], [3060], [-558], [-5544], [-4856], [-7030], [-738], [-1854], [-1404], [2056], [2340], [-1616], [3286], [-9936], [2116], [-7874], [10476], [-7030], [-5310], [-7628], [-13778], [-2566], [-7120], [14040], [4972], [-8766], [-12042], [8002], [-364], [1502], [-3532], [8946], [1602], [-4356], [2110], [13698], [12028], [-10286], [-11516], [13932], [-10682], [11660], [-12404], [2308], [1984], [3982], [-18368], [2870], [-14176], [12884], [-15588], [-4730], [-4724], [16838], [9932], [15714], [20340], [-16434], [8234], [6506], [-20542], [-11116], [3574], [7110], [1728], [-14724], [23076], [27252], [-18910], [-350], [-13468], [-12852], [1080], [-22720], [-22346], [-35244], [-25074], [23742], [4932], [26248], [-26146], [-4202], [-31018], [-7570], [-31392], [14608], [-30204], [-306], [34920], [-14720], [14030], [-24764], [-1810], [-4500], [29458], [15030], [27368], [-39352], [-32246], [1714], [-1288], [12888], [44920], [-12384], [8190], [-4698], [-10646], [25852], [3172], [53150], [9802], [-46660], [-41994], [11848], [7390], [47682], [-28054], [57604], [-39204], [8442], [6440], [20330], [31366], [16146], [50436], [-58324], [55970], [-14222], [-11474], [28548], [57870], [63410], [42408], [40932], [29710], [-72692], [17686], [-73120], [18226], [-56340], [65708], [-56380], [-37076], [59170], [7478], [23390], [-54230], [36720], [69116], [34946], [16982], [-98], [-26604], [-86688], [-70334], [64876], [-64886], [-10648], [-38242], [-20876], [-1934], [60700], [59292], [-31670], [58374], [7718], [-82368], [2268], [-71018], [-59094], [-76626], [-24390], [93172], [-82430], [7186], [-51476], [-30014], [56380], [12430], [-54272], [-101806], [-99310], [52264], [44060], [65834], [-92740], [112716], [-99540], [-96228], [-71612], [30718], [-61030], [-23782], [13820], [-73738], [16812], [-13516], [36216], [-60354], [40658], [9644], [16282], [102856], [56732], [-113354], [82332], [-61344], [33786], [50138], [82580], [1990], [96346], [-36162], [-107892], [11812], [-54198], [-99592], [46508], [40474], [67636], [72826], [-126442], [-118494], [117530], [-26284], [47826], [-117522], [9468], [137452], [51554], [-30780], [-50086], [-126280], [-89032], [88462], [143316], [2854], [59522], [121684], [-120636], [-83358], [76572], [-54142], [-41220], [63154], [52312], [-121788], [-52336], [54710], [-72252], [-70074], [-30996], [153728], [-77922], [2452], [-109378], [-62820], [48410], [29912], [39528], [-83034], [47816], [-124448], [132426], [-73228], [68180], [-183762], [-179798], [44380], [-39322], [-103032], [-42658], [88182], [-40582], [175896], [97072], [2416], [-40388], [-4258], [-86724], [144026], [-65412], [42716], [169668], [-130598], [14602], [-126234], [-119662], [88802], [-21506], [-26856], [-109934], [-60768], [-3172], [132622], [206820], [-157356], [-40208], [135440], [9890], [22608], [147906], [-32174], [163498], [116784], [-77508], [-129834], [-126864], [52154], [-118782], [-160488], [122756], [74708], [-182242], [-181480], [154558], [-195382], [-132404], [-148960], [-175824], [4248], [217198], [-146674], [78764], [26712], [-66590], [142398], [134758], [103036], [30294], [200654], [133074], [-89776], [-112032], [135358], [69182], [-9332], [-54796], [133522], [22932], [-125996], [-20008], [82984], [-65582], [63514], [-52114], [78192], [-109476], [136242], [-21762], [-151902], [176742], [238968], [227286], [211870], [225846], [13672], [-24628], [37638], [-9180], [-70268], [-118664], [140246], [259160], [9752], [-15634], [-219690], [-20484], [240268], [54738], [-104504], [74124], [-20250], [4104], [211972], [-11502], [48888], [295020]]
