
# q-expansion of newform 72.16.a.f, downloaded from the LMFDB on 11 May 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 = 72
weight = 16
poly_data = [-22, 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, 1920], 1]]

hecke_ring_character_values = None
aps_data = [[0, 0], [0, 0], [9170, 19], [-340200, 203], [38860316, -8646], [-103940666, -11546], [836656846, 200918], [-1120443556, 653134], [-8327900776, 1498154], [69746987946, 4485641], [-21566811712, -1001617], [-728552772498, -4401848], [688961918886, 25160866], [-1381827248828, 6760490], [3698220841200, -315053666], [2912330130626, -426498403], [11396392387724, 2961839352], [7311708697558, -2851127524], [34207175494892, 5296855880], [-32202111651128, -1039362654], [114740075268730, 4532958624], [-4451077951472, -19271905877], [119736316709092, -15802156222], [-236302624469226, -37801246524], [1016068325597474, -58194785300], [-55863874634382, 166349576277], [-1043765176771592, 63800637445], [1482105211453884, 58873939516], [-379972560986138, 319388450258], [2401196839213806, -139146057580], [6568415971342624, 391284609229], [-5758548053872556, -218900053520], [-1587596353605498, 408754458470], [19412560575090852, 405874444096], [13765445593433314, 1812662525171], [23511810148814984, -370954670485], [-6127298985416714, 473447481816], [36925940412725196, -3319501307286], [4191340950014952, -883368510120], [33979505622012282, 5230146589895], [79459835815071492, -5088141617368], [-32330726617640034, -4462446263830], [37723454590564800, 12115517127560], [42512777691941186, -6893476093568], [-203355826346204334, 447575234041], [28203974028904984, 31180993501065], [-55123528472682020, -51384929292520], [-134895862982892224, 13597930674961], [340846602328683636, -44460373867866], [-685642617344998802, -16093204142866], [-460678435201757530, -2853507762620], [221557010579434864, 103693688517244], [-356708766361656942, -38404051204508], [276703495442589580, -24468841439622], [-366270144951558914, -9405000944288], [1482618656229877064, -85440661645488], [714057126280235290, 179228129601193], [900685852670662928, 154449733661881], [-1742821190898448322, -267384064465542], [-2598753216779337386, -8280355444400], [3782265622944030356, -64743720751520], [-11227685790315726, -289155837095347], [4182346883416501884, -100215769070104], [3253400858758157304, -379389895630812], [5308847051937214602, -321146952645456], [5228441949130603338, -410024237446475], [-2117778424517741980, 1378689776815556], [5279337498897072306, 435964821531392], [14285751584194609644, -29082741024014], [-9081570348575597130, 1220847136032348], [-6353676746695393826, -1728564741738572], [60383048587322856, -1326885084887166], [-5267380617473584016, -308388238823465], [-13311156524464476130, 2175518349165252], [-10361886937580708620, 954006625240878], [-18165495584021212800, -2353226858690112], [2426084226432875858, 723673784910739], [-34939435128683903482, -2825122123887180], [-27943400970194821170, -656126978602734], [6579714821619490986, 6888327166569076], [-21808913090673041868, -263245356484258], [-32546417324733414610, -1516586644344630], [-34019614234472263952, -3110806814770366], [-59827945309784565422, -3226193375029656], [-64867997011354752600, -2026909718685555], [-53852022631142343860, 4893993437000866], [74798661807739938686, 6387263855288670], [51222328174738573946, 776889612561788], [70635229721720008346, -10832193693468705], [-27566231623484802736, 2127837007220481], [-17258730312902105628, -16979038544013314], [-2133087850968997856, 2767186316035730], [-17720207829622527944, -9141339307440461], [-9832421701330860228, 21823095263714812], [43065758721481715388, -6114456321976576], [13720902504111744888, 3898512630101018], [75626262486013189386, -12922928135362707], [24244694447211776134, -11638257058593702], [56380614901226090212, 373736921244382], [-65412011910930198858, 11408965386979578], [-100066658634995742772, -28219305706716074], [8227520298942620282, 27337347039016803], [216677699862174235076, -21613454774752270], [242713648585420605110, -33923449042026078], [-92335178554288173324, -19608131870727500], [-333197039598103199806, 27252170504857936], [53357080242508520348, -14659908259782876], [16838236344078122702, 55798367424998868], [-588453209000755780776, -30615199827891514], [-577638677620380486038, -50772577937057000], [-70961896080293433280, -79172007617769099], [288063986749131323054, 38594864075486012], [-386305911224917119834, -27708499211672728], [550019464417326002884, 15911505270941112], [-1021841164680553889624, 54426558479898603], [119645813956859695934, -119206053244687146], [252738540768650366316, 24941289655721358], [288519126427097348104, -24751720199177894], [-1389812274738584746278, 40777958066474475], [227579642102860489572, 144796524638198388], [-237984142553993307010, -180948860995408408], [-791527083559309693598, 58018129126874176], [-1192793017267795265806, 55062698536538783], [1058138034922061416508, -190015898858162578], [-2085774285693618237124, 56890740299190186], [713139184669099899594, -174904631494632859], [414876307502337357710, -83293742742671090], [-725012250403327165552, -16961790248138594], [51908948342788675656, 262313069015907867], [1373324521983219311222, 393789323584179374], [4455409648520865006284, -199426366552755900], [-3191938943054031207256, -182719272449765908], [4525864409414443930224, -33293336758128301], [-438472872714292531234, -280438025808523634], [5512405833379462556662, 170298085717445766], [1731626666429405669378, -400713262046376216], [4669957565829663889554, -308428156194334207], [-2666145361889444799524, -72651509311989718], [7675363500064496510186, -100921104960721189], [1398754274135300903206, 144434675797191766], [-3655910760773567785916, 442191680721299514], [3779395444416116181570, 511194375894149873], [-653023689266419383448, -249163575750647001], [5223270806754563624716, 487504551762127028], [-3628549612134353619050, -513382851689030254], [-5450507698483691602104, -1121712566352543250], [-3302731886153262340930, -1395324705626188896], [-4108483202865547825194, 140771285903745858], [-2909839670952076168428, -1580199560870357210], [-14933432712515618736544, 386287469463320056], [-1041967286669444835546, 1265972558183617636], [-12253089532999210063250, 599327349842133368], [3651932805044885027708, -205276366519385902], [5485222146642608667064, 1325873765216053472], [-3812013322570758626972, 708958440386200542], [-12741506181368020842736, 357960496278440436], [-11020894569932222819576, -469310944608323433], [-1956359837924832860450, -2772188369544493734], [-5796376972924784851686, 194476414247694960], [22651904521411088238714, 371766302976970183], [21492662978602944906756, 787321460379656776], [-4605268600539788113098, 1321825262154484986], [-11455599188812815293032, -3336892773320920835], [22221150920564662719324, -1806903251947255210], [27826190590088555581710, 2235005930264956138], [-41675262010035228156648, -790797129356034936], [18304953239875935706240, -1726687606416375581], [-9655651366009393847762, 2295204644636263908], [-7474348180838862404974, 496701796918009444], [-10262740312577790418750, -2301116659160682769], [7571976364867797633996, 4766226293100143588], [-398404402633588062570, -679516765250367072], [40886772980394343504840, -1508136789816217172], [38345110440457288236730, 260998228021970304], [19551374738944227212240, 1448640322285237479], [1295133748316369699926, 3578522821693855696], [8843389694015252141972, -5335308106867262144], [-24789959992248999030030, -182039647936942189], [14959787950442221244728, -394255967935183827], [51137123406492108873446, 2034861767526120248], [13377369423323994203936, -10078101135897711525], [75728425910601537065812, 4737836909825168250], [91416945851161915825422, 803194325198497606], [-16702090367630284065402, 60303215121625888], [-2342664612043707125424, 435640599760845312], [-78940505522329303835358, 350498943652276295], [-54586485408158539939850, -3536321380024608730], [-15867084452135213075508, 2549823341717319288], [-58893139085880175087910, 7088969667737108308], [-24737257242149325782400, -871872215519794832], [26187100717017689009794, -13857461491082192488], [-119879203341120976676004, -6774038321572545536], [-74810559017814849493220, -7577717353399285200], [-48539822090940859355542, -12781697491944204773], [-9221965281717186638988, -8386090863310962416], [55095922576349771119846, -9442147123906522472], [-101896873169890043248814, 656883504017765600], [-4579923449866225144682, 22734797854064627302], [-30904385709593371455554, 8004485958852964856], [-240653073647915526634872, -3398169174885669956], [159539500777418124540058, -3235573404476109193], [-2825193011374028078512, 12276500339897142881], [1295685975753120504446, -2346335914926484806], [-32114148575819412903134, -8177593048112141360], [-28059288870377755753860, -9269955638609997538], [319689244081354034321418, 2440685967121006029], [126531101017051639308704, 8983536750066966581], [246963325381476261320724, 11821481486911415306], [-103923787337595113787962, 12037608431075228252], [69844177779471753201124, -17122390873277004882], [2739161073915848007666, 40717970666169677224], [393228506275910238690018, -4402222306202641441], [-147619392470723603679416, -2991824774519573755], [-116509231145725381344404, 25063563192501130448], [294167204918393771259688, -12601849419339123442], [141638687369430701484698, -38563279084635875112], [-103835196439994875875280, -9436841926387284717], [-293032377298943377139698, 15058527762769548310], [95171890786291624362648, 38409727863368098856], [40571818184575247085738, 11201591861682518135], [-80651116180504567749010, 6943271031311320018], [-197894479819214599839000, -58073359188292884459], [-81312810566328333586242, 72995553248514348586], [373895072681776263457424, 28325081034534783337], [586402298781190510508580, 13448724329437760242], [-321452057201713830428290, 49973206606516035400], [-386497140179941232085162, 22269261783474975708], [127187509219270691133408, -34563574813856657998], [-616339457354798763649224, 13593387110685529001], [-694126029897691791637252, -19999280245901446820], [-300403308738389393319258, 47973760143385577698], [-169503051452584214438468, -88405672422874818138], [-149281158359621373396640, -18381137586897735303], [106218531189372098230790, -50369844624187273416], [254365790587169003722020, -20672958537176845282], [-234011106943214683926512, -62691458180463683414], [-6937167925072117833550, -13148028357604837068], [-357477333623478328323550, 99507993131308678339], [280655542112959812023020, 28830152846424030646], [30741926913584450701160, 134123812397965502826], [325902541225796431263108, 13604155505388400162], [686306068174719971626292, 26627988674049521204], [-219297604584563717123048, 90851486813557252515], [163247107388590042440454, -50729055703932571648], [165535894496227416535566, -92312462001851721168], [132706593689908884641560, -95908276962401352218], [709522439324328998634688, -101218197745438916425], [-232803826383718823461260, 62184602383346298620], [38760183486537405800068, 63808376356850047652], [42794480387773661019568, 102137739243813984852], [1110830744476753334862486, -21865188338008144926], [44552380761370925143230, 28735062042314414100], [1279583870008571177798344, -21474921268298483342], [398216247101866641882490, 58922141412330099336], [-549468520433992535081382, -145470292414200501927], [293180594402692569002532, -133210792921332172868], [1276637719318935005320958, -68018539011941591382], [162679312640579841464788, -42949819528367215692], [-1120550868720165711354126, -121932498876700039567], [199493671597130076511306, 127617276939569737304], [417124764111760982568736, -98920076716600778579], [2272878720728899017405780, 36068820406259531368], [742289170479378897825358, 89316773236235749170], [-36268314033253100572938, 29462505200585050080], [1100423098382971047927518, 75352961037320992962], [-973500815521121024017396, -88169598776146575556], [53018345810060612713978, 76463487398558421979], [1413272994121528663497334, 132129080968791303628], [-1705390057344874527034828, 45658612597568762642], [884878123192401061872274, -91342901716833523805], [829453916641243827876550, -74471050209160263756], [182630499856677158736476, 185207601234676446156], [-791313632500876142908694, -216689032009100400384], [2384119939045762113228160, -101861311138197970813], [1658194985307703682362642, -49366419016646099936], [-65216315555109589272472, -221266552622346481395], [-3790522345123885841457396, -60383473506105921402], [-1544355972174162504122602, 182543184220290125596], [-388726229241611491813190, 104186595137166071624], [-3692197611740084366055196, 30230765045096935324], [-600340538240194709414560, -196100112651600183726], [-1337616918886243937006024, -68273988946438183763], [1153865795508427652317496, 87725829945265113374], [-1093467237126329718215218, -175367890596567271132], [-2216890711797967396417756, -242427961018832537062], [-719171177719935079211056, 169341743355847393564], [-3867322386332025795340750, -19035862464778484148], [-1983751757050903227340254, -256369850359175408073], [-3616013275005287460447544, 97674116946345000723], [-1574052138231602869249058, 301085284668052799092], [2636781368375375001213626, -283096774920022483189], [993076707485432636126916, -178076166505713728800], [-3934169862184632944223946, 148454173838015694076], [-5267470376113450453352868, -16323112996492306432], [-1495548464898197499457914, 455010343322879037736], [-1537392843818931714404374, 248997370657483858543], [9218774169596964995509760, -23680219850756239347], [-694848395430287538317502, 169009239593091095285], [-1126498703888952051971892, -850056606080463700898], [1053851864278773299263148, 454414155773808616050], [6844295841865694610879482, 195654118145550486616], [-2413964729998730550138854, -274008439941254989093], [1912104522873805472468240, 793088034624341147471], [4294537659456444262317860, 249860625216658630840], [5765422471158624371916564, 378388131932094731018], [-749680047556704328772446, -306382452414956389340], [7263657043473562195885308, 412612223269290884186], [4803484668547233122725094, 577442754062719331254], [-3519722105699718303369224, 146869682522049092846], [-6033349114903474768608754, -839916872165274344004], [4199293125757913431500816, 611228797719396860888], [5850738054099640543239330, -671002478474705105899], [2597686681394077021783006, -625502971600399929058], [-415196454313274080446260, 680459614142798481102], [9517045226948498541436136, -205615085756451236956], [-4792168513342777486836838, -85443334050931032248], [1761509350398949880083716, -1007250744421956262212], [-7289389643034531309489408, 3306803119675765590], [224664346564893728048066, -49621143958321377760], [1509716937508792819645902, 180468457286373410908], [6552342366404854006143580, -694731785701109465480], [4036655131075373580738154, 839431052019561923832], [1918713110768590214251498, -669872390648719309383], [-6367984101924467560404608, 287259339205026476399], [9233018353752787051343846, 1098183861883415457762], [-1160269092460295953194222, -1441843373157446322356], [-338397295882746456671892, -1466926817631099547106], [-822907757842370015208108, 514130216747333819762], [7755155445161248222795424, 110258923564525413008], [4050615217441977687165810, -914507665601394940045], [15127620980555780201866918, -646572464017485494726], [-8689989494343870359965686, -162534460131327751105], [-11990707868403163595462304, -892339706162372389231], [8303561698881074018691348, -1037707736977570984124], [4627099373864212811257188, 1991769335778757215032], [-1183325509440452500680468, -145700990268228096690], [-18281779336983697050703178, 173403900220232983264], [-11185649545132889846881698, -466942001472508625636], [-2702191801590797978280742, -2447462997608450569032], [4835426457335770063810224, 936087820808662645605], [4639639606783351559650846, -2321800383425681357520], [16295271007164124108762998, 444220263604458301042], [-9944957315054266862323182, -959687589702049342307], [-12358222296803397332500008, -993041358120534127831], [3400375303555860631571498, -1842381911339515723163], [3608413122466913047184180, 1069648253994375760362], [-14670765768071735907739602, 1105996096550162374798], [-15253742633082507185892476, -1166848495281515698460], [-5563499385872757747805200, -2226913815881550693010], [-13151829511126081927056062, -96893452012419205511], [18710205533995775835104556, 1662104700599674173138], [-18794896989682430183158534, -416850536056722039476], [28491154362462764406666458, 620081504827208092885], [1133573380627266859284048, -3175478409310475954139], [16190656621653745383877310, -1386295827323337210464], [3323849549847601942124182, 82932657521651362424], [-10085071205101098425467936, -781875019251531648780], [21040533995635236957732796, -177086925261368618716], [-3845649466627970178116818, 1344195488994996788894], [-26476794743765375900297928, -468974737191801039988], [168350311761429524159246, -666660070669851727184], [29734994961655534256246598, -357429650846367969020], [3419522905463478498727824, -2616457435509446997816], [6870424495742184549589420, -3865697756753532322], [26087219662259241656676364, 2153794146144407728820], [40266547773883287819596826, -158472570298537445640], [-8963863606505738968825926, -3299726831610522625487], [53423731767091454572730584, 224332018135504224583], [-35097971092506246785883158, -2709096629335727652272], [-8086559516253410149087628, 4918093529845284177198], [-4357005361109925732290556, 715310536470820016510], [26625745539733776585752560, -1097830189632513232760], [-11091961579744027215832702, -2690752808496652722267], [-48751196676548868288954584, 704220203350841489115], [1866874115880002735754326, -5155609936222483180930], [38900956608870050580829860, -3431786454584926729774], [48189231384489403703628576, -2884583570394586258264], [706359117242075085908962, -1299335896079121943680], [-30453907344880973368158354, 1130370651718741761114], [-255242533402212495895798, 5364331322615393098956], [29296537442194451882237322, -927297755919097077249], [-1413088243150008951029690, 996184827061671665686], [-37860666087553616293236024, -4463899068022073411349], [-61189280479335071146806690, 377092807406537124368], [-28906849614969066797489780, -1875820561792952118250], [-63212811881562212597160792, -1900266739698996668560], [-9330291757573657072505616, -7081497089402166893469], [11409927381158461360017374, 580352701931371838922], [54711002962886843981437492, -3582768394692938863584], [14779176073564947024974016, 6169961043801177386610], [-31164935410976812876105598, -3680298890107295266024], [-48633473287402162068099886, 322893314790323863431], [22028809125379399918794588, -8222121635002274490448], [3826277339647442570681820, -669582659071717357802], [-29232568057608748759782312, -8155558829425775416852], [58879899981773274439084714, -2625080936412040653172], [-14510917079419392232702464, -130391689135526453595], [-98499674536379911299075546, 1728629840812381730658], [-5427146845002359022725308, 7391848964799714180398], [49131171874543513362972674, 2653056298691638159747], [-49249306607083802221621162, -2261465902546488325484], [-21917282564999883806501634, -723302038483993155518], [-29149487460954712204969520, 2635408652596187677901], [20474644351310080007426134, -6469031160252728972790], [-8090500919298362429400334, 12761735211039487071149], [64540332187907448463584184, 891174510538071991831], [-27030239944623070047800474, 1877712042004037035074], [36540458593270769552799534, -1957282859030841365582], [-3705333630268937012090500, -6126405084044846615650], [-27707345170805687798501868, -225613239759334984630], [70978475805512604508185842, -7576551801620369197680], [23621157641786535567016418, -194444649242929557625], [37506059994460967233188268, -411921979512248522574], [64587766348232571780902476, -16001503653706302382], [1148999045287632035325594, -4080293835104539711016], [93912091027735565365857338, 1887768506969299514921], [146397929005882205236800, -112211452714264881832], [5489643118642294808544344, -13881795468056991991953], [42752115865514020560839310, 6869294218064130740474], [39585943014615286124159320, -6134010259932008116818], [-56871475681802108122074710, -4062328004859377790097], [56660682094874901603205934, -7619703621860367169720], [4585732015764237082323952, -171703988951410648228], [-55774344974452242649524596, 3854426955298366789246], [109257485814467715252636730, 6586012064638321103864], [26767950268954289806223770, 13227994920760269950937], [-15734601554002497982418524, 9701132519949025119166], [-27735306499135944267921066, 9862966251009664796860], [159162071317115503676029908, 4529942181602306171582], [-42230851135816764360461512, -15877866487368121440054]]
