
// Make newform 462.2.k.g in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_462_k();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_462_k_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_462_2_k_g();".
// 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_462_2_k_g();".
// 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 := [59049, -118098, 124659, -91854, 45198, -10206, -2025, 162, 4005, -5292, 3864, -1764, 445, 6, -25, -42, 62, -42, 19, -6, 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], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-118098, 124659, -91854, 45198, -10206, -2025, 162, 4005, -5292, 3864, -1764, 445, 6, -25, -42, 62, -42, 19, -6, 1], [31768362, 245178009, -345007998, 229184478, -73085652, -16693290, 33358068, -6755409, -15200136, 16839312, -8896860, 1843352, 876018, -634019, 4362, 236878, -186672, 79886, -11100, -1501], [308714733, -412074540, 278601930, -97402176, -11202462, 34447518, -6842565, -17354826, 19686408, -10975692, 2792384, 636608, -637247, 17812, 259474, -220028, 102482, -21322, 1727, -538], [510911631, -1341278352, 1366284510, -788081805, 205478127, 78093396, -85305366, -11854773, 69171228, -61555452, 29395380, -5701892, -2317281, 1525880, 320778, -914977, 662019, -277064, 57282, -3941], [71849511, -83383749, 64977957, -34327152, 9271179, 1561923, -480339, -2422512, 3415020, -2673888, 1323236, -377696, 48103, 9539, 20905, -38128, 29807, -13781, 5597, -1232], [-958365270, 863079867, 20008863, -556770105, 499197330, -203353173, -39769353, 103555899, -47301912, -12111708, 28682472, -18502708, 4421898, 1611259, -1654737, 376723, 259002, -321337, 143919, -25957], [638910180, 667299627, -1264040073, 817623801, -226227168, -92936241, 153518787, -38767311, -56788704, 61346796, -29969184, 3850868, 5266932, -2948021, -97281, 920893, -657600, 252995, 12315, -27967], [72748368, -73647225, 70196139, -48186171, 21356784, -3302613, -932877, -280755, 2511648, -3104724, 2086560, -850012, 170544, 55495, -21261, -30839, 38256, -21937, 9627, -1795], [1053650673, -2043224433, 2047560525, -1232760870, 368996553, 72635103, -106185159, -17699238, 98000868, -91395192, 47132428, -11644248, -1708639, 2060487, 304937, -1265262, 1002997, -452289, 123337, -16230], [977831757, 321659586, -1196901360, 557608455, -22349439, -224192286, 193247640, -46075725, -66235932, 57440292, -17331972, -7037044, 10593261, -3963446, -583692, 1140403, -578403, 62150, 134496, -77773], [9848061, -13349448, 48032352, -53653428, 33002964, -9822762, -2192535, 3733470, -82656, -2571492, 2515464, -1282736, 279033, 98336, -74616, -6520, 36660, -27746, 12045, -2234], [-2300135697, 2881302516, -1450422774, -349427925, 864944163, -576670104, 53283474, 211271067, -175929012, 42981204, 32169732, -37754276, 14980239, 701660, -4048698, 1927079, -119673, -485684, 304506, -85589], [-4479437457, 8846780229, -9138902193, 5685256674, -1854776961, -225610515, 475914555, 52577226, -419791428, 412578600, -221733708, 59906504, 5032575, -9383507, -826701, 5525050, -4614381, 2151005, -620469, 93578], [-1121931000, 1660595661, -2449643391, 2440417167, -1428453144, 413911377, 70354305, -115379577, -22194144, 121783620, -112828800, 56722540, -13469688, -3231763, 3023385, 437723, -1667448, 1259389, -566055, 125911], [-3856962582, 5730633279, -5145807609, 3546173115, -1416627306, 153565875, 124498107, 47527875, -204881544, 230624772, -145135704, 55561436, -9418854, -2943185, 796455, 2474215, -2696802, 1552223, -609981, 152435], [-523252872, 1424334051, -370711809, -1265543271, 1365724152, -738808857, 96843519, 190314801, -148635648, -5090820, 73261440, -59172428, 22815672, 356867, -4756569, 1645421, 498360, -946949, 572295, -160799], [-375510087, 560678274, -548061228, 412395219, -189421119, 32159862, 14806224, -1256013, -19008444, 25338180, -17571540, 7216412, -1313943, -415238, 185688, 249247, -310323, 186410, -75384, 17987], [1122121269, -1524903246, 1690294392, -1500670557, 799358949, -217437318, -30538260, 35400591, 34860756, -79654428, 66684268, -32524772, 8009669, 1361690, -1388020, -458641, 1038097, -747026, 337060, -83249]];
    Rf_basisdens := [1, 1, 19683, 25351704, 8450568, 33802272, 4828896, 101406816, 101406816, 4828896, 33802272, 101406816, 2816856, 101406816, 101406816, 101406816, 101406816, 101406816, 11267424, 33802272];
    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_462_k();"
function MakeCharacter_462_k()
    N := 462;
    order := 6;
    char_gens := [155, 199, 211];
    v := [3, 5, 6];
    // 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_462_k_Hecke();"
function MakeCharacter_462_k_Hecke(Kf)
    N := 462;
    order := 6;
    char_gens := [155, 199, 211];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 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]];
    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, -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, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -2, -1, -2, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 2, 0, 1, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0, -1, -1, 0, 0, 1, -1, 2, 0, 0, 0, 0, 0], [1, 2, 1, -1, -1, -1, 0, 0, -1, 1, -1, 0, -1, 0, 0, -1, 0, -2, 0, 0], [0, -1, 2, 0, -1, 0, 0, -3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], [1, 0, -1, 0, 2, -1, -4, 0, 1, -1, 1, -2, 1, 0, 0, 0, 0, 1, 0, 0], [2, -1, -4, 1, 1, -1, 1, 3, -1, 2, -1, 0, 0, 3, -2, -1, 2, 1, 4, 0], [2, 0, 2, 2, -1, 1, 0, -1, 1, 0, 1, 0, 0, -1, 1, 2, 0, 0, -2, 0], [0, 0, 0, 0, 0, 1, -1, -2, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [3, -2, -1, 0, 2, -1, 1, 2, -2, 2, -1, 0, -1, 2, -1, 0, 2, 1, 2, 0], [-1, 3, 3, 1, -2, 1, -2, -1, -1, 3, -1, 4, -1, 0, 0, -1, 0, -2, 0, -2], [0, -2, 3, 1, -5, 2, -2, -2, 1, 5, -2, 2, 1, 0, 0, -1, 0, -1, 0, -2], [0, 0, -2, 0, 0, 1, 0, 0, -1, 0, -1, 0, -2, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, -1, -1, 0, 0, 0, -3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 3, 2, 3, -4, 0, -1, -1, 1, -1, 0, 0, -2, -1, 0, 0, -2, 0, 0, 0], [0, 0, 0, 0, 0, 1, -3, 0, 1, 2, -1, 0, 0, 0, -3, 0, 0, 0, 0, 0], [0, 1, 3, 0, -2, 3, -1, -3, 4, -1, 3, 0, 1, -3, 2, 2, -2, -2, -4, 0], [0, -1, -1, 0, 0, 3, 0, 0, 2, 2, 3, 0, 1, 0, 0, 1, 0, 0, 0, 0], [0, 5, 1, 0, -1, 1, 2, 4, -3, -2, -1, 0, 1, -6, 3, 0, 0, 0, 0, 0], [1, -2, -3, -1, 2, 0, -2, -1, -2, -5, 0, -4, 1, -1, -1, 1, 0, 2, 0, 2], [-3, 0, 0, -6, 0, -2, 0, 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-2, 2, 2, -1, -1, 0, 2, -2, -1, -1, 0, 2, 0, -2, 4, 1, 0, -1, 0, 2], [2, -1, 2, -2, 0, 1, -2, -3, 2, -3, 1, 0, 0, -3, 1, 0, -4, 0, -2, 0], [-2, -1, 4, -2, -1, 0, 0, -1, 0, -2, 0, 0, 4, -2, 2, 2, 0, 0, 0, 4], [0, 4, 1, 6, -1, -1, 2, 2, -2, 1, -1, 0, -1, 2, 0, -1, 4, -1, 0, 0], [0, -2, -2, 0, -2, 2, -5, 0, 1, 3, -2, 0, -2, 0, -5, 0, 0, 0, 0, 0], [-8, 1, 0, 0, -1, -1, 0, 0, -1, 1, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0], [0, 1, 0, 0, 0, 1, -6, -3, 6, 7, -1, 0, 0, -1, -1, 0, 0, 0, 0, 0], [0, -4, -1, -1, 1, -1, -2, -2, 2, -1, 1, -2, 1, 2, 0, 1, 0, 1, 0, 2], [-6, 0, 0, -12, 0, -2, 0, 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, -4, -1, 1, 0, 0, 0, -3, 2, 3, 0, 0, -1, 5, -5, -1, 0, 0, 0, -2], [0, 0, 0, -6, -1, -1, 0, 0, 2, -3, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0], [2, -1, -6, 1, 3, -1, 1, 3, -3, 0, -1, 0, 2, 3, -2, -3, 2, 3, 4, 0], [5, -1, -2, 5, 0, 3, 0, 1, 2, 3, 3, 0, 0, 1, -1, 0, 0, 0, 2, 0], [-1, -7, 2, -2, -1, -1, -1, -2, 2, -2, 1, -2, 4, 2, -1, 2, 0, 1, 0, 4], [0, -2, 0, 0, -3, 1, 2, 1, -2, -1, -1, 0, 0, -1, -1, 0, 0, 0, 0, 0], [0, 2, 5, 2, -8, 2, 10, 10, -4, 2, -2, 4, 1, -4, 0, -2, 0, -2, 0, -4], [1, 10, 7, 2, -6, -5, -1, 0, -2, -4, -5, 0, -9, 0, -1, -6, -2, -3, 2, 0], [0, 0, 0, 0, 0, -4, 0, 0, 2, -2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -9, -5, -6, 4, 3, 1, 1, 2, 1, 3, 0, 5, 1, 0, 6, 2, 6, 0, 0], [-2, 3, 5, 0, -1, 3, -3, 0, -5, 0, -3, 4, 1, 0, 1, 0, 0, -2, 0, 0], [-12, -1, -4, -6, 2, 0, 1, 3, -1, 1, 0, 0, 0, 3, -2, -2, 2, 2, 4, 0], [-10, 0, -2, 0, 0, -1, 1, 2, -1, 2, -1, 0, 0, 2, -1, 0, 2, 0, 2, 0], [9, 0, 1, 18, -2, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 2, 0, 1, 0, 0], [2, -2, -5, 1, 1, -1, 1, -1, 2, 1, 1, -2, -3, 2, -4, -1, 0, 1, 0, -2], [2, -4, -6, -2, 4, 0, 4, 6, 0, 2, 0, 0, 2, 6, -2, 2, 8, 4, 4, 0], [0, 4, 0, 0, 0, -2, 0, -7, -1, -3, 2, 0, 0, -4, 4, 0, 0, 0, 0, 0], [1, -2, -3, 0, 0, 4, 5, 0, -6, -3, -4, -2, -1, 0, -3, 0, 0, 1, 0, 0], [-6, 0, -1, -3, -1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, -1, 0, 0], [2, -4, 2, 4, -4, -2, 0, 0, 2, 6, 2, 4, -2, 8, -4, -4, 0, -2, 0, -8], [1, -1, -3, -1, 4, -1, 4, 2, 5, 1, 1, -4, 1, 0, 0, 1, 0, 2, 0, 2], [0, 3, 0, 1, 1, -4, -1, -1, -4, -6, 4, 2, -2, 1, 0, -1, 0, -1, 0, -2], [2, -2, -3, 1, 1, -5, -7, 7, 6, 1, 5, -2, -1, 2, -4, -1, 0, 1, 0, -2], [9, 1, 5, -9, 1, -2, -2, -3, 4, -5, -2, 0, -3, -3, 1, -3, -4, -6, -2, 0], [0, 3, 3, -6, -2, -2, -3, -3, 1, -3, -2, 0, -3, -3, 0, -4, -6, -4, 0, 0], [1, 0, -1, 0, 2, -2, 4, 0, -2, -5, 2, -2, 1, 0, 5, 0, 0, 1, 0, 0], [-8, 1, 2, -4, 2, 2, -1, -3, -1, -5, 2, 0, 2, -3, 2, -2, -2, 2, -4, 0], [1, 3, -2, 2, 1, 2, -5, -10, 0, 5, -2, 2, -4, 2, -1, -2, 0, -1, 0, -4], [-1, 6, 3, -2, 0, 0, 0, 0, -3, 0, 0, 0, -3, 0, 0, -6, 0, -3, 0, 0], [-2, 1, 1, -1, -1, 1, -8, 8, -1, 0, -1, 2, -1, -1, 2, 1, 0, -1, 0, 2], [2, -5, -2, -2, 0, 5, -2, -3, -3, 2, 5, 0, 4, -3, 1, 4, -4, 8, -2, 0], [0, -4, 2, 0, -1, 3, 0, 6, 0, 3, -3, 0, 2, 3, -3, 0, 0, 0, 0, 0], [7, 1, -4, 7, 6, -5, 0, -1, -6, -7, -5, 0, 6, -1, 1, -6, 0, 0, -2, 0], [0, 7, 1, 0, -7, -2, -1, -2, 1, 1, -2, 0, 1, -2, 1, 0, -2, -6, -2, 0], [0, -2, -1, 2, 4, -8, 5, 5, 2, -2, 8, 4, -5, 12, 0, -2, 0, -2, 0, -4], [6, -3, -2, 12, 1, 2, 0, 0, 1, 2, 2, 0, 2, 0, 0, 2, 0, 1, 0, 0], [0, 2, 0, 0, 0, -6, 0, 0, 4, -2, 6, 0, 0, -2, 4, 0, 0, 0, 0, 0], [1, 2, 7, 1, -4, 0, 0, -7, -3, -2, 0, 0, 7, -5, 5, -1, 0, 0, 0, -2], [-22, 0, 0, -11, 3, 1, 0, 0, -2, -3, 1, 0, 0, 0, 0, -3, 0, 3, 0, 0], [14, 5, 3, 14, -1, -6, 0, 3, -5, -2, -6, 0, -9, 3, -3, -7, 0, 0, 6, 0], [9, -5, 7, 0, 5, 2, -1, -2, 3, -3, 2, 0, -5, -2, 1, 0, -2, 0, -2, 0], [-1, -4, 3, 1, -9, 1, -8, -4, 3, 7, -1, 4, -1, 0, 0, -1, 0, -2, 0, -2], [0, 8, -6, -2, 10, -1, 3, 3, -3, -8, 1, -4, -2, -4, 0, 2, 0, 2, 0, 4], [-3, 1, -1, 3, 1, -2, 2, 3, -7, 8, -2, 0, -1, 3, -1, -1, 4, -2, 2, 0], [-2, 1, -10, -2, 6, -5, 0, 1, 5, -2, 5, 0, -10, 3, -3, 2, 0, 0, 0, 4], [4, 1, 7, 2, 0, 3, -1, -3, 2, -3, 3, 0, -3, -3, 2, 0, -2, 0, -4, 0], [0, 6, -6, 0, 6, -4, 2, 4, 0, -4, 4, 0, -6, 0, 0, 0, 0, 0, 0, 0], [-7, -2, -3, 0, 2, -1, -1, -2, -10, 0, -1, 0, 5, -2, 1, 0, -2, 7, -2, 0], [0, 9, -6, -1, 11, 0, 1, 1, 0, -2, 0, -2, -4, -1, 0, 1, 0, 1, 0, 2], [-2, 3, 0, -4, 3, 0, 0, 0, -3, 0, 0, 0, 0, 0, 0, -6, 0, -3, 0, 0], [0, 0, -1, 0, -1, 1, 0, 0, 7, -7, 1, 0, 1, 0, 0, 1, 0, 2, 0, 0], [-2, 3, 4, -2, -1, -2, 0, -8, -1, -5, 2, 0, 4, -6, 6, 2, 0, 0, 0, 4], [1, -3, -4, 0, -1, 6, -3, 0, -2, 3, -6, -2, -2, 0, -11, 0, 0, 1, 0, 0], [11, -3, 1, 11, -5, 6, 0, 1, 7, 8, 6, 0, -3, 1, -1, 7, 0, 0, 2, 0], [0, 7, -5, 0, 5, 1, -3, -6, -1, 0, -1, 0, -5, -2, 1, 0, 0, 0, 0, 0], [14, -4, -2, 0, 4, 2, 0, 0, -2, -2, 2, 0, 2, 0, 0, 0, 0, 6, 0, 0], [0, 1, 0, 0, -5, 6, 4, 2, -7, -1, -6, 0, 0, -6, -6, 0, 0, 0, 0, 0], [2, 1, 9, 1, 1, -1, -5, 5, -1, -2, 1, -2, 11, -1, 2, -1, 0, 1, 0, -2], [0, 7, 2, 15, -5, -1, 3, 3, -1, 0, -1, 0, -2, 3, 0, 1, 6, 1, 0, 0], [-5, 3, 8, 0, -7, 0, -1, 0, -1, 4, 0, 10, -2, 0, 6, 0, 0, -5, 0, 0], [0, -2, -4, 0, 4, -6, 0, -2, -4, -6, -6, 0, 8, -2, 2, 0, 0, 0, -4, 0], [-1, -2, -3, -2, 4, 4, 1, 2, 2, 3, -4, -2, -1, 2, -1, 2, 0, 1, 0, 4], [-1, -3, 3, 1, -7, 0, -18, -9, 3, 6, 0, 4, -1, 1, 1, -1, 0, -2, 0, -2], [-2, 1, 1, -1, -1, -2, -5, 5, 2, 0, 2, 2, -1, -1, 2, 1, 0, -1, 0, 2], [6, 1, -4, -6, -2, 1, 2, 3, 0, 1, 1, 0, 2, 3, -1, 2, 4, 4, 2, 0], [13, 1, -8, 13, 7, -2, 0, 2, -5, -3, -2, 0, 4, 2, -2, -10, 0, 0, 4, 0], [1, 2, -1, 0, -2, -4, 0, 0, -7, 4, -4, 0, 1, 0, 0, 0, 0, -1, 0, 0], [0, -1, 5, 5, -5, -2, 7, 7, 4, 12, 2, 10, -5, 11, 0, -5, 0, -5, 0, -10], [4, 3, 8, 2, 2, 0, -3, 3, -5, -5, 0, -4, 12, -3, 6, -2, 0, 2, 0, -4], [1, -1, 1, 1, -1, 6, 0, 17, -3, 4, -6, 0, 1, 1, -1, -1, 0, 0, 0, -2], [0, -9, -4, 2, 4, 10, -1, -1, -5, 15, 10, 0, 4, -1, 0, 4, -2, 4, 0, 0], [-20, 1, -3, -10, -5, 6, -1, -3, 10, 2, 6, 0, 7, -3, 2, 5, -2, -5, -4, 0], [0, 6, 6, 0, -6, -3, -2, -4, -6, -9, 3, 0, 6, -12, 6, 0, 0, 0, 0, 0], [-1, 1, 3, 1, 4, -7, -8, -4, 4, 0, 7, 4, -1, 8, 8, -1, 0, -2, 0, -2], [0, 3, 1, 2, 0, 0, 14, 14, 1, 5, 0, 4, -3, 3, 0, -2, 0, -2, 0, -4], [3, 4, 3, 6, -8, -1, -3, 0, 2, 2, -1, 0, -9, 0, -3, -2, -6, -1, 6, 0], [7, -2, -8, -7, 3, -1, 6, 9, -6, 9, -1, 0, 2, 9, -3, 2, 12, 4, 6, 0], [0, 9, 6, 5, -6, -1, -3, -3, -2, 1, -1, 0, -6, -3, 0, -6, -6, -6, 0, 0], [3, -5, -8, 0, 1, 0, 14, 0, 1, -2, 0, -6, -2, 0, -4, 0, 0, 3, 0, 0], [-18, 1, 2, -9, -6, -1, -1, -3, 4, 3, -1, 0, 2, -3, 2, 6, -2, -6, -4, 0], [-3, -4, 1, 0, 4, 2, 2, 4, 7, 0, 2, 0, -5, 4, -2, 0, 4, -1, 4, 0], [0, -6, -5, -1, 9, -3, -10, -10, 10, 5, 3, -2, -3, 12, 0, 1, 0, 1, 0, 2], [-4, -3, 1, -8, -5, 0, 0, 0, 4, 0, 0, 0, -1, 0, 0, 8, 0, 4, 0, 0], [-2, -1, -3, -1, -1, 9, 2, -2, -7, 2, -9, 2, -5, 1, -2, 1, 0, -1, 0, 2], [0, -4, -8, 0, 4, 10, 0, -1, -1, 9, -10, 0, -8, 8, -8, 0, 0, 0, 0, 0], [5, -3, -8, 0, 7, -4, 11, 0, -1, -10, 4, -10, 2, 0, 4, 0, 0, 5, 0, 0], [2, -1, 6, 1, 1, 5, 1, 3, 5, 2, 5, 0, -10, 3, -2, -1, 2, 1, 4, 0], [6, 3, 7, 0, -3, -2, -3, -6, -3, -1, -2, 0, -1, -6, 3, 0, -6, -4, -6, 0], [-1, 0, 3, 1, 0, -4, 6, 3, -8, -9, 4, 4, -1, 5, 5, -1, 0, -2, 0, -2], [0, 4, -12, -6, 18, 3, -22, -22, 5, -4, -3, -12, 0, -4, 0, 6, 0, 6, 0, 12], [-5, -6, -2, 5, 1, 5, -2, -3, 3, -4, 5, 0, 4, -3, 1, 4, -4, 8, -2, 0], [-6, -3, 3, 0, -15, 1, 7, 0, 3, 10, -1, 12, -9, 0, 1, 0, 0, -6, 0, 0], [18, -2, -4, 18, 1, 1, 0, 1, 1, 2, 1, 0, 2, 1, -1, 0, 0, 0, 2, 0], [0, -2, 0, 0, -3, 1, 24, 12, 0, 1, -1, 0, 0, -1, -1, 0, 0, 0, 0, 0], [3, -6, -3, 6, -2, 5, -1, 0, 4, 6, 5, 0, 1, 0, -1, 6, -2, 3, 2, 0], [-4, 3, -7, 4, -7, 4, 2, 3, -7, 8, 4, 0, 5, 3, -1, 5, 4, 10, 2, 0], [0, -3, -2, 9, 9, -5, 1, 1, -1, -4, -5, 0, 2, 1, 0, -5, 2, -5, 0, 0], [0, -3, -3, 0, -3, 3, 16, 0, -4, -1, -3, 0, -3, 0, -2, 0, 0, 0, 0, 0], [-1, -1, -1, -1, -1, 16, 0, 1, 9, 10, 16, 0, -1, 1, -1, 1, 0, 0, 2, 0], [-11, 6, 7, 0, -6, -5, -1, -2, 0, 4, -5, 0, -5, -2, 1, 0, -2, -11, -2, 0], [-2, 4, 6, 2, -3, -1, -24, -12, 2, 7, 1, 8, -2, 3, 3, -2, 0, -4, 0, -4], [-16, -10, -8, -32, 2, 4, -2, 0, 4, 6, 4, 0, 4, 0, -2, 4, -4, 2, 4, 0], [-2, 0, 5, -1, -1, -1, 5, -5, 2, 1, 1, 2, 3, 0, 0, 1, 0, -1, 0, 2], [6, -2, 6, 3, 5, -5, 2, 6, -8, 1, -5, 0, -14, 6, -4, -5, 4, 5, 8, 0], [2, -5, 13, 4, -15, 5, 6, 12, -3, 8, -5, 4, 9, -2, 1, -4, 0, -2, 0, -8], [0, 8, -3, -1, 5, 5, 23, 23, 0, 3, -5, -2, -1, -6, 0, 1, 0, 1, 0, 2], [-6, 4, 0, -12, 4, -6, 0, 0, -4, -6, -6, 0, 0, 0, 0, -8, 0, -4, 0, 0], [-2, -2, -12, -2, 7, -3, 0, 5, 6, 1, 3, 0, -12, 7, -7, 2, 0, 0, 0, 4], [0, -9, -2, -7, 5, -1, -5, -5, 5, -6, -1, 0, 2, -5, 0, -1, -10, -1, 0, 0], [0, 9, 9, 0, 9, -6, -5, 0, 2, -4, 6, 0, 9, 0, 10, 0, 0, 0, 0, 0], [-16, -3, -5, -8, 8, -1, 3, 9, -6, 1, -1, 0, -7, 9, -6, -8, 6, 8, 12, 0], [-2, 3, -7, -4, 9, -11, 8, 16, 1, -16, 11, -4, -3, -2, 1, 4, 0, 2, 0, 8], [5, -8, -10, 10, 14, -8, 1, 0, -3, -9, -8, 0, 12, 0, 1, -4, 2, -2, -2, 0], [0, 1, 5, 0, 0, -12, -2, 2, 11, -1, 12, 0, 5, -1, 2, 0, 0, 0, 0, 0], [-3, 5, 8, 3, -6, 1, -6, -9, 2, -5, 1, 0, -2, -9, 3, -2, -12, -4, -6, 0], [-2, 3, 4, -2, -1, -12, 0, -5, 4, -10, 12, 0, 4, -6, 6, 2, 0, 0, 0, 4], [4, 7, 7, 4, 1, -14, 0, -1, -11, -12, -14, 0, -5, -1, 1, -7, 0, 0, -2, 0], [0, 0, -2, 0, 2, -8, 17, 34, 1, -7, 8, 0, -2, 2, -1, 0, 0, 0, 0, 0], [23, 1, 13, 0, -1, 4, -3, -6, 13, -7, 4, 0, -7, -6, 3, 0, -6, -8, -6, 0], [1, 1, -3, -1, -3, 8, 2, 1, -2, 3, -8, -4, 1, -9, -9, 1, 0, 2, 0, 2], [0, 5, 3, -5, -4, -2, -1, -1, 1, -3, -2, 0, -3, -1, 0, -2, -2, -2, 0, 0], [0, -5, -5, 0, -5, 5, 10, 0, 1, 6, -5, 0, -5, 0, -11, 0, 0, 0, 0, 0], [-29, -5, -12, -29, 10, 3, 0, -3, -1, -4, 3, 0, 18, -3, 3, -2, 0, 0, -6, 0], [1, 1, -3, -1, 6, -1, -40, -20, -1, -5, 1, -4, 1, 0, 0, 1, 0, 2, 0, 2], [-2, 9, 5, -4, -7, -2, -3, 0, -1, 1, -2, 0, -11, 0, -3, -8, -6, -4, 6, 0], [-2, 4, -2, -1, -1, -8, -6, 6, 5, -3, 8, 2, -4, -4, 8, 1, 0, -1, 0, 2], [-2, 4, 2, -2, 0, -4, 0, -8, 0, -6, 4, 0, 2, -6, 6, 2, 0, 0, 0, 4], [1, -4, -5, 0, -2, 0, -16, 0, 2, 1, 0, -2, -3, 0, -3, 0, 0, 1, 0, 0], [11, 0, 8, 0, 0, 2, -5, -10, -3, -7, 2, 0, 2, -10, 5, 0, -10, 2, -10, 0], [2, -4, -6, -2, 12, -8, 28, 14, -3, -17, 8, -8, 2, 6, 6, 2, 0, 4, 0, 4], [0, -7, -1, -3, -1, 2, 3, 3, 2, -2, -2, -6, 5, -3, 0, 3, 0, 3, 0, 6], [6, 0, -1, 3, 3, 1, -9, 9, -4, -3, -1, -6, 5, 0, 0, -3, 0, 3, 0, -6], [0, -14, -6, -5, 7, 5, -2, -2, 2, 3, 5, 0, 6, -2, 0, 5, -4, 5, 0, 0], [22, -1, 11, 11, -1, -6, 1, 3, -4, 4, -6, 0, -15, 3, -2, 1, 2, -1, 4, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_462_k_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_462_2_k_g();".
// 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_462_2_k_g(:prec:=20)
    chi := MakeCharacter_462_k();
    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_462_2_k_g();".
// 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_462_2_k_g( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_462_k();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![144, 0, 4368, 0, 124336, 0, 240704, 0, 358652, 0, 170564, 0, 59212, 0, 7444, 0, 677, 0, 31, 0, 1]>,<17,R![241864704, 0, 248832000, 0, 165425152, 0, 64568320, 0, 18281408, 0, 3485632, 0, 486784, 0, 42632, 0, 2561, 0, 59, 0, 1]>],Snew);
    return Vf;
end function;