
// Make newform 882.6.a.bo in Magma, downloaded from the LMFDB on 07 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_882_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_882_6_a_bo();".
// 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_882_6_a_bo();".
// 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, 2]];
    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_882_a();"
function MakeCharacter_882_a()
    N := 882;
    order := 1;
    char_gens := [785, 199];
    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_882_a_Hecke( : Kf := Kf)
    return MakeCharacter_882_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 := 6;
    raw_aps := [[4, 0], [0, 0], [0, 7], [0, 0], [-476, 0], [0, 71], [0, 66], [0, 47], [-3696, 0], [-1394, 0], [0, 142], [12090, 0], [0, -1122], [9724, 0], [0, 2158], [-4310, 0], [0, 1537], [0, 685], [20236, 0], [-29792, 0], [0, 832], [-33176, 0], [0, 261], [0, 5216], [0, -1310], [0, -6629], [0, -598], [-125908, 0], [89170, 0], [29702, 0], [-243112, 0], [0, -7899], [332842, 0], [0, -13755], [202330, 0], [345760, 0], [0, -6109], [127476, 0], [0, -49486], [0, -25639], [625236, 0], [0, 17803], [-212952, 0], [135002, 0], [-548838, 0], [0, 46582], [-159940, 0], [0, 64636], [0, 16109], [0, 105263], [429418, 0], [338328, 0], [0, 39562], [0, 40459], [0, 125024], [-1966160, 0], [0, 31837], [0, -43552], [828262, 0], [719130, 0], [0, -156593], [0, 23127], [0, 208099], [0, 32552], [0, -104934], [-1253598, 0], [-3382228, 0], [1945286, 0], [2082324, 0], [0, -232785], [0, -188004], [-2434672, 0], [0, -319316], [-3664346, 0], [-1243524, 0], [0, -110970], [3859302, 0], [0, 244763], [-3693366, 0], [0, -297990], [0, 178687], [-6656394, 0], [610520, 0], [0, 2210], [0, 27264], [639036, 0], [-1906818, 0], [6600386, 0], [0, -363507], [257576, 0], [0, -39955], [0, 463578], [-6184784, 0], [4937532, 0], [-742212, 0], [0, -215908], [0, 446573], [0, 368546], [0, -677497], [-7538834, 0], [3733108, 0], [7953906, 0], [0, -652609], [-6437742, 0], [-10694676, 0], [0, 959020], [0, -939281], [0, -200220], [10474848, 0], [0, 55640], [0, 676392], [-8855542, 0], [-7507534, 0], [0, -747893], [-9282576, 0], [-17073958, 0], [0, 201369], [0, -417654], [-8131874, 0], [1990124, 0], [0, 234989], [-17227618, 0], [0, -864267], [-6403828, 0], [0, -847493], [17116718, 0], [16968922, 0], [0, 1773882], [0, -239110], [0, -1911695], [-5533868, 0], [-10949088, 0], [4932600, 0], [7697818, 0], [0, 536266], [0, -1270906], [0, 292059], [0, -251597], [0, -396651], [19914750, 0], [0, -1657429], [18828058, 0], [-9230000, 0], [-34408884, 0], [0, -1854083], [0, -2414682], [0, -1260025], [0, 530262], [0, 1099329], [-32494296, 0], [-17251182, 0], [0, 2545120], [-39989300, 0], [0, 2739078], [17836564, 0], [600440, 0], [41454336, 0], [0, -3590574], [0, -1810344], [0, 617955], [-11150228, 0], [15731238, 0], [53868448, 0], [0, -2258759], [-11590574, 0], [0, -44930], [21837224, 0], [0, -2554171], [-2290742, 0], [0, -1891443], [-55588164, 0], [0, -573537], [15933456, 0], [43098198, 0], [0, 2289982], [0, -2696404], [-3743500, 0], [56836854, 0], [0, -3730996], [0, -1303415], [27004968, 0], [0, -2641621], [26410362, 0], [0, -2130036], [39838696, 0], [0, -3343315], [-19581154, 0], [0, 5377647], [-21792074, 0], [0, 3768038], [0, 4069868], [34911356, 0], [49106396, 0], [0, -3683151], [66549668, 0], [0, 1189564], [-20267450, 0], [-24565934, 0], [0, -3469016], [0, 2301744], [-43992974, 0], [0, 4201442], [0, -634783], [0, 3839816], [0, -6852831], [0, 1604727], [0, 3084250], [84506940, 0], [19717262, 0], [0, 8260169], [-59297514, 0], [0, 2648739], [9562624, 0], [0, 250761], [0, -665936], [0, -8267146], [-7662248, 0], [0, 6563730], [-11728992, 0], [117688174, 0], [100399498, 0], [0, 9981072], [70727550, 0], [-100323160, 0], [0, -3953751], [-24079078, 0], [0, -4218032], [-105159928, 0], [0, -5102796], [-26897196, 0], [59926050, 0], [0, 3341389], [35821720, 0], [33332374, 0], [0, -1854117], [0, -8755544], [0, -6119258], [-122832550, 0], [103218764, 0], [0, 6901300], [-39707524, 0], [0, -5828657], [0, -3337924], [98001614, 0], [0, -5658408], [0, 8105610], [0, 7382176], [0, -6234447], [-109961540, 0], [-13037752, 0], [-94420146, 0], [0, -287732], [-106153584, 0], [0, -3898688], [0, 2538003], [78716164, 0], [-181793254, 0], [0, -7440239], [0, 4458027], [0, 14809682], [127967240, 0], [-95870788, 0], [0, -10077139], [0, 884457], [0, 2886534], [0, -8745055], [31987650, 0], [0, -14594760], [-201468124, 0], [38661446, 0], [0, 11116335], [-103705868, 0], [0, 11856476], [101079736, 0], [0, -15238456], [0, -6838564], [157019764, 0], [-142915394, 0], [132042418, 0], [0, -9751287], [0, 8528732], [-149353648, 0], [0, 7672934], [0, 1180121], [0, -5866421], [80575464, 0], [129739922, 0], [252591114, 0], [0, -3465974], [0, 2950116], [11312274, 0], [0, 7626745], [301276578, 0], [0, 8334553], [182969982, 0], [0, -7370587], [0, 13192096], [0, -139427], [0, -10681641], [0, -11715155], [0, 6121234], [193330638, 0], [185899528, 0], [-163946196, 0], [328736556, 0], [243472670, 0], [-9558860, 0], [0, -17411143], [101173632, 0], [210247798, 0], [0, -1530540], [139824150, 0], [-61421598, 0], [100963220, 0], [-72211216, 0], [0, 23315264], [0, 20551759], [-177395048, 0], [0, 9514768], [368261714, 0], [0, 25814045], [-13568698, 0], [0, -19967889], [-348078584, 0], [423714526, 0], [0, 11675922], [200679876, 0], [0, -30081537], [-200808696, 0], [-41250218, 0], [-172552882, 0], [41341134, 0], [0, -9898182], [0, -30995665], [-172979980, 0], [0, -34245007], [250175074, 0], [0, 29253452], [0, -21451372], [0, -2431134], [-290142058, 0], [-338070222, 0], [0, 12701021], [82481664, 0], [44408302, 0], [117674412, 0], [0, -27071817], [298926892, 0], [0, 16940652], [0, -1389405], [0, 38188185], [66085418, 0], [266186770, 0], [0, -14233534], [-253894186, 0], [0, -28243508], [0, 21242850], [0, -13072283], [-83375602, 0], [145244128, 0], [-291897418, 0], [0, 34887144], [282709992, 0], [-328913524, 0], [0, 5610079], [-28932594, 0], [0, 15935409], [62451392, 0], [-204023278, 0], [-244278204, 0], [0, 32529797], [307766872, 0], [182980474, 0], [0, -20519528], [-655713074, 0], [0, 29315233], [-238321960, 0], [0, -10424848], [0, -5052866], [0, 31979314], [0, 10342161], [576421854, 0], [150403344, 0], [-116016482, 0], [0, -30159451], [0, -16321776], [269232840, 0], [0, -530175], [368976212, 0], [0, 42245886], [153258230, 0], [0, 3452723], [263672044, 0], [0, 17808829], [-413824528, 0], [-35879738, 0], [0, -7418322], [0, -3413214], [-211382140, 0], [-416912250, 0], [0, -4568503], [317268158, 0], [31673000, 0], [0, -48755746], [0, -38609415], [0, 42503642], [241086046, 0], [43210998, 0], [0, -23779855], [0, 16871103], [0, -2275432], [-680892282, 0], [-46739756, 0], [-534403652, 0], [-539676138, 0], [0, -14516679], [620977320, 0], [0, 26666170], [0, 54133334], [0, -4365060], [252336286, 0], [0, 64886941], [-853479384, 0], [0, 49730091], [0, -56889062], [0, 15144095], [588913068, 0], [635204442, 0], [0, -37604915], [0, 53195482]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_882_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_882_6_a_bo();".
// 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_882_6_a_bo(:prec:=2)
    chi := MakeCharacter_882_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_882_6_a_bo();".
// 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_882_6_a_bo( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_882_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<5,R![-9016, 0, 1]>,<11,R![476, 1]>],Snew);
    return Vf;
end function;