
// Make newform 336.2.w.a in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_336_w();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_336_w_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_336_2_w_a();".
// 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_336_2_w_a();".
// 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 := [1024, -2048, 2048, -2048, 2240, -1792, 1024, -672, 500, -240, 100, -120, 125, -84, 64, -56, 35, -16, 8, -4, 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], [-65792, 142464, -101568, 63520, -70528, 47552, -8740, 1616, -8180, 4632, -1249, 4162, -4952, 2640, -1247, 978, -424, 12, 35, -2], [-38912, 66560, -36352, 28032, -37312, 19104, -400, 1856, -5448, 1258, -32, 2505, -2444, 890, -472, 519, -160, -34, -4, 1], [-156672, 327936, -297216, 211264, -206016, 156816, -60600, 14796, -20406, 17244, -6845, 9213, -13586, 9760, -4867, 3055, -1786, 500, 7, -11], [36608, 37632, -93440, 17216, -12720, 50888, -20320, -12724, 1156, 9230, 972, -2759, -3368, 3190, -292, 151, -692, 74, 168, -3], [-20480, 25088, -27520, 24448, -18752, 14240, -7288, 2308, -1240, 1620, -958, 729, -1140, 1024, -562, 255, -176, 80, 14, -11], [-11264, 179200, -350464, 319744, -235904, 225728, -168080, 67992, -20296, 23046, -18344, 8165, -10588, 14510, -10464, 5483, -3440, 1962, -588, 37], [400384, -523264, 202240, -171392, 296960, -129376, -34320, -25912, 63008, -8270, -3844, -22877, 19956, -3110, 2284, -4707, 1464, 382, 224, -269], [5632, -21504, 23808, -25024, 24544, -19232, 12752, -7340, 3904, -1940, 1360, -1139, 1052, -1032, 864, -589, 320, -176, 84, -15], [-512, 53760, -12672, -10208, -35872, 28664, 3280, 1926, -12848, 3173, 3328, 1620, -2944, 195, 148, 884, -500, -19, -84, 86], [-34816, -66304, 142720, -114432, 115200, -116016, 83880, -38992, 22098, -14410, 6511, -4087, 5286, -5850, 4569, -3357, 2134, -1138, 539, -179], [216576, -517888, 496768, -394752, 415168, -325168, 154800, -71928, 60118, -36812, 14215, -18734, 24078, -17700, 11001, -8070, 4818, -1840, 679, -202], [70656, -32256, -84480, -37888, 135680, -41344, 23920, -80008, 52032, 1110, 1084, -14323, 2764, 2910, 3516, -4973, 1576, -822, 1176, -451], [227328, -184576, 61312, -61440, 115232, -33968, -21320, -20744, 30480, -3618, -394, -11013, 7628, 430, 578, -1987, 576, 162, 210, -237], [72192, -125440, 84352, -68192, 98592, -64504, 20240, -19426, 21248, -6673, 872, -5995, 5884, -2435, 1812, -2109, 1060, -261, 224, -121], [105984, -175616, 122368, -163456, 202848, -118240, 59400, -61072, 41074, -7792, 5427, -13648, 9130, -4280, 5309, -4964, 2126, -876, 707, -260], [11264, -41472, 49792, -47808, 48992, -38512, 23680, -13552, 7862, -3768, 2055, -2306, 2302, -1960, 1609, -1170, 642, -300, 151, -38], [102400, -220416, 217344, -258432, 293344, -200672, 122960, -99600, 59008, -17186, 11888, -17953, 12532, -8130, 9320, -7631, 3736, -1814, 1204, -393], [105472, -220416, 214976, -245344, 265536, -185056, 112520, -82666, 49296, -16239, 10890, -15073, 11436, -8285, 8362, -6495, 3236, -1595, 938, -279], [252928, -476672, 425216, -482432, 551616, -375280, 204160, -160304, 104718, -32264, 17159, -31806, 26070, -16040, 15753, -13238, 6522, -2892, 1799, -610]];
    Rf_basisdens := [1, 8960, 2560, 17920, 8960, 3584, 17920, 35840, 1792, 8960, 17920, 17920, 35840, 17920, 8960, 17920, 2560, 17920, 8960, 17920];
    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_336_w();"
function MakeCharacter_336_w()
    N := 336;
    order := 4;
    char_gens := [127, 85, 113, 241];
    v := [4, 1, 4, 4];
    // 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_336_w_Hecke();"
function MakeCharacter_336_w_Hecke(Kf)
    N := 336;
    order := 4;
    char_gens := [127, 85, 113, 241];
    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, 0, 0, 0, -1, 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, 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, -1, 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, -1, 0, -1, 0, 0, 1, 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, -1, 0, 0, 0, 0], [1, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0, -1, -2, 0, 0, -1, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, -1, -2, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 0, 2, -1, 1, 0, 0, 1, 1, 1, 0, 0, 1, -1, 1, 0, 0, 0, 0], [0, 1, -1, 1, 0, -1, 0, -2, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1], [0, 0, 0, 1, 0, -2, -2, -2, 0, -1, 0, 0, -2, 1, -1, 1, 0, 1, 0, 0], [-1, 0, -3, 3, -2, 1, -1, -2, 1, -2, 1, 0, 0, 3, 0, 2, -1, -1, 0, -2], [-2, 2, -3, 3, -4, 1, -2, -2, 0, -3, 1, 2, 2, 1, 1, 1, -3, 1, 0, -4], [3, -3, 0, 0, 2, 1, -1, 0, 1, 0, -1, 2, -2, 2, -4, -1, 0, -4, 1, 3], [0, -1, 1, -1, 0, -2, 0, 0, 2, 0, 2, -1, 0, 0, 1, 0, 0, -1, -1, 0], [1, 0, -1, 2, 0, 1, 0, 0, 0, 0, 1, 2, 0, 0, 0, -1, -3, 1, -1, 0], [0, 0, 2, -1, 4, -2, 0, 0, -2, -1, 0, -1, 0, -2, 2, -2, 3, 1, -2, 1], [-3, 0, -1, -2, -1, -4, 1, 0, 2, 0, 0, -4, -2, -1, 2, 2, 1, 2, 0, 0], [-2, 1, 1, -2, -1, -1, 2, 0, -1, 0, -1, -2, 4, -3, 6, -1, 1, 4, -1, -1], [0, -1, -3, 2, 0, 2, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, -3, 0, -1], [-1, -1, -1, 0, -2, 3, 3, 4, 1, 2, -2, 0, 0, -1, 0, -2, 0, -2, -1, 1], [0, -1, 1, 0, 0, 2, -2, 0, -2, 3, -2, 2, 0, 0, 1, -2, -3, -2, 3, 3], [0, 1, 0, 2, 0, -2, -1, 2, -1, -2, 3, 0, 2, 1, -2, -1, -3, -3, 0, -1], [2, -1, 1, -3, 2, 2, -2, 2, 0, 0, -2, 0, -2, -1, 0, -1, -1, -3, 1, 1], [4, 1, 3, -4, 5, -5, 0, 0, -3, 0, 1, 0, 0, -3, 0, 1, 1, 0, 1, 1], [0, -1, 3, -1, 0, 0, 6, 0, 1, 1, -1, -2, 0, -2, 3, -2, 3, -2, -2, -1], [-2, 0, 0, -2, 2, 0, -2, -4, -2, 0, 0, 2, 4, 2, -2, 2, 0, 0, 2, -2], [2, 3, -5, 2, -3, 0, -2, 0, -1, 0, 2, 3, 4, 1, -2, -1, -3, 2, 2, -3], [0, 0, -2, 2, 0, -1, 1, 0, 1, -3, 0, -2, 0, 1, -1, -1, 3, 1, 1, -2], [-1, 0, -1, -1, 3, 1, 1, 0, -3, 0, -2, 3, -2, 1, -2, 2, 3, 4, 0, 0], [-1, 1, -1, -3, 2, 4, 0, 4, 0, 2, 0, 0, 0, -3, 0, -4, 3, -3, -1, 3], [-4, 5, -3, 2, -4, 0, -4, -2, 0, -3, 2, 1, 2, 3, 2, 3, -4, 4, 1, -6], [8, -5, 8, -8, 6, 4, 3, 2, 1, 4, -5, -2, -2, -3, -2, -3, 1, -1, 2, 7], [-4, 3, -1, -2, -1, 1, -2, 4, -1, -2, -1, 0, 0, 1, 0, -3, -3, 0, 1, 1], [0, -1, 3, -1, 0, 0, 6, 2, 2, 0, -4, -2, 2, -1, 2, -1, 7, -1, -1, -1], [4, -1, 0, 4, 2, 2, 3, 0, -1, 0, 1, 0, -4, 1, -2, -3, 1, 3, -2, 1], [-3, 0, 3, -4, 1, 0, 1, 0, 0, 0, -2, -2, -2, -1, 2, 2, 3, 0, 0, 0], [0, -2, 1, 1, 0, 4, 3, -4, 1, 0, -5, 0, -4, 2, 0, -4, 4, 0, -1, 2], [2, 3, -1, 0, 2, 0, -5, 2, -1, -4, 2, 0, 0, 0, 0, 2, 1, 3, 0, -1], [3, 1, -1, -2, 0, -3, 3, 8, -3, -2, 4, 0, 0, -1, 0, 2, 2, -2, -5, -1], [0, 4, 0, -2, 0, -2, -10, 4, -2, 0, 2, 6, 4, 2, -6, 2, -6, -4, 4, 2], [-4, -3, -1, 2, -5, 6, 2, -4, 2, 3, -1, 0, 0, 1, 0, -3, 0, 1, -3, 0], [1, 0, 1, -3, 2, 2, 3, -2, 2, 5, -5, 0, 0, -3, 0, -2, 0, -6, 4, 5], [0, 1, -2, 5, -2, 4, 0, 0, 0, 0, 3, 4, 2, 0, 0, 0, -7, 1, -1, -1], [4, -1, 3, 2, 1, 5, -2, 2, 1, 2, 1, -1, -2, 0, -1, 0, 2, -2, -1, 2], [-6, 2, 2, -10, 2, -3, 1, 2, -1, -1, -4, -4, -2, -3, 5, -3, -1, 3, 1, 2], [1, 5, 2, 0, 2, -5, -1, 0, -3, 0, 1, -2, 2, -2, 4, -3, 2, 6, -5, -5], [0, -1, 1, -3, 0, 0, 0, 2, 4, 0, 0, 0, 2, 1, 0, -3, 3, -3, 1, 1], [1, -6, 4, -3, 2, 1, 5, 0, 1, 10, 2, 0, 0, -2, 0, -1, 5, -5, -2, 4], [-4, 4, -6, 8, -4, 2, -8, 0, -4, -4, 6, 6, 0, 6, -2, 6, 0, 0, 0, -10], [6, -2, 4, -6, 4, 2, -2, 4, -2, 6, -4, 0, 0, -2, 0, 4, -4, 0, 6, 4], [2, -4, 3, -6, 2, -4, 6, 0, 4, 0, -3, -8, -2, -3, 6, -5, 4, 4, -2, 4], [0, 1, -1, -4, 0, 2, 0, -2, -2, 5, 0, 1, -2, -5, 4, -1, -2, 6, -1, 0], [-6, -2, -2, 5, -1, 3, -2, -4, -2, -1, 2, 4, 4, 1, -3, 1, 2, -4, -1, -2], [-2, 7, 2, -2, 2, -2, -5, -2, -9, -8, 3, 0, 2, -1, 8, -1, 5, 11, -4, -7], [2, 0, -4, 2, -4, 2, 0, 0, 6, 0, 4, 0, 8, 2, -4, 0, -8, -2, 2, 0], [-8, 2, -4, 4, -9, 5, -2, 4, 1, -3, 1, 2, -4, 1, 1, 1, -4, 0, 0, -4], [0, 1, -1, -2, 0, -2, 4, 8, 1, 0, 3, -3, 8, -4, 3, 6, 2, 1, 0, -4], [-2, -2, -4, 5, 2, -3, 4, 0, 0, -3, 1, 0, 0, -2, 0, -4, 3, -3, -1, -5], [6, -3, -2, -2, 0, -3, 4, 0, 6, 5, -3, 0, 0, 2, -5, 2, -6, -4, 5, 3], [-1, -2, 0, 4, 4, -3, -2, 0, -2, 0, 0, 2, -10, 1, -2, 2, 1, -1, -3, 2], [0, 3, -3, 4, 0, -8, -2, -2, 0, -7, 2, -3, -2, 1, -4, 5, 4, 8, -3, -6], [2, 2, -4, 8, -6, 5, -8, 0, -2, 0, 4, 8, 6, 3, -6, 1, -7, -11, 5, -2], [4, 0, 2, 1, -4, 7, 0, 0, -1, 0, 0, 3, 4, -2, 4, -6, -4, -4, 2, 0], [4, 1, -3, 1, 2, -1, -2, -6, 0, -2, 0, 0, 0, 2, 0, 6, -2, -4, 4, -1], [0, -4, 0, -1, 0, 8, 2, 0, 2, 3, 0, 1, 0, 2, 2, 2, -3, -3, -2, 5], [0, -2, 4, 0, 0, -4, 6, 0, -2, 4, -2, -4, 0, -6, 8, 8, 2, 2, 0, -2], [3, -3, 0, 7, -1, -8, 5, -6, 0, -4, 2, 0, 0, 0, 0, 3, 2, 3, -3, -7], [-7, 5, -4, 9, -6, -1, 0, 0, 0, 0, 7, -2, -4, -1, 2, 6, -6, 4, -2, -5], [12, -1, -3, 5, 4, -8, 2, 2, 0, 0, 2, 2, -2, 1, -2, 1, 1, -1, -1, -1], [5, -12, 1, 3, 7, 1, -5, 0, 1, 0, -4, 5, -14, 7, -14, 2, 5, -18, 4, 12], [-2, -1, 3, 6, -2, -2, 1, -6, 5, 0, 2, 0, 0, 0, 0, -2, 7, 5, -4, -1], [0, 2, -6, 14, -7, -1, 0, -12, 1, -5, 5, 6, 12, 3, -1, 3, -4, 4, -2, -8], [0, -4, 0, 7, 0, -2, 4, 2, 1, -4, -1, -5, 2, 3, 1, -5, 3, 2, -3, -1], [0, -5, 1, 3, 0, 0, 6, -2, 2, 4, 0, 2, 2, 1, -6, 1, 1, -1, 1, 3], [-5, 3, 9, -7, -4, 8, 6, 0, 0, 0, -2, -4, 12, -7, 14, -2, -1, 3, -1, -3], [-5, -2, 5, 0, 0, -3, 8, 0, 4, 0, 1, -10, 8, -6, 12, -1, -1, 7, -7, 2], [-4, 10, -6, 3, -4, -8, -4, 0, -2, -7, 4, -1, 0, 2, 8, 2, -3, 9, -2, -9], [7, -5, 4, 2, 6, -3, 7, 0, 1, 0, -1, -8, -6, 0, 0, -7, 8, 4, -5, 5], [16, -6, 8, -5, 8, -4, 9, 2, -1, 10, -4, 0, 0, -11, 0, 5, 6, -2, 1, 4], [-8, 3, -9, 7, -4, -2, -6, -6, -2, -4, 4, 2, 6, 1, 2, 1, 1, -7, -3, -5], [0, -2, 4, 4, 0, 0, 2, -4, -4, 2, -4, 0, -4, 0, 2, 6, -2, 0, -2, 2], [-6, 3, -7, 4, -5, 3, 0, 8, 1, -6, 3, 0, 0, 3, 0, -3, 1, -2, -5, -3], [-1, 5, -2, 4, -2, -1, -1, 0, 1, 0, 5, -2, -2, 2, -4, 3, -2, 2, -1, -5], [14, -6, 0, -5, 1, -1, 6, -4, -3, 2, -3, 3, 4, -1, -5, -1, 3, -3, 2, 3], [6, -5, -4, 0, -4, 4, 1, -2, -7, 0, 1, 6, 2, 1, -6, 1, 7, -7, 0, -1], [0, 3, -3, 1, 0, 4, 4, -6, 0, -4, -4, 0, -6, 1, -4, 1, 7, -3, 5, -3], [1, 2, 1, -1, 3, -3, 7, 0, -1, 0, 0, -7, 6, -1, 2, -2, 7, 12, -4, -2], [-6, 10, -4, -3, 0, -8, -6, 0, -2, -5, 2, -5, 0, 0, 10, 0, -1, 5, -2, -5], [0, -4, -4, 0, 0, -2, 2, -4, 6, -2, 4, -6, -4, 0, 4, -6, 4, 12, -8, -2], [-2, 0, 6, -5, 8, -11, 2, 4, -2, 3, -1, 0, 0, -2, 0, -4, -1, -5, 7, 3], [-2, 2, -1, -11, -6, 2, 1, -8, 1, 0, -5, -2, 8, 0, 2, 0, -6, 2, 5, 0], [-6, 4, -2, 4, -4, 6, -10, -8, 4, -4, -2, 0, 0, 6, 0, 0, -4, 6, 4, 0], [20, -10, 10, -7, 12, -4, 12, 16, 2, 7, -6, -3, -16, -6, -4, -6, 5, -1, 0, 13], [0, -3, 1, 1, 0, 10, 0, 2, -2, 4, -4, 4, 2, 3, 0, 5, -5, -7, 3, 7], [1, 1, 0, -4, -6, 8, -1, 0, 3, 0, 0, 5, -2, -2, 4, -3, -10, -4, 4, -1], [-3, 1, 1, -8, 2, 1, 5, 0, -3, 4, 2, 0, 0, -5, 0, -8, 4, -6, -5, 5], [0, 2, -2, 5, 0, -4, 2, -4, -2, -5, 2, -3, -4, 0, -2, -4, 1, 3, -2, -5], [-4, 5, -1, -8, -1, 10, -8, 0, 0, 3, -5, 0, 0, 3, 0, -1, -8, -3, 7, 8], [0, 7, -5, 3, 0, -8, -10, 4, -1, -9, 9, 2, 4, 4, -11, 8, -5, -2, 2, -5], [0, 6, -2, 4, -2, -8, -4, 0, 2, 0, 6, -4, 0, 0, 0, 0, -4, 2, -4, -6], [-5, 2, 7, -3, 0, -9, 3, -6, 1, 2, -1, 0, 0, 1, 0, -4, -1, -1, 2, 4], [7, -3, 3, -4, 0, 3, 5, 8, -1, 6, -4, 0, 0, -5, 0, 2, 0, 0, -1, 3], [-3, 3, 0, -1, -3, 2, -9, -6, -2, -4, 0, 0, 0, 6, 0, 3, -8, 7, 3, -1], [2, 1, 5, -2, -3, 5, -10, -4, -1, 0, 1, 0, 0, 3, 0, 5, -3, 14, -1, 1], [0, -4, -8, 5, 0, 4, 6, 4, 4, -5, -2, -7, 4, 2, 2, -8, 9, 7, 2, -3], [-3, 6, 1, 0, -4, 7, -8, 0, -8, 0, -1, 12, 16, -2, 4, 1, -5, -5, 3, -6], [-2, -3, 0, -8, 0, 0, 3, 10, 5, 10, -3, -4, -10, 3, -6, 3, -1, -7, 6, 7], [2, 6, -6, 0, -6, 0, -4, 0, -6, 0, 0, 6, -4, -2, 4, -4, -2, 4, 4, -6], [0, -6, 4, 4, 11, -3, 2, 0, -6, 0, 2, 5, 0, -1, -5, -1, 9, -1, -3, 1], [0, 1, 1, -6, 0, 2, 4, -4, 0, 5, 0, 0, -4, -6, 5, -8, 1, -2, 3, -1], [0, 2, -4, 2, 0, 4, -2, 4, -8, 4, -4, 2, 4, -4, 2, 6, -4, 8, 4, 0], [16, -10, 6, 2, 12, -8, 12, 8, -4, 4, 0, 4, -8, -2, -8, -2, 10, 2, -2, 6], [-1, 5, -5, -1, -10, 6, -8, 0, 4, 0, 4, 8, 8, 1, -2, 2, -15, -9, 7, -5], [0, -2, -6, 6, 0, 10, -2, -4, 0, -4, 0, 2, -4, 8, -6, 2, -4, 2, -4, 4], [-6, -5, 2, 0, 2, -2, -5, 0, -5, 0, -5, 4, -16, -1, 2, 5, 5, -9, 2, 5], [0, -7, 4, -4, 0, 6, 11, 2, 3, 8, -9, -4, 2, -5, 12, -9, 9, 5, -2, 3], [20, -5, 7, 3, 12, 0, 0, 6, -2, 4, 2, 4, -6, 3, -8, 3, 5, 1, 1, 1], [-6, 3, 1, 7, 2, -13, 2, 6, 0, -10, 2, 0, 0, -2, 0, -8, 4, 6, -2, -7], [0, -4, 0, 6, 0, 14, 10, 4, -4, 2, -8, 0, 4, 2, 2, -6, 0, -2, -2, 4], [-9, -3, 12, -7, 3, -6, 5, 10, 0, 10, 0, 0, 0, -4, 0, -13, 4, 1, -1, 7], [7, -9, 0, -2, 1, 1, 15, 2, -6, 5, 1, 0, 0, -12, 0, -5, 7, 0, -12, -4], [0, 2, 7, -6, 8, -8, 10, 0, 2, 0, -1, -10, 2, -7, 14, -7, 2, 20, -14, -2], [-8, 4, -4, 4, -6, 5, -7, -10, -1, -1, 4, 2, 10, 5, -1, 5, -1, -1, 1, -6], [-4, -1, -1, 4, 1, -4, -4, 0, -3, 0, 0, 1, 4, 1, -2, 5, 3, -4, 0, 1], [-9, 12, -7, 9, -9, -3, -7, 0, -1, 0, 10, 3, 10, -1, 2, 8, -13, 4, -2, -12], [6, -2, 6, -4, 4, -4, 2, -8, -6, 0, 0, 0, 0, -8, 0, -2, 2, 10, -4, -2], [7, 5, 4, -5, 5, -6, -3, 2, 0, 0, -4, 0, 0, 0, 0, 7, -4, -3, 9, 5], [-5, 3, 7, -1, 2, 2, 2, 0, 2, 0, 2, -4, -8, -1, 2, 4, -1, 1, -5, -3], [-8, 2, -6, 1, -10, 2, 0, 0, -2, -1, 2, 3, 0, 4, -2, 4, -1, 1, 2, -5], [0, 0, 0, 2, 0, -5, 3, -8, -1, -1, 6, -4, -8, -3, 3, -1, -3, -1, -1, -4], [4, -7, 3, 0, 8, 0, -5, 6, -1, 6, 6, 0, 0, 0, 0, 4, 5, 1, 2, -1], [-1, 3, 1, -8, 2, 7, -13, 8, -3, 2, -4, 0, 0, 5, 0, 4, -12, 2, 11, 5], [0, 6, 0, -3, 0, 6, 2, 10, -3, 0, 3, 5, 10, -1, -5, -9, -5, 0, -9, -1], [-8, 2, -10, 10, -8, 4, -8, -12, -2, -10, 2, 10, 12, 2, 0, 2, -8, -4, 0, -12], [3, 3, -3, 7, -8, 8, -4, 0, -6, 0, 2, 4, 8, 3, -6, 0, 3, -9, 9, -3], [0, 3, 7, -9, 0, 0, -14, 8, -5, 11, -3, 12, 8, -2, -1, -6, -11, -14, 14, 9], [-2, -3, -2, -12, 0, -4, 5, 18, -1, 4, -5, -4, -18, -3, 0, -3, 3, -7, 2, 7], [14, -7, -11, 12, -3, 8, -10, 0, -1, 0, 2, 15, -4, 11, -22, -3, -5, -20, 12, 7], [0, -3, 8, -10, 12, 0, 3, 0, -3, 10, -3, 0, 0, -13, 0, -13, 7, -1, 2, 7], [-8, 1, -5, 2, -11, 8, -6, -12, 2, -1, -5, 0, 0, 13, 0, 5, -16, -1, 7, 0], [0, 0, 2, 3, 0, 0, 4, -4, -4, 1, -4, -1, -4, -2, 2, 16, 1, -7, 8, -1], [4, -8, 6, -10, 8, 6, 6, 0, -2, 0, -10, 0, -16, 2, -4, -2, 14, -2, 4, 8], [-5, 0, -3, 16, -7, 8, -1, 0, 4, 0, 10, 0, 10, 5, -10, 10, -9, -10, 2, 0], [0, 6, -4, 2, 0, -2, -16, -8, -4, -4, 10, 8, -8, 6, -12, -2, -16, -10, 6, 2], [-5, 1, -4, -10, -8, -2, -3, 0, 5, 0, -2, -1, -2, -2, 4, 3, -4, -4, 8, -1], [-8, -3, -9, 8, -8, 10, 7, 10, 7, 2, -2, 0, 0, 2, 0, -6, 3, -9, -4, -1], [0, -2, 2, -4, 0, 4, 0, -8, 4, 2, -10, 2, -8, 2, 0, -2, 10, -4, 8, 4], [2, -4, 1, -4, 6, -2, -6, 0, 6, 0, -1, 6, 2, 3, -6, 1, -8, -8, -2, 4], [0, 9, -3, -7, 0, 0, -6, -8, -1, -1, 1, 6, -8, -2, -7, -6, 1, -12, 16, -3], [12, -6, -2, 14, 0, 3, 0, 0, 0, 0, 4, 0, -6, 5, -10, -7, 1, -9, 1, 6], [8, 9, -1, -4, 7, -5, -12, -2, -7, -10, 1, 1, 2, 0, 9, 0, -2, 6, -1, -10], [9, -1, 5, -7, -4, 2, 0, 12, -6, 2, -2, 0, 0, -1, 0, 8, -7, 9, -3, 1], [-20, 4, -2, 6, -13, 9, -2, -4, 4, 2, 4, -5, 4, 1, 3, 1, 1, -1, -3, 1], [3, 9, -7, 4, -4, 1, -11, -20, 1, -12, -2, 0, 0, 9, 0, 12, -10, 2, 7, -3], [0, -8, 8, 6, 0, 6, 14, -4, 0, 2, -4, -4, -4, 2, 6, -6, 0, -6, -10, 4], [5, 2, -1, -10, -2, -5, -2, 0, 6, 0, -1, -2, 8, -2, 4, -7, -5, 1, 1, -2], [10, -10, 4, 17, -1, 9, 6, -4, 11, 10, 3, 1, 4, 1, -11, 1, 1, -9, -2, 9], [0, -9, 4, 6, 0, 0, -5, -14, 7, -4, -11, 0, -14, 13, -4, 1, 9, -5, 4, 9], [16, -6, 12, -6, 5, 7, 6, -8, -2, 6, -2, -1, 8, -1, -5, -1, 7, 5, 1, 7], [0, 3, -2, 2, 0, -10, 3, -10, -1, -4, 3, -6, -10, -5, 2, 5, 5, 3, 4, -9], [-2, 1, 1, -2, 3, -4, 8, 0, -2, -1, 3, 0, 0, -9, 0, -11, 10, -1, -9, 0], [5, 0, -5, -1, -6, 8, 1, -10, 2, 3, -7, 0, 0, 5, 0, 10, -10, -8, 6, 3], [0, -5, 5, 3, 0, 0, 0, 2, 0, 2, -4, 0, 2, 3, 2, -9, -1, -3, -1, 5], [0, -1, -1, 1, 0, -12, -6, 2, 8, -8, 4, -4, 2, 5, -4, 3, 7, 7, -5, -3], [4, 0, 6, -6, -2, 4, 2, 0, 2, 0, -2, 0, -8, -6, 12, -10, -6, 0, -2, 0], [-26, 20, -4, 13, -8, -8, -8, -12, -4, -17, 10, -1, 12, 2, 18, 2, -5, 27, -8, -19], [0, -12, 4, 8, 0, -6, 14, -20, 12, -8, -10, -14, -20, 6, 6, 14, 24, 4, -4, -2], [-6, 10, 3, 1, 4, -6, -5, -4, -1, -6, 3, -6, 4, -2, 12, -2, 0, 12, -5, -4], [8, -10, 7, 6, 10, -6, 10, 0, 2, 0, -1, -14, -6, 1, -2, -7, 14, 2, -8, 10]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_336_w_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_336_2_w_a();".
// 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_336_2_w_a(:prec:=20)
    chi := MakeCharacter_336_w();
    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_336_2_w_a();".
// 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_336_2_w_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_336_w();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![4096, -36864, 165888, -212224, 138512, -23360, 98432, -117824, 71872, -8928, 12288, -14400, 8840, -1040, 288, -336, 240, -24, 0, 0, 1]>],Snew);
    return Vf;
end function;