
// Make newform 546.2.bm.b in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_546_bm();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_546_bm_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_546_2_bm_b();".
// 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_546_2_bm_b();".
// 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 := [576, 0, 215520, 0, 1263505, 0, 2035844, 0, 1447090, 0, 552164, 0, 123139, 0, 16508, 0, 1306, 0, 56, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [8506128, 0, 501209410, 0, 848977739, 0, 345978835, 0, 134404286, 0, 65265673, 0, 17182550, 0, 2192815, 0, 132131, 0, 3022, 0], [635189599008, 1467907393416, 61065638669232, -56873843883391, 110553906440468, -112674210776124, 68761329525984, -79467120501562, 20962795318116, -27758334534728, 3535551559876, -5391398303493, 340385291796, -604945859288, 18053043108, -38602727614, 460750880, -1283960340, 3676068, -16974619], [49665168, 610118280, -1984961058, 0, 1920888413, 0, 11072929004, 0, 9194428011, 0, 3334559671, 0, 629361751, 0, 64093833, 0, 3326870, 0, 68783, 0], [-49665168, 610118280, 1984961058, 0, -1920888413, 0, -11072929004, 0, -9194428011, 0, -3334559671, 0, -629361751, 0, -64093833, 0, -3326870, 0, -68783, 0], [-13652335440, 395714733552, -804441103050, 5268731003973, -1362609271095, 11171084080987, -555296030175, 10572724690426, -215718879030, 5042771893329, -104751405165, 1322768996024, -27577992750, 199629861749, -3519468075, 17247293007, -212070255, 790524490, -4850310, 14856982], [-2399382291456, -4010123301240, -28630898868504, -39535638354895, -56102602880186, -64574560029530, -42604079503458, -45106099779540, -16905660839712, -16966527705440, -3900900559222, -3743049420175, -540038980872, -497204747280, -44009978766, -39004638160, -1937602550, -1659317510, -35398716, -29415555], [2399382291456, -4010123301240, 28630898868504, -39535638354895, 56102602880186, -64574560029530, 42604079503458, -45106099779540, 16905660839712, -16966527705440, 3900900559222, -3743049420175, 540038980872, -497204747280, 44009978766, -39004638160, 1937602550, -1659317510, 35398716, -29415555], [4195815050880, -38407760456184, -10979716228260, -225383049182661, -44801530182100, -337345097373984, -39051161390160, -215842472125742, -16065764420820, -73424383345548, -3736505960960, -14608051723923, -519074683140, -1756829707708, -42564285900, -125695121574, -1891987600, -4920211380, -34968720, -81018389], [4195815050880, 38407760456184, -10979716228260, 225383049182661, -44801530182100, 337345097373984, -39051161390160, 215842472125742, -16065764420820, 73424383345548, -3736505960960, 14608051723923, -519074683140, 1756829707708, -42564285900, 125695121574, -1891987600, 4920211380, -34968720, 81018389], [-1582858934208, -17215230963000, -21074924015892, -114339799652545, -44684336323948, -190792879709240, -42290898761704, -136332666788530, -20171087573316, -51930495392480, -5291075984096, -11564236180015, -798519446996, -1551010693280, -68989172028, -122970816790, -3162097960, -5289840320, -59427928, -94807885], [-1582858934208, 17215230963000, -21074924015892, 114339799652545, -44684336323948, 190792879709240, -42290898761704, 136332666788530, -20171087573316, 51930495392480, -5291075984096, 11564236180015, -798519446996, 1551010693280, -68989172028, 122970816790, -3162097960, 5289840320, -59427928, 94807885], [-2440473120, -82272045672, 0, -428095530333, 0, -657864772052, 0, -462319287686, 0, -177101468424, 0, -39952824679, 0, -5437184344, 0, -437128002, 0, -19039100, 0, -344897], [1824337931904, -8838421625112, 25759775744436, 68173843836067, 43033037004044, 168056538877328, 25844069280772, 141574139518154, 7322561212008, 59401464181676, 1024826425528, 14032943832661, 58826777048, 1949844438556, -977742396, 157753029898, -252356260, 6859712900, -7693436, 123568043], [3119514604704, 67044202893432, 50688962013936, 285433819851903, 102655008267884, 404673911407992, 73725442937132, 264922559713626, 26980040013768, 94442358003564, 5819128016788, 19803931915569, 774344657368, 2507500302684, 62283517764, 188167076682, 2757223100, 7688673660, 51179864, 131492007], [-635189599008, 34136347726776, -61065638669232, 171805755421699, -110553906440468, 268911548642356, -68761329525984, 193198213075498, -20962795318116, 76102656250232, -3535551559876, 17737074056537, -340385291796, 2497075527272, -18053043108, 207338905966, -460750880, 9295720300, -3676068, 172641151], [3867753991680, -52016067402984, 18303873785700, -257661071860311, 60623708205580, -411689959278924, 79598602064640, -295724587957202, 44929184189460, -113794727769888, 12988633033160, -25447075375413, 2085640207380, -3403815370048, 187918056900, -267792362934, 8870380840, -11398391100, 170259720, -201918419], [-82015264800, 22605956964792, 7320897503490, 120761030260743, 26356309596920, 187258764163227, 29662440863700, 127891765020736, 15248737152570, 46804777778859, 4181284748530, 10013781774834, 651178722630, 1290161269439, 57620585700, 98371871127, 2690592110, 4079650620, 51307110, 70734202], [2806319104416, 74540001435000, 48870394053144, 467947463340515, 101532544719416, 763523329994560, 74182962936288, 542829366020310, 26551812327192, 205774317577720, 5270273410432, 45401111928245, 605238958872, 6008355434520, 39698937336, 468890923370, 1367677040, 19838226880, 18978576, 349867935], [-2806319104416, 74540001435000, -48870394053144, 467947463340515, -101532544719416, 763523329994560, -74182962936288, 542829366020310, -26551812327192, 205774317577720, -5270273410432, 45401111928245, -605238958872, 6008355434520, -39698937336, 468890923370, -1367677040, 19838226880, -18978576, 349867935]];
    Rf_basisdens := [1, 137229096, 1762021592640, 1220236560, 1220236560, 440505398160, 881010796320, 881010796320, 1762021592640, 1762021592640, 1762021592640, 1762021592640, 4880946240, 1762021592640, 1762021592640, 1762021592640, 1762021592640, 440505398160, 1762021592640, 1762021592640];
    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_546_bm();"
function MakeCharacter_546_bm()
    N := 546;
    order := 6;
    char_gens := [365, 157, 379];
    v := [6, 2, 5];
    // 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_546_bm_Hecke();"
function MakeCharacter_546_bm_Hecke(Kf)
    N := 546;
    order := 6;
    char_gens := [365, 157, 379];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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+1)]];
    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 := 2;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1], [2, -1, 1, 0, -1, 1, 0, 0, 0, -1, 0, 2, 1, -1, -1, 0, 0, 1, 1, 0], [0, 1, 1, -1, -1, 1, 0, 0, 1, 0, -1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [-2, 1, 1, -1, -1, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, -1, 0, 0, -1, 1], [-1, 2, 0, -1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 1], [-1, 1, 0, 1, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, -1, 0, 1, 1, 0, 1], [1, 0, 1, 0, -1, 0, -1, -1, 1, -1, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 0, 1, 1, -1, 0, 0, -1, -1, -1, 0, 1, 0, 0], [0, 0, -1, 1, 1, 0, 1, 1, 1, -1, 2, -2, 0, 0, 0, -1, 0, 0, 0, 0], [-1, 2, 0, 0, 0, 1, 0, -1, 0, 0, 2, 0, 1, 1, 1, 1, 1, 1, 0, -1], [0, 1, -1, 1, 1, 1, 1, 1, -1, -2, -1, 0, -2, -1, 0, -1, 1, -2, -1, 0], [2, -1, -1, 1, -1, 1, 0, 1, 0, -1, 1, 3, 1, 1, 0, 1, 0, 1, 0, -1], [3, 0, 2, -1, -2, 1, 0, 0, 1, -1, -1, 2, 3, -1, -1, 1, 0, 1, 1, 0], [1, -1, 1, 1, 0, -2, -2, -2, 0, 1, 1, 0, 2, 1, -1, 1, -1, 1, 1, 0], [2, 0, 0, 0, 0, 3, 1, 2, -1, 1, -1, 2, 2, 0, 0, 0, -1, 0, -1, -2], [0, 0, 0, -1, 0, 0, 2, -1, 0, 2, -1, -3, 0, 0, 1, -1, 0, -2, 1, -1], [2, -1, 0, 1, 0, 1, 0, 0, 0, -2, 1, -1, 1, 0, -1, 1, 0, 2, 1, 0], [0, 0, 1, -3, -1, 0, 1, 0, 1, 1, -4, 1, 0, 0, -1, -1, -1, 0, 0, 0], [0, -2, -2, 0, 1, -2, 1, 0, -1, -2, 2, -2, -2, -2, 0, -2, 1, -2, -1, -1], [-2, -1, -1, 2, 2, -2, -1, -1, -2, 2, 1, -1, -4, 0, 0, -1, 0, 0, 1, 1], [-1, -1, 0, -2, -2, -2, 0, 0, 2, -1, 0, 0, -2, 0, 0, 0, -1, 1, 1, 1], [-6, 0, 0, -1, -2, 0, 2, 1, 1, 0, -1, 3, -3, 0, 1, -1, 1, 0, 1, -3], [0, 0, 2, 2, -1, 0, 0, -2, 0, 0, 0, 2, -2, 2, -2, 0, 0, 0, 2, -2], [0, 3, 1, 0, -1, 3, -1, 0, 2, 1, 2, 0, 0, 1, -1, 0, -2, 1, 2, 1], [4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0], [2, -2, -1, 2, 1, -1, 0, -1, 1, 1, 4, -1, -2, -1, 0, 0, 2, 3, 1, -1], [0, -3, -1, -2, 0, -3, 1, 0, 1, -1, 2, -2, 1, -1, 1, 0, -1, -1, -2, -1], [0, 0, -2, -1, 0, -2, 1, 3, 1, -1, -2, 2, 0, 0, 2, -2, 0, 1, -4, -3], [0, -3, 0, 5, 2, -3, 0, 1, -3, -2, 3, -1, -2, 0, -1, -1, 3, -2, 1, 1], [-3, 1, 0, -4, -4, 2, -2, -2, 2, -1, 0, 0, -6, 0, 0, 0, -1, 1, 1, 1], [0, 0, 1, 2, 1, 0, -1, 1, 1, 1, -4, 2, 0, 1, 1, 2, -1, 1, 0, 2], [2, 0, 1, 1, -1, 0, -3, 1, -1, -1, 2, 1, -2, 3, 2, 2, 0, -1, 0, 1], [0, 0, 0, 0, 0, 0, -2, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 2, 0], [-3, 0, 0, 0, -2, 1, -3, -1, 1, -1, 3, -4, -3, 1, -1, 1, 0, 1, -1, 1], [2, -4, -3, -1, 3, -2, 1, 1, -4, -4, 2, -3, -2, -4, -1, -1, 1, -3, -1, 1], [-1, 0, 2, 0, -2, 0, -1, -1, 2, 2, -5, 2, 1, 2, 0, 0, -3, -1, 2, -1], [-3, 0, 0, 0, 2, -4, -2, 0, 0, 0, -1, 0, -3, -1, 1, -1, 0, 0, -3, 0], [0, -3, -3, 4, 5, -3, 0, 0, -4, -3, 10, -8, -1, -3, 3, 0, 4, -3, -3, 0], [-1, -2, -2, 3, 1, 0, 0, 0, -2, -2, 4, 0, 0, 0, 0, 2, 0, 0, 2, -2], [-1, 0, 0, 0, 0, 0, 1, 2, 2, -2, -2, 4, -1, 0, 0, 0, 0, 2, -1, -2], [-8, 0, 0, -1, 2, 0, 1, 0, -2, 0, -1, 9, -4, 0, 1, -1, -2, 0, 0, -1], [-2, 0, -1, -2, 1, 0, 3, 1, -1, -1, -2, -1, 2, -5, -4, -4, 2, 1, 0, 1], [6, -4, -1, 2, 4, 0, -1, 1, -4, -3, 7, 1, 0, -4, -4, 1, -1, -1, 2, 2], [-2, 0, -2, 3, 4, -4, -1, 0, -4, 4, 4, -6, -2, 2, 0, 0, 0, -4, -1, 0], [4, -2, 0, 0, 0, -1, -3, 0, 2, 2, 10, 0, -4, 3, 3, 3, -1, 1, 0, 0], [4, 0, -4, -2, -1, 0, 4, 4, 0, -1, -4, 3, 8, -1, 1, -4, 1, -1, -3, -2], [-4, 3, 0, 0, -2, -3, 0, -1, 2, -1, 0, 1, -2, 0, 0, 0, 2, 1, 0, 1], [0, 3, -2, -2, 1, 3, 1, 4, 2, 1, -6, 1, -2, -2, 2, 0, -2, 1, -3, 3], [5, 0, 1, -1, -1, 0, -1, -1, -2, 3, -7, 7, 10, 0, 0, 1, -1, 1, 2, 2], [4, -2, 1, 4, 2, -4, 0, 0, 1, -2, -2, 4, 8, 2, -2, 1, 1, -1, 1, -1], [0, 0, -2, 2, 1, 0, 4, 5, -2, -1, 10, -5, -1, -2, -2, -4, 2, -1, -2, 1], [5, -5, 2, -4, 0, 0, 0, 0, 2, 1, -4, 0, 0, 0, 0, -2, 1, 1, 1, -1], [0, -2, -2, 2, 2, -2, 2, 2, 0, 0, 14, -8, 4, -2, 0, -2, 0, 0, -2, 0], [-3, 4, 3, -2, 0, 0, 0, 0, -2, -2, 1, 3, 0, -4, -4, -3, 0, 0, 0, 4], [-4, -3, -1, -1, 1, -6, -1, -1, -1, 2, -2, 0, -8, -2, 2, -1, -1, 1, -2, 0], [-6, 1, 3, 1, -6, 0, 1, -1, 0, 1, -7, -2, 0, -1, -1, -3, -1, -1, -1, 2], [-1, 3, 1, 2, 2, 6, -1, -1, -1, 1, 12, -12, -2, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 2, 2, 1, 0, 1, 2, -3, 4, -3, -2, 0, 2, 2, -2, -3, -2, 1], [2, -1, -1, 0, 3, 1, 4, -4, 1, 2, 0, 1, 1, 1, 1, 0, 1, -2, 3, 0], [0, 0, -3, 3, 5, 0, 0, 0, -3, -1, 0, -2, 0, -2, 2, -3, 4, -4, 1, 3], [-6, 0, 4, 1, 0, 0, -3, -4, -3, 3, 8, -14, -6, -1, -3, 3, -5, 2, 4, 4], [0, 5, 3, -6, -4, 5, 1, -2, 2, 2, -16, 9, 10, 3, 1, 4, -2, 2, -2, -3], [0, -2, -2, 0, -1, 2, 6, 2, 0, 2, 0, 0, 0, 2, 2, 0, 0, -2, 4, -8], [5, -2, -5, 1, 5, -1, 0, 0, -2, -2, 0, -5, -5, -4, 1, 1, 1, -1, -1, 0], [-1, 0, 1, -4, -1, 0, 1, -1, 0, 1, -1, 4, 0, 3, 3, -1, -1, -1, -2, -1], [4, -5, 1, 0, -1, 0, 1, -1, -1, -1, -8, -7, 0, -1, -1, -1, 0, 0, 4, -3], [4, 6, -2, 1, 2, 3, -5, 4, 1, 1, 6, -2, -4, 2, 4, 4, -2, -1, -3, 4], [-4, 4, -1, -1, 4, -4, -1, -2, 3, 0, -1, -14, -2, 1, 2, -1, 3, 0, -3, 3], [-14, 2, 2, 0, -4, -2, -1, -3, 1, -1, 0, 3, -7, -2, -2, 0, 1, 1, 1, 4], [0, 6, -1, -8, -2, 6, -1, 0, 5, 4, -10, 3, 0, -1, 3, 2, -5, 4, -2, 1], [1, 0, 1, 0, -3, -3, -2, -1, 1, -1, -3, 9, 1, 1, -2, 2, -3, 4, 1, 1], [-4, 6, 0, -3, 0, 3, 0, 0, 5, 5, -5, 0, 4, 4, 4, 4, -3, 2, -4, 0], [-2, 0, 4, -3, -4, 0, 3, -2, -1, -1, 6, 4, 2, 1, -3, -3, 1, 0, 2, -2], [2, 0, -1, 0, -1, -1, -1, -1, 0, 0, -4, 9, 2, 1, 0, 0, -4, 4, 0, 1], [4, 4, 1, -2, -1, 2, -1, 0, -4, -4, -4, 1, -4, 0, -1, -1, 3, -1, 2, 0], [7, -1, 1, 2, 1, -2, 2, 2, 1, 2, 2, -1, 14, 1, -1, 1, -3, 3, 3, 2], [3, 0, 4, -2, -3, 0, -1, -1, 1, -1, 3, -2, 6, 1, -1, 4, 0, 0, 1, 0], [-6, 0, 0, 0, -2, 1, 1, 4, -3, 3, -6, 14, -6, 1, -1, 1, -5, 2, -2, -4], [-1, -3, 0, 1, -1, -6, 1, 1, -5, 2, -3, 5, -2, 2, -2, 0, 3, -3, 1, -1], [4, -2, 3, 0, -9, 2, -1, -3, 5, -10, 0, 7, 2, -3, -3, 0, 5, 10, 2, 4], [0, 0, 1, -3, 0, 0, -5, -4, 1, -1, 3, -3, -8, 1, 4, 5, -1, -1, 1, 1], [0, 0, 0, 3, -3, 0, -4, 4, -4, -5, 4, 4, 0, 0, 0, 0, 1, 1, -5, 5], [0, 1, 1, 8, 4, 1, -6, -3, -2, 0, 2, -1, -4, 1, 1, 2, 2, 0, 5, 3], [2, -1, -1, 0, 2, 1, 3, -2, -1, 3, 0, -2, 1, 1, 1, 0, -1, -3, 2, -1], [2, 1, 1, 2, -2, 2, 1, 1, 2, 3, 5, -1, 4, 4, -4, 1, -5, 5, 3, -1], [-4, -3, 4, 3, -2, 3, -3, -1, 0, -4, 3, 5, -2, -4, -7, 3, 0, 4, 4, 4], [2, 2, -2, -6, -4, 4, 0, 0, 2, 0, -4, 2, 4, -2, 2, -2, -2, 2, -1, 1], [0, 1, -2, -1, 1, 1, 2, -2, -1, 1, 17, -10, 5, -2, 1, -1, 1, 1, -3, -4], [10, -6, 0, 2, -6, 6, 3, 1, 1, -3, 2, 9, 5, 0, -2, 2, 1, 3, 5, -4], [2, 1, 1, -2, -4, 2, 1, 1, -3, 3, -16, 18, 4, 2, -2, 1, 0, 0, -2, -4], [-6, 0, 0, 2, 0, 2, -2, 0, 2, -2, -6, 16, -6, 2, -2, 2, 0, 2, 0, 0], [-6, -1, 3, 0, 6, 1, -4, -1, 1, 1, 0, -8, -3, -3, -3, 0, 1, -1, -1, 5], [0, 4, 2, 0, -2, 4, -1, 2, 1, -1, -10, 7, -2, 2, -2, 0, -1, -1, 3, 3], [-3, -4, -4, 1, 4, -8, -4, -4, -4, -3, 0, -3, -6, -3, 3, -4, 7, -7, -6, -3], [-4, 0, -1, -4, -1, -7, 3, 2, -1, 1, -4, 1, -4, -3, 4, -4, 4, -5, -3, -2], [-3, -9, 1, 0, -2, 0, -1, 1, 3, 3, -10, -8, 0, 0, 0, -1, 0, 0, 3, -3], [-4, -3, -6, 4, 2, 3, 2, 3, -4, 3, 4, 11, -2, 6, 2, 4, -4, -3, 0, -5], [-2, 0, 0, 4, -3, 0, 2, -2, -1, -3, 13, 12, 0, -1, -1, 0, 2, 2, 4, -3], [-8, 2, 0, -3, 1, -2, 3, 3, -1, 2, -3, 7, -4, 0, 3, -3, -1, -2, 0, -6], [7, -3, -1, -1, -3, 0, -2, 2, 0, 2, 1, 5, 0, 6, 6, 1, -2, -2, 0, -6], [-19, 9, 1, -6, 3, 0, 0, 0, 5, 6, -2, 1, 0, 1, 1, -1, -1, -1, -1, 0], [3, 0, -3, 3, 3, -4, -3, -3, -1, 1, -1, 5, 3, 3, 0, 0, -1, 0, 0, 3], [9, 0, -3, 9, 3, 0, -3, 0, -3, -3, -4, -3, -9, -1, 2, 2, 8, 5, 1, 0], [3, 0, 1, 2, -1, 0, 3, -4, -2, -2, 8, 1, -3, 0, -1, -1, -1, -3, 2, -4], [-16, 4, 1, -2, 8, -4, -2, -3, -2, 7, -2, 0, -8, -1, 1, -2, -2, -7, -3, 5], [5, 0, 1, -1, -1, -1, 2, -3, 2, -2, 7, -15, 5, -1, 0, 0, 1, 1, 5, 3], [-13, 0, -2, 2, 0, -2, 3, 1, 1, -1, -4, 12, -13, 3, -1, 1, 1, 0, 3, -1], [-6, 0, 0, 0, 2, 3, 4, -3, 0, 0, -4, 6, -6, -1, 1, -1, -1, 1, 6, 3], [-6, 2, 0, -1, 3, -2, -3, -1, -6, 8, -1, -5, -3, 0, 1, -1, -6, -8, -4, 4], [-12, 2, -6, -2, -2, -2, 2, 4, 2, 0, -2, -4, -6, 6, 8, -2, 2, 0, -6, -6], [2, 2, -3, 4, 3, 1, -5, 5, -3, -3, 5, -3, -2, -2, 1, 1, 4, 1, -1, 5], [-12, 0, 4, -2, 1, 0, -3, -3, 1, -2, -2, -10, -6, -4, -2, -2, 1, 2, -1, 6], [-1, 3, -2, 0, 7, 0, -1, 1, -2, 2, 0, -7, 0, -3, -3, 2, -4, -4, 0, 3], [-2, -1, -3, 3, -4, 1, -4, 4, 1, 1, 3, 9, -1, 3, 0, 3, 1, -1, -4, 0], [0, 0, 1, 6, 3, 0, 2, 4, 0, 3, 0, 0, 1, 1, 1, 2, 0, 3, -3, 2], [4, -4, -2, -3, 5, 0, -2, 2, 0, 6, 4, 2, 0, 2, 2, 2, -6, -6, -2, 0], [0, -4, -1, 3, 3, -4, -4, 1, -5, -1, 23, -13, -3, -1, 2, 1, 5, -1, 2, 5], [2, -2, 1, -5, -8, 2, -2, 5, 1, 1, -5, -3, 1, -1, 4, -5, 1, -1, -6, -3], [-5, 0, 0, 0, 2, -3, 1, 0, 5, -5, 3, -8, -5, -1, 1, -1, 0, 5, 0, 0], [0, -7, -1, -3, -1, -7, 1, 1, 2, 2, -1, 0, -9, -1, 0, -1, -2, 2, -1, 0], [-2, 2, -2, 0, 3, 4, 0, 0, 0, -1, 10, -13, -4, -3, 3, -2, 1, -1, 1, 4], [6, 5, 2, -5, -4, 10, 2, 2, 0, 5, 2, -3, 12, -1, 1, 2, -5, 5, -2, -1], [0, 9, 1, -5, 4, 0, -2, 2, 4, 4, -3, -2, 0, -1, -1, -1, 0, 0, -8, 9], [-9, 10, 1, -1, -1, 5, 0, 2, 1, 1, 1, 1, 9, 0, -1, -1, -4, -3, -1, 2], [-8, 0, 3, -6, -11, 1, 0, -1, 3, -3, -9, 17, -8, -2, -1, 1, 0, 3, 2, 1], [-4, -6, 6, 1, -7, 0, 1, -1, -2, -7, 0, 6, 0, -6, -6, -6, 5, 5, 2, 4], [6, 1, 0, -1, 2, -1, 3, 0, 1, 0, -1, 11, 3, 0, 1, -1, 1, 0, 2, -3], [-8, 2, 7, 2, 2, -2, -1, -4, 1, -1, 2, 8, -4, -7, -9, 2, 1, 1, 8, 5], [4, -6, 1, 3, -1, -3, -1, -1, -2, -2, -3, 1, -4, 5, 4, 4, 1, -1, -2, -1], [8, -4, 2, 2, -4, 0, 0, 0, -8, -6, -2, 0, 0, -2, -2, -2, -2, -2, 1, 1], [11, 0, 4, -5, -4, 6, 6, 3, 2, -2, -7, 8, 11, -5, 1, -1, 2, 0, 2, -3], [-8, 8, 2, -6, -2, 4, -3, -2, 5, 5, -12, 2, 8, 5, 3, 3, -3, 2, 2, -2], [0, 6, -3, -1, 3, 3, 3, 7, 3, 3, 3, -3, 0, -8, -5, -5, -2, 1, -5, 7], [2, -2, -3, -3, 2, -4, 0, 0, 0, -1, -3, -2, 4, -5, 5, -3, 1, -1, -6, -1], [4, 2, 2, -5, -5, 4, 7, 7, 4, -4, -14, 14, 8, 0, 0, 2, 0, 0, -1, -1], [0, -4, -6, 3, 5, -4, 3, -1, -1, -4, 11, -9, -8, -6, 1, -5, 1, -4, -4, -4], [0, 4, -3, -2, 4, 4, -2, 1, -2, -5, 26, -18, 18, -3, 7, 4, 2, -5, -5, 3], [-7, -3, -4, -5, -1, -6, -3, -3, 0, -4, 16, -20, -14, -4, 4, -4, 4, -4, -6, -2], [5, 4, 4, -10, -9, 8, -2, -2, 6, -3, 0, -1, 10, -1, 1, 4, -3, 3, 0, 1], [-14, 3, 2, -1, -1, 0, 3, -3, 3, 1, -9, -7, 0, -2, -2, -2, 2, 2, 4, -2], [6, 6, 4, 0, -4, 12, -2, -2, 2, 0, 14, -10, 12, 4, -4, 4, -2, 2, 6, 2], [0, 0, -8, 5, 7, 0, 5, 7, -4, -4, 13, -11, -5, -8, 1, -7, 4, -4, -6, 2], [34, -1, 1, 3, -5, 1, -3, 1, -5, 0, 3, 4, 17, -1, -4, 3, -5, 0, 1, 2], [2, 2, 3, -7, -10, 4, 2, 2, 1, 1, -4, 7, 4, 3, -3, 3, -2, 2, 2, -1], [-21, 0, -5, -3, -1, 1, 1, 6, 2, -2, 1, -7, -21, 0, 5, -5, 8, -6, -10, -6], [0, 1, -6, 8, 7, 1, -1, 4, -6, -4, -14, 4, -1, -6, 0, -6, 6, -4, 1, 5], [-20, 4, 6, -4, -4, -4, 1, -8, 1, -3, -4, -7, -10, -6, -2, -4, 1, 3, 3, 7], [1, 0, 5, -11, -5, 0, 5, 4, 6, 6, -12, 5, -1, -2, -7, -7, -3, 3, -2, 4], [0, 0, -9, 3, 15, -10, 2, 1, -5, 5, 7, -23, 0, 0, 9, -9, 4, -9, -8, -1], [11, -6, -3, 6, 3, 0, 4, -4, -3, -8, 6, -3, 0, -3, -3, 3, 5, 5, 2, 1], [-12, -1, -3, 0, 3, 0, -2, 2, -1, 3, -6, -9, 0, 3, 3, 3, -4, -4, 2, -5], [0, -7, -5, -8, -2, -7, 4, 1, -1, -1, 8, -6, -17, -5, -1, -6, 1, -1, -3, -3], [-15, -5, 4, -7, -2, 0, 3, -3, 3, 4, -5, 4, 0, 1, 1, -4, -1, -1, 2, -3], [8, 0, 0, -3, -4, 1, 6, -2, -3, 3, -8, 14, 8, -1, 1, -1, -5, 2, 7, 2], [11, 2, -4, 8, 4, 1, -3, 3, -3, -3, 14, -4, -11, -2, 2, 2, 0, -3, -2, 3], [11, -13, 4, 2, -2, 0, -1, 1, -5, -3, -1, -1, 0, -8, -8, -4, -2, -2, 6, 2], [1, 0, 4, 3, -4, 0, -4, 2, 4, 4, -5, 4, -1, 3, -1, -1, -4, 0, 3, 2], [7, -4, -8, 9, 13, -8, -1, -1, -8, -2, 8, -12, 14, -4, 4, -8, 10, -10, -3, 1], [0, -10, -4, 0, 1, -10, 2, 5, -5, -5, 8, -5, -13, -4, -2, -6, 5, -5, 0, 3], [8, 4, 1, 1, 5, 8, 1, 1, -2, -2, 1, -5, 16, -4, 4, 1, 4, -4, -4, 0], [12, 0, 9, -1, -3, -2, -4, -4, 0, 0, -12, 25, 12, -4, -5, 5, -1, 1, 5, 4], [6, -2, -7, 6, 9, 2, 4, 4, -3, 4, 6, 9, 3, 7, 1, 6, -3, -4, 3, -8], [1, -6, -1, -4, 1, -3, -9, 2, 1, 1, 6, -1, -1, 6, 7, 7, -3, -2, 0, 2], [0, 2, 3, -8, -7, 2, 1, 2, 0, 0, 4, 1, 2, 3, -3, 0, 0, 0, 2, 1], [-5, 0, 2, 1, -3, 0, 0, 0, 2, 2, 0, 2, 0, -2, -2, -2, 0, 0, -2, 4]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_546_bm_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_546_2_bm_b();".
// 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_546_2_bm_b(:prec:=20)
    chi := MakeCharacter_546_bm();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 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_546_2_bm_b();".
// 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_546_2_bm_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_546_bm();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![576, -19296, 215448, 804, -631751, 10242, 1613768, 1609092, 250999, -392970, -139756, 72234, 40612, -5544, -5416, 318, 523, 0, -28, 0, 1]>],Snew);
    return Vf;
end function;