
# q-expansion of newform 1250.2.a.f, downloaded from the LMFDB on 20 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, 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 = 1250
weight = 2
poly_data = [16, 4, -9, -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, 0, 0], 1], [[0, 1, 0, 0], 1], [[0, -5, -1, 1], 4], [[-5, -1, 1, 0], 1]]

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