
# q-expansion of newform 450.6.c.f, downloaded from the LMFDB on 25 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 = 450
weight = 6
poly_data = [1, 0, 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], 1], [[0, 2], 1]]

hecke_ring_character_values = [[101, [1, 0]], [127, [-1, 0]]]
aps_data = [[0, 2], [0, 0], [0, 0], [0, 59], [-192, 0], [0, 553], [0, 381], [2740, 0], [0, -783], [5910, 0], [-6868, 0], [0, 2759], [378, 0], [0, -1217], [0, 6561], [0, 4587], [-34980, 0], [-9838, 0], [0, -16861], [-70212, 0], [0, 10993], [-4520, 0], [0, 54537], [38490, 0], [0, 959], [-77622, 0], [0, -23357], [0, -519], [-206930, 0], [0, -69693], [0, -149941], [-7872, 0], [0, -82119], [282100, 0], [-388950, 0], [-97948, 0], [0, 1859], [0, -21617], [0, 93261], [0, 187227], [272100, 0], [-75418, 0], [356988, 0], [0, -219347], [0, -78399], [162520, 0], [-181648, 0], [0, -144137], [0, 562761], [415810, 0], [0, -385293], [-595320, 0], [273902, 0], [-850752, 0], [0, 412701], [0, -682323], [-113310, 0], [-849628, 0], [0, -219301], [1456698, 0], [0, -60197], [0, 1321047], [0, 723779], [928068, 0], [0, 1147813], [0, 1368261], [3818792, 0], [0, 1105439], [0, -1163619], [311290, 0], [0, 1543287], [-3530760, 0], [0, -17881], [0, -857627], [3101740, 0], [0, -2659743], [1161450, 0], [0, -314281], [2724318, 0], [-1780190, 0], [650580, 0], [-3540598, 0], [548748, 0], [0, -746207], [-4862120, 0], [0, 930777], [3737190, 0], [0, 3241379], [-1509102, 0], [0, 4342003], [0, 3482061], [-5510520, 0], [0, -2759041], [1512768, 0], [1930420, 0], [0, -3365523], [-556650, 0], [-10111002, 0], [0, -3518597], [-4231138, 0], [0, -2220121], [0, -4507239], [0, 4906437], [13315230, 0], [9958952, 0], [0, -2251861], [0, 312921], [0, 1251927], [-756480, 0], [-13856458, 0], [0, -5688601], [0, -3500807], [0, 3951501], [-4023620, 0], [-10022668, 0], [-6373902, 0], [0, 2502283], [0, -4359639], [0, 792387], [12640980, 0], [-3615718, 0], [0, 5565673], [0, -117759], [0, -10291503], [-9548248, 0], [-1293042, 0], [21272050, 0], [8317320, 0], [0, 2183699], [0, -2028227], [-768260, 0], [0, -3093903], [18169772, 0], [0, -9674701], [30199158, 0], [-21585410, 0], [0, -1954473], [0, 13254119], [0, 5397021], [-11144550, 0], [-11486608, 0], [-30434682, 0], [0, 2048863], [0, -8532579], [24761710, 0], [31652880, 0], [0, 14133553], [0, 13043481], [33811060, 0], [0, -11140863], [0, 17337419], [-14260302, 0], [0, -18758837], [0, 20382861], [0, 17855819], [21138948, 0], [-18599600, 0], [44511030, 0], [0, 10970939], [7777218, 0], [0, 15859941], [0, 2801427], [0, 10176599], [23430648, 0], [0, -21520599], [0, 23750157], [20923052, 0], [0, -14816581]]
