
# q-expansion of newform 50.12.b.f, downloaded from the LMFDB on 10 February 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, 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 = 50
weight = 12
poly_data = [242064, 0, 985, 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, 493, 0, 1], 246], [[0, 7385, 0, 5], 246], [[19700, 0, 40, 0], 1]]

hecke_ring_character_values = [[27, [-1, 0, 0, 0]]]
aps_data = [[0, -16, 0, 0], [0, 151, -1, 0], [0, 0, 0, 0], [0, -3523, -177, 0], [210792, 0, 0, 627], [0, 432631, -1452, 0], [0, 1580907, -5028, 0], [14448700, 0, 0, 3702], [0, -11309019, -39081, 0], [-29113110, 0, 0, -53796], [20706692, 0, 0, -56721], [0, -94313863, 303192, 0], [-392635518, 0, 0, 584406], [0, -363246809, 986667, 0], [0, 322031937, 2086863, 0], [0, -7622709, -9183012, 0], [-4338551220, 0, 0, 630708], [557749382, 0, 0, -11491992], [0, 3168442427, 22637439, 0], [6899916492, 0, 0, 3884283], [0, -4460519879, 29730708, 0], [6318465160, 0, 0, 15037362], [0, 10496622231, -77912265, 0], [-6604370010, 0, 0, -17917740], [0, 15446865707, 175966980, 0], [162371998542, 0, 0, 1288716], [0, -65641543439, 122360355, 0], [0, -16327688613, -196595421, 0], [54373013050, 0, 0, 21374916], [0, 84787261041, 111012504, 0], [0, 41908575617, -1074674601, 0], [74412124872, 0, 0, -380393259], [0, 66434570547, -1472480352, 0], [-769913844740, 0, 0, 98300268], [-388528067550, 0, 0, -706654980], [219154305452, 0, 0, 354812895], [0, 632256094277, -1205309832, 0], [0, -679589200949, 2584898715, 0], [0, 733790435577, -2774110461, 0], [0, 585245262291, -4298684280, 0], [-243249151980, 0, 0, 121587576], [-362350231858, 0, 0, -1122807576], [-754681310388, 0, 0, 2097158853], [0, 1942108456621, 5151800340, 0], [0, -485424252003, -2326791036, 0], [2686765720360, 0, 0, 5692825824], [-1810726430488, 0, 0, -8122051095], [0, -1826260661699, 12887715531, 0], [0, 5549058669147, 10327151727, 0], [-2137500938750, 0, 0, -4378281072], [0, 5739467242401, 6386717052, 0], [-14499398747880, 0, 0, -8776822218], [4315452774842, 0, 0, 18421356030], [-17329757391048, 0, 0, 5624311155], [0, -7480360289433, 6861661752, 0], [0, 3858954106461, -13907998329, 0], [-20740290387990, 0, 0, 7234967136], [7716100389212, 0, 0, 16858654461], [0, -12245719563343, 34341747288, 0], [1843721411682, 0, 0, -4629829710], [0, -18654793839209, 2859019491, 0], [0, -9229512477729, 78411439440, 0], [0, 28391446194947, -1466422065, 0], [21686166390372, 0, 0, 53576906169], [0, -17028227577779, 3773170632, 0], [0, 9066354331377, 607657884, 0], [72645337712912, 0, 0, -5839627383], [0, -28213355281633, -115994524440, 0], [0, 19636561433667, -59264049069, 0], [-18557300253830, 0, 0, 108390492648], [0, -23282572732359, 10055771928, 0], [-34153009174680, 0, 0, -169933190856], [0, 6225308233157, 352707536907, 0], [0, -29531808439409, -288738259080, 0], [-76908990951260, 0, 0, 170902180254], [0, -56798370391299, -94480574853, 0], [17263472046210, 0, 0, 79305780048], [0, -15343478596183, -47978598324, 0], [-60268559924238, 0, 0, -316049998896], [-14765893429730, 0, 0, -360428609346], [-279635394250860, 0, 0, 159785943108], [218282022955022, 0, 0, 244708257060], [190194656961132, 0, 0, -43956184815], [0, 29131779047101, -215822901108, 0], [143865435602200, 0, 0, 20359286064], [0, -65991178998549, 5950528863, 0], [-220998989240970, 0, 0, 234344713962], [0, 110867993831747, -1278829764720, 0], [-152396688236538, 0, 0, 506318844060], [0, 173032684800781, 246076018083, 0], [0, -112640194421073, 1333635104979, 0], [-429647076798120, 0, 0, -167589038190], [0, 220404173657537, 77512123227, 0], [892217597554152, 0, 0, -149387671461], [194723254271260, 0, 0, 333889090614], [0, 135594961155681, -1570160591733, 0], [237285660458490, 0, 0, 1326665989872], [-189236489669478, 0, 0, 920036560320], [0, -256334837009489, 1659649748787, 0], [1012299648351062, 0, 0, -523448364732], [0, -50379348221773, -749905951113, 0], [0, -401580686325843, 3468793432536, 0], [0, 354972897802071, -3635385759033, 0], [1253226993202590, 0, 0, 1132016731878], [-765951535972528, 0, 0, 1894209692205], [0, 442224594333647, -2634309659088, 0], [0, 424624438959207, 2590604808039, 0], [0, -465575017542999, 4019193272208, 0], [995538933925440, 0, 0, -1244576937474], [1581591462708482, 0, 0, -1420080940518], [0, 866216511083417, 3052197880047, 0], [0, 960570182196091, -2366897332716, 0], [0, -466409221008513, -4796260534620, 0], [447718086966820, 0, 0, 862512744330], [1119697831496492, 0, 0, 2066370856359], [1251099672307242, 0, 0, -2812824613170], [0, 163796059129891, -101634945453, 0], [0, -26307483514863, 7894446969243, 0], [0, 2156462603534991, -1712497236132, 0], [-921129090857100, 0, 0, 838933487736], [1884173109719822, 0, 0, 1777184830584], [0, 2531004074624941, 4193819473860, 0], [0, 2194039301209317, -1118581949076, 0], [0, 2055137621224191, 1531986153171, 0], [1435286203652192, 0, 0, 196752443715], [-1963862480811018, 0, 0, -563062859508], [-2104580101946510, 0, 0, -4629628617108], [-93621930038280, 0, 0, -7926624340650], [0, -1173957735083443, -7312509453177, 0], [0, -3465841479164429, 9411278240304, 0], [-3513144225900620, 0, 0, 1716231931596], [0, -1410999045809079, -9439100097525, 0], [-9579448906102108, 0, 0, 229369347171], [0, -121966918723783, -3693547660608, 0], [6408451662552042, 0, 0, 347616056352], [-441772986012050, 0, 0, 6946144334052], [0, 123960174283491, -7881470940900, 0], [0, -716174121944353, -26013472380477, 0], [0, 6537494926821177, -2091900628668, 0], [-2555121890495610, 0, 0, -568991621088], [-6462724890314008, 0, 0, 9127508346987], [-2031926158143618, 0, 0, 3495749718804], [0, -2353031745934499, 3290971792911, 0], [0, 5830191938250987, 20020208331291, 0], [-9622597211250950, 0, 0, 4241141758008], [3874793939695920, 0, 0, 21030073526862], [0, 9550640756017051, -1474165664676, 0], [0, 6190709132046387, -24433207452696, 0], [19115851660598620, 0, 0, 2683400017464], [0, -9073674695381079, 14547001009407, 0], [0, -1699659172030123, -17934088963920, 0], [14034069758821482, 0, 0, -3097990107630], [0, -4181410971190769, 6760728304815, 0], [0, -5921785341901083, 8376003685695, 0], [0, -5564318586629713, 51715159004799, 0], [15558769964605812, 0, 0, -579714308505], [5651437760396080, 0, 0, -1881035427726], [-13244424500281770, 0, 0, -30885817692630], [0, -3488468839935433, 18392805044940, 0], [-704644774155498, 0, 0, -10724458135776], [0, 2510244770769507, 26756422843695, 0], [0, -1372314436877019, -78567647441808, 0], [0, 3761519033372837, 62431878911175, 0], [21435919444615872, 0, 0, 16041906871005], [0, 4112064938052507, 89490864836268, 0], [0, 4708136802113901, 25007911300527, 0], [-11674087182570508, 0, 0, -10656499987485], [0, -11504013767479483, -51266317947444, 0]]
