
# q-expansion of newform 4256.2.a.f, downloaded from the LMFDB on 11 February 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, 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 = 4256
weight = 2
poly_data = [1, 2, -3, -2, 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], 1], [[0, 1, 0, 0], 1], [[-1, -2, 1, 0], 1], [[1, -2, -2, 1], 1]]

hecke_ring_character_values = None
aps_data = [[0, 0, 0, 0], [1, -1, 0, 0], [1, -1, -1, 1], [-1, 0, 0, 0], [0, 1, 0, 0], [-1, 1, 1, -2], [-2, 2, -1, -1], [-1, 0, 0, 0], [-1, 0, 0, -3], [0, -1, 2, 2], [2, 2, 3, -1], [-5, 2, 0, -3], [-2, -1, 0, -3], [0, 0, -2, 2], [1, 1, -1, 4], [-1, 3, 4, -1], [1, -3, -1, 5], [-5, 3, -1, 1], [-4, 6, -3, -4], [1, 0, -4, 0], [-5, 1, 0, 6], [0, 0, -2, 4], [-9, 6, 5, 1], [-8, 0, 4, -6], [1, -7, -3, 6], [-1, 1, 1, -1], [5, -7, -1, 7], [3, -2, 4, 0], [-3, -4, -4, 3], [-7, -1, -2, 5], [6, 2, -2, -6], [-2, 5, 0, -3], [-2, -4, 4, -2], [-1, -1, -1, -8], [-1, -2, -2, 6], [-2, 2, 3, 4], [-2, 4, 1, 7], [3, -7, 4, 7], [7, -13, 1, 9], [10, -8, 0, 4], [4, -2, -1, -6], [0, -3, -10, -1], [-7, -3, -2, 5], [-2, -9, 0, 2], [5, -4, -1, -12], [5, 1, -3, -10], [5, -4, 3, 4], [-1, 5, 7, -1], [12, 0, -5, 1], [-6, 12, 0, -2], [-6, 2, 3, 4], [11, -14, -8, 9], [-12, 4, -2, -6], [-6, 1, 6, -3], [-11, 6, 3, -1], [-3, -3, -2, -7], [-1, 6, 1, -13], [4, -7, -10, 7], [16, -16, -2, 2], [-15, 8, 6, -5], [17, -4, -3, 1], [-1, 5, 7, 2], [-8, 4, 9, -3], [-6, 7, 12, -7], [-16, 8, 4, 0], [6, 0, -6, 14], [-5, -6, -3, 6], [0, -1, 2, 4], [13, -7, -8, 3], [-7, -7, 2, 4], [0, -8, 3, 9], [-4, 3, -2, -6], [11, 1, -5, 8], [3, 1, 0, 7], [3, -2, -2, -14], [-7, 9, -5, -15], [-2, 4, -7, -4], [10, -10, 0, -2], [-16, 13, 2, -2], [-23, 4, 5, -9], [-17, -5, 11, -10], [11, -8, 8, 7], [-2, 6, 4, -4], [-5, -9, -1, 0], [6, -4, 4, 2], [-5, -7, -8, 1], [-1, 5, -2, -17], [-7, 10, -7, -2], [9, 1, -12, -4], [-25, 14, 12, 1], [-5, 14, 11, -19], [10, -1, 4, 1], [-13, 12, 10, -10], [-20, -6, 8, -10], [-1, -11, -8, 7], [2, 10, 0, 2], [-8, 16, -2, -18], [-19, 15, -1, 0], [17, -13, 1, 5], [4, -6, 4, 2], [-7, 6, -11, -4], [10, -4, 5, 2], [-7, 1, -9, 3], [-15, 12, 0, 5], [-11, 16, 12, -11], [15, -7, -10, -4], [6, -16, -10, 18], [-9, 3, -15, -15], [7, -8, -1, 16], [11, -22, -7, 11], [7, -5, -7, -7], [3, 12, 9, -18], [2, -6, -9, 14], [7, -6, 5, -7], [1, -10, -6, 1], [20, -7, -2, 12], [-13, -5, 7, 2], [29, -9, 5, 8], [9, 8, 2, -10], [-6, 4, 11, -4], [-2, 14, -8, 0], [-1, 11, 6, 5], [17, 4, 1, 3], [41, -10, -8, 4], [-16, 10, -8, -12], [22, -6, -4, 10], [-13, -2, 4, -10], [2, 4, 4, 10], [-15, 5, -5, -8], [-2, -8, 2, -10], [15, 6, -2, -15], [-1, 6, 2, -10], [-15, -12, 3, -2], [4, -6, -14, -8], [-5, 7, -3, 5], [4, 4, 2, -14], [-2, 24, 0, -20], [14, -4, 2, 22], [12, 11, -2, -7], [13, -4, -10, 14], [0, -8, -10, 16], [12, 4, -8, -6], [-12, 6, -2, -16], [-25, 20, 12, 8], [-10, 4, 2, -6], [4, -2, 4, -4], [19, -15, -4, 10], [-8, -3, -6, 15], [12, 3, -2, 19], [-19, -4, -1, 8], [12, -12, -12, 12], [7, -9, 4, 4], [-1, 6, 8, -7], [11, 5, -1, -13], [17, -24, -20, 16], [-28, 32, 12, -12], [-37, -2, 16, -9], [15, 5, 4, 14], [4, 0, 1, -35], [28, -16, -2, 10], [-17, -13, -2, 7], [12, -23, 0, 14], [-2, 9, 10, -8], [3, 3, -3, -19], [24, -18, -18, 2], [13, 9, -5, -13], [-26, 4, 0, 4], [7, 9, 16, -4], [-7, 26, 0, -13], [30, -14, -12, -6], [29, -2, -7, 2], [-30, 19, 16, -15], [-34, 11, 16, -4], [11, -6, -14, 2], [46, -4, -2, -4], [16, -26, -10, 20], [-21, 11, -4, 9], [29, -6, 0, 10], [27, -3, 5, 13], [-24, -6, 9, -3], [-20, -13, -4, 6], [-25, 7, -3, 5], [5, -7, 2, -11], [1, 2, -11, 7], [-9, 2, 4, 11], [22, -18, -6, 24], [-19, 0, 4, 17], [-5, 5, -2, -24], [-19, 19, 4, -1], [29, -14, -19, 15], [-6, 18, 6, 10], [6, -13, 6, 8], [-2, 20, 4, -28], [11, -3, 11, 10], [30, 8, -2, -8], [13, 8, -5, -17], [-7, -4, 10, 4], [-23, -8, 12, -6], [11, 13, 5, -13], [-22, -2, 16, 4], [2, -4, -4, 18], [-7, 7, -10, -16], [17, -11, -15, 8], [22, -16, -20, -10], [-22, -23, 0, 13], [6, -8, 3, -15], [8, -16, -16, 12], [-20, 4, 2, -30], [-12, 32, -4, -8], [27, 1, -6, 30], [30, -20, -8, 20], [9, 17, 12, -6], [-8, 16, 2, -22], [7, 11, 3, 3], [-6, 4, -24, -18], [-5, -17, -11, 12], [-41, 4, 16, -3], [26, -38, 2, 10], [6, -18, 8, -14], [-5, -4, -10, 10], [1, -10, 2, -11], [19, -29, 8, 16], [26, -10, -26, 10], [-35, 14, 0, 13], [14, -6, -3, 23], [11, -16, -5, 26], [3, -17, 11, 12], [37, -16, -11, -8], [-10, -16, 22, 0], [-24, -5, 4, -2], [-21, 24, -1, -12], [0, -8, 8, 2], [-3, -14, 10, 10], [7, 14, 16, -3], [-9, -2, 5, -35], [-17, -10, 9, -13], [-20, 4, 11, -17], [-18, 18, 2, -24], [1, 24, 12, -7], [24, -10, -7, 11], [-24, 28, 4, 2], [-11, 31, 7, -30], [25, 3, -13, 14], [-18, -18, -18, 14], [-8, -21, -6, 1], [-8, 15, -6, -15], [16, -2, 12, 6], [-9, 13, -8, 16], [36, -12, -22, 10], [-15, 24, 6, -27], [-19, 10, 20, 6], [-18, 18, -9, -17], [26, -21, -10, 12], [8, -3, 12, -9], [12, -24, -10, 6], [7, 0, -8, 13], [7, -22, -10, 32], [20, 10, -10, 8], [1, -14, -3, -9], [9, 13, 1, -31], [-16, 36, -4, -20], [-14, 8, -16, -26], [-35, -7, 13, 1], [20, -30, 4, 26], [66, -26, -8, -2], [16, -38, 4, 20], [-7, 0, -4, 9], [-19, 13, 9, -19], [-2, -16, -4, -8], [-5, 4, 19, 14], [-24, 1, -14, -19], [36, -6, -18, 6], [-29, 9, 24, 0], [-9, -21, -14, 9], [-5, 0, 9, 23], [-18, 6, -12, 2], [0, -5, 0, 36], [-24, 8, 8, -6], [-26, -2, 12, 12], [-5, 1, 19, 0], [-3, 37, 12, -26], [-59, 4, 6, 3], [-10, 18, -4, 14], [-18, 4, -14, 10], [-12, 24, 4, -20], [-20, 16, 10, -26], [-19, 24, 4, -32], [19, 2, -12, -3], [31, -9, -17, 12], [-15, 17, -17, -22], [-47, 0, -6, -8], [-7, 4, -7, -9], [0, -21, -12, 18], [22, -24, -18, 10], [-55, 17, -2, -3], [-5, -33, -14, 22], [29, 5, -13, 19], [10, -8, -10, 2], [-30, 16, -1, -5], [-35, 6, 29, -11], [-37, -11, 17, -11], [35, -14, 14, 9], [-6, -6, -6, 2], [-7, -10, 11, -16], [-56, 47, 12, -6], [11, -2, -6, 11], [27, 14, 16, -12], [-59, 10, 15, -3], [38, -14, 24, 34], [-6, 4, -7, 20], [-11, 15, 5, -12], [-10, -2, -7, -20], [25, -26, -32, 9], [7, 10, 5, -14], [-14, 4, -8, 16], [2, -4, -6, 20], [-13, 20, 1, -25], [31, -2, -8, -10], [11, 15, 4, -30], [-28, 4, -6, 26], [-27, 17, 3, -25], [6, 4, -3, -12], [-12, -1, 2, -21], [-19, 10, -5, 20], [-14, -26, -14, 12], [-23, 10, 39, -7], [-5, -14, 15, -8], [62, -6, -17, 13], [-23, -12, -7, 18], [-5, -16, -1, 4], [-42, -2, 8, -22], [34, -8, -28, 24], [-24, 3, 24, -25], [7, -21, -11, 50], [31, -14, 0, 23], [-12, -21, 18, 15], [-67, 4, 2, 5], [16, -1, 12, 1], [-51, 11, 11, -15], [-13, -8, -11, -3], [-24, 11, 2, -20], [-34, 42, 3, -14], [15, 9, -11, -12], [3, 36, -2, -20], [-23, 16, 0, -21], [58, -22, -21, 16], [-10, -2, 14, -18], [-14, -20, 12, 12], [9, 25, 15, -35], [-43, 27, 14, -6], [11, -1, -3, -13], [23, -6, 2, 41], [-11, 28, -11, -8], [6, 0, 7, 27], [-28, 25, 4, 12], [2, -19, -12, 11], [-14, 0, 26, -6], [17, 23, -5, -12], [8, -38, 16, 14], [-44, 14, -5, 14], [-25, 6, -2, 10], [-29, 41, 22, -36], [-5, -8, -8, 22], [-40, 20, 16, -8], [-47, 1, 17, -2], [-16, 4, -8, -26], [3, -3, 13, 35], [-10, 6, 27, 2], [-4, -2, -6, -36], [30, -11, 4, 12], [52, -28, -12, -12], [-2, -40, -14, 44], [-42, 0, 20, -20], [1, -20, 1, -11], [-41, 18, -3, -32], [-2, -8, -6, 34], [-27, -8, -16, 1], [50, -36, -30, 18], [19, -27, -11, -9], [-15, 29, 5, 12], [13, -31, 17, 20], [6, 16, 18, -20], [-21, 36, 14, -31], [-29, 36, 10, 8], [50, -4, -2, -20], [-64, 36, 18, -12], [-30, -1, 28, -8], [-29, -7, -2, 20], [13, -2, -10, 27], [-29, 29, 28, -20], [-10, 33, 2, -16], [5, -20, -13, 5], [3, 4, -16, -19], [32, -23, -36, 31], [67, -8, -10, 22], [-35, 2, -2, -41], [57, -7, 1, -21], [-30, -8, -4, -6], [2, 0, 18, 2], [-15, 30, 35, -12], [-5, -31, 25, 16], [-41, 10, 14, 0], [-9, -6, -34, 0], [9, 3, 21, 6], [6, -23, -2, 41], [-17, -8, 15, 9], [-34, 18, 5, -24], [-30, 12, 4, 22], [-32, 4, 32, -12], [36, -45, 6, 13], [-13, -11, -7, -8], [-33, 54, 22, -32], [-8, 34, 31, -30], [39, -7, 4, 3], [24, -6, 22, 20], [14, -20, -17, 41], [21, -28, -26, -4], [29, -23, -26, 12], [-11, -17, 19, 7], [13, -15, 2, 28], [19, 8, 18, -1], [-37, 29, 15, -6], [-57, 0, -8, -9], [-17, -1, 14, 2], [-2, -13, 10, 3], [57, 17, -5, -2], [44, 12, -27, 16], [29, -30, -10, 4], [-17, -15, -13, 42], [-20, 12, 6, 4]]
