
# q-expansion of newform 448.4.p.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 = 448
weight = 4
poly_data = [576, -672, 808, -20, 29, -1, 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, 0, 0, 0, 0], 1], [[-428592, 19488, -23432, 1629, -841, 29], 45520], [[596328, -82172, 30793, 5459, 989, 64], 68280], [[-4176, -159176, -986, -5713, 197, -203], 136560], [[543504, 35804, 24959, 4792, 1012, -133], 68280], [[11952, 481472, 2822, 16351, 221, 581], 45520]]

hecke_ring_character_values = [[127, [-1, 0, 0, 0, 0, 0]], [197, [1, 0, 0, 0, 0, 0]], [129, [1, 0, 0, 1, 0, 0]]]
aps_data = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 1], [0, 1, 1, 0, 0, 0], [-4, 0, 0, 9, -1, 0], [22, 1, 0, 11, -1, 1], [23, 0, 1, 46, -1, 0], [0, 11, 0, 0, -5, 8], [49, -2, 1, 49, -2, -1], [0, 5, 6, 0, 0, 1], [51, 22, -1, 0, -1, 0], [0, 1, 2, 77, -1, -23], [73, 26, -2, 73, 4, 24], [141, -8, -9, 282, 9, -16], [20, -22, -16, 40, 16, -44], [-33, 22, -1, -33, 2, 21], [0, -6, -12, -237, 6, 48], [0, -2, -4, -108, 2, -3], [189, 2, -6, -189, 0, -8], [88, -8, 0, 44, 42, -25], [322, -26, 14, 644, -14, -52], [190, -58, 0, 95, -42, -8], [372, 33, -14, -372, 0, -47], [42, -92, -22, 0, -22, 0], [-291, 4, -28, 291, 0, -32], [45, 48, -1, 90, 1, 96], [432, 125, 0, 216, -35, 80], [-770, 119, -48, -770, 96, 71], [-503, 64, 13, 503, 0, -51], [0, -19, -38, 94, 19, -168], [-399, 242, 25, 0, 25, 0], [-420, -118, -32, -840, 32, -236], [606, 233, 4, 606, -8, 237], [0, -11, -22, 1596, 11, 72], [688, 60, 80, 0, 80, 0], [-228, 71, 73, -228, -146, 144], [30, -235, 0, 15, -81, -77], [-438, 110, 0, -219, -2, 56], [-34, 45, -172, 34, 0, -217], [1581, -48, 45, 0, 45, 0], [1815, -4, 12, -1815, 0, 16], [-742, -17, 0, -371, -107, 45], [544, -56, -52, 1088, 52, -112], [697, -138, -167, -697, 0, -29], [0, -79, -158, -1544, 79, -336], [-495, 26, -23, 0, -23, 0], [0, 31, 62, -2009, -31, -187], [-628, 50, -128, -1256, 128, 100], [-1202, 224, -42, 0, -42, 0], [0, 35, 70, -2889, -35, 159], [-668, -3, -43, 668, 0, -40], [-1956, -235, -101, -1956, 202, -336], [-2011, -96, 109, -4022, -109, -192], [-594, 462, 0, -297, -82, 272], [1113, -44, -31, 0, -31, 0], [2682, 101, -3, -2682, 0, -104], [1088, -108, 0, 544, 130, -119], [-498, 104, 0, -249, 120, -8], [1636, 265, -134, 1636, 268, 131], [0, 120, 240, -1759, -120, 48], [-3189, 478, 23, 0, 23, 0], [0, -23, -46, 4169, 23, 91], [2856, -144, 132, 5712, -132, -288], [-6244, -300, 52, 0, 52, 0], [0, 204, 408, -6, -204, 375], [433, -64, -200, -433, 0, -136], [-1011, 614, -134, -1011, 268, 480], [88, -745, -310, -88, 0, 435], [-3967, 954, 153, 0, 153, 0], [7376, -268, 0, 3688, 310, -289], [-495, -440, -1, -990, 1, -880], [-2496, -1189, 0, -1248, -133, -528], [-1115, 34, 181, 1115, 0, 147], [0, -114, -228, 976, 114, 731], [1049, -142, 286, 1049, -572, 144], [4195, -76, -173, 8390, 173, -152], [2427, -1054, -101, 2427, 202, -1155], [0, -313, -626, -744, 313, -1008], [226, -645, -29, -226, 0, 616], [-180, 629, 259, -180, -518, 888], [-1096, -777, 0, -548, -217, -280], [-720, -620, 248, 0, 248, 0], [-1429, -594, 351, 0, 351, 0], [-8506, -183, 0, -4253, -269, 43], [1475, 272, -415, 2950, 415, 544], [-1069, -1230, -77, -1069, 154, -1307], [1871, -146, 695, -1871, 0, 841], [2061, -478, -227, 0, -227, 0], [-3143, -936, -336, -3143, 672, -1272], [4905, -344, -25, 9810, 25, -688], [1630, -570, -206, 3260, 206, -1140], [-2118, -667, 160, -2118, -320, -507], [0, 34, 68, 1620, -34, 531], [6152, 944, 0, 3076, 14, 465], [-1185, -308, 207, -2370, -207, -616], [-3542, 905, 264, 3542, 0, -641], [9342, -632, 86, 0, 86, 0], [780, -555, -1019, -780, 0, -464], [10266, 444, 0, 5133, -484, 464], [1511, -592, -517, 1511, 1034, -1109], [-6758, -703, 367, -6758, -734, -336], [-3093, 316, 939, -6186, -939, 632], [0, -297, -594, -3336, 297, 72], [0, -118, -236, -13344, 118, 1125], [3351, -1222, -50, 3351, 100, -1272], [-8646, 1295, 0, -4323, -1003, 1149], [13870, 238, 0, 6935, -18, 128], [4188, 1644, 36, 0, 36, 0], [2028, 503, 151, -2028, 0, -352], [-7336, 1440, 0, -3668, -1058, 1249], [5161, -880, -997, 10322, 997, -1760], [-9271, -924, 13, -9271, -26, -911], [0, -75, -150, -5162, 75, 216], [-8913, -754, -29, 0, -29, 0], [0, -584, -1168, -4286, 584, 257], [-9532, -62, -680, -19064, 680, -124], [0, -574, -1148, 3969, 574, -1296], [11978, -2412, -254, 0, -254, 0], [0, 96, 192, 17238, -96, 687], [15783, -292, -284, 15783, 568, -576], [-1164, 770, 552, -2328, -552, 1540], [-6214, -1178, 0, -3107, -234, -472], [-4547, 850, -259, 0, -259, 0], [-2844, -1811, 101, 2844, 0, 1912], [14334, -1579, 0, 7167, -669, -455], [5780, 179, -322, 5780, 644, -143], [-210, -1832, 188, 0, 188, 0], [10763, -872, 560, 10763, -1120, -312], [2352, -915, 606, 2352, -1212, -309], [-17020, 536, 524, 0, 524, 0], [743, -1380, -148, -743, 0, 1232], [4842, -1137, 0, 2421, 629, -883], [11252, 514, 280, 22504, -280, 1028], [6261, 562, -995, -6261, 0, -1557], [-12527, 602, -23, 0, -23, 0], [-9066, -1479, 625, 9066, 0, 2104], [3641, 216, 611, 7282, -611, 432], [-21636, 1675, 0, -10818, -1173, 1424], [0, -118, -236, 20104, 118, -1723], [-6573, 1384, 885, -13146, -885, 2768], [0, -118, -236, 19545, 118, 1752], [3142, 3820, 238, 0, 238, 0], [-306, -3379, 235, -306, -470, -3144], [-2768, 1668, 0, -1384, -910, 1289], [-922, -1994, -950, -1844, 950, -3988], [-5960, -767, 0, -2980, 529, -648], [16830, -696, 702, 0, 702, 0], [3755, -176, 165, 7510, -165, -352], [-2118, 2524, 0, -1059, 1548, 488], [-3239, 342, 305, -3239, -610, 647], [4770, 1743, 1836, -4770, 0, 93], [-14428, 1399, 713, -14428, -1426, 2112], [-10572, -2952, -724, -21144, 724, -5904], [6466, -2106, -626, 12932, 626, -4212], [24261, -856, -215, 24261, 430, -1071], [-26124, -1886, 0, -13062, 44, -965], [-4596, -1830, -648, -9192, 648, -3660], [-2207, 3230, 537, 2207, 0, -2693], [9963, 1530, -830, -9963, 0, -2360], [7372, 1712, 316, 14744, -316, 3424], [6762, -66, 0, 3381, 1822, -944], [4738, 2633, -8, -4738, 0, -2641], [4929, -3934, -479, 0, -479, 0], [-2842, 1454, -1326, -5684, 1326, 2908], [-38130, -335, -508, -38130, 1016, -843], [0, 225, 450, 23208, -225, 48], [0, -409, -818, 13815, 409, 981], [8600, -4672, 0, 4300, -258, -2207], [16054, -3300, 0, 8027, 2700, -3000]]
