
# q-expansion of newform 441.4.e.m, downloaded from the LMFDB on 31 December 2025.

# 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 = 441
weight = 4
poly_data = [1, -1, 1]

# The basis for the coefficient ring is just the power basis
# in the root of the defining polynomial above.
hecke_ring_character_values = [[344, [1, 0]], [199, [0, -1]]]
aps_data = [[0, 4], [0, 0], [0, -4], [0, 0], [62, -62], [-62, 0], [84, -84], [0, -100], [0, -42], [10, 0], [48, -48], [0, 246], [248, 0], [68, 0], [0, 324], [258, -258], [120, -120], [0, -622], [-904, 904], [678, 0], [642, -642], [0, -740], [-468, 0], [0, 200], [-1266, 0], [232, -232], [0, 1792], [0, -1906], [90, -90], [-458, 0], [804, 0], [0, 812], [414, -414], [-1620, 0], [0, 2370], [568, -568], [266, -266], [0, 272], [1876, 0], [0, -152], [610, -610], [1042, 0], [0, -2038], [2602, -2602], [-2354, 0], [-1680, 1680], [-668, 0], [-1832, 0], [4944, -4944], [0, 5470], [0, -2802], [1170, 0], [2338, -2338], [-2792, 0], [0, 7024], [2438, -2438], [-6780, 6780], [0, 1928], [-5554, 5554], [-1942, 0], [-4828, 4828], [6152, 0], [5884, 0], [9132, -9132], [0, 9382], [0, 3114], [0, -1532], [-4166, 0], [-11366, 11366], [9310, 0], [-8572, 8572], [0, -4790], [-5424, 5424], [0, -1838], [-4260, 0], [0, 9048], [-11490, 11490], [0, 1866], [0, 13662], [13210, -13210], [-6960, 0], [8162, 0], [16602, -16602], [7738, 0], [0, 840], [0, 6618], [-3090, 0], [0, -5914], [15968, 0], [-1172, 0], [0, 5304], [5740, -5740], [-8944, 8944], [5558, 0], [0, 19820], [-1848, 0], [0, 340], [10212, -10212], [0, 9332], [0, 8998], [-3416, 0], [-526, 526], [-6712, 6712], [0, 4190], [-3032, 3032], [-5434, 5434], [-464, 0], [0, 11748], [7650, -7650], [-22878, 0], [0, -704], [-24958, 24958], [8826, 0], [-21220, 21220], [-3268, 0], [13062, -13062], [-28012, 0], [3844, -3844], [0, -28482], [9330, 0], [-8782, 8782], [-10562, 0], [0, -26016], [8898, -8898], [0, -30572], [30618, 0], [0, 8130], [0, -27840], [14624, 0], [0, 20862], [13920, -13920], [-25578, 0], [0, -33472], [25934, 0], [0, 26952], [23450, 0], [39568, -39568], [12356, -12356], [21736, 0], [-38310, 38310], [2132, 0], [0, 5002], [3612, -3612], [27666, 0], [-12890, 12890], [9340, 0], [-33082, 0], [7544, -7544], [0, -8180], [0, 10518], [0, -14134], [-6492, 0], [38228, 0], [0, -43076], [32236, -32236], [46518, 0], [0, -17840], [0, 7000], [36114, 0], [-4748, 4748], [0, 42694], [16742, 0], [-9956, 0], [0, -26388], [-786, 786], [51888, -51888], [51928, -51928], [386, -386]]
