
# q-expansion of newform 4026.2.a.m, downloaded from the LMFDB on 24 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
    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 = 4026
weight = 2
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 = None
aps_data = [[1, 0], [-1, 0], [0, -2], [-1, 1], [1, 0], [0, 3], [-6, -1], [-3, -1], [2, 0], [6, -6], [-4, 6], [5, 3], [-6, 4], [-4, 2], [4, -3], [-6, 5], [-7, -3], [-1, 0], [-10, 3], [6, -2], [-6, 4], [10, -5], [8, -12], [-14, 2], [-5, -7], [-8, 10], [7, -11], [0, 3], [-3, 3], [-6, -7], [6, -6], [-8, 1], [3, -1], [-16, -2], [6, 0], [-2, 9], [7, -11], [-16, 8], [12, 0], [6, -12], [-14, 0], [-16, 9], [10, -12], [9, -21], [-9, -9], [-1, -7], [-14, 10], [-22, -2], [0, -6], [-8, 16], [5, -11], [-8, -2], [-8, 16], [-4, 17], [-14, 27], [2, -4], [-10, 0], [10, -12], [8, 10], [-1, -1], [11, 5], [-9, 11], [4, 2], [2, 8], [-2, -12], [18, -20], [15, -7], [-4, -5], [1, 13], [24, -16], [-11, 13], [-16, -3], [14, 1], [18, -16], [16, -6], [-2, 14], [-5, 23], [-10, 20], [-6, -18], [-5, -3], [21, -19], [16, -11], [10, -14], [16, -4], [32, 0], [-6, 20], [-2, -11], [20, -11], [-2, 5], [-30, 9], [12, 9], [-8, 24], [5, -1], [12, -9], [20, -28], [16, -30], [26, -19], [-20, 6], [30, -12], [-30, 6], [-14, 16], [-14, 14], [-1, 15], [-10, 0], [-4, -24], [14, -2], [0, -20], [-1, 19], [-14, 28], [6, -12], [26, -6], [40, 3], [6, -18], [-16, -8], [-2, 10], [-22, 18], [18, 1], [22, 14], [14, 3], [-8, 29], [-38, 4], [-6, 12], [-4, 4], [2, 18], [36, -16], [-22, -6], [-31, 19], [0, -25], [17, -17], [-21, -15], [6, 18], [20, 0], [-22, 11], [-6, 16], [-2, 29], [34, -28], [16, -38], [20, -16], [0, -16], [12, 0], [16, 0], [12, -10], [-52, 4], [28, -19], [10, -30], [7, -29], [26, -8], [-4, 22], [-8, 32], [-13, 15], [18, 8], [23, -37], [27, -27], [-47, 5], [29, -13], [-27, 21], [-16, 30], [-49, -1], [12, -40], [12, 2], [-20, 1], [-29, -17], [22, 20], [36, -18], [-19, 49], [26, -36], [14, 13], [-18, 12], [22, -44], [6, -24], [-58, 6], [30, -24], [19, -13], [-12, 44], [20, 8], [-30, 3], [46, -5], [38, 7], [4, 16], [-42, 24], [-18, 20], [-10, 0], [-6, 24], [-46, 8], [51, -9], [18, -12], [37, 11], [-56, 0], [-7, -5], [-28, -5], [6, -38], [-15, -7], [-12, 24], [2, 24], [34, -4], [-23, 41], [4, -12], [-15, -17], [-52, -10], [10, -10], [38, -5], [-21, 37], [23, -11], [-22, 20], [-46, -4], [-26, 36], [-30, 2], [-26, 42], [-10, -15], [38, -9], [-24, -10], [12, -24], [41, -9], [16, 1], [-16, -20], [-58, 20], [10, -24], [-8, -10], [-28, -4], [-34, 16], [-3, -1], [2, 16], [-26, -24], [20, 0], [20, -8], [-28, -4], [-38, 14], [-72, 3], [-43, 27], [9, 9], [-22, 44], [-22, 13], [24, 24], [49, -43], [32, -2], [-1, 31], [-44, 35], [-34, -12], [-8, 27], [56, -8], [25, 9], [18, 6], [14, -6], [-36, -15], [-34, 36], [20, 6], [12, -52], [50, 12], [10, -24], [-22, -18], [-24, 28], [-40, 20], [-28, 48], [-6, -38], [-58, -12], [-34, 36], [-12, 1], [-4, 16], [42, 0], [-4, 7], [46, -16], [-21, 23], [32, -11], [-48, 3], [12, 24], [-36, -20], [-2, 48], [54, 1], [44, 0], [-58, -13], [9, -13], [-60, 14], [-16, 7], [-2, 37], [15, 17], [48, 16], [7, -13], [49, -37], [47, -27], [16, -27], [20, 12], [-14, -3], [8, -19], [-54, 0], [-44, 36], [-20, 16], [-34, 48], [-62, 28], [-35, 55], [-37, 19], [26, -9], [-58, 42], [36, -44], [-6, 22], [-31, 59], [33, -55], [34, -53], [7, 35], [-19, 57], [-36, 8], [32, -42], [18, -21], [-34, 8], [-16, 27], [-23, 27], [27, 1], [-32, 18], [-46, 42], [40, -8], [28, -20], [-40, 63], [58, -26], [17, -51], [-8, -26], [4, -14], [-16, 42], [68, -32], [15, 3], [56, -17], [-10, 48], [-34, 33], [-14, -6], [0, 18], [12, -60], [-10, -51], [26, -72], [-70, 23], [65, -9], [76, -5], [36, -18], [13, -37], [-32, -4], [-32, 16], [-23, 13], [-40, -12], [56, -9], [-50, 52], [-70, 38], [24, -60], [-66, 33], [26, 36], [6, -12], [70, -11], [-6, -6], [-38, 24], [-62, 6], [13, 15], [-28, 36], [-44, 39], [-22, 6], [-48, -20], [-68, 10], [73, 1], [-2, -42], [20, 32], [-58, 30], [17, -23], [-26, 0], [18, 9], [22, -4], [-71, 39], [42, 14], [34, -74], [8, 29], [-32, 16], [24, -6], [26, 24], [42, -9], [24, -34], [25, -51], [-26, 43], [-8, 42], [39, -33], [-30, 23], [-12, 36], [20, 3], [-29, -5], [-70, 16], [-12, 60], [17, -17], [-38, -5], [-34, 40], [-26, -45], [52, -24], [33, 3], [-6, 38], [-47, 3], [28, -15], [-66, -9], [56, -31], [-57, -19], [32, 44], [-62, -16], [6, 39], [64, -28], [-20, 5], [16, -12], [-53, 55], [14, 42], [54, -5], [-6, -28], [22, -30], [-40, -4], [-20, 4], [16, -38], [10, -68], [20, 42], [68, -36], [-18, 50], [-4, 6], [4, -12], [10, 0], [4, 0], [-38, -13], [37, -17], [13, -71], [0, -40], [-62, 49], [-40, -8], [4, -10], [48, 14], [58, -4], [-65, 51], [-18, -28], [-21, 41], [-10, 56], [-12, -24], [-2, -4], [33, -45], [-15, 49]]
