
# q-expansion of newform 7.16.a.b, downloaded from the LMFDB on 01 May 2026.

# 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 = 7
weight = 16
poly_data = [-586980, -167250, -7385, -2, 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], [[-556746, -51090, -101, 7], 1138], [[-12683370, -645910, -655, 113], 3414], [[-18093066, 112250, 6473, -43], 3414]]

hecke_ring_character_values = None
aps_data = [[23, 1, 0, 0], [2138, 3, -1, 0], [1886, 226, -31, 31], [-823543, 0, 0, 0], [23842482, -267531, -11072, 9263], [178278178, 348504, 24063, -6513], [644257010, -389732, -139286, -214738], [-1052178918, -15306281, -302135, -249034], [-3206869862, -26420761, -691930, -3147173], [17085464638, -278077432, 25460814, -11453322], [34246995272, -213251552, 28723990, -8764474], [1711022298, 997026102, 56818386, 19249092], [97151170630, 6070223942, 19680106, -78438964], [462898327534, -3387772961, -142586960, -60317059], [2636571839364, 3359305458, 622547334, -105743412], [-792092448278, 70243706, 1458528596, 722830402], [-653994659818, -51868939691, -329200883, -3169938124], [7855586185662, 47458748182, 1291816825, 915751379], [9307432425186, 10421356453, -15649644158, 1578166001], [50858481548636, -86281850738, -7795465760, 3776566250], [-32547047851886, 47122608500, 25177597988, -2584584032], [-72821639044376, 917274140644, -16624190828, -5596603936], [8303630688506, -24572702345, 17866413757, -3063184534], [205778675027750, -547925848406, 30356678060, 51130152298], [240652663279966, -904125005938, -169795547194, 65018448544], [163932850890266, 1103114872828, -75734333067, 226069878657], [326659557243624, -4773891041092, 239609715818, 21426295054], [135095648633834, -7002063254987, -207768521962, -13709330027], [-1074658272310110, -1359688411626, -243095089650, -143960319552], [1954853117240600, 5835858253465, 416096835872, -198327434693], [-598292663166902, -5975060022349, -868335403582, 1025217360955], [1921844518486218, -1631232514593, 379766629873, 12837544118], [3406029283290970, -36101379185224, 1373587103300, 102310250188], [-2780331097008994, 19702919934109, -643556457329, -322473138178], [5775107579502414, 10789308111360, 900383140764, 2615646919356], [-5350097399689610, -26351644086143, 3953275884742, -2436541991959], [2848029255221210, -158955520616188, 4277225662559, 342214294195], [6245644706541830, -116459882829961, -10759553737912, 6580200957085], [-17131373900983932, 172075580866374, 4279391936770, -8048401018204], [-8733797700822206, 51157178323328, -2023707545909, -4525167257101], [-50081006311270310, 288959978269481, -13862477006210, 6272343481817], [5517970791163158, 71005185639106, -253978767053, 10695983309441], [-111488787150812660, 39559958440970, 28442524893288, 6309355622502], [117196645448492708, 212460200503779, 18891849345816, -12230195203983], [83743976754538650, 95501069515170, 10648094468992, 5267637040646], [-24961178524504128, -804653080776024, -188221424658, 4570271664630], [-20509999975040558, 859627808978565, 22876220784810, -245932838535], [-137238883190096588, -512205488475810, 24291916258296, 67928995792050], [-225760865256982902, -779041046881401, 14927902338105, -87217483972554], [345860212668689002, -84123824538176, -87152380375829, 26603962866131], [176241183554703066, 475771823079456, 41781687397800, 9562566642888], [-605057268709075570, -1144267708419167, 111350484416242, 11005275902741], [82257362510568310, -696149438085590, -7645729380266, 79830689627972], [385287522763336134, 562475007530409, -372927575802857, 65030546991146], [-547337066846532678, -1973779526518668, -68052764251600, 145027434957388], [560842923372650428, 964021907683214, 299941969710336, -50680625198838], [723199083179501242, 2838634600181060, -14731148479645, 21010552831063], [-1034661467139488060, -188342736058554, -42105442708140, -222729354947226], [880705333117114294, -4038661055018028, -7862183999976, 366528572275476], [1285231757396928890, 7745763269865448, 245512581632448, 81950979478008], [1612483583435973662, -2526025351148167, 163879796401445, -110431146737864], [2957270976348330026, -9467618582402708, 232028047801137, -33977791366995], [3402720261384184826, 4081060936695983, 32727683195057, -615092465918234], [1086008139865906752, 11069829007783980, 1179733083476976, 271938349693620], [-859877208674840706, 13693880727453986, -919359916987198, 1169465804211640], [-733901915724609486, 12106765551643338, 130615136826960, -639915673628082], [-349589357488580034, -5179690713101929, -128488576504240, 345801070217413], [-3675398173731908572, 275031123948443, -776640931402528, 1697092019591329], [-5334356407853529562, 3388349291716459, 1904424949783200, -717771098680239], [-3361636333919328482, 46831028170162146, -279293701767393, 289124773345389], [-1613622192604838426, 30836994388207502, -1843142105425044, -7744604147178], [-13749035111663049494, 7854826954932335, -181532788602062, -1161260129733601], [6192366114528616196, -15062982579308018, 3060797882787712, -2218333464263926], [-7684618732884478658, 1305195073985464, 1409744203119244, 2688713628635348], [-2492195201907391874, 95171490777910631, 1219002846697244, 1409658809350561], [24856064324748192556, -3723038202590314, -2314582086307426, -1250393919979952], [6065776730070264258, 54446185641074130, -2466775652537406, 1300552715452872], [-32526306923108824354, 678885847514842, 1906985033792143, 1620609903708869], [-11332202641011342424, -79595174597766743, 2350297759944820, 763922760050975], [11852308873228487690, 16836657339176388, 1396010191452282, -6891222710769354], [36343338992394513522, -37438969286952033, -7281419375387205, -1038939210768528], [860429063273058894, 225876852263148752, -10385964041665672, 2718323738956072], [49144323238801449402, 131374932640380843, 3515993581018590, 2086093863308511], [16535514443926266722, 305236410660324380, -873455610064186, 7625216651248810], [-37975950324198394724, 247118776170466478, -3356872048863988, -8599915523945450], [35621684002136301718, 153764898870630383, 5702754446323982, 3561725550619675], [50418152134958120946, -67742387256674472, -25325920192149288, 1510546685577120], [-7830189817628290756, -14965710727677853, 5000775523575320, -14309217877385999], [32592729054284470062, 198121529605605210, 10196798396547419, -11901403084208975], [-101674236084939410316, -62938131247585802, -5432604406579556, -1667174272671106], [-28586671021725456470, -177943251073434553, 12939667869369941, 11423750611291570], [46774381081626038128, -125068435667436052, 1607903482773502, 4617770953592978], [-68649321387925570182, -307051840976309345, 22692287447547814, -17683188807637117], [-10321501430459541722, -113282380196098273, 17497443320424454, 14102643869043683], [25771741611794565190, 59392265744394459, 7561264810316814, -20575996248892257], [64867102521744518556, 55456616996069718, -27699577309272312, -10637196705525078], [142934505368241066886, -729398510557038466, 35547362528414071, -14418074339884903], [123330241979875326410, 745297006739590708, -19976681022678722, 8582025753775658], [-14630536873793992378, 5007467153833085, -19353342830319847, -7721654374889000], [-158811367680412597066, -335973198535527864, 70566035401533300, -13961936625799380], [-64844307964595055754, -1009290998844661993, 29572540141632884, 53353291680769609], [-62064840625765819070, -451118960622584470, -69169951274048856, -16455255453395514], [-103098984241401816606, -84720419550121185, 36958351151636695, -21732427892053972], [277311910270563667744, 746024033456115593, 27265042451032476, 54843838090316967], [-153145879888777521002, -1411627492466627813, -72202454869565300, 69087658163834093], [-46090897601853468146, 1178805727522739658, -8506336817054148, -116558338455737382], [-389493858570966732002, 1107388047770126549, -47433459560176557, 69668943723279306], [-175500906472666579774, 1427622554919501712, 20928582746601268, -97399136416543420], [-79858952622596146400, -957644726684398900, 158394266571285680, 32700510174428500], [-323940081177666969826, -1365473561637183122, -538375769034092, -49426174024087906], [-139332867558320907408, -153325067548043752, 193222949193842336, -18567207731916440], [-330002994816294974378, 1871386668264697992, 179090477510714478, -50646063002061546], [332686094539249133948, -1148344525435805501, -127869482934710480, -38877023803454359], [74232086347707580166, -423410765301029971, 53395804388503949, 104174878864129852], [49832688218649882816, -158238637301673484, 147845989759642532, -51418287307801952], [-274467722877099198440, -4041223436182185655, -191509543643750116, 94394878454878567], [19015454202887299210, -1443078995622467741, -55615044133198625, -50543380790625280], [445177625272546134224, -4851927673428687728, 235878630288149166, -113089392895232274], [426601740721395838486, -324631112845555108, -72397516317886198, -106118442861107570], [554682869619853233326, 2419003830137447683, 33258696466333108, -90740127563698675], [-1312564370099456564966, -5568569560506185028, -190814693229027927, -112065245982335403], [1257408037927607070490, 4216538439783478572, 177277572736348884, 204511461372354936], [1523171473936903342, -1718931573807774514, -27016335552111757, 458024245629592741], [-257944120904084937638, 5967949146626314997, 168035126249734970, -123282857369199911], [1143638377750609600674, -7931642934930177013, 171289050878974193, -88203594330463238], [-1552222309325495070890, -1525667385207263548, 197042012830750994, -204904324592785394], [-1620004433668177974030, 3916031453488843242, 46424669771568354, -242201926569227856], [-1862592999513273790220, -3615709142356922110, 90254959489902530, 112948186971278680], [1088258892527784970604, 11704675435467972306, 11795246479459518, 148422665521898724], [1178798461315292941614, 6640200660422688462, -306195971483415087, 227508152594743827], [-1402601666154633695450, 1406947803231519623, -379837230684928696, 519807774896668621], [-2130096892551106463934, -304366604983488957, -61561520614348734, -69907596454399893], [303885218468989452770, 1366400195413666919, 938596324862118470, -337569946723457285], [-795221386161872946482, -7624687402969395020, -274489305233158994, 385925037219261338], [2308543010661633546782, 9382886328812802106, -738261937882310450, 164334831043481132], [4259222286978117915070, -11749071432782800538, 659817642149760370, -312809396607138316], [1780707105836282176134, -2782208345368093818, -179683524296969611, 454933878603568447], [1338848924434581951786, 7998893485675196023, -330607821143205635, 332532775875918506], [799658789556707321074, 11536032210572378336, -1358285425851420573, -533101600869085461], [231595386958129937868, 1122018214413308571, 871353065756820768, -553916491377121311], [-1777715787258053674666, -5153934114443257923, 706181292684108753, 159417587062668432], [-3755303783418747270842, -4224660382341068452, 1820604793429531984, -42008506853823580], [5732007441263037330300, -7283565180191035938, 464832269054095236, -172484370543155874], [-1707135621098257810654, -4366785556590174095, -2072304374875595378, -187680848705523775], [-2888762923446067249874, 28593144827166800686, 1063468326936280561, -1381199918710113709], [-3107564230575424756440, -22592319106706432628, -1572436260465065294, 802353304839966854], [-213410933633901410038, -25426415033336782392, 727975861838162139, -566321451769448229], [5196729031965324938482, -18368976390830176144, 1587672121582688418, -452444406704715294], [-4069985464760032880466, 7193277712055325989, 3132759277951996175, -452679636584224106], [-3726374273318852209500, 3547551791242985982, 317552907173949720, 583054291334298546], [-7675646819702650243238, 15243206633489477346, -3815903505553828662, 2686729974170126016], [6219577706432385312374, 16457449448185938262, 4034988354162621856, -2607134140746994558], [-2471819866442870772938, -21693141954003334757, -2227710261613879766, 44712117770438171], [4937138647351865627116, 5945787014132297474, 173177360447937094, 1106482118175118268], [708052464987227119542, -35137037730935995825, 615791448429521618, 2309426216549761759], [1624093317235523106374, -7538434386478921763, 947139951509295142, -4235152722958551523], [-58479565485980857332, 8089690572646391702, -1148314889035419436, -2840529532019647274], [12328009480215915507498, 27446650124884993896, 1607668320169820282, 2801376260156627554], [10276966390261815960090, -3805605481996547424, -4346448059841757812, -505800853091134452], [-7453161377441389536062, 48456272741245661780, -3428632064131589795, 3505731166753114289], [11432329560496866740574, -7123360712822000373, 1645362632137561484, -1721046120714491459], [-3050200734969023940238, -31986028783820686244, -1887534666013659120, -2317515055539873948], [9196466405685143876386, -58233587396455750149, -1038343076443765098, 3968279373651112647], [-4830092613247287976010, -101909387387001304627, -885862212857520043, -387451321804940252], [4543293371796811374154, 48907546965534455564, 4664650859052022316, -1597976848279488080], [23407632955203769990392, 21495677495347487820, -412427561520519630, 1320762271940572230], [-5602103650553278220128, -53206253814018117480, 1830993286920522024, -588754265826789840], [-20419251704912481047314, 34907801873618234498, 6470793350422760261, 88868155951490371]]
