
# q-expansion of newform 114.6.a.f, downloaded from the LMFDB on 23 December 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
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K.gens()[0]**i for i in range(len(poly_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 = 114
weight = 6
poly_data = [-1022, -1, 1]

# The basis for the coefficient ring is just the power basis
# in the root of the defining polynomial above.
hecke_ring_character_values = None
aps_data = [[-4, 0], [9, 0], [-24, -1], [-50, -5], [362, 1], [-38, 20], [780, -39], [-361, 0], [792, 116], [6354, 16], [4344, -130], [6318, -202], [10250, -270], [2458, -21], [10470, 119], [12682, -168], [764, 32], [-1808, 1493], [-23500, 32], [30768, -1480], [-28336, -505], [-49524, -320], [-12576, 3372], [-7394, 2932], [-36366, -4336], [117178, 96], [-32056, -334], [-17104, -470], [67014, 5430], [-72210, -3112], [35704, 4486], [-180666, 3447], [-132396, -5327], [400898, -1009], [-307388, -3947], [-50284, -2664], [-225226, 11032], [110252, -588], [106780, -7490], [5674, 6868], [427048, 10726], [95650, -15816], [-112454, 21737], [-117210, 22926], [-90894, 4508], [208406, 20787], [-205180, -11092], [1227652, 5000], [89672, 8394], [-820420, -1065], [-676488, -21477], [196922, -21235], [-421898, 28362], [-724122, -8209], [-446518, 31330], [-12666, 831], [662530, 32704], [1256904, -10588], [224452, -25197], [1018838, 21468], [1364682, 30975], [83694, 55482], [276180, -8748], [286630, 11771], [-125870, 41372], [-2354818, 446], [1484220, 36604], [1730626, -17820], [1062326, 30111], [1436716, -3393], [-1775406, -35724], [2661402, -60195], [1375696, -2496], [-1960050, -40586], [907136, 118022], [-3212156, -25522], [-1215992, -102185], [-2728036, -78561], [-1314414, 19090], [-2833510, 63784], [-48544, -102292], [-2158454, -61960], [-2092220, -21206], [-6401318, 18056], [1050208, -52078], [-1908242, 96443], [708226, -12898], [-8187108, 5341], [6988652, -16355], [-3721846, -158663], [-3676186, 94899], [5091856, -9448], [-2076004, 257152], [4360088, 3808], [1033398, -23047], [1801472, -47704], [-6213582, 1152], [6884842, -55494], [-2085680, -230206], [3648032, -5151], [-4639224, -224698], [8805460, -91639], [3926060, -19528], [4703622, -58940], [-9916268, -43348], [5165428, -35659], [1966142, 361415], [-485614, -119328], [-1522728, 13692], [9877774, -217806], [-1770808, -154254], [95236, -114297], [-11949100, 88613], [-4336956, 380960], [4042334, -121161], [4223758, 13000], [-16279062, -101581], [9044746, -14295], [-3508980, -123243], [-4217360, 293454], [-245082, -1654], [4082126, 152850], [-15218798, 13628], [11915048, 79554], [12889478, -236371], [6531858, 308360], [-8069018, -542456], [-9827462, -415015], [-1491542, -311679], [-22651874, 103900], [-11701446, -490961], [14862560, 14308], [3968308, 146564], [5892928, 561645], [2208356, -132919], [11230452, -281539], [10923430, -183290], [-3783724, -195644], [-3691778, 450766], [-2791952, 241603], [-5854472, 717106], [11389516, -54779], [-9758682, -427325], [-10128340, -861572], [-9485602, -748174], [164596, -756858], [-23307778, 496436], [27052290, -269682], [-21308790, 444023], [25620760, 146884], [-7893846, 399680], [15535692, 32949], [-5768990, 140655], [-9087344, 797528], [7953632, 492498], [14890924, -451430], [32966728, 250400], [-857310, -1065868], [-22750656, 536623], [-16181822, -173344], [-3190888, 394580], [-16445574, 418358], [11492208, -1017120], [7597756, 292224], [-25184690, -183264], [247056, 1331340], [-16068876, 395540], [14559668, -231185], [-49278322, 329158], [-23411516, -984275], [8574340, -441008], [16875546, -556580], [2049640, -1190576], [-2407390, -351516], [15070688, -482314], [-2462064, 1183767], [-2949524, 1005728], [-3473580, -1417491], [2557316, -51392], [20941192, 37985], [57905106, 181949], [44279072, -582462], [8498738, 145864], [21486090, -1163858], [23760962, 794453], [-46560572, -105563], [-35649542, 1164320], [-15031100, -866220], [22184442, 731752], [21230424, -1717896], [-27980542, -499868], [15430658, 288193], [-17136224, -549510], [-28400050, 1939118], [34849248, 718996], [6034718, -515596], [-56549192, 825911], [-21908578, -105196], [11871122, -857240], [3081726, 200727], [-18498994, 175046], [-7691764, -375932], [-44080450, 645298], [27738170, -1848192], [-30925816, -1135820], [66913588, 1291197], [-17812918, 2222661], [28599044, -1118380], [1400788, 1297189], [-21519128, 1405070], [-12912054, 1996036], [-798982, 1790356], [-35580170, 1876483], [3626332, -278480], [3304780, 2691442], [94313326, 500446], [-43498616, -1327976], [-26855438, -431486], [-20473060, -2191758], [-35148072, -1125261], [-5860378, 2335994], [54321620, -532236], [-6485362, -2371376], [11688650, -286431], [-28251828, -2654176], [39705120, -22743], [19966786, -2696070], [-29140880, -3051128], [107074956, 480064], [-80727214, 2393381], [11606312, 2922941], [81866632, -187966], [-21207720, -3336750], [15465306, 3697666], [-50054338, -234099], [-24293846, 2612869], [-64388328, -341049], [71727240, 556511], [-59465120, 142572], [6773088, -1902888], [-57087712, 923454], [19908342, 12905], [-71246696, -172020], [93633830, 2427426], [1687374, 3992196], [147795918, 731595], [79518554, 1646905], [-24627580, 355180], [-149185804, 794076], [61663702, -1791029], [-17934418, 2645620], [-23565208, -280697], [28408320, 2779172], [59068774, 3674138], [54336536, -2508521], [-28564400, 1807508], [-127196284, -596077], [29295208, -2344918], [60756942, 3303018], [-65372054, 1198224], [213962668, 94332], [-62035060, 2288600], [39894320, 1269485], [-95613446, -2553740], [97594712, -329125], [155817000, 1323302], [-16699526, -43820], [-19455112, 1349771], [-32279956, -3868176], [43881920, -2864173], [34416690, 3701736], [-214739772, -385420], [-159853056, -1439217], [33945062, -4465389], [-21918034, -5197518], [-75481816, 558728], [-101501398, -1239679], [104868274, 3249744], [-148535386, 2633182], [-19796894, 1271413], [-11307784, 2258144], [-24610496, 6754056], [-22211330, -644285], [7572486, 4168158], [45893786, -2461217], [-132277998, 571449], [161648324, -1339627], [-47904886, -4686568], [101968070, 626167], [-67158098, -1419588], [-191940470, -1505576], [-67055518, 2326505], [160014830, 1528928], [94845020, 6695380], [16321638, -358502], [233289970, 1232604], [30196956, -5010848], [192473440, 1312479], [-123281008, 4702494], [17242870, -3735971], [138228840, 646907], [34100426, 359980], [79436022, 1544771], [-20789168, -1306026], [-196351114, 2800373], [11745194, 2164548], [-176945212, 4753748], [-126859934, -6176860], [94495138, -3694967], [-37742146, 4171716], [-21274718, -2649355], [-217520990, -1570676], [20496210, 7299394], [51331708, -4929332], [-188311336, 5306576], [30668738, 1422584], [113822678, -8912401], [-354741404, -1088902], [39346004, 8200437], [29071756, 2229293], [343310924, 1072852], [-119445840, -445137], [-188397406, -1596424], [-94111568, -3503650], [181286866, 5515636], [-227048162, 90502], [160560896, -4592078], [215057668, -4291416], [-95536408, -3979896], [93382812, -6528151], [-142216880, -3789111], [88960554, -2901468], [-246453344, 1422752], [181424706, 315745], [-287297854, 2126267], [48108422, 5871295], [323381674, 997504], [24825550, 6788248], [-75066908, -9047623], [32778376, 4018296], [116535606, 6358706], [29584756, -4059167], [-1143958, 1433168], [128521716, 978928], [-87418018, 10773166], [131454920, -5438670], [-446157226, 1604564], [161291184, -4621230], [108474372, -11377306], [-101884508, -4236983], [83065104, 6212870], [21821486, -1797366], [217250840, 8449591], [187257576, 1873110], [105251990, -2855766], [349435142, 3315480], [20644712, -13788416], [-200043864, -4505964], [438507244, -2892343], [207214940, 5759774], [315039804, 1401707], [10976450, -6119096], [7150984, -12265748], [15753468, 7020668], [61405494, -14876375], [-157480718, 6842708], [4809346, 6946912], [133694376, -5655486], [143444322, -12513496], [31757744, -9303508], [241124072, -3417922], [12954910, 60231], [116293910, 5165238], [-47262010, 3581475], [-270021532, 8825175], [260354952, 9433754], [-69172312, 1625896], [-4899652, 7692633], [-82262576, -17011481], [162568630, 3700894], [91163362, -652928], [203649792, 1336619], [-415835758, 265513], [-5650152, 996303], [495682552, -5880314], [190753340, 15583978], [-379023688, -9472616], [140292894, -3477196], [-501638042, 6537837], [11626620, -8065694], [-92342138, 8127278], [97333394, -10889252], [-295859528, 7337224], [-175752386, -8831535], [-212556760, -11489932], [-185372286, -9397820], [-46010068, -8336888], [128162158, -8984472], [408531072, -865078], [-118289254, -6003844], [259527782, -436446], [-292010632, 8213259], [-345592648, -756838], [-298516722, -1586624], [-150557610, 10547118], [68425450, -5365327], [-117210108, -996889], [-121514934, 2764706], [359198608, 749190], [-453501314, -2434341], [-202536254, -14874000], [163166048, -17895037], [77597976, -11008910], [-418836362, -3693151], [156917674, 7305840], [-264228078, -13029480], [-318145916, -10430042], [202229644, 3136784], [-342887966, 11722192], [171116812, -18337246], [-473007530, -1867790], [111479506, -9162352], [60541326, 6578483], [-3926152, 15387558], [-145156050, 13000646], [-757113454, -3472504], [-24858400, -3969818], [154128328, -674557], [339127994, -11610549], [-136482466, 18083563]]
