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

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