
// Make newform 256.8.a.f in Magma, downloaded from the LMFDB on 10 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_256_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_256_8_a_f();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_256_8_a_f();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function ConvertToHeckeField(input: pass_field := false, Kf := [])
    if not pass_field then
        poly := [-46, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 8]];
    Rf_basisdens := [1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_256_a();"
function MakeCharacter_256_a()
    N := 256;
    order := 1;
    char_gens := [255, 5];
    v := [1, 1];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

function MakeCharacter_256_a_Hecke( : Kf := Kf)
    return MakeCharacter_256_a();
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..prec]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 8;
    raw_aps := [[0, 0], [0, 1], [-180, 0], [0, 4], [0, -49], [3820, 0], [-15842, 0], [0, 661], [0, 1916], [-97748, 0], [0, 2272], [238748, 0], [455622, 0], [0, 7403], [0, 24920], [1284364, 0], [0, 2019], [-1602564, 0], [0, 43269], [0, 28468], [2742762, 0], [0, -115592], [0, 10129], [346458, 0], [-6841298, 0], [18194428, 0], [0, -222844], [0, 13127], [20854300, 0], [18626962, 0], [0, -53968], [0, 729501], [-10320474, 0], [0, -702389], [2437308, 0], [0, 1215420], [75510140, 0], [0, 1715321], [0, 941076], [14264172, 0], [0, -1777127], [53594428, 0], [0, -518704], [-76586994, 0], [16388076, 0], [0, -1972732], [0, -1043735], [0, -4050848], [0, 5129761], [-111567668, 0], [370240970, 0], [0, -5061528], [-4140290, 0], [0, -1771629], [-134765566, 0], [0, 710836], [-167903076, 0], [0, 1025832], [-417550804, 0], [-71984166, 0], [0, 1324679], [-678092340, 0], [0, 1798197], [0, -2557796], [-977284778, 0], [8520524, 0], [0, 8659319], [1013777138, 0], [0, -20797845], [648421516, 0], [346139746, 0], [0, -20285436], [0, -30595752], [-1188848020, 0], [0, 7196027], [0, -5744576], [1807811708, 0], [1906921276, 0], [-773205730, 0], [-1381564106, 0], [0, -52023787], [55988588, 0], [0, 13437096], [751243838, 0], [0, -57871716], [0, 34935039], [-2276891122, 0], [2291817446, 0], [214064028, 0], [0, 19060792], [0, 54059325], [0, 9159776], [0, 67741652], [0, -55349997], [0, -72903551], [0, 15129708], [1252936092, 0], [4465012902, 0], [0, 58360183], [3931460828, 0], [0, 117395109], [-419131892, 0], [0, -146488539], [-3463818922, 0], [0, 80625839], [6149458818, 0], [0, 20249375], [428953266, 0], [0, -133607028], [-9222336166, 0], [0, -106143632], [-10753931988, 0], [5820771466, 0], [0, -110274785], [0, 123214060], [-5463654066, 0], [0, 63091269], [0, 192277236], [-1210621988, 0], [0, 146004993], [-4624945060, 0], [7571115758, 0], [8360670044, 0], [0, -139627837], [0, -215004023], [-8617439044, 0], [-5638069060, 0], [0, 146578200], [0, 112503500], [-9355269844, 0], [0, -19907407], [0, 303653972], [0, 290600200], [-15435151716, 0], [7002893078, 0], [-7662677426, 0], [19243812284, 0], [0, 438484713], [8060440124, 0], [-11969623610, 0], [0, -32519521], [22921140396, 0], [0, 251527324], [0, -354875881], [8102478172, 0], [0, -251732508], [3838403564, 0], [-6182697866, 0], [0, -144092645], [0, 321869504], [36817883836, 0], [11501293522, 0], [0, 284595965], [0, -364850916], [0, 596974595], [0, 169549704], [0, -320428260], [24111226094, 0], [-15810460150, 0], [15075091228, 0], [0, -647698683], [16152847446, 0], [0, 419460708], [0, 626759395], [-8649350178, 0], [0, 738317036], [0, 381225872], [10184905628, 0], [-22457031426, 0], [18961098108, 0], [0, -708222577], [-49436333844, 0], [0, 604598484], [-22240117142, 0], [0, -1117419512], [39014057434, 0], [0, -830210285], [35508633340, 0], [0, 369664820], [-40155654484, 0], [0, 1072215904], [0, 321855169], [-16600363956, 0], [-37041177558, 0], [0, -197949624], [-4402774276, 0], [-69667810500, 0], [0, 659119481], [2790197894, 0], [0, -435344256], [-36365687998, 0], [0, -964933445], [0, -1144417763], [18104456940, 0], [0, 106611273], [-50097009078, 0], [-85806971566, 0], [-110084547428, 0], [33618330690, 0], [0, 916252916], [107918515692, 0], [0, 421819096], [-108240833972, 0], [51336720162, 0], [0, -2819673], [108851040876, 0], [0, -1989560128], [0, 1065445241], [-152419246550, 0], [0, -1564225985], [-30241847266, 0], [113827912476, 0], [0, 2315124588], [0, 936227247], [0, -420049356], [38745213894, 0], [0, 314606248], [-83846843682, 0], [0, 196330572], [141320166188, 0], [121330699148, 0], [0, -641985012], [-12184023218, 0], [0, 621259480], [0, -976399099], [97905366988, 0], [-70059819750, 0], [0, -2797057040], [0, -1643558620], [0, 2672681371], [-77930730244, 0], [0, 2745763565], [0, -2006726816], [66919681194, 0], [0, 552574931], [0, -4373030728], [-187054118050, 0], [163834657948, 0], [0, -2747372953], [0, 218618868], [0, 2780740529], [0, -3361619865], [0, 162190164], [33528488524, 0], [70960101170, 0], [0, -1986079092], [0, 2069638496], [0, -3433452483], [0, 4408459315], [0, 3272424104], [-7081358484, 0], [-308124592766, 0], [0, -2460639660], [-90789725718, 0], [113572899708, 0], [0, -3561857479], [-78615027780, 0], [0, 546540259], [-160019623332, 0], [-210784798186, 0], [0, 224266112], [0, -623365263], [-247341732, 0], [148818139532, 0], [253473045102, 0], [0, -2370982939], [144682516572, 0], [47000442, 0], [0, 1105462643], [-16756099492, 0], [-261103724756, 0], [0, -2537223731], [-328083175910, 0], [0, 5894318640], [370431233618, 0], [0, -4607716788], [0, -5582539449], [362601454364, 0], [192545187370, 0], [0, -866030811], [0, -2022981504], [0, -5488275452], [0, 2392033740], [-105985948788, 0], [0, 2495715723], [0, 5388307144], [116137484894, 0], [-234446470356, 0], [0, -8165779332], [181949982306, 0], [-241199380100, 0], [0, -2453324267], [506117077946, 0], [0, -2999784657], [136770079068, 0], [-552206933284, 0], [0, -3559221856], [402019155996, 0], [0, 4778699895], [0, 12426114109], [180832244326, 0], [-333974708052, 0], [0, 6206558216], [0, -8691349839], [0, -695505593], [501859920686, 0], [0, -10000737041], [706028265580, 0], [0, 13590427068], [37593273148, 0], [0, -11759083224], [223089343900, 0], [-592575602322, 0], [0, 1802287133], [0, 3922239028], [63197104522, 0], [0, -5599071135], [0, 1448444480], [-58390734398, 0], [221553005234, 0], [0, 537613473], [-613795893130, 0], [-21292863732, 0], [0, 7013290352], [-301573688314, 0], [491284693502, 0], [0, -13616505183], [0, -12246529281], [0, 7673045824], [-605195374644, 0], [701512642572, 0], [-89927651700, 0], [0, 131305472], [0, -6080798635], [0, 12257186115], [0, -9831664653], [962547355244, 0], [280509538530, 0], [-143712561142, 0], [0, -12053275112], [-469223458052, 0], [494966544150, 0], [-333171139972, 0], [0, -18569884076], [-672325161444, 0], [0, -5284315671], [1067584758444, 0], [0, 4188418895], [0, -9826146776], [-926539374692, 0], [0, 13766748505], [-670639335194, 0], [-387491357012, 0], [0, -10389727080], [356966116476, 0], [-296322012774, 0], [0, 4992931504], [0, -20402341365], [136733629310, 0], [0, 3029194524], [-471321225700, 0], [-648155299414, 0], [0, 9646051560], [0, -12770447493], [0, -20559499327], [943088061514, 0], [-1014267677364, 0], [0, -15237656684], [-442367529482, 0], [0, -12429459579], [0, -10732182001], [0, 2834187832], [-387242280660, 0], [0, -16422993140], [-1178502604916, 0], [0, 15290576905], [0, 1541957280], [168500535010, 0], [1340434420670, 0], [757292193750, 0], [-1187602432820, 0], [-912783353498, 0], [0, -23508007108], [1086526685346, 0], [0, 14599166833], [0, -24304171932], [0, -1775086248], [1065118197452, 0], [0, -17339426557], [0, -14896496160], [-4628087486, 0], [-450463994948, 0], [0, 297419559], [0, -13233281807], [0, -11517724212], [-49695411402, 0], [0, -18953343952], [-1899266771258, 0], [0, -21171727133], [-742464311828, 0], [98820880364, 0], [496151916558, 0], [0, -2732246056], [1079631467382, 0], [227425813484, 0], [0, -12969913724], [558340470028, 0], [1470947997310, 0], [0, -21075344751], [0, 16185899261], [-1531495133390, 0], [-342266493108, 0], [0, 10990161011], [0, 3943347441], [-597486092086, 0], [762991085452, 0], [0, 4316787744], [0, -18403739404], [858673762014, 0], [0, -2884453876], [1293794839004, 0], [218542803580, 0], [0, 30316584664], [0, -36851993845], [94078583078, 0], [-2672013030708, 0], [0, 31069633037], [-2003870600934, 0], [0, 43819447367], [0, 21796519004]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_256_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_256_8_a_f();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
function MakeNewformModFrm_256_8_a_f(:prec:=2)
    chi := MakeCharacter_256_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_256_8_a_f();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function MakeNewformModSym_256_8_a_f( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_256_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<3,R![-2944, 0, 1]>,<5,R![180, 1]>,<7,R![-47104, 0, 1]>],Snew);
    return Vf;
end function;