
# q-expansion of newform 1071.2.a.f, downloaded from the LMFDB on 22 September 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 = 1071
weight = 2
poly_data = [-3, 0, 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, 1], [0, 0], [2, -1], [-1, 0], [5, 0], [-2, -3], [-1, 0], [-2, 3], [3, 0], [-4, 0], [-3, 1], [3, -1], [10, -1], [-1, -6], [-3, 1], [-3, -5], [3, 3], [-5, 1], [-8, 2], [0, -2], [0, 2], [5, 3], [6, -4], [2, -6], [0, -8], [1, -1], [2, 3], [11, 0], [3, -5], [-7, 6], [3, -6], [8, -3], [-3, 3], [-12, -2], [0, -2], [2, 0], [4, 9], [-14, 4], [-10, 3], [-2, 3], [-8, -2], [-8, 10], [-10, -4], [5, 11], [11, 0], [-3, -1], [7, 9], [-2, -7], [0, 11], [8, -8], [-9, -4], [-3, 13], [8, 4], [17, 7], [-5, 5], [-10, -2], [18, 3], [-14, -1], [4, -6], [22, -6], [-29, -1], [-8, -4], [16, 4], [0, 16], [-7, 7], [-18, -4], [5, -4], [19, -3], [22, 0], [10, -3], [-7, 9], [1, 9], [-12, 4], [26, 2], [-12, 4], [9, 3], [6, 2], [-9, -7], [-27, -4], [-10, 3], [12, 10], [-13, 6], [-12, -4], [-14, 11], [3, -15], [3, -3], [30, 6], [13, 6], [13, -3], [-26, 4], [12, 6], [-26, 3], [10, 4], [10, -8], [1, -1], [12, 5], [-8, 12], [24, 5], [-14, -14], [14, -18], [-23, 9], [5, -5], [8, -6], [14, 14], [-4, 16], [10, 7], [5, -13], [-33, 7], [-6, -20], [3, -17], [-7, 21], [-17, 4], [12, 4], [1, -19], [11, 4], [-3, 8], [-28, -8], [-20, -6], [3, 6], [-3, -1], [-8, 15], [-2, -4], [24, -7], [-9, 0], [-31, -5], [-18, 6], [-18, -16], [30, 7], [2, 6], [12, 18], [21, 6], [30, 8], [-17, -3], [-19, -2], [-42, -4], [14, 7], [-5, -3], [1, 19], [8, -8], [-9, -10], [-10, -20], [-17, -10], [3, 15], [-3, 14], [-10, -24], [-10, -19], [-7, 9], [20, 10], [2, -14], [15, -21], [-35, -1], [0, -6], [23, 2], [16, 7], [8, -26], [15, -14], [-31, 10], [-14, -15], [-24, 12], [-26, -8], [-26, 8], [-17, -1], [-17, 12], [-30, 4], [0, -22], [-24, 3], [32, -12], [-2, -4], [10, -6], [-14, 0], [21, -13], [0, -1], [45, -6], [-19, 2], [-52, 3], [28, -7], [-17, -21], [17, 14], [-12, 27], [-38, -7], [-19, 16], [12, -24], [35, -15], [-14, 6], [-24, 10], [16, 14], [-2, 28], [4, -3], [43, 9], [-16, -14], [7, -17], [-24, -10], [5, 10], [-27, 15], [-37, 2], [-36, 4], [-4, -26], [-6, 18], [-6, 24], [-12, -10], [13, 2], [38, 10], [-30, -15], [34, 5], [-53, -7], [19, 23], [36, -16], [-18, 10], [45, 14], [-20, 18], [21, -17], [21, -19], [43, 5], [-4, -12], [4, -15], [-14, -10], [-1, -28], [8, -28], [5, 24], [-15, -3], [-13, -22], [-14, 14], [-20, -24], [53, -5], [-26, -4], [-10, 30], [-22, 5], [-23, 2], [14, 3], [0, 18], [1, 0], [1, 1], [8, -22], [41, -5], [6, -6], [27, 15], [-11, 19], [1, -10], [15, -6], [-38, -10], [21, -10], [-6, 18], [-6, -3], [13, 22], [0, -3], [-10, -23], [-8, -10], [34, 15], [19, 2], [66, -2], [-31, 4], [0, 6], [-19, -3], [-38, -6], [-22, -12], [1, 33], [14, -38], [39, -3], [12, 29], [8, 20], [-28, -6], [22, -18], [17, -37], [-28, 12], [28, 17], [26, -15], [-33, -7], [47, 5], [-20, -28], [17, -17], [25, 23], [-25, -4], [34, -21], [50, 0], [16, 14], [50, 9], [-16, -20], [-3, 40], [19, -18], [34, -6], [49, -9], [0, 2], [-32, 28], [-32, -6], [-1, 27], [-12, 16], [25, -25], [6, -24], [14, 15], [48, 16], [17, -20], [20, 29], [42, -4], [-24, 19], [7, -9], [8, 23], [-8, -12], [-32, 12], [34, -17], [20, -6], [-12, -23], [12, -16], [16, -16], [-31, -10], [-18, -6], [-12, 14], [-21, -23], [33, 27], [-22, 2], [-32, 0], [-42, -6], [-2, 12], [27, 0], [45, 4], [46, -6], [56, 17], [0, -10], [57, -12], [43, 5], [-15, -31], [50, 12], [52, -18], [-21, 19], [41, -10], [12, -4], [-8, 21], [-8, 6], [23, -5], [-14, -12], [-33, 22], [-2, 18], [15, 16], [53, 1], [42, -8], [49, -3], [56, 17], [65, 6], [-18, 33], [-1, 23], [28, -1], [13, -28], [19, 11], [6, 13], [19, -14], [4, 16], [5, 6], [-32, -22], [-5, -14], [-6, 19], [10, -28], [-14, 5], [-3, 9], [-67, 5], [-18, 12], [-17, 32], [-5, -35], [-63, 11], [-36, -2], [-17, 12], [6, 16], [54, 10], [-28, -39], [21, 41], [52, -16], [2, -37], [-17, 34], [4, -13], [-56, 4], [18, 6], [-3, -39], [-48, -12], [-3, -10], [51, -1], [20, 14], [-68, 0], [38, -29], [-40, 12], [2, -9], [39, -1], [36, 7], [-62, -19], [-15, 29], [7, -9], [25, -32], [15, -21], [22, -39], [-37, 32], [4, -46], [-7, -7], [-30, -30], [7, 49], [-78, -11], [27, 35], [-10, -33], [1, -29], [37, 33], [34, -22], [27, 27], [51, 3], [3, 21], [-37, 17], [13, -23], [25, 24], [12, 34], [21, 21], [-62, 20], [-12, -28], [-53, -9], [-40, -7], [0, -21], [59, 13], [34, -20], [4, 24], [40, -16], [9, 24], [-72, -16], [75, -2], [20, 26], [78, -1], [33, -3], [-54, -8], [43, 7], [19, -2], [-23, 1], [-25, -15], [12, 44], [-52, 18], [-9, -22], [84, 9], [-48, -5]]
