
# q-expansion of newform 200.6.c.f, 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, 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 = 200
weight = 6
poly_data = [3600, 0, 121, 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, 0, 0], 1], [[0, 61, 0, 1], 60], [[0, 181, 0, 1], 60], [[121, 0, 2, 0], 1]]

hecke_ring_character_values = [[151, [1, 0, 0, 0]], [101, [1, 0, 0, 0]], [177, [-1, 0, 0, 0]]]
aps_data = [[0, 0, 0, 0], [0, -4, -1, 0], [0, 0, 0, 0], [0, -4, -2, 0], [-100, 0, 0, -21], [0, 296, 52, 0], [0, 139, -16, 0], [420, 0, 0, -59], [0, 976, 98, 0], [2340, 0, 0, -148], [-2504, 0, 0, -354], [0, 6250, 484, 0], [-2667, 0, 0, 936], [0, -112, -1076, 0], [0, 13036, 0, 0], [0, 23406, -360, 0], [40888, 0, 0, 416], [-23466, 0, 0, 44], [0, 34404, 323, 0], [3724, 0, 0, -344], [0, 54411, -72, 0], [54052, 0, 0, -3062], [0, -13612, 3841, 0], [-35495, 0, 0, -5024], [0, -48426, -3800, 0], [-75534, 0, 0, -7860], [0, -100276, 1240, 0], [0, 57260, 5165, 0], [-70714, 0, 0, 8980], [0, 32127, -11064, 0], [0, -54896, 7738, 0], [133880, 0, 0, -988], [0, -148469, 4104, 0], [-122708, 0, 0, -2939], [-268884, 0, 0, 12964], [122748, 0, 0, -12134], [0, -122882, 27104, 0], [0, -386276, -5643, 0], [0, -166580, -6512, 0], [0, 174096, 34088, 0], [-298028, 0, 0, -21727], [-224134, 0, 0, -20856], [149864, 0, 0, -14846], [0, -76475, 3216, 0], [0, 188770, 33168, 0], [212480, 0, 0, -18428], [-659420, 0, 0, -22459], [0, 384176, -15660, 0], [0, 796568, 22316, 0], [879396, 0, 0, 26920], [0, 24790, -41936, 0], [368508, 0, 0, -41148], [-463215, 0, 0, -14888], [-453436, 0, 0, 84869], [0, 767530, 15400, 0], [0, 1315224, -24726, 0], [1305376, 0, 0, 42320], [-413976, 0, 0, 98910], [0, 209556, -6676, 0], [337334, 0, 0, -89544], [0, 577676, 23997, 0], [0, -4254, 24868, 0], [0, -251700, -87527, 0], [17268, 0, 0, -140026], [0, -1263198, 104824, 0], [0, 214028, -80680, 0], [-2532212, 0, 0, -19145], [0, -341835, 73864, 0], [0, 1551172, -50971, 0], [-230386, 0, 0, -22564], [0, -426594, 133256, 0], [-276084, 0, 0, 203418], [0, -4253640, 27020, 0], [0, -2615534, -37224, 0], [-2631580, 0, 0, -54225], [0, 240900, -116226, 0], [-2611998, 0, 0, -153168], [0, -2094756, 46528, 0], [3088757, 0, 0, 151616], [-25317, 0, 0, 390592], [-3215004, 0, 0, 157473], [-2173268, 0, 0, 268984], [4301028, 0, 0, 81542], [0, -638459, 184736, 0], [2772716, 0, 0, -213588], [0, -749996, 340345, 0], [-292377, 0, 0, 237504], [0, -3955233, -282512, 0], [309652, 0, 0, -225080], [0, -1784552, 376444, 0], [0, 8519040, -34268, 0], [1620336, 0, 0, -444202], [0, -5713696, -196854, 0], [1389816, 0, 0, 414900], [4347816, 0, 0, 141572], [0, -141488, -124724, 0], [2776494, 0, 0, 223808], [524845, 0, 0, 107840], [0, -4661844, 164831, 0], [-7154632, 0, 0, 342520], [0, 2135468, -415751, 0], [0, 443152, 246404, 0], [0, -5566248, -455336, 0], [3397855, 0, 0, 339872], [-5837488, 0, 0, 587812], [0, -1959467, 133800, 0], [0, 13406660, -154057, 0], [0, 4227951, -616248, 0], [3995972, 0, 0, 204962], [-8185221, 0, 0, 475136], [0, -8455544, 506536, 0], [0, -4697026, 44144, 0], [0, -1202638, -453376, 0], [696520, 0, 0, -171756], [-5065872, 0, 0, -848362], [7369506, 0, 0, 18312], [0, -1625920, 264332, 0], [0, -1308912, -224580, 0], [0, 1253826, 995780, 0], [-9343556, 0, 0, 390343], [-10216044, 0, 0, -623028], [0, -13850374, -9088, 0], [0, -9060680, 382008, 0], [0, 2730188, 400031, 0], [-9371700, 0, 0, -931841], [16653224, 0, 0, -59948], [-5239820, 0, 0, 534552], [-17202892, 0, 0, -284186], [0, -24254916, -199948, 0], [0, -13885432, -102028, 0], [-8002864, 0, 0, 157148], [0, 9570928, 382498, 0], [2143780, 0, 0, 1280476], [0, -4823736, 197576, 0], [8837893, 0, 0, -709064], [3656659, 0, 0, 486752], [0, -5999676, -537036, 0], [0, -6642408, 557060, 0], [0, -6074522, 420160, 0], [-747450, 0, 0, -779112], [-614992, 0, 0, 1190724], [14295122, 0, 0, 839880], [0, 1948856, -322532, 0], [0, 1674852, 690615, 0], [7901216, 0, 0, -483204], [-7754992, 0, 0, 633792], [0, 377138, 1356120, 0], [0, -12555853, 583904, 0], [8787084, 0, 0, -529435], [0, 1631740, 2012092, 0], [0, -762700, -1837896, 0], [7282870, 0, 0, -283400], [0, 27319812, 40447, 0], [0, 34264016, -341876, 0], [0, -13389200, 938812, 0], [-15082136, 0, 0, 234956], [11333248, 0, 0, 229134], [29542418, 0, 0, -598064], [0, 18576949, 67424, 0], [1666080, 0, 0, 384076], [0, 2501624, -2696576, 0], [0, 28357625, 1458224, 0], [0, 40914408, 699528, 0], [-8974828, 0, 0, -1799837], [0, -28000417, -222000, 0], [0, -9014204, -2742050, 0], [3733404, 0, 0, -1081514], [0, 18597132, 2007840, 0]]
