
# q-expansion of newform 546.6.a.f, downloaded from the LMFDB on 25 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
    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 = 546
weight = 6
poly_data = [0, 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], [9], [-54], [49], [-192], [169], [-1422], [1748], [-3792], [-954], [-568], [7886], [-14802], [4964], [-18948], [-426], [34872], [-25618], [-67060], [-28428], [-22894], [-1408], [-17304], [-93690], [16826], [-129090], [-5536], [-201996], [32510], [-36918], [-169792], [177660], [141582], [282356], [203682], [114368], [48734], [-18124], [261300], [550710], [-264444], [-31930], [-210240], [-488062], [-165558], [-800152], [-382060], [-303016], [383376], [226070], [1163874], [-661332], [-662854], [-221100], [1129722], [1015440], [1392822], [-1487392], [195782], [-1503762], [365660], [1879362], [1187372], [-539808], [3305354], [1926402], [-967612], [-763966], [-3328932], [2027606], [2943366], [4254564], [-3307864], [2863574], [1413596], [-4391484], [-1338858], [3389942], [-2846946], [811970], [4411596], [5621702], [3354420], [-691486], [7771280], [-1399404], [246846], [-2559118], [-8340366], [-3170656], [7534668], [-3180684], [2092448], [1213140], [-63316], [1060320], [-3461358], [10595634], [2498852], [-9361474], [10039532], [3857178], [1620564], [-4099758], [-826660], [-9546622], [8658288], [-10780962], [-7083600], [15930698], [5972120], [-877426], [-9605682], [818276], [-2739472], [-13938270], [-3927700], [-18507192], [-5057706], [-10381116], [-14068018], [19227938], [-9598314], [-18847152], [-19646932], [-4956642], [-8402602], [7195560], [4225928], [-7644034], [-26271844], [-24631404], [19630520], [-8871514], [19798302], [-8148286], [-7691454], [-24983668], [6193278], [-5090766], [2110988], [-29226174], [10871216], [7790112], [-14952274], [29408316], [25945358], [-27198126], [15564860], [36126372], [-6969898], [-17308038], [-19766572], [500856], [37090508], [40415520], [-12553432], [-8471466], [-21310918], [-27062934], [-23446608], [-32656686], [-47479024], [14748], [-41601186], [52848828], [1097336], [36302486], [62015834], [46099710], [-32800968], [65863286], [-24224352], [-31086670], [-49657240], [28901178], [-21715276], [-36983406], [-58610752], [38457230], [42200528], [60528324], [-61008778], [-32208378], [72425052], [42210246], [9366446], [-30873964], [-42856606], [30409740], [31331954], [23458704], [61729004], [6810330], [-63036684], [3201282], [-76333438], [-5661202], [-7595106], [36802632], [39669810], [-48312040], [57779558], [-39115246], [2941080], [-47776578], [59887352], [-43858212], [-45155898], [-63107956], [-96160606], [-85414602], [37866776], [-61820784], [31135164], [6957338], [-6613552], [-94444926], [4811940], [-62217030], [43913366], [-41151592], [-16712802], [47747864], [106879836], [82811318], [-4896006], [109199016], [97044152], [2007960], [-134657794], [10455212], [34869968], [30908010], [48267140], [-164211444], [106041770], [-79104510], [54255996], [42815400], [-31786968], [9880796], [-26299432], [-149054362], [-127518066], [45669120], [55432064], [-94878720], [52949708], [177243576], [99018062], [37106982], [-188941524], [-17789926], [168259590], [34463832], [-10710970], [-152305348], [91083798], [-126778390], [173086736], [71200548], [-173038618], [-148680178], [-3579618], [-160762828], [-154876830], [11159886], [50919380], [-45391458], [85925294], [63281324], [-178302046], [-4731256], [102284306], [63437960], [-103830072], [65590502], [104710826], [-120805380], [-69472656], [-91253800], [145947288], [71535758], [15613172], [39042336], [133352354], [274613154], [150944288], [-7548918], [281883102], [-60575148], [-85509498], [248998968], [128557742], [182111934], [-110369848], [13517910], [104304636], [-54889060], [24507242], [-48331518], [225102440], [59493156], [-56519164], [-126596230], [234448812], [-363559618], [-235869204], [-102711850], [-26356248], [121907226], [163449114], [-26947468], [310863972], [-254692438], [298835520], [99643908], [157262810], [-57966126], [-343998292], [230781194], [-191408082], [-422525464], [38426166], [157638530], [271340372], [-171031756], [192853344], [-6670866], [-112125442], [385887702], [255780032], [-433348440], [-333168532], [-103486896], [238187990], [-226558506], [397670066], [-388310632], [288130334], [377299986], [-237782910], [-350996080], [-244171422], [-56595276], [189669782], [214285676], [-156088404], [-117480666], [33367868], [56690642], [45076746], [-163451920], [-403600618], [-108928062], [206049180], [153813240], [-107534790], [96208284], [-313974130], [-294741510], [31421208], [-528474120], [34448060], [-263990326], [224934738], [119757728], [-309365062], [544947276], [223987124], [50098860], [-123064026], [37608200], [-530141650], [30618552], [155219232], [169717250], [-466480686], [608204858], [94978026], [-124104834], [290707544], [-396088146], [-220028572], [-217410180], [-32604592], [216071846], [-90745972], [705865896], [-36519430], [-652142094], [-486380928], [335319476], [595918692], [-18445654], [-665017216], [-296391894], [405527084], [677942586], [-490130650], [129479202], [296591552], [-459977994], [248895450], [-468990808], [421511486], [622412862], [-454755268], [-292187832], [138943634], [754787766], [-101961636], [678409340], [-844733926], [93572670], [-160836852], [-332492728], [263078862], [-397222512], [-571364634], [683318702], [491250780], [-765708060], [558068906], [-141031254], [-55075044], [425957094], [346253852], [948147096]]
