
# q-expansion of newform 1078.6.a.f, downloaded from the LMFDB on 19 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 = 1078
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], [29], [31], [0], [121], [-112], [1142], [612], [-1941], [1192], [1037], [8083], [10444], [58], [-8656], [-20318], [21351], [-47044], [48093], [-24967], [42288], [-72410], [15806], [114761], [5159], [61426], [-185896], [-23970], [-56326], [-261903], [87404], [-265122], [245857], [363594], [-55750], [65642], [275367], [291940], [337344], [116742], [-19107], [16177], [685333], [-309292], [-120930], [-915536], [-134580], [-468839], [-275022], [642281], [-1504848], [-304694], [-1271808], [-629965], [-544086], [-1989334], [-1754458], [1658240], [-42634], [319510], [2027348], [-718844], [1981420], [1510300], [-2000919], [-259331], [51203], [266870], [622800], [-2436490], [-1559571], [1919608], [-3612251], [3939682], [-2188289], [-768387], [324313], [-334758], [-902022], [5004574], [3001236], [4562238], [4897826], [-6728757], [3350336], [-7124343], [-2709285], [2413612], [6560652], [-4724207], [2284439], [-951544], [3514843], [-5787192], [1029124], [727370], [1946297], [10313283], [6868396], [10054476], [9857248], [-14589166], [10241316], [-751816], [-7018540], [3363767], [-14058548], [5394196], [-12020376], [-1646358], [-4884506], [3490112], [9120722], [-14663515], [-16387005], [-3268353], [-8328425], [-2496941], [-789105], [-8313926], [4335171], [7293134], [-15581402], [-2169304], [13219475], [-25939506], [3575311], [1958141], [-15535975], [14600204], [-20668246], [11706452], [-12760715], [-14086854], [-23382160], [10957520], [-16933594], [7516552], [-3937885], [-17360900], [-27085002], [35938390], [-505509], [-29995488], [-29694153], [14137137], [4685394], [41284552], [3548051], [-30760536], [30553528], [-42101773], [57164], [11610630], [20985492], [47412500], [40432586], [-33075690], [31513244], [9541470], [22420753], [16898478], [-30694648], [-33566411], [24789677], [-5226059], [24082600], [13260598], [-31350226], [6729761], [3452046], [-39349702], [-34022508], [57281052], [8788879], [-8020761], [-61850570], [53042979], [-47310284], [-25851564], [20898904], [-33834990], [-30263427], [-10130446], [-35676967], [56898486], [-20117780], [42902896], [41165654], [32551254], [-5972089], [58449806], [-21313679], [-53582190], [-13394000], [43835261], [37437550], [5292047], [-32405310], [-27172786], [-8740456], [51793266], [63685422], [53932208], [43636285], [-42812657], [-44450669], [113692612], [75295656], [-43098992], [-2737072], [-21383691], [9505379], [94548940], [81676050], [48288145], [58510952], [8705292], [-71803552], [-46976865], [107978288], [-80459400], [-79696591], [-12905727], [5176192], [-125943662], [6801994], [-94421688], [-19943760], [-72160608], [-33689863], [-71701216], [-130306202], [-8271960], [57148483], [37423534], [64813591], [-2144872], [145074939], [51966327], [77925795], [61241008], [86568700], [127498705], [-82600616], [42528244], [170357852], [47721948], [191563130], [-155852142], [112060160], [-57061190], [-34271507], [87112354], [-56104446], [6305220], [103442902], [-27086282], [24741759], [53299886], [-103316756], [183499388], [65537466], [-44272886], [105428562], [64068336], [204822627], [13565475], [85314322], [-215647198], [95633415], [108490595], [1833798], [193968332], [-52053708], [165615033], [68242683], [2969186], [-73225672], [221073352], [135706012], [-111701559], [-49345800], [-121975238], [-129858852], [58975257], [-148746630], [139915078], [-4355049], [-96045306], [2898045], [82039756], [106919692], [-243720218], [116515170], [258242580], [12746555], [181769889], [328859590], [-134504426], [133716726], [-193218300], [122439012], [120611556], [116569815], [-109252505], [30202539], [-87315725], [-86028588], [154247784], [82684192], [-54175930], [-108152018], [-225552499], [156052080], [61525262], [-92568287], [18426138], [147456526], [-18001464], [247573320], [-322855255], [-112934738], [-295661511], [-317900706], [97345741], [-41430993], [360114989], [-228829204], [90288564], [2740806], [-103550682], [313256258], [52296000], [-281421704], [-259724409], [240765345], [90898188], [-116459791], [274359382], [430689101], [492497063], [-202836872], [420501167], [55448811], [385667522], [247439333], [280461991], [-343257740], [294193217], [-28314136], [-256257117], [445176510], [232747236], [84115666], [186524674], [224746791], [-81796070], [349040130], [507204917], [-319183842], [-11239246], [352489959], [354273330], [-135015327], [-340560411], [334244708], [-47109010], [-514313028], [-262749099], [215625560], [-227505546], [-355277648], [-219965318], [-441363211], [569134980], [521417234], [-177545710], [-341795178], [-100703134], [-168520974], [316479935], [494743258], [587892770], [-436185960], [649208589], [346494480], [15808479], [349166732], [399963613], [356646677], [561872769], [129286629], [63116077], [347712363], [-621945020], [-567370670], [-229747126], [449636084], [580187478], [-263514766], [587814897], [-413077072], [-13733934], [-291075924], [91000346], [-371283210], [-294880640], [-512828812], [546099109], [-238293458], [-824009594], [-182641996], [296061582], [-425864766], [843738647], [-68628240], [-371378587], [-259085078], [-420420662], [595272527], [-203451616], [103767456], [215368902], [119903574], [-710347819], [235542739], [101567706], [-364422239], [-433754320]]
