
# q-expansion of newform 312.4.a.f, downloaded from the LMFDB on 17 March 2026.

# 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, ZZ
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K([c/ZZ(den) for c in num]) for num, den in basis_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 = 312
weight = 4
poly_data = [-43, 0, 1]

# The entries in the following list give a basis for the
# coefficient ring in terms of a root of the defining polynomial above.
# Each line consists of the coefficients of the numerator, and a denominator.
basis_data  = [[[1, 0], 1], [[0, 2], 1]]

hecke_ring_character_values = None
aps_data = [[0, 0], [3, 0], [6, 1], [22, 1], [26, 0], [-13, 0], [-10, -2], [-30, -5], [-4, -12], [66, -12], [-70, -15], [34, -14], [14, -7], [0, 14], [18, -6], [334, -4], [-254, -22], [170, -8], [-470, -43], [150, 68], [562, -6], [-760, -44], [262, 42], [950, -1], [-718, -18], [1270, 10], [-68, 78], [-400, -40], [-614, 60], [350, 68], [-1316, 18], [-1600, 52], [-66, 105], [-1644, 108], [814, 39], [318, -5], [-2426, 12], [110, -91], [122, -70], [1494, -114], [732, 192], [830, 164], [88, 40], [-3294, -68], [566, -43], [1676, -14], [1804, 72], [226, -3], [2726, 92], [4010, 148], [962, 426], [-682, -212], [1618, 226], [4432, 24], [10, -258], [-1404, 376], [882, 20], [3710, -111], [5318, 136], [142, -303], [456, -266], [-762, -117], [5030, 11], [-3652, -292], [-5418, 96], [718, -83], [6634, -367], [-6330, -420], [2892, 588], [762, -546], [-4946, -159], [-3366, 642], [968, -80], [6722, 120], [-5006, -121], [-6450, -78], [1834, -382], [1506, 754], [8286, 363], [-974, -146], [-6864, -564], [7658, -516], [-8274, 530], [358, -744], [-11020, 374], [-5272, -584], [-8018, 455], [-9222, -206], [3934, -199], [3166, -763], [-6104, -224], [-910, 424], [-6006, -1039], [-14472, 0], [-9702, 201], [-268, 932], [-15154, 521], [-13258, -524], [-1524, 788], [13746, -456], [5356, 1100], [5702, -1209], [20644, -172], [1178, 1158], [-11128, 890], [7962, -668], [6958, 170], [5766, -773], [-7148, 28], [2678, -1832], [5024, 468], [106, 938], [2294, 209], [-12050, 795], [8822, 1219], [15270, 214], [15482, 341], [-21016, 748], [9066, -504], [-356, -1748], [12122, -1458], [6674, 2020], [11710, 632], [16930, 452], [-6342, 265], [12506, 1394], [-20022, 1192], [2812, -880], [-13348, 1130], [-19014, 376], [4254, 631], [-2730, -1244], [-9236, -974], [-6310, -144], [-15418, -1259], [-21270, -416], [-6810, 2331], [-10834, -977], [-1254, 1702], [-18634, 1564], [-18582, 1583], [5974, 439], [19068, -1982], [-17342, -1416], [-18334, 856], [30762, 540], [19530, 286], [1818, 654], [-13676, 532], [18966, 982], [-13478, -506], [3410, -458], [-33968, -946], [-28768, -236], [-7304, 786], [-9408, -44], [-19600, 868], [-16482, -103], [19910, -1552], [-2746, 2555], [19458, -2154], [-13590, 1170], [17882, 669], [-38532, -276], [-13458, 2139], [19202, 2888], [3016, 684], [11646, 1568], [21002, 990], [11278, -1102], [26502, 444], [1746, 2202], [-50220, -904], [17810, -3122], [-20812, 2514], [5618, -2384], [-15634, 1899], [21414, 867], [24796, -2274], [20826, -1856], [25254, 1717], [35500, -2520], [5626, 472], [670, 1735], [6762, -3630], [12234, 2394], [-30186, -2788], [-5102, -2753], [-36022, 1606], [474, -2934], [51306, -268], [35062, -938], [-7260, 320], [26990, -681], [3668, -640], [41066, -158], [-32454, -3196], [-5574, -4120], [40982, -2441], [-20816, 712], [-43506, -2119], [35400, 1564], [13242, 2632], [-2406, -1300], [2234, 4142], [18510, 768], [-8886, 2701], [25064, 3068], [974, -4097], [-10896, -4450], [60358, -1352], [45062, -2056], [992, 448], [11922, -1804], [-67666, 646], [35634, -3488], [60128, -2496], [69394, -292], [-50418, 2700], [-22794, 963], [6014, -4032], [-18034, 3521], [-16346, 1963], [33546, -5015], [29040, 3444], [2086, 5444], [8930, -6088], [-83396, -992], [19700, 2990], [-86638, 858], [22518, 2940], [-28260, -1000], [49258, 1403], [8302, -1306], [-8900, 3496], [28534, 252], [-96870, -482], [-21026, 311], [-42580, 3376], [-54536, -388], [61422, -3510], [-28144, 3426], [39216, -1252], [-46118, 1794], [-7746, 1659], [-35860, -1460], [-23178, -6619], [-9974, 2386], [-5910, 1475], [-9092, -2448], [-27566, 3712], [58686, 2721], [-16062, -2896], [25614, -3004], [55218, -3264], [31202, -3748], [-11998, 456], [28730, -4373], [-29126, -3158], [67202, -440], [-22524, 2150], [-37284, -1644], [2306, 5548], [101110, -2360], [24558, -3785], [-87660, -2072], [-84946, 1045], [-50674, -4031], [21814, 5375], [-80122, -1382], [-39702, 1052], [58050, 1177], [-110710, 994], [1492, -3738], [69310, 816], [45858, 1687], [-44082, 2112], [874, -9358], [-31014, 7052], [-34424, -6088], [76072, -2584], [21006, 4493], [66832, 992], [24642, -7778], [-25738, 9723], [66520, -2356], [-78154, 2400], [84382, -569], [-41882, 4931], [-2686, 1450], [54742, -1360], [-48828, 4380], [-44706, 4843], [25786, 1498], [35030, 716], [59842, -850], [-9648, -9512], [-11286, -3606], [3476, -6388], [-21850, 4563], [-33766, 6216], [-53002, -143], [14908, -598], [-35828, 752], [18956, -7024], [-64774, -4878], [65756, -5284], [23318, 1704], [-61774, 8080], [-122718, -2204], [12108, 7104], [146998, -971], [-41242, -9140], [135092, 316], [-81094, 1902], [19398, -440], [-36162, -8436], [31302, -1230], [-85630, -5430], [48126, -8730], [-81536, 3918], [-20942, 2988], [131294, 4732], [7734, 13619], [-82274, 1031], [15878, 3128], [-23282, 9685], [-74910, 6597], [-35384, -4444], [-53590, -688], [27370, 6912], [48690, 2304], [71096, 5792], [101586, 2940], [4754, 11711], [37366, 2854], [-69382, -9662], [9558, 5001], [48890, -5022], [-87676, 7022], [-33702, 3566], [-147186, 3288], [79814, 1523], [-9684, 12618], [-107338, 5937], [90788, 6276], [58946, 3488], [-74722, 2353], [-65022, 3042], [10098, -4162], [-24854, 3877], [62610, 7330], [-90786, -7805], [28100, -1810], [-35038, 5388], [-13586, -9756], [7034, -4806], [50382, 3152], [-60742, -11550], [121750, 2914], [63314, -1434], [82734, -1830], [107268, 7380], [141806, 2920], [-2584, -16370], [-103510, -1924], [18494, 7493], [19622, 12583], [-41222, -12084], [-14216, 4896], [-62320, -12778], [148978, 7254], [25398, -7340], [169648, 1284], [-110682, -3008], [69222, 150], [16, -308], [79034, -12692], [48786, -2196], [236178, -920], [-30282, 11175], [-9698, 7125], [-30530, -2939], [-58194, 471], [82894, -7875], [5146, -5840], [53730, 7851], [-63734, 4304], [-117894, -9601], [71428, -1484], [-76246, -11042], [12334, -10321], [210242, -3568], [-3076, -7012], [-8830, -12766], [-76018, 13216], [-33614, -2021], [-22818, -630], [9428, 9420], [185950, 629], [-36334, -2154], [135998, 5510], [76198, -4047], [-49810, 4939], [95182, -12883], [58632, -1468], [17274, -19864], [120926, -9901], [60446, -9429], [-84086, 7876], [22370, 3576], [-87298, -6888], [-134884, -2156], [-116144, -4206], [192474, -948], [11462, 7152], [156590, 5324], [25496, -2268], [7158, -15789], [-73780, -17240], [-212618, 762], [138866, 4326], [-26026, 11848], [41264, -6692], [-51990, -2476], [-267874, 403], [-118048, -5304], [35566, 20155], [64526, -607], [70480, 6116]]
