
# q-expansion of newform 243.5.b.d, downloaded from the LMFDB on 27 June 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 = 243
weight = 5
poly_data = [1, -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], 1], [[-3, 6], 1]]

hecke_ring_character_values = [[2, [-1, 0]]]
aps_data = [[0, -1], [0, 0], [0, -5], [50, 0], [0, -4], [254, 0], [0, -66], [251, 0], [0, -65], [0, 209], [380, 0], [-1324, 0], [0, -596], [-3586, 0], [0, 269], [0, 969], [0, 346], [1826, 0], [5225, 0], [0, 1809], [-3031, 0], [-4360, 0], [0, -1300], [0, -2010], [-319, 0], [0, 905], [-2704, 0], [0, 1470], [17864, 0], [0, -3746], [-6256, 0], [0, -1970], [0, 680], [27434, 0], [0, -1436], [14066, 0], [-11374, 0], [-28549, 0], [0, -3095], [0, 1505], [0, 3456], [50444, 0], [0, 59], [20606, 0], [0, 9540], [54296, 0], [-24766, 0], [-10642, 0], [0, 12656], [-1420, 0], [0, -12540], [0, 16891], [-50314, 0], [0, 990], [0, 16270], [0, 10076], [0, -11484], [-17224, 0], [-53410, 0], [0, 6950], [47045, 0], [0, -2075], [140789, 0], [0, -7055], [51251, 0], [0, 23156], [84965, 0], [-115711, 0], [0, -596], [-163174, 0], [0, -23320], [0, -3795], [173690, 0], [11414, 0], [259271, 0], [0, 37015], [0, -11215], [55682, 0], [0, 24310], [91829, 0], [0, -36356], [127526, 0], [0, 45075], [-38971, 0], [93896, 0], [0, -71350], [0, -4434], [-294286, 0], [0, -32560], [-119230, 0], [0, -70974], [0, 59540], [-286264, 0], [0, -64736], [-191659, 0], [0, -64629], [0, -25109], [0, 49254], [-212641, 0], [-247330, 0], [197279, 0], [0, 51300], [0, 78400], [0, 74120], [363557, 0], [69941, 0], [0, -38500], [0, -104124], [0, 14599], [-269491, 0], [488954, 0], [-286396, 0], [0, 36160], [231614, 0], [433646, 0], [0, -4450], [593915, 0], [0, -22191], [0, -60284], [0, -16654], [-703174, 0], [-60115, 0], [0, -1945], [0, 40470], [-793849, 0], [0, 43224], [849146, 0], [0, 151020], [766646, 0], [136946, 0], [-311014, 0], [0, -62771], [416306, 0], [120314, 0], [0, 169510], [-785041, 0], [0, -144195], [1203719, 0], [0, -192599], [0, -134766], [83015, 0], [0, 195515], [-300634, 0], [0, 53544], [-929440, 0], [0, -32461], [-1232470, 0], [0, 103304], [150491, 0], [0, 134031], [1047800, 0], [0, 159576], [978326, 0], [0, 160780], [1210415, 0], [0, 97181], [-1254904, 0], [0, -56386], [255590, 0], [0, 35389], [0, -132220], [0, -9456], [995756, 0], [0, 55770], [0, 207184], [0, 4940], [62444, 0], [-496360, 0]]
