
# q-expansion of newform 1800.4.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 = 1800
weight = 4
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], [0], [-20], [56], [86], [-106], [4], [136], [206], [-152], [-282], [246], [-412], [40], [-126], [-56], [-2], [388], [672], [-1170], [408], [668], [-66], [926], [198], [1532], [-444], [62], [414], [996], [264], [2278], [1812], [1534], [-3016], [1814], [1844], [3768], [938], [-3968], [-3514], [1480], [2774], [-3806], [-856], [3020], [1684], [2004], [-5042], [-3090], [-2136], [98], [5040], [-1986], [1416], [6670], [48], [-6938], [1694], [6364], [-3134], [236], [-3776], [7918], [4362], [7980], [8294], [-964], [8670], [-2314], [1896], [-1484], [-12370], [5620], [5880], [-2082], [1742], [3270], [-6134], [10392], [-12690], [7408], [5062], [-7160], [17100], [-8634], [-2986], [2406], [14316], [-292], [-14056], [11204], [-4608], [2468], [12192], [-1714], [18014], [16748], [-14018], [412], [18218], [23524], [-23330], [-13124], [-11714], [-17628], [-2802], [2664], [23962], [-11940], [-16794], [-20706], [10724], [-5744], [-27906], [-20556], [-10224], [-12982], [1512], [16710], [-7962], [12226], [-8748], [-7324], [21934], [-10690], [-13792], [24004], [-8562], [-13836], [-22224], [11544], [3814], [25662], [30658], [-30894], [-21596], [-8646], [-24954], [40004], [-16570], [4388], [14364], [-21170], [-10664], [3190], [20814], [-18988], [11664], [8246], [-22890], [-33548], [-32264], [-51228], [2144], [33584], [3590], [21686], [5174], [35524], [-16122], [-19188], [38464], [-43930], [17328], [-18160], [9102], [14306], [-5710], [56056], [-12170], [4360], [-8450], [31400], [31806], [-60428], [-21170], [-2668], [-62474], [-8756], [8952], [25558], [-5018], [23864], [-33698], [-36170], [2308], [64490], [63080], [-18314], [-36276], [380], [49318], [46108], [76454], [51666], [-7578], [-10066], [29552], [77238], [-63992], [29374], [-59694], [-23160], [-37318], [20104], [-29084], [40398], [-2356], [47414], [-22322], [-31604], [40044], [-16672], [-74262], [-58780], [37702], [12432], [-62438], [-13330], [-84680], [92318], [-25284], [-67380], [28990], [6662], [4768], [101524], [-105272], [-54442], [21852], [-12400], [68030], [26940], [-94608], [-41070], [52530], [94040], [-38160], [66772], [52252], [41588], [42094], [56534], [-96800], [-94828], [-80240], [23548], [-106528], [-94386], [-21250], [-48024], [56810], [8762], [-10968], [-35242], [2412], [82866], [-117906], [110324], [-83020], [31518], [-54722], [82622], [-93836], [-56602], [-28026], [45708], [-99614], [-29530], [9164], [2814], [-30040], [-31322], [17932], [134956], [111758], [133370], [-120216], [-50400], [31656], [-101776], [-63698], [-57004], [127064], [29230], [22674], [-67704], [4062], [38726], [121884], [69726], [-125928], [159134], [31926], [66680], [139602], [27848], [25212], [52638], [90954], [-69280], [-139300], [-102996], [40526], [-121788], [-83786], [5376], [88414], [107584], [-65610], [105366], [-14260], [-154096], [-11798], [55616], [-75048], [-104986], [-89698], [169220], [-125714], [92958], [-22612], [6334], [66018], [-163652], [-123212], [143576], [-510], [29318], [-40454], [-86984], [-37748], [-28172], [135348], [26342], [172038], [-129062], [-201564], [42814], [-109458], [-73402], [181832], [-127958], [-221920], [-60002], [119636], [3480], [97842], [153676], [111414], [-110242], [-196028], [-112090], [-482], [179664], [198056], [-82322], [64088], [16174], [-156442], [-81304], [-79320], [24516], [-48346], [87546], [135916], [166922], [167232], [-10876], [5480], [71718], [35976], [-210866], [79680], [71776], [201838], [-67914], [-45962], [-101738], [5350], [-68436], [81990], [-33300], [12952], [-101336], [216006], [105828], [134224], [187522], [-19614], [157848], [37460], [-194552], [131686], [-117904], [85734], [-165028], [-41106], [-168042], [-138066], [-203500], [-31434], [-244074], [131904], [-263986], [9414], [-129100], [230472], [-96802], [-250158], [38852], [110116], [106286], [226158], [-159520], [97196], [248190], [-153720], [24150], [8846], [-5672], [-102736], [-209010], [-27030], [-153636], [-131946], [-191332], [-45752]]
