
# q-expansion of newform 252.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, 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 = 252
weight = 4
poly_data = [-7, 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, 6], 1]]

hecke_ring_character_values = None
aps_data = [[0, 0], [0, 0], [0, 1], [7, 0], [0, 1], [26, 0], [0, -5], [68, 0], [0, 3], [0, -16], [212, 0], [218, 0], [0, 25], [260, 0], [0, 26], [0, -30], [0, -18], [-322, 0], [356, 0], [0, -71], [-226, 0], [440, 0], [0, -16], [0, 13], [-1330, 0], [0, 15], [-1804, 0], [0, -11], [-454, 0], [0, 112], [-904, 0], [0, -84], [0, -102], [-880, 0], [0, -162], [3512, 0], [-322, 0], [3404, 0], [0, -174], [0, -221], [0, 227], [-502, 0], [0, 157], [1310, 0], [0, 74], [4592, 0], [-1780, 0], [4088, 0], [0, -306], [-6382, 0], [0, -138], [0, -337], [4214, 0], [0, -90], [0, 53], [0, -17], [0, 173], [-6244, 0], [8126, 0], [0, -194], [-604, 0], [0, 483], [-1636, 0], [0, -206], [-5038, 0], [0, 622], [428, 0], [-9106, 0], [0, 123], [-1834, 0], [0, -661], [0, -843], [-208, 0], [5774, 0], [-12004, 0], [0, 444], [0, 76], [3470, 0], [0, 86], [-11842, 0], [0, -218], [15518, 0], [0, 437], [-4006, 0], [-7504, 0], [0, 1151], [0, 532], [10214, 0], [0, -81], [-1408, 0], [0, -718], [0, 678], [4712, 0], [0, 995], [-16540, 0], [0, -688], [0, 137], [0, 739], [15440, 0], [19046, 0], [1892, 0], [0, 1490], [0, -438], [0, 694], [7580, 0], [-6718, 0], [0, 1530], [0, 1267], [0, 377], [-8230, 0], [8696, 0], [-5794, 0], [0, -850], [-19336, 0], [632, 0], [0, 1190], [28460, 0], [0, 646], [0, 376], [0, -507], [-12178, 0], [12902, 0], [0, 887], [0, -1257], [2168, 0], [0, -1952], [-19294, 0], [0, 1784], [15860, 0], [38498, 0], [-26356, 0], [0, -567], [-17800, 0], [2882, 0], [0, 529], [-40630, 0], [0, -285], [-6496, 0], [0, -145], [0, 472], [38864, 0], [0, 990], [36416, 0], [0, -1555], [-17302, 0], [0, -1842], [-82, 0], [0, -671], [25508, 0], [0, -2153], [10838, 0], [0, -389], [22100, 0], [0, 1306], [6812, 0], [0, 733], [-1168, 0], [0, -607], [-32254, 0], [0, -259], [0, 433], [0, 2140], [43952, 0], [0, -248], [0, 766], [0, 2484], [10760, 0], [-9970, 0], [-31774, 0], [0, -1577], [0, 1389], [10766, 0], [0, -2879], [7202, 0], [-21016, 0], [0, 1723], [-1660, 0], [0, -1284], [43652, 0], [-19738, 0], [-38032, 0], [0, -1900], [41222, 0], [0, -3013], [0, 3143], [0, 3355], [-59110, 0], [-41848, 0], [-13294, 0], [0, -2332], [12686, 0], [0, -1935], [-25972, 0], [0, 5027], [0, 1769], [0, -1969], [27014, 0], [31502, 0], [0, -2955], [0, 4366], [0, -638], [-65728, 0], [-35854, 0], [-13930, 0], [0, 2284], [0, -621], [-72016, 0], [0, 2997], [0, -4292], [-34972, 0], [55586, 0], [0, 1993], [-55960, 0], [0, 2664], [0, -4966], [27050, 0], [31736, 0], [0, -117], [0, 3827], [0, -5860], [61874, 0], [28604, 0], [0, 1952], [77096, 0], [0, -1924], [20522, 0], [0, 2913], [0, -893], [-47644, 0], [0, -4433], [77834, 0], [35588, 0], [-56440, 0], [0, -296], [93476, 0], [0, -1648], [-9634, 0], [0, 1954], [0, 2691], [0, -2064], [0, 4351], [20960, 0], [52064, 0], [46730, 0], [0, 173], [0, 4322], [-55540, 0], [0, 6286], [91100, 0], [0, -2965], [24410, 0], [0, -5473], [0, 2265], [11678, 0], [0, -2149], [0, 673], [-36058, 0], [-5836, 0], [0, -6205], [-38374, 0], [-24592, 0], [0, 3215], [-90022, 0], [-53314, 0], [0, 2367], [-78664, 0], [0, 2970], [0, -5501], [-124, 0], [0, 3804], [-119842, 0], [34004, 0], [69998, 0], [-31576, 0], [-59794, 0], [15932, 0], [0, -6715], [-20614, 0], [115046, 0], [0, 5726], [0, 3956], [-48280, 0], [0, 9636], [-1570, 0], [-14560, 0], [0, 5325], [-67906, 0], [0, 190], [95468, 0], [0, -8191], [0, 1090], [0, -8420], [0, 5190], [0, -2422], [-84778, 0], [0, -7753], [19808, 0], [0, 397], [0, 2702], [-41176, 0], [-56518, 0], [0, -888], [-80512, 0], [0, 1909], [-54916, 0], [11390, 0], [0, 3187], [13634, 0], [0, 4133], [-154174, 0], [0, -2076], [0, 10952], [0, 4842], [118172, 0], [0, -8909], [112814, 0], [0, -5324], [0, -7089], [159542, 0], [0, -4798], [-126604, 0], [-77314, 0], [0, 11027], [-87688, 0], [0, -1832], [150950, 0], [121484, 0], [100028, 0], [0, 10285], [0, 4408], [22730, 0], [0, -2392], [78500, 0], [0, -4922], [-134548, 0], [0, 5726], [-54682, 0], [0, -12015], [39086, 0], [189380, 0], [27278, 0], [0, -4414], [0, -7267], [74936, 0], [0, 11380], [0, -9903], [137450, 0], [109604, 0], [0, 7260], [0, -5541], [-36484, 0], [-125494, 0], [0, -3826], [-96208, 0], [-117202, 0], [0, -13957], [0, 3800], [0, 14416], [0, -1364], [0, 11785], [-7810, 0], [0, 909], [0, 10869], [0, -8047], [-167032, 0], [-196450, 0], [0, 3057], [-169912, 0], [9686, 0], [0, 7471], [199820, 0], [0, 1265], [0, 15062], [-165244, 0], [-132490, 0], [0, 15028], [0, 6451], [100226, 0], [0, -7521], [-63226, 0], [0, -8861], [0, -8584], [-161800, 0], [0, -13276], [-41776, 0], [0, -10692], [-227464, 0], [-20230, 0], [-207292, 0], [0, -14346], [-120646, 0], [0, -1483], [0, 3673], [155108, 0], [0, 9465], [-136474, 0], [260120, 0], [0, 16999], [176756, 0], [0, -3648], [224966, 0], [0, -10332], [51536, 0], [0, 2905], [0, 12965], [95408, 0], [-23434, 0], [0, 11960], [-230872, 0], [0, -8618], [-162358, 0], [0, 6684], [0, -4269], [-226060, 0], [132194, 0], [0, -14219], [0, -17], [64724, 0], [0, -3849], [0, 8650], [0, -16192], [92150, 0], [0, 753], [0, 6812], [159194, 0], [0, -10769], [0, 4783], [0, -15206], [-123928, 0], [0, -15262]]
