
# q-expansion of newform 576.8.a.f, downloaded from the LMFDB on 12 June 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 = 576
weight = 8
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 = [[0], [0], [-210], [-1016], [-1092], [-1382], [-14706], [-39940], [68712], [-102570], [-227552], [-160526], [-10842], [-630748], [472656], [-1494018], [-2640660], [-827702], [-126004], [-1414728], [980282], [3566800], [-5672892], [11951190], [8682146], [-10079538], [-3747992], [17985564], [-12257030], [-16594962], [-1168256], [7923828], [315654], [39203780], [-21886050], [29415448], [-60554966], [57085292], [-87726504], [8569542], [-18804060], [59962498], [93986112], [-35194558], [102985326], [-83637560], [-97401028], [14645728], [184540884], [8754610], [119556198], [396209040], [-256606318], [73477548], [202701054], [154254072], [-624018330], [387983248], [-453952286], [-333769962], [537694772], [335600142], [215028956], [792061512], [-118457398], [-50730954], [273756932], [-91851214], [1367004684], [-1131432470], [44839518], [398280600], [-1634717456], [1546331458], [-1056882220], [224909952], [1017882030], [1475652634], [-274912242], [-1634272150], [1112798100], [-922528142], [-981507888], [2849979602], [1056218680], [-1823254932], [-1848459330], [-2980660294], [-2527807578], [890290768], [-2656667196], [1300933920], [1074466024], [783344028], [-623187940], [-2709270648], [3499434870], [1376833158], [-2861538748], [-5344671062], [-3371346964], [-5611058874], [-6696895452], [-1968501450], [1029257492], [3311792066], [559410684], [3024589518], [-5632460760], [340791722], [-3854196896], [-9222445262], [-6536112666], [1365585380], [-1540786952], [4540181118], [11405383052], [-12639339144], [-10500443418], [-9648179580], [6582986338], [-8546489758], [8713048206], [-14610865572], [-14734767268], [1315018422], [-664028270], [4950344880], [-8811008936], [149413738], [-4708057300], [1696762392], [-10664999312], [-6228758846], [8383341558], [-11864884990], [5566800942], [134611196], [-7415475114], [14154174630], [-26370790108], [8062640382], [23420185528], [-5557221396], [-28425575990], [10403565240], [18058024738], [6340342614], [12148877300], [-28711114848], [-24602117126], [12537766638], [19309723292], [32026812936], [2337034436], [22034303472], [14327739160], [-13127971170], [-38762629414], [20627937222], [21170525604], [-21487568202], [-39262517816], [56264662908], [8434369614], [-22422959448], [-34672761632], [29647405234], [25204552850], [38304931902], [28613746860], [19612034698], [2603909112], [-17628345478], [40734593680], [-41253294570], [-27206017228], [36077870862], [38998034728], [-14282848070], [52450122304], [-7265419212], [19062457618], [-71883292986], [-61513380048], [54709387230], [72293908714], [44375799212], [19586264090], [72547143552], [6587199362], [57010802748], [47431522172], [-93201751338], [-40810514796], [-45141655002], [97393786322], [46721325898], [3265908414], [82977485112], [-37095064410], [-18435887792], [-70643591006], [-88482466270], [31373989020], [-145489180554], [-133547098880], [-40579541772], [-78517662330], [43530649412], [-9151955854], [7800874782], [-95098568552], [-7333113396], [-22516052520], [-91193713318], [126816224944], [116621470158], [-172647572184], [85118113302], [87317232178], [37457154040], [21181027710], [-173507770352], [52005656964], [70138986850], [-10114036842], [-140715315360], [-132168579416], [-200783968932], [-67735365062], [165695367260], [172732301248], [-57396093882], [-97474716028], [-96757425744], [-36909717070], [145695907422], [-7514785140], [116421627672], [171892612068], [-158260609708], [-20626746872], [140763918490], [81289527438], [202234656360], [-200870257376], [-174760865772], [84862482980], [19916849232], [-263710614326], [48948622398], [-129854917704], [291081125690], [-210950395098], [-152791812540], [31348744738], [8281203956], [-62565032754], [15700548746], [-51864624512], [-147853885836], [-179296587950], [-142905561302], [313323755934], [-290037000340], [-205482728250], [96747264438], [133763912852], [322266468462], [187077952858], [357045760316], [115688864042], [348346478560], [179908527506], [-315472831112], [-124472220756], [-19606769270], [313259827322], [235815981828], [125551921632], [211839280168], [48492908616], [-66158581742], [106794433796], [-148458003408], [-494945614798], [-226143599394], [-41261198120], [369907091550], [-414465613818], [-58856594076], [-556398038922], [7270073148], [587366400538], [449140242390], [-188460621152], [-63420509058], [527888120940], [-105178495924], [118114493882], [390063868326], [490291066960], [553223098308], [655645606772], [237584641826], [-365745391716], [475960905850], [-90690209400], [-90946936622], [-59974301328], [-494575795170], [62548578078], [674074004972], [386276037336], [-260270932390], [-490769665500], [125735174592], [465970891202], [424250190030], [-206633891908], [-358267609174], [-81770425578], [-391564544672], [812488054758], [681118966802], [-242124775540], [-315818034508], [-41464150944], [82403955342], [-180814252742], [709411293366], [-522841175360], [316683783348], [-1019896095868], [-368061944436], [534410175850], [566715653598], [-560810745958], [288720141424], [84906558658], [563029563894], [-356792336850], [-764499178232], [-192125264298], [875698696980], [-262085411342], [-557885774044], [282104534352], [-111181495554], [897365109452], [1170045749306], [353227546662], [-776302744112], [-780069575390], [122470235478], [-954226282080], [-182432454372], [-1029608418066], [-1376781587448], [110041109074], [-799526803962], [-348888747024], [142765520460], [407897781356], [-487157108518], [690371459526], [652281191368], [693825221162], [375202383828], [368309716580], [-1120039859568], [1307697300030], [805416122488], [232108358794], [-574806444540], [26766212832], [-196567115038], [159616571310], [400704899786], [-1338057814218], [-967136870202], [-1604628975656], [18361844574], [-459359359060], [257582978712], [-769207799312], [1046255246914], [723508132052], [206872492416], [-1328148964990], [335041625262], [668233459260], [-781071089284], [-19509318168], [1383481551722], [-659699331680], [1436478333990], [100758459812], [-1508879472258], [816810404170], [-543595773762], [-810926668976], [1216609318614], [461567373390], [-666528424472], [-1743647911046], [-1298443822482], [2029635768092], [-1833591575820], [-280430443918], [-1817453147874], [-1608458516532], [-1963432441108], [-2182294637734], [1148104773702], [1568589117120], [-988542510776], [-809549234226], [-874485553368], [-557781133290], [2616857237554], [-25883011824], [-627472431060], [-52110226438], [1351693640166], [1187921108868], [-748110462570], [601440810932], [1322158032840]]
